in legacy/javascript/src/refactor.js [669:714]
refactorPipeline() {
var iterations = 0;
this.changed = true;
this.flagAPIToLiteral();
while (this.changed && iterations < this.max_cleanup_steps) {
this.changed = false;
this.evalBoolExpressions();
this.reduceIfStatements();
var redundantVarnames = this.getRedundantVarnames();
this.pruneVarReferences(redundantVarnames);
var functionsWithSingleReturn = this.getFunctionsWithSingleReturn();
var redundantFunctions = this.getRedundantFunctions(functionsWithSingleReturn);
this.pruneFuncReferences(redundantFunctions);
iterations++;
}
this.finalizeLiterals();
if (this.print_to_console) {
if (!this.changed) {
if (iterations == 1 && this.max_cleanup_steps != 1) {
console.log(
colors.yellow(
`Piranha did not make any changes to ${this.filename} to cleanup ${this.flagname}`,
),
);
} else {
console.log(
`Took ${iterations} ${iterations == 1 ? 'pass' : 'passes'} over the code to reach fixed point.`,
);
}
} else {
console.log(
`Terminated before fixed point in ${iterations} ${
iterations == 1 ? 'pass' : 'passes'
} over the code.`,
);
}
}
}