Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/jsifier.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,16 @@ export async function runJSify(outputFile, symbolsOnly) {
const symbolsNeeded = DEFAULT_LIBRARY_FUNCS_TO_INCLUDE;
symbolsNeeded.push(...extraLibraryFuncs);

for (const fileName of [...PRE_JS_FILES, ...POST_JS_FILES]) {
const content = readFile(fileName);
addImplicitDeps(content, symbolsNeeded);
}
for (const snippet of EM_JS_SNIPPETS) {
addImplicitDeps(snippet, symbolsNeeded);
if (!symbolsOnly) {
for (const fileName of [...PRE_JS_FILES, ...POST_JS_FILES]) {
const content = getIncludeFile(fileName);
if (!errorOccured()) {
addImplicitDeps(content, symbolsNeeded);
}
}
for (const snippet of EM_JS_SNIPPETS) {
addImplicitDeps(snippet, symbolsNeeded);
}
}
for (const sym of EXPORTED_RUNTIME_METHODS) {
if ('$' + sym in LibraryManager.library) {
Expand Down Expand Up @@ -640,6 +644,7 @@ function(${args}) {
let isStub = false;

const mangled = mangleCSymbolName(symbol);
let snippet = LibraryManager.library[symbol];

if (!LibraryManager.library.hasOwnProperty(symbol)) {
const isWeakImport = WEAK_IMPORTS.has(symbol);
Expand Down Expand Up @@ -692,17 +697,14 @@ function(${args}) {
stubFunctionBody = assertion + `return ${target}(...args);`;
}
isStub = true;
LibraryManager.library[symbol] = new Function('...args', stubFunctionBody);
snippet = new Function('...args', stubFunctionBody);
}

librarySymbols.push(mangled);

if (!isStub && LibraryManager.library[symbol + '__export']) {
extraExports.add(mangled);
}

const original = LibraryManager.library[symbol];
let snippet = original;
const isUserSymbol = LibraryManager.library[symbol + '__user'];
// Check for dependencies on `__internal` symbols from user libraries.
for (const dep of deps) {
Expand Down Expand Up @@ -988,9 +990,11 @@ var proxiedFunctionTable = [
);
}

timer.start('symbolHandler');
for (const sym of symbolsNeeded) {
symbolHandler(sym);
}
timer.stop('symbolHandler');

if (symbolsOnly) {
writeOutput(
Expand Down
Loading