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

Commit

Permalink
AST visitors to log iids of top-level expressions in a statement.
Browse files Browse the repository at this point in the history
Search for the comment                     // to Manu: node.arguments[0].value should be stored in a file
  • Loading branch information
ksen007 committed Feb 6, 2014
1 parent 24ddbb1 commit bde88a9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 2 deletions.
Binary file modified jout/production/jalangijava/AndFormula.class
Binary file not shown.
Binary file modified jout/production/jalangijava/FalseFormula.class
Binary file not shown.
Binary file modified jout/production/jalangijava/Formula.class
Binary file not shown.
Binary file modified jout/production/jalangijava/OrFormula.class
Binary file not shown.
Binary file modified jout/production/jalangijava/RegexpEncoder.class
Binary file not shown.
Binary file modified jout/production/jalangijava/RelConstant.class
Binary file not shown.
Binary file modified jout/production/jalangijava/TrueFormula.class
Binary file not shown.
50 changes: 48 additions & 2 deletions src/js/instrument/esnstrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,52 @@
"ForStatement":funCond
};

var exprDepth = 0;
var visitorIdentifyTopLevelExprPre = {
"CallExpression":function (node) {
if (node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
node.callee.object.name === astUtil.JALANGI_VAR) {
var funName = node.callee.property.name;
if (exprDepth === 0 &&
(funName === 'F' ||
funName === 'M' ||
funName === 'A' ||
funName === 'P' ||
funName === 'G' ||
funName === 'R' ||
funName === 'W' ||
funName === 'H' ||
funName === 'T' ||
funName === 'Rt' ||
funName === 'B' ||
funName === 'U' ||
funName === 'C' ||
funName === 'C1' ||
funName === 'C2' ||
funName === '_'
)) {
// to Manu: node.arguments[0].value should be stored in a file
// console.log(node.arguments[0].value);
}
exprDepth++;
}
}
};

var visitorIdentifyTopLevelExprPost = {
"CallExpression":function (node) {
if (node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
node.callee.object.name === astUtil.JALANGI_VAR) {
exprDepth--;
}
return node;
}
};



function addScopes(ast) {

function Scope(parent) {
Expand Down Expand Up @@ -1284,7 +1330,7 @@
condCount = 3;
}
wrapProgramNode = tryCatchAtTop;
var newAst = transformString(code, [visitorRRPost, visitorOps], [visitorRRPre, undefined]);
var newAst = transformString(code, [visitorRRPost, visitorOps, visitorIdentifyTopLevelExprPost], [visitorRRPre, undefined, visitorIdentifyTopLevelExprPre]);
var newCode = escodegen.generate(newAst);

if (!tryCatchAtTop) {
Expand Down Expand Up @@ -1341,7 +1387,7 @@
wrapProgramNode = true;
instCodeFileName = makeInstCodeFileName(filename);
writeLineToIIDMap("orig2Inst[filename] = \"" + sanitizePath(require('path').resolve(process.cwd(), instCodeFileName)) + "\";\n");
var newAst = transformString(code, [visitorRRPost, visitorOps], [visitorRRPre, undefined]);
var newAst = transformString(code, [visitorRRPost, visitorOps, visitorIdentifyTopLevelExprPost], [visitorRRPre, undefined, visitorIdentifyTopLevelExprPre]);
//console.log(JSON.stringify(newAst, null, '\t'));

var newFileOnly = path.basename(instCodeFileName);
Expand Down

0 comments on commit bde88a9

Please sign in to comment.