From 8be9f67e9316c7c4e675f6f235dbc1ecd97bb287 Mon Sep 17 00:00:00 2001 From: Koushik Sen Date: Tue, 10 Dec 2013 10:55:48 -0800 Subject: [PATCH] Fixed issue #11 --- scripts/units.py | 3 ++- src/js/instrument/esnstrument.js | 13 +++++++++++-- tests/unit/implicit-type.js | 10 ++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/unit/implicit-type.js diff --git a/scripts/units.py b/scripts/units.py index 3c68f65d..fd169da5 100644 --- a/scripts/units.py +++ b/scripts/units.py @@ -40,7 +40,8 @@ "tests/unit/exception", "tests/unit/symbolic" , "tests/unit/gettersetter" , - "tests/unit/gettersetter2" + "tests/unit/gettersetter2", + "tests/unit/implicit-type" ] SCRIPT = "src/python/jalangi_command.py" diff --git a/src/js/instrument/esnstrument.js b/src/js/instrument/esnstrument.js index 0115d7a9..21ae0a0e 100644 --- a/src/js/instrument/esnstrument.js +++ b/src/js/instrument/esnstrument.js @@ -445,6 +445,12 @@ return ret; } + function makeNumber(node, left) { + var ret = replaceInExpr(" + "+RP + "1 ",left); + transferLoc(ret, node); + return ret; + } + function wrapLHSOfModStore(node, left, right) { var ret = replaceInExpr(RP + "1 = " + RP + "2", left, right); @@ -837,9 +843,12 @@ } } - function instrumentLoadModStore(node) { + function instrumentLoadModStore(node, isNumber) { if (node.left.type === 'Identifier') { var tmp0 = instrumentLoad(node.left); + if (isNumber) { + tmp0 = makeNumber(node, instrumentLoad(tmp0)); + } var tmp1 = wrapRHSOfModStore(node.right, tmp0, node.right, node.operator.substring(0, node.operator.length - 1)); var tmp2; @@ -863,7 +872,7 @@ function instrumentPreIncDec(node) { var right = createLiteralAst(1); var ret = wrapRHSOfModStore(node, node.argument, right, node.operator.substring(0, 1) + "="); - return instrumentLoadModStore(ret); + return instrumentLoadModStore(ret, true); } function adjustIncDec(op, ast) { diff --git a/tests/unit/implicit-type.js b/tests/unit/implicit-type.js new file mode 100644 index 00000000..e0421487 --- /dev/null +++ b/tests/unit/implicit-type.js @@ -0,0 +1,10 @@ + +var j = "0"; +var k = j++; +console.log(j); +console.log(k); +var l = "1"; +var m = ++l; +console.log(l); +console.log(m); +