diff options
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r-- | tools/js-optimizer.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index c1ba41ec..5d883bc3 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -3291,6 +3291,14 @@ function outline(ast) { } // replace in stats stats.splice.apply(stats, [start, end-start+1].concat(reps)); + // if we just removed a final return from the original function, add one + var last = getStatements(func)[getStatements(func).length-1]; + if (last[0] === 'stat') last = last[1]; + if (last[0] !== 'return') { + if (allCodeInfo.hasReturnInt || allCodeInfo.hasReturnDouble) { + getStatements(func).push(['stat', ['return', makeAsmCoercion(['num', 0], allCodeInfo.hasReturnInt ? ASM_INT : ASM_DOUBLE)]]); + } + } return [newFunc]; } |