Since NodeTransformer.transform(tree) never replaces tree, change its signature to return void which allows to eliminate ScriptOrFnNode.replaceFunctionNode.

git-svn-id: svn://10.0.0.236/trunk@139214 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
igor%mir2.org 2003-03-10 20:26:58 +00:00
parent 84ef3fcaa9
commit 12783ca6b9
3 changed files with 7 additions and 15 deletions

View File

@ -73,7 +73,7 @@ public class Interpreter {
public ScriptOrFnNode
transform(Context cx, IRFactory irFactory, ScriptOrFnNode tree)
{
tree = (new NodeTransformer(irFactory)).transform(tree);
(new NodeTransformer(irFactory)).transform(tree);
return tree;
}

View File

@ -54,11 +54,11 @@ public class NodeTransformer {
* Return new instance of this class. So that derived classes
* can override methods of the transformer.
*/
public NodeTransformer newInstance() {
protected NodeTransformer newInstance() {
return new NodeTransformer(irFactory);
}
public ScriptOrFnNode transform(ScriptOrFnNode tree)
public void transform(ScriptOrFnNode tree)
{
loops = new ObjArray();
loopEnds = new ObjArray();
@ -80,8 +80,7 @@ public class NodeTransformer {
int fnIndex = node.getExistingIntProp(Node.FUNCTION_PROP);
FunctionNode fnNode = tree.getFunctionNode(fnIndex);
NodeTransformer inner = newInstance();
fnNode = (FunctionNode)inner.transform(fnNode);
tree.replaceFunctionNode(fnIndex, fnNode);
inner.transform(fnNode);
}
break;
@ -423,8 +422,6 @@ public class NodeTransformer {
}
}
}
return tree;
}
protected void visitNew(Node node, ScriptOrFnNode tree) {
@ -555,9 +552,9 @@ public class NodeTransformer {
sourceName, lineno, null, 0);
}
protected ObjArray loops;
protected ObjArray loopEnds;
protected boolean inFunction;
private ObjArray loops;
private ObjArray loopEnds;
private boolean inFunction;
protected IRFactory irFactory;
}

View File

@ -84,11 +84,6 @@ public class ScriptOrFnNode extends Node {
return (FunctionNode)functions.get(i);
}
public final void replaceFunctionNode(int i, FunctionNode fnNode) {
if (fnNode == null) Context.codeBug();
functions.set(i, fnNode);
}
public final int addFunction(FunctionNode fnNode) {
if (fnNode == null) Context.codeBug();
if (functions == null) { functions = new ObjArray(); }