📄 arrayexpr.java
字号:
// $Id: ArrayExpr.java,v 1.4 2000/10/10 15:47:50 mdeeds Exp $package java6035.tools.IR;/** * ArrayExpr represents an array reference. */public class ArrayExpr extends Expression implements Lhs{ protected Rhs base; protected Rhs offset; /** * Constructs an Array Expression where @param(base) is the * array variable, and @param(offset) is the index into the * array. * * Requires: base, offset are not null. **/ public ArrayExpr(Rhs base, Rhs offset) { this.base = base; this.offset = offset; if (this.base == null) throw new IRException ("ArrayExpr: constructor: base null"); if (this.offset == null) throw new IRException ("ArrayExpr: constructor: offset null"); } /** * Returns the globally specified ID for this type of Expression. * (i.e. ARRAY_EXPR) **/ protected int expkind() { return ARRAY_EXPR; } /** * Returns the base (array variable) of this. **/ public Rhs getBase() { return base; } /** * Sets the base (array variable) of this. **/ public void setBase(Rhs base) { this.base = base; if (this.base == null) throw new IRException("ArrayExpr: setBase: base null"); } /** * Returns the offset (index) of this. **/ public Rhs getOffset() { return offset; } /** * Sets the offset (index) of this. **/ public void setOffset(Rhs offset) { this.offset = offset; if (this.offset == null) throw new IRException("ArrayExpr: setOffset: offset null"); } /** * Walkable interface: returns the name of the node. **/ public String getNodeName() { return "array_expr"; } /** * Walkable interface: returns the number of neighbors (children) * in the IR tree. These are the base and the offset. i.e. 2. **/ public int getNeighborCount() { return 2; } /** * Walkable interface: returns the specified neighbor. * specify 0 for base, and 1 for offset **/ public Object getNeighbor(int index) { if (index == 0) return base; else return offset; } public String PPrint(int indent, boolean recursive) { String output = new String(); for(int i=0;i<indent;i++) output += " "; output += "(array_expr\n"; if (recursive) { output += base.PPrint(indent+2, true); output += offset.PPrint(indent+2, true); } for(int i=0;i<indent;i++) output += " "; output += ") /* array_expr */\n"; return output; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -