diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-19 10:47:22 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-19 10:47:22 -0700 |
commit | 93a3268b6a42c0ea5df36bbd99510655e1ce4fc3 (patch) | |
tree | feb5363a512a45b15a3266ed149d65c16d215ec1 /tools/js-optimizer.js | |
parent | e24923c6b98e8de99582e4e0c532134ef19c2282 (diff) |
ensure a final return after inlining, if necessary
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]; } |