📄 callexpr.java
字号:
// $Id: CallExpr.java,v 1.6 1999/10/11 06:54:33 deberg Exp $package java6035.tools.IR;import java.util.*;/** * CallExpr represents a method call expression. */public class CallExpr extends Expression{ protected Vector arguments; protected ProcDescriptor proc; /** * Constructs a call expression, given the procedure and the list of * arguments. */ public CallExpr(ProcDescriptor proc, Vector args) { if (proc == null) throw new IRException("CallExpr: constructor: procedure null"); this.proc = proc; this.arguments = args; if (this.arguments == null) this.arguments = new Vector(); for(int i=0; i<arguments.size(); i++) { Rhs arg; // sigh... no polymorphic implementation of vector try { arg = (Rhs) arguments.elementAt(i); } catch (ClassCastException e) { throw new IRException ("CallExpr: constructor: arguments must be Rhs objects"); } if (arg == null) throw new IRException ("CallExpr: constructor: arguments must not be null"); } } protected int expkind() { return CALL_EXPR; } /** * Returns the procedure descriptor. */ public ProcDescriptor getProc() { return this.proc; } /** * Sets the procedure descriptor. */ public void setProc(ProcDescriptor proc) { this.proc = proc; if (this.proc == null) throw new IRException("CallExpr: setProc: procedure null"); } /** * Returns an enumeration of arguments. */ public Enumeration args() { return arguments.elements(); } /** * Returns number of arguments */ public int getArgumentCount() { return arguments.size(); } /** * Returns the argument at the specified index. */ public Rhs getArgumentAt(int index) { return (Rhs) arguments.elementAt(index); } /** * Removes argument at given index from the argument list. */ public void removeArgumentAt(int index) { arguments.removeElementAt(index); } /** * Removes an argument from the argument list. */ public void removeArgument(Rhs arg) { arguments.removeElement(arg); } /** * Replace an argument in the argument list with a new one. */ public void setArgumentAt(Rhs arg, int index) { if (arg == null) throw new IRException ("CallExpr: setArgumentAt: arguments must not be null"); arguments.setElementAt(arg, index); } /** * Inserts an argument into the argument list at the specified * index. */ public void insertArgumentAt(Rhs arg, int index) { if (arg == null) throw new IRException ("CallExpr: insertArgumentAt: arguments must not be null"); arguments.insertElementAt(arg, index); } /** * Appends an argument onto the argument list. */ public void appendArgument(Rhs arg) { if (arg == null) throw new IRException ("CallExpr: appendArgument: arguments must not be null"); arguments.addElement(arg); } /** * Walkable interface: returns the name of the node. */ public String getNodeName() { return "call_expr"; } /** * Walkable interface: returns the number of neighbors. */ public int getNeighborCount() { return 1+getArgumentCount(); } /** * Walkable interface: returns the specified neighbor: 0, proc descriptor; * 1 - n, arguments 0 - n-1. */ public Object getNeighbor(int index) { if (index == 0) return proc; else return getArgumentAt(index-1); } public String PPrint(int indent, boolean recursive) { String output = new String(); for(int i=0;i<indent;i++) output += " "; output += "(call_expr " + proc.toString() + "\n"; if (recursive) for (int j=0; j<arguments.size(); j++) output += ((Rhs)arguments.elementAt(j)).PPrint(indent+4, true); for(int i=0;i<indent;i++) output += " "; output += ") /* call_expr " + proc.toString() + " */\n"; return output; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -