Skip to content

Commit

Permalink
Add global helper for human-readable addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
longouyang committed Mar 2, 2015
1 parent 7c9c27b commit 2be2ddd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion wctransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ var WrapIfs =
}
}

var nextid = 0
var nextid = 0;

var idToFunctionName = {};

global.humanizeAddress = function(name) {
var splitName = name.split("."),
erpStack = splitName[0].split(":"),
loopCounter = splitName[1];

return erpStack.map(function(name) { return idToFunctionName[name]}).join(" ") + "." + loopCounter;
}

var MoveCalls =
{
Expand All @@ -81,6 +91,7 @@ var MoveCalls =
//replace with new identifier, add to call queue.
var id = nextid++
var idNode = {type: "Identifier", name: "call"+id}
idToFunctionName[id + ""] = node.callee.name;
var newCallBlock = templateReplace("{enterfn("+id+"); var call"+id+"=__REPLACEME__; leavefn();}",node)
newCallBlock.body[1].loc = node.loc //original location of new assignment is set to original call. needed because error stack inside eval doesn't give character, only line.
callsToMove.push(newCallBlock)
Expand Down

0 comments on commit 2be2ddd

Please sign in to comment.