diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-06 14:24:35 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-11-06 14:24:35 -0800 |
commit | 6942df9f2d8f463eff9e6c70580d4719cabcffa9 (patch) | |
tree | 29f67543d3416d713fbbb329bf79c3f7b8c0fe07 /src/jsifier.js | |
parent | 5318a2f9cdc2279a0e04441e539ff38613597f25 (diff) |
generate indexedFunctions in pre, and give it the information to do so
Diffstat (limited to 'src/jsifier.js')
-rw-r--r-- | src/jsifier.js | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index dcf4e3fa..68bf35ab 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -40,7 +40,7 @@ function JSify(data, functionsOnly, givenFunctions) { var preFile = BUILD_AS_SHARED_LIB ? 'preamble_sharedlib.js' : 'preamble.js'; var pre = processMacros(preprocess(read(preFile).replace('{{RUNTIME}}', getRuntime()))); print(pre); - } else if (phase == 'funcs') { + Functions.implementedFunctions = set(data.unparsedFunctions.map(function(func) { return func.ident })); } } @@ -90,6 +90,7 @@ function JSify(data, functionsOnly, givenFunctions) { Functions.currExternalFunctions = !mainPass ? givenFunctions.currExternalFunctions : {}; // Now that first-pass analysis has completed (so we have basic types, etc.), we can get around to handling unparsedFunctions + // XXX do we need this? (!mainPass ? data.functions : data.unparsedFunctions.concat(data.functions)).forEach(function(func) { // Save just what we need, to save memory Functions.currFunctions[func.ident] = { @@ -110,24 +111,26 @@ function JSify(data, functionsOnly, givenFunctions) { } }); - var MAX_BATCH_FUNC_LINES = 1000; - while (data.unparsedFunctions.length > 0) { - var currFuncLines = []; - var currBaseLineNums = []; - while (currFuncLines.length == 0 || - (data.unparsedFunctions.length > 0 && currFuncLines.length + data.unparsedFunctions[0].lines.length <= MAX_BATCH_FUNC_LINES)) { - currBaseLineNums.push([currFuncLines.length, data.unparsedFunctions[0].lineNum-1]); - currFuncLines = currFuncLines.concat(data.unparsedFunctions[0].lines); // for first one, assign, do not concat? - data.unparsedFunctions.shift(); + if (phase == 'funcs') { // pre has function shells, just to defined implementedFunctions + var MAX_BATCH_FUNC_LINES = 1000; + while (data.unparsedFunctions.length > 0) { + var currFuncLines = []; + var currBaseLineNums = []; + while (currFuncLines.length == 0 || + (data.unparsedFunctions.length > 0 && currFuncLines.length + data.unparsedFunctions[0].lines.length <= MAX_BATCH_FUNC_LINES)) { + currBaseLineNums.push([currFuncLines.length, data.unparsedFunctions[0].lineNum-1]); + currFuncLines = currFuncLines.concat(data.unparsedFunctions[0].lines); // for first one, assign, do not concat? + data.unparsedFunctions.shift(); + } + dprint('unparsedFunctions','====================\n// Processing function batch of ' + currBaseLineNums.length + + ' functions, ' + currFuncLines.length + ' lines, functions left: ' + data.unparsedFunctions.length); + if (DEBUG_MEMORY) MemoryDebugger.tick('pre-func'); + JSify(analyzer(intertyper(currFuncLines, true, currBaseLineNums), true), true, Functions); + if (DEBUG_MEMORY) MemoryDebugger.tick('post-func'); } - dprint('unparsedFunctions','====================\n// Processing function batch of ' + currBaseLineNums.length + - ' functions, ' + currFuncLines.length + ' lines, functions left: ' + data.unparsedFunctions.length); - if (DEBUG_MEMORY) MemoryDebugger.tick('pre-func'); - JSify(analyzer(intertyper(currFuncLines, true, currBaseLineNums), true), true, Functions); - if (DEBUG_MEMORY) MemoryDebugger.tick('post-func'); + currFuncLines = currBaseLineNums = null; // Do not hold on to anything from inside that loop (JS function scoping..) + data.unparsedFunctions = null; } - currFuncLines = currBaseLineNums = null; // Do not hold on to anything from inside that loop (JS function scoping..) - data.unparsedFunctions = null; // Actors |