diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-29 12:38:56 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-02 17:31:36 -0700 |
commit | 07b106ef35b0b0f82187c59d80960faf0feb9ab8 (patch) | |
tree | 07387ff266bba5511616c1b47c25e182c62e6ef9 | |
parent | 435f17d4955c75e9ccef3fccd991c0da7756d7f0 (diff) |
register phi variables in function
-rw-r--r-- | src/jsifier.js | 10 | ||||
-rw-r--r-- | src/parseTools.js | 3 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index efebab62..78183a35 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1016,10 +1016,10 @@ function JSify(data, functionsOnly, givenFunctions) { } // TODO: eliminate unneeded sets (to undefined etc.) var deps = {}; // for each ident we will set, which others it depends on - var valueJSes = {}; + var map = {}; labelSets.forEach(function(labelSet) { deps[labelSet.ident] = {}; - valueJSes[labelSet.ident] = labelSet.valueJS; + map[labelSet.ident] = labelSet; }); labelSets.forEach(function(labelSet) { walkInterdata(labelSet.value, function mark(item) { @@ -1038,13 +1038,15 @@ function JSify(data, functionsOnly, givenFunctions) { } for (var i = 0; i < idents.length; i++) { if (keys(deps[idents[i]]).length == 0) { - post = 'var ' + idents[i] + '=' + valueJSes[idents[i]] + ';' + post; + post = idents[i] + '=' + map[idents[i]].valueJS + ';' + post; + if (!ASM_JS) post = 'var ' + post; + else addVariable(idents[i], map[idents[i]].value.type); remove(idents[i]); continue mainLoop; } } // If we got here, we have circular dependencies, and must break at least one. - pre += 'var ' + idents[0] + '$phi=' + valueJSes[idents[0]] + ';'; + pre += 'var ' + idents[0] + '$phi=' + map[idents[0]].valueJS + ';'; post += 'var ' + idents[0] + '=' + idents[0] + '$phi;'; remove(idents[0]); } diff --git a/src/parseTools.js b/src/parseTools.js index f60c0cc1..8dd6dccf 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -2560,6 +2560,7 @@ function deParen(text) { function addVariable(ident, type, funcData) { funcData = funcData || Framework.currItem.funcData; + assert(type); funcData.variables[ident] = { ident: ident, type: type, @@ -2569,7 +2570,7 @@ function addVariable(ident, type, funcData) { hasValueTaken: false, pointingLevels: 0, uses: 0, - impl: "native" + impl: VAR_EMULATED }; } |