From becd55dced7546ee4ba12cec5d849f76878059be Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Thu, 26 Sep 2013 15:05:00 -0500 Subject: moved eqproc to the correct magic position also added mEqCString to evalOps so the test runs --- compiler/jsgen.nim | 4 ++-- compiler/semfold.nim | 1 + tests/js/testmagic.nim | 10 ++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/js/testmagic.nim diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index eadad27d0..fec14870e 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -302,12 +302,12 @@ const # magic checked op; magic unchecked op; checked op; unchecked op ["", "", "($1 <= $2)", "($1 <= $2)"], # LeB ["", "", "($1 < $2)", "($1 < $2)"], # LtB ["", "", "($1 == $2)", "($1 == $2)"], # EqRef - ["", "", "($1 == $2)", "($1 == $2)"], # EqProc ["", "", "($1 == $2)", "($1 == $2)"], # EqUntracedRef ["", "", "($1 <= $2)", "($1 <= $2)"], # LePtr ["", "", "($1 < $2)", "($1 < $2)"], # LtPtr ["", "", "($1 == $2)", "($1 == $2)"], # EqCString ["", "", "($1 != $2)", "($1 != $2)"], # Xor + ["", "", "($1 == $2)", "($1 == $2)"], # EqProc ["NegInt", "", "NegInt($1)", "-($1)"], # UnaryMinusI ["NegInt64", "", "NegInt64($1)", "-($1)"], # UnaryMinusI64 ["AbsInt", "", "AbsInt($1)", "Math.abs($1)"], # AbsI @@ -402,12 +402,12 @@ const # magic checked op; magic unchecked op; checked op; unchecked op ["", "", "($1 <= $2)", "($1 <= $2)"], # LeB ["", "", "($1 < $2)", "($1 < $2)"], # LtB ["", "", "($1 == $2)", "($1 == $2)"], # EqRef - ["", "", "($1 == $2)", "($1 == $2)"], # EqProc ["", "", "($1 == $2)", "($1 == $2)"], # EqUntracedRef ["", "", "($1 <= $2)", "($1 <= $2)"], # LePtr ["", "", "($1 < $2)", "($1 < $2)"], # LtPtr ["", "", "($1 == $2)", "($1 == $2)"], # EqCString ["", "", "($1 != $2)", "($1 != $2)"], # Xor + ["", "", "($1 == $2)", "($1 == $2)"], # EqProc ["NegInt", "", "NegInt($1)", "-($1)"], # UnaryMinusI ["NegInt64", "", "NegInt64($1)", "-($1)"], # UnaryMinusI64 ["AbsInt", "", "AbsInt($1)", "Math.abs($1)"], # AbsI diff --git a/compiler/semfold.nim b/compiler/semfold.nim index ca06ea1b6..ebde9a2be 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -315,6 +315,7 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode = of mLtStr: result = newIntNodeT(ord(getStr(a) < getStr(b)), n) of mLeStr: result = newIntNodeT(ord(getStr(a) <= getStr(b)), n) of mEqStr: result = newIntNodeT(ord(getStr(a) == getStr(b)), n) + of mEqCString: result = newIntNodeT(ord(getStr(a) == getStr(b)), n) of mLtU, mLtU64: result = newIntNodeT(ord(`<%`(getOrdValue(a), getOrdValue(b))), n) of mLeU, mLeU64: diff --git a/tests/js/testmagic.nim b/tests/js/testmagic.nim new file mode 100644 index 000000000..c58496dfd --- /dev/null +++ b/tests/js/testmagic.nim @@ -0,0 +1,10 @@ +discard """ + cmd: "nimrod js --hints:on -r $# $#" + output: '''true''' +""" + +# This file tests some magic + +const foo = cstring("foo") +const bar = cstring("foo") +echo(foo == bar) -- cgit 1.4.1-2-gfad0 From ab31ad2704da49734349a2d6b9638a21cb0af31b Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Thu, 26 Sep 2013 15:10:54 -0500 Subject: don't mess with semfold, use vars instead --- compiler/semfold.nim | 1 - tests/js/testmagic.nim | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/semfold.nim b/compiler/semfold.nim index ebde9a2be..ca06ea1b6 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -315,7 +315,6 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode = of mLtStr: result = newIntNodeT(ord(getStr(a) < getStr(b)), n) of mLeStr: result = newIntNodeT(ord(getStr(a) <= getStr(b)), n) of mEqStr: result = newIntNodeT(ord(getStr(a) == getStr(b)), n) - of mEqCString: result = newIntNodeT(ord(getStr(a) == getStr(b)), n) of mLtU, mLtU64: result = newIntNodeT(ord(`<%`(getOrdValue(a), getOrdValue(b))), n) of mLeU, mLeU64: diff --git a/tests/js/testmagic.nim b/tests/js/testmagic.nim index c58496dfd..2c02d24be 100644 --- a/tests/js/testmagic.nim +++ b/tests/js/testmagic.nim @@ -5,6 +5,6 @@ discard """ # This file tests some magic -const foo = cstring("foo") -const bar = cstring("foo") +var foo = cstring("foo") +var bar = cstring("foo") echo(foo == bar) -- cgit 1.4.1-2-gfad0