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:
parent
84ef3fcaa9
commit
12783ca6b9
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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(); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user