Skip to content

Commit

Permalink
Remove unused 2nd pass from runJSify. NFC (#18236)
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Nov 21, 2022
1 parent 2e02d0e commit d659edc
Showing 1 changed file with 20 additions and 37 deletions.
57 changes: 20 additions & 37 deletions src/jsifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,35 @@ function isDefined(symName) {
}

// JSifier
function runJSify(functionsOnly) {
const mainPass = !functionsOnly;
function runJSify() {
const functionStubs = [];

const itemsDict = {type: [], functionStub: [], function: [], globalVariablePostSet: []};

if (mainPass) {
// 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)
// 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();
LibraryManager.load();

const libFuncsToInclude = DEFAULT_LIBRARY_FUNCS_TO_INCLUDE;
for (const sym of EXPORTED_RUNTIME_METHODS) {
if ('$' + sym in LibraryManager.library) {
libFuncsToInclude.push('$' + sym);
}
const libFuncsToInclude = DEFAULT_LIBRARY_FUNCS_TO_INCLUDE;
for (const sym of EXPORTED_RUNTIME_METHODS) {
if ('$' + sym in LibraryManager.library) {
libFuncsToInclude.push('$' + sym);
}
if (INCLUDE_FULL_LIBRARY) {
for (const key in LibraryManager.library) {
if (!isJsLibraryConfigIdentifier(key)) {
libFuncsToInclude.push(key);
}
}
if (INCLUDE_FULL_LIBRARY) {
for (const key in LibraryManager.library) {
if (!isJsLibraryConfigIdentifier(key)) {
libFuncsToInclude.push(key);
}
}
libFuncsToInclude.forEach((ident) => {
functionStubs.push({
identOrig: ident,
identMangled: mangleCSymbolName(ident),
});
});
}
libFuncsToInclude.forEach((ident) => {
functionStubs.push({
identOrig: ident,
identMangled: mangleCSymbolName(ident),
});
});

function convertPointerParams(snippet, sig) {
// Automatically convert any incoming pointer arguments from BigInt
Expand Down Expand Up @@ -472,14 +469,6 @@ function ${name}(${args}) {

itemsDict.globalVariablePostSet = itemsDict.globalVariablePostSet.concat(orderedPostSets);

//

if (!mainPass) {
const generated = itemsDict.function.concat(itemsDict.type);
print(generated.map((item) => item.JS).join('\n'));
return;
}

const shellFile = MINIMAL_RUNTIME ? 'shell_minimal.js' : 'shell.js';

const shellParts = read(shellFile).split('{{BODY}}');
Expand All @@ -493,9 +482,6 @@ function ${name}(${args}) {
}
print(pre);

// Print out global variables and postsets TODO: batching
runJSify(true);

const generated = itemsDict.functionStub.concat(itemsDict.globalVariablePostSet);
generated.forEach((item) => print(indentify(item.JS || '', 2)));

Expand Down Expand Up @@ -552,10 +538,7 @@ function ${name}(${args}) {
}

// Data

if (mainPass) {
functionStubs.forEach(functionStubHandler);
}
functionStubs.forEach(functionStubHandler);

finalCombiner();
}

0 comments on commit d659edc

Please sign in to comment.