1 32 package org.jruby.ast; 33 34 import java.io.IOException ; 35 import java.util.List ; 36 37 import org.jruby.ast.types.INameNode; 38 import org.jruby.ast.visitor.NodeVisitor; 39 import org.jruby.evaluator.Instruction; 40 import org.jruby.lexer.yacc.ISourcePosition; 41 import org.jruby.runtime.MethodIndex; 42 43 48 public final class CallNode extends Node implements INameNode, IArgumentNode, BlockAcceptingNode { 49 static final long serialVersionUID = -1993752395320088525L; 50 51 private final Node receiverNode; 52 private String name; 53 private Node argsNode; 54 private Node iterNode; 55 public final int index; 56 57 public CallNode(ISourcePosition position, Node receiverNode, String name, Node argsNode) { 58 this(position, receiverNode, name, argsNode, null); 59 } 60 61 public CallNode(ISourcePosition position, Node receiverNode, String name, Node argsNode, 62 Node iterNode) { 63 super(position, NodeTypes.CALLNODE); 64 this.receiverNode = receiverNode; 65 this.name = name.intern(); 66 this.argsNode = argsNode; 67 this.iterNode = iterNode; 68 this.index = MethodIndex.getIndex(this.name); 69 } 70 71 private void readObject(java.io.ObjectInputStream in) throws IOException , ClassNotFoundException { 72 in.defaultReadObject(); 73 74 name = name.intern(); 76 } 77 78 82 public Instruction accept(NodeVisitor iVisitor) { 83 return iVisitor.visitCallNode(this); 84 } 85 86 public Node getIterNode() { 87 return iterNode; 88 } 89 90 public void setIterNode(Node iterNode) { 91 this.iterNode = iterNode; 92 } 93 94 98 public Node getArgsNode() { 99 return argsNode; 100 } 101 102 107 public void setArgsNode(Node argsNode) { 108 this.argsNode = argsNode; 109 } 110 111 116 public String getName() { 117 return name; 118 } 119 120 125 public Node getReceiverNode() { 126 return receiverNode; 127 } 128 129 public List childNodes() { 130 return Node.createList(receiverNode, argsNode, iterNode); 131 } 132 133 public String toString() { 134 return "CallNode: " + getName(); 135 } 136 } 137 | Popular Tags |