diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 53 | ||||
-rw-r--r-- | src/modules.js | 4 | ||||
-rw-r--r-- | src/parseTools.js | 4 |
3 files changed, 33 insertions, 28 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index fae92f70..6d3fe781 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -65,24 +65,27 @@ function JSify(data, functionsOnly, givenFunctions) { // Add additional necessary items for the main pass. We can now do this since types are parsed (types can be used through // generateStructInfo in library.js) LibraryManager.load(); - var libFuncsToInclude; - if (INCLUDE_FULL_LIBRARY) { - assert(!BUILD_AS_SHARED_LIB, 'Cannot have both INCLUDE_FULL_LIBRARY and BUILD_AS_SHARED_LIB set.') - libFuncsToInclude = []; - for (var key in LibraryManager.library) { - if (!key.match(/__(deps|postset|inline)$/)) { - libFuncsToInclude.push(key); + + if (phase == 'pre') { + var libFuncsToInclude; + if (INCLUDE_FULL_LIBRARY) { + assert(!BUILD_AS_SHARED_LIB, 'Cannot have both INCLUDE_FULL_LIBRARY and BUILD_AS_SHARED_LIB set.') + libFuncsToInclude = []; + for (var key in LibraryManager.library) { + if (!key.match(/__(deps|postset|inline)$/)) { + libFuncsToInclude.push(key); + } } + } else { + libFuncsToInclude = DEFAULT_LIBRARY_FUNCS_TO_INCLUDE; } - } else { - libFuncsToInclude = DEFAULT_LIBRARY_FUNCS_TO_INCLUDE; - } - libFuncsToInclude.forEach(function(ident) { - data.functionStubs.push({ - intertype: 'functionStub', - ident: '_' + ident + libFuncsToInclude.forEach(function(ident) { + data.functionStubs.push({ + intertype: 'functionStub', + ident: '_' + ident + }); }); - }); + } } // Functions @@ -1279,6 +1282,19 @@ function JSify(data, functionsOnly, givenFunctions) { return; } + // Print out global variables and postsets TODO: batching + if (phase == 'pre') { + legalizedI64s = false; + JSify(analyzer(intertyper(data.unparsedGlobalss[0].lines, true), true), true, Functions); + data.unparsedGlobalss = null; + + var generated = itemsDict.functionStub.concat(itemsDict.GlobalVariablePostSet); + generated.forEach(function(item) { print(indentify(item.JS || '', 2)); }); + } else { + assert(data.unparsedGlobalss[0].lines.length == 0, dump([phase, data.unparsedGlobalss])); + assert(itemsDict.functionStub.length == 0, dump([phase, itemsDict.functionStub])); + } + if (phase == 'pre' || phase == 'funcs') { // serialize out the data that later passes need PassManager.serialize(); // XXX for funcs pass, do not serialize it all. I think we just need which were indexized. @@ -1299,8 +1315,6 @@ function JSify(data, functionsOnly, givenFunctions) { print(read('headless.js').replace("'%s'", "'http://emscripten.org'").replace("'?%s'", "''").replace('%s,', 'null,').replace('%d', '0')); print('}'); } - var generated = itemsDict.functionStub.concat(itemsDict.GlobalVariablePostSet); - generated.forEach(function(item) { print(indentify(item.JS || '', 2)); }); if (RUNTIME_TYPE_INFO) { Types.cleanForRuntime(); print('Runtime.typeInfo = ' + JSON.stringify(Types.types)); @@ -1310,11 +1324,6 @@ function JSify(data, functionsOnly, givenFunctions) { var postParts = processMacros(preprocess(read(postFile))).split('{{GLOBAL_VARS}}'); print(postParts[0]); - // Print out global variables and postsets TODO: batching - legalizedI64s = false; - JSify(analyzer(intertyper(data.unparsedGlobalss[0].lines, true), true), true, Functions); - data.unparsedGlobalss = null; - print(Functions.generateIndexing()); // done last, as it may rely on aliases set in postsets // Load runtime-linked libraries diff --git a/src/modules.js b/src/modules.js index 60b4ff87..1449e3f4 100644 --- a/src/modules.js +++ b/src/modules.js @@ -242,16 +242,14 @@ var Functions = { for (var ident in this.indexedFunctions) { vals[this.indexedFunctions[ident]] = ident; } - // Resolve multi-level aliases all the way down for (var i = 0; i < vals.length; i++) { while (1) { var varData = Variables.globals[vals[i]]; if (!(varData && varData.resolvedAlias)) break; - vals[i] = vals[varData.resolvedAlias]; + vals[i] = vals[+varData.resolvedAlias || eval(varData.resolvedAlias)]; // might need to eval to turn (6) into 6 } } - var indices = vals.toString().replace('"', ''); if (BUILD_AS_SHARED_LIB) { // Shared libraries reuse the parent's function table. diff --git a/src/parseTools.js b/src/parseTools.js index 6a10176c..1205aff5 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1997,9 +1997,7 @@ function parseBlockAddress(segment) { } function finalizeBlockAddress(param) { - assert(param.func in Functions.blockAddresses); - assert(param.label in Functions.blockAddresses[param.func]); - return Functions.blockAddresses[param.func][param.label]; + return '{{{ BA_' + param.func + '|' + param.label + ' }}}'; // something python will replace later } function stripCorrections(param) { |