Skip to content

Commit

Permalink
5-1-2015: final version of pnut
Browse files Browse the repository at this point in the history
  • Loading branch information
siren-myx committed May 1, 2015
1 parent 43bfef3 commit 51c9a16
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions assets/js/pnut.js
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,22 @@ var pnut = (function () {
}
break;
case "IfStatement":
dict = dictDecFuncs(nd.consequent, dict);
var csqt = nd.consequent;
dict = dictDecFuncs(csqt, dict);

if(csqt.type=="FunctionDeclaration") {
name = csqt.id.name + "("+ csqt.params.length+" params)";

if(dict.getItem(name)==undefined) {
dict.setItem(name, [nd.start, nd.end]);
}
}
break;
case "WhileStatement":
dict = dictDecFuncs(nd.body, dict);
break;
case "ForStatement":
dict = dictDecFuncs(nd.body, dict);
break;
}
}
Expand All @@ -1942,8 +1957,7 @@ var pnut = (function () {
// create a dictionary to map function calls with their occurrence order.
//------------------------------------------------------------------------
function dictFuncCalls(ast, fCalls) {
var calls = new HashMap();
var nd, dec, name, exp;
var calls, nd, dec, name, exp;

if(arguments.length==2) {
calls = fCalls;
Expand Down Expand Up @@ -2372,4 +2386,4 @@ var pnut = (function () {
}

}) // end anonymous function declaration
(); // now run it to create and return the object with all the methods
(); // now run it to create and return the object with all the methods

0 comments on commit 51c9a16

Please sign in to comment.