From 66b82ca2dec555661e898da20bf48d5f737a2c2e Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 30 Jan 2004 07:03:29 +0000 Subject: [PATCH] 2003/07/07 01:50:03 darcs-hash:20040130070329-aa32f-dd00bed603eb776a0e742951d4e14e4e83ee6f2b.gz --- src/org/xwt/js/CompiledFunctionImpl.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/org/xwt/js/CompiledFunctionImpl.java b/src/org/xwt/js/CompiledFunctionImpl.java index 217a613..8f063b2 100644 --- a/src/org/xwt/js/CompiledFunctionImpl.java +++ b/src/org/xwt/js/CompiledFunctionImpl.java @@ -37,7 +37,12 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens { private CompiledFunctionImpl cloneWithNewParentScope(JS.Scope s) throws IOException { CompiledFunctionImpl ret = new JS.CompiledFunction(sourceName, firstLine, null, s); - ret.paste(this); + // Reuse the same op, arg, line, and size variables for the new "instance" of the function + // NOTE: Neither *this* function nor the new function should be modified after this call + ret.op = this.op; + ret.arg = this.arg; + ret.line = this.line; + ret.size = this.size; return ret; } @@ -63,7 +68,7 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens { try { cx.currentCompiledFunction = (CompiledFunction)this; int size = cx.stack.size(); - cx.stack.push(new CallMarker()); + cx.stack.push(callMarker); cx.stack.push(args); eval(scope); Object ret = cx.stack.pop(); @@ -454,7 +459,7 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens { // FunctionScope ///////////////////////////////////////////////////////////////// - private class FunctionScope extends JS.Scope { + private static class FunctionScope extends JS.Scope { String sourceName; public FunctionScope(String sourceName, Scope parentScope) { super(parentScope); this.sourceName = sourceName; } public String getSourceName() { return sourceName; } @@ -464,6 +469,7 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens { // Markers ////////////////////////////////////////////////////////////////////// public static class CallMarker { public CallMarker() { } } + private static CallMarker callMarker = new CallMarker(); public static class CatchMarker { public CatchMarker() { } } private static CatchMarker catchMarker = new CatchMarker(); -- 1.7.10.4