Skip to content
This repository has been archived by the owner on Dec 9, 2017. It is now read-only.

Commit

Permalink
Fixed issue #11
Browse files Browse the repository at this point in the history
  • Loading branch information
ksen007 committed Dec 10, 2013
1 parent a15a616 commit 8be9f67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion scripts/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 11 additions & 2 deletions src/js/instrument/esnstrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/implicit-type.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 8be9f67

Please sign in to comment.