more occurences of 'pure' proc pragma fixed
This commit is contained in:
parent
d560e84fcc
commit
dd190a5c01
4 changed files with 30 additions and 29 deletions
|
|
@ -184,7 +184,7 @@ Example:
|
||||||
static int cvariable = 420;
|
static int cvariable = 420;
|
||||||
""".}
|
""".}
|
||||||
|
|
||||||
proc embedsC() {.pure.} =
|
proc embedsC() {.noStackFrame.} =
|
||||||
var nimrodVar = 89
|
var nimrodVar = 89
|
||||||
# use backticks to access Nimrod symbols within an emit section:
|
# use backticks to access Nimrod symbols within an emit section:
|
||||||
{.emit: """fprintf(stdout, "%d\n", cvariable + (int)`nimrodVar`);""".}
|
{.emit: """fprintf(stdout, "%d\n", cvariable + (int)`nimrodVar`);""".}
|
||||||
|
|
|
||||||
|
|
@ -1248,7 +1248,7 @@ when not defined(NimrodVM):
|
||||||
proc seqToPtr[T](x: seq[T]): pointer {.inline, nosideeffect.} =
|
proc seqToPtr[T](x: seq[T]): pointer {.inline, nosideeffect.} =
|
||||||
result = cast[pointer](x)
|
result = cast[pointer](x)
|
||||||
else:
|
else:
|
||||||
proc seqToPtr[T](x: seq[T]): pointer {.pure, nosideeffect.} =
|
proc seqToPtr[T](x: seq[T]): pointer {.noStackFrame, nosideeffect.} =
|
||||||
asm """return `x`"""
|
asm """return `x`"""
|
||||||
|
|
||||||
proc `==` *[T: typeDesc](x, y: seq[T]): bool {.noSideEffect.} =
|
proc `==` *[T: typeDesc](x, y: seq[T]): bool {.noSideEffect.} =
|
||||||
|
|
@ -1481,7 +1481,7 @@ when not defined(ECMAScript):
|
||||||
inc(i)
|
inc(i)
|
||||||
{.pop.}
|
{.pop.}
|
||||||
else:
|
else:
|
||||||
proc add*(x: var string, y: cstring) {.pure.} =
|
proc add*(x: var string, y: cstring) {.noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var len = `x`[0].length-1;
|
var len = `x`[0].length-1;
|
||||||
for (var i = 0; i < `y`.length; ++i) {
|
for (var i = 0; i < `y`.length; ++i) {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,8 @@ proc rawWriteStackTrace(): string =
|
||||||
result = "Traceback (most recent call last)\n"& auxWriteStackTrace(framePtr)
|
result = "Traceback (most recent call last)\n"& auxWriteStackTrace(framePtr)
|
||||||
framePtr = nil
|
framePtr = nil
|
||||||
|
|
||||||
proc raiseException(e: ref E_Base, ename: cstring) {.compilerproc, pure.} =
|
proc raiseException(e: ref E_Base, ename: cstring) {.
|
||||||
|
compilerproc, noStackFrame.} =
|
||||||
e.name = ename
|
e.name = ename
|
||||||
if excHandler != nil:
|
if excHandler != nil:
|
||||||
excHandler.exc = e
|
excHandler.exc = e
|
||||||
|
|
@ -116,7 +117,7 @@ proc raiseIndexError() {.compilerproc, noreturn.} =
|
||||||
proc raiseFieldError(f: string) {.compilerproc, noreturn.} =
|
proc raiseFieldError(f: string) {.compilerproc, noreturn.} =
|
||||||
raise newException(EInvalidField, f & " is not accessible")
|
raise newException(EInvalidField, f & " is not accessible")
|
||||||
|
|
||||||
proc SetConstr() {.varargs, pure, compilerproc.} =
|
proc SetConstr() {.varargs, noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var i = 0; i < arguments.length; ++i) {
|
for (var i = 0; i < arguments.length; ++i) {
|
||||||
|
|
@ -132,7 +133,7 @@ proc SetConstr() {.varargs, pure, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc cstrToNimstr(c: cstring): string {.pure, compilerproc.} =
|
proc cstrToNimstr(c: cstring): string {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var i = 0; i < `c`.length; ++i) {
|
for (var i = 0; i < `c`.length; ++i) {
|
||||||
|
|
@ -142,7 +143,7 @@ proc cstrToNimstr(c: cstring): string {.pure, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc toEcmaStr(s: string): cstring {.pure, compilerproc.} =
|
proc toEcmaStr(s: string): cstring {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var len = `s`.length-1;
|
var len = `s`.length-1;
|
||||||
var result = new Array(len);
|
var result = new Array(len);
|
||||||
|
|
@ -153,7 +154,7 @@ proc toEcmaStr(s: string): cstring {.pure, compilerproc.} =
|
||||||
return result.join("");
|
return result.join("");
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mnewString(len: int): string {.pure, compilerproc.} =
|
proc mnewString(len: int): string {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = new Array(`len`+1);
|
var result = new Array(`len`+1);
|
||||||
result[0] = 0;
|
result[0] = 0;
|
||||||
|
|
@ -161,7 +162,7 @@ proc mnewString(len: int): string {.pure, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetCard(a: int): int {.compilerproc, pure.} =
|
proc SetCard(a: int): int {.compilerproc, noStackFrame.} =
|
||||||
# argument type is a fake
|
# argument type is a fake
|
||||||
asm """
|
asm """
|
||||||
var result = 0;
|
var result = 0;
|
||||||
|
|
@ -169,14 +170,14 @@ proc SetCard(a: int): int {.compilerproc, pure.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetEq(a, b: int): bool {.compilerproc, pure.} =
|
proc SetEq(a, b: int): bool {.compilerproc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
for (var elem in `a`) { if (!`b`[elem]) return false; }
|
for (var elem in `a`) { if (!`b`[elem]) return false; }
|
||||||
for (var elem in `b`) { if (!`a`[elem]) return false; }
|
for (var elem in `b`) { if (!`a`[elem]) return false; }
|
||||||
return true;
|
return true;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetLe(a, b: int): bool {.compilerproc, pure.} =
|
proc SetLe(a, b: int): bool {.compilerproc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
for (var elem in `a`) { if (!`b`[elem]) return false; }
|
for (var elem in `a`) { if (!`b`[elem]) return false; }
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -185,7 +186,7 @@ proc SetLe(a, b: int): bool {.compilerproc, pure.} =
|
||||||
proc SetLt(a, b: int): bool {.compilerproc.} =
|
proc SetLt(a, b: int): bool {.compilerproc.} =
|
||||||
result = SetLe(a, b) and not SetEq(a, b)
|
result = SetLe(a, b) and not SetEq(a, b)
|
||||||
|
|
||||||
proc SetMul(a, b: int): int {.compilerproc, pure.} =
|
proc SetMul(a, b: int): int {.compilerproc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var elem in `a`) {
|
for (var elem in `a`) {
|
||||||
|
|
@ -194,7 +195,7 @@ proc SetMul(a, b: int): int {.compilerproc, pure.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetPlus(a, b: int): int {.compilerproc, pure.} =
|
proc SetPlus(a, b: int): int {.compilerproc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var elem in `a`) { result[elem] = true; }
|
for (var elem in `a`) { result[elem] = true; }
|
||||||
|
|
@ -202,7 +203,7 @@ proc SetPlus(a, b: int): int {.compilerproc, pure.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetMinus(a, b: int): int {.compilerproc, pure.} =
|
proc SetMinus(a, b: int): int {.compilerproc, noStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var elem in `a`) {
|
for (var elem in `a`) {
|
||||||
|
|
@ -211,7 +212,7 @@ proc SetMinus(a, b: int): int {.compilerproc, pure.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc cmpStrings(a, b: string): int {.pure, compilerProc.} =
|
proc cmpStrings(a, b: string): int {.noStackFrame, compilerProc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`a` == `b`) return 0;
|
if (`a` == `b`) return 0;
|
||||||
if (!`a`) return -1;
|
if (!`a`) return -1;
|
||||||
|
|
@ -225,7 +226,7 @@ proc cmpStrings(a, b: string): int {.pure, compilerProc.} =
|
||||||
|
|
||||||
proc cmp(x, y: string): int = return cmpStrings(x, y)
|
proc cmp(x, y: string): int = return cmpStrings(x, y)
|
||||||
|
|
||||||
proc eqStrings(a, b: string): bool {.pure, compilerProc.} =
|
proc eqStrings(a, b: string): bool {.noStackFrame, compilerProc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`a == `b`) return true;
|
if (`a == `b`) return true;
|
||||||
if ((!`a`) || (!`b`)) return false;
|
if ((!`a`) || (!`b`)) return false;
|
||||||
|
|
@ -313,42 +314,42 @@ proc rawEcho {.compilerproc.} =
|
||||||
node.appendChild(document.createElement("br"))
|
node.appendChild(document.createElement("br"))
|
||||||
|
|
||||||
# Arithmetic:
|
# Arithmetic:
|
||||||
proc addInt(a, b: int): int {.pure, compilerproc.} =
|
proc addInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` + `b`;
|
var result = `a` + `b`;
|
||||||
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc subInt(a, b: int): int {.pure, compilerproc.} =
|
proc subInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` - `b`;
|
var result = `a` - `b`;
|
||||||
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mulInt(a, b: int): int {.pure, compilerproc.} =
|
proc mulInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` * `b`;
|
var result = `a` * `b`;
|
||||||
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc divInt(a, b: int): int {.pure, compilerproc.} =
|
proc divInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`b` == 0) `raiseDivByZero`();
|
if (`b` == 0) `raiseDivByZero`();
|
||||||
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
|
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
|
||||||
return Math.floor(`a` / `b`);
|
return Math.floor(`a` / `b`);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc modInt(a, b: int): int {.pure, compilerproc.} =
|
proc modInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`b` == 0) `raiseDivByZero`();
|
if (`b` == 0) `raiseDivByZero`();
|
||||||
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
|
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
|
||||||
return Math.floor(`a` % `b`);
|
return Math.floor(`a` % `b`);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc addInt64(a, b: int): int {.pure, compilerproc.} =
|
proc addInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` + `b`;
|
var result = `a` + `b`;
|
||||||
if (result > 9223372036854775807
|
if (result > 9223372036854775807
|
||||||
|
|
@ -356,7 +357,7 @@ proc addInt64(a, b: int): int {.pure, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc subInt64(a, b: int): int {.pure, compilerproc.} =
|
proc subInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` - `b`;
|
var result = `a` - `b`;
|
||||||
if (result > 9223372036854775807
|
if (result > 9223372036854775807
|
||||||
|
|
@ -364,7 +365,7 @@ proc subInt64(a, b: int): int {.pure, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mulInt64(a, b: int): int {.pure, compilerproc.} =
|
proc mulInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` * `b`;
|
var result = `a` * `b`;
|
||||||
if (result > 9223372036854775807
|
if (result > 9223372036854775807
|
||||||
|
|
@ -372,14 +373,14 @@ proc mulInt64(a, b: int): int {.pure, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc divInt64(a, b: int): int {.pure, compilerproc.} =
|
proc divInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`b` == 0) `raiseDivByZero`();
|
if (`b` == 0) `raiseDivByZero`();
|
||||||
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
|
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
|
||||||
return Math.floor(`a` / `b`);
|
return Math.floor(`a` / `b`);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc modInt64(a, b: int): int {.pure, compilerproc.} =
|
proc modInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`b` == 0) `raiseDivByZero`();
|
if (`b` == 0) `raiseDivByZero`();
|
||||||
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
|
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
|
||||||
|
|
@ -389,7 +390,7 @@ proc modInt64(a, b: int): int {.pure, compilerproc.} =
|
||||||
proc nimMin(a, b: int): int {.compilerproc.} = return if a <= b: a else: b
|
proc nimMin(a, b: int): int {.compilerproc.} = return if a <= b: a else: b
|
||||||
proc nimMax(a, b: int): int {.compilerproc.} = return if a >= b: a else: b
|
proc nimMax(a, b: int): int {.compilerproc.} = return if a >= b: a else: b
|
||||||
|
|
||||||
proc internalAssert(file: cstring, line: int) {.pure, compilerproc.} =
|
proc internalAssert(file: cstring, line: int) {.noStackFrame, compilerproc.} =
|
||||||
var
|
var
|
||||||
e: ref EAssertionFailed
|
e: ref EAssertionFailed
|
||||||
new(e)
|
new(e)
|
||||||
|
|
@ -459,7 +460,7 @@ proc NimCopy(x: pointer, ti: PNimType): pointer =
|
||||||
|
|
||||||
|
|
||||||
proc ArrayConstr(len: int, value: pointer, typ: PNimType): pointer {.
|
proc ArrayConstr(len: int, value: pointer, typ: PNimType): pointer {.
|
||||||
pure, compilerproc.} =
|
noStackFrame, compilerproc.} =
|
||||||
# types are fake
|
# types are fake
|
||||||
asm """
|
asm """
|
||||||
var result = new Array(`len`);
|
var result = new Array(`len`);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ static int cvariable = 420;
|
||||||
|
|
||||||
""".}
|
""".}
|
||||||
|
|
||||||
proc embedsC() {.pure.} =
|
proc embedsC() {.noStackFrame.} =
|
||||||
var nimrodVar = 89
|
var nimrodVar = 89
|
||||||
{.emit: """fprintf(stdout, "%d\n", cvariable + (int)`nimrodVar`);""".}
|
{.emit: """fprintf(stdout, "%d\n", cvariable + (int)`nimrodVar`);""".}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue