Skip to content

Commit

Permalink
fix: Remove runPass and use runPasses only (AssemblyScript#2005)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGraey authored Jul 26, 2021
1 parent e7e7a1d commit 397ed55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
14 changes: 11 additions & 3 deletions cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ exports.main = function main(argv, options, callback) {
transforms = transforms.map(classOrModule => {
// Except if it’s a legacy module, just pass it through.
if (typeof classOrModule !== "function") {
return classOrModule;
return classOrModule;
}
Object.assign(classOrModule.prototype, {
program,
Expand Down Expand Up @@ -881,12 +881,20 @@ exports.main = function main(argv, options, callback) {
if (opts.trapMode === "clamp") {
stats.optimizeCount++;
stats.optimizeTime += measure(() => {
module.runPass("trap-mode-clamp");
try {
module.runPasses(["trap-mode-clamp"]);
} catch (e) {
crash("runPasses", e);
}
});
} else if (opts.trapMode === "js") {
stats.optimizeCount++;
stats.optimizeTime += measure(() => {
module.runPass("trap-mode-js");
try {
module.runPasses(["trap-mode-js"]);
} catch (e) {
crash("runPasses", e);
}
});
} else if (opts.trapMode !== "allow") {
module.dispose();
Expand Down
10 changes: 0 additions & 10 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2191,16 +2191,6 @@ export class Module {
binaryen._BinaryenModuleSetFeatures(this.ref, featureFlags);
}

runPass(pass: string, func: FunctionRef = 0): void {
var cStr = allocString(pass);
if (func) {
binaryen._BinaryenFunctionRunPasses(func, this.ref, cStr, 1);
} else {
binaryen._BinaryenModuleRunPasses(this.ref, cStr, 1);
}
binaryen._free(cStr);
}

runPasses(passes: string[], func: FunctionRef = 0): void {
var numNames = passes.length;
var cStrs = new Array<StringRef>(numNames);
Expand Down

0 comments on commit 397ed55

Please sign in to comment.