diff options
author | alon@honor <none@none> | 2010-08-26 22:52:02 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-08-26 22:52:02 -0700 |
commit | c96ca4ad280e3d9704b8f127311e5b48b707e3bd (patch) | |
tree | b63e654f7df8a9c18f4477edfdec4b26a428424c /src/parser.js | |
parent | a9256705ada4ae335870cdb60ae7f9c8373038e3 (diff) |
cleanup + prep for enzymatic2
Diffstat (limited to 'src/parser.js')
-rw-r--r-- | src/parser.js | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/parser.js b/src/parser.js index ba0a36e4..390daf9b 100644 --- a/src/parser.js +++ b/src/parser.js @@ -24,6 +24,7 @@ if (!this['read']) { load('utility.js'); load('enzymatic.js'); +load('enzymatic2.js'); // Tools @@ -89,13 +90,6 @@ function addIdent(token) { return token; } -// Splits out items that pass filter. Returns also the original sans the filtered -function splitter(array, filter) { - var splitOut = array.filter(filter); - var original = array.filter(function(x) { return !filter(x) }); - return { original: original, splitOut: splitOut }; -} - function combineTokens(tokens) { var ret = { lineNum: tokens[0].lineNum, @@ -822,7 +816,7 @@ function analyzer(data) { ['globalConstant', 'globalVariable', 'functionStub', 'type'].forEach(function(intertype) { var temp = splitter(item.items, function(item) { return item.intertype == intertype }); item[intertype + 's'] = temp.splitOut; - item.items = temp.original; + item.items = temp.leftIn; }); // Functions & labels item.functions = [] @@ -1307,7 +1301,7 @@ print("\n\n// XXX MAKEBLOCK " + entry + ' : ' + labels.length + ' : ' + getLabel print("//no first line"); return; } - var others = split.original; + var others = split.leftIn; var lastLine = first.lines.slice(-1)[0]; print("// makeBlock " + entry + ' : ' + getLabelIds(labels) + ' IN: ' + first.inLabels + ' OUT: ' + first.outLabels); // If we have one outgoing, and none incoming - make this a block of 1, @@ -1332,7 +1326,7 @@ print('// loop ? b'); // outside the loop. Insiders are those that can get back to the entry var split2 = splitter(others, function(label) { return label.allOutLabels.indexOf(entry) == -1 }); var outsiders = split2.splitOut; - var insiders = split2.original; + var insiders = split2.leftIn; print('// potential loop : in/out : ' + getLabelIds(insiders) + ' to ' + getLabelIds(outsiders)); // Hopefully exactly one of the outsiders is a 'pivot' - a label to which all those leaving // the loop must go. Then even some |if (falala) { ... break; }| will get ... |