public abstract class Expression extends java.lang.Object implements java.lang.Cloneable, java.lang.Comparable<Expression>, Traversable
| Modifier and Type | Method and Description |
|---|---|
Expression |
clone()
Creates and returns a deep copy of this expression.
|
int |
compareTo(Expression e) |
boolean |
equals(java.lang.Object o)
Checks if the given object is has the same type with this expression and
its children is same with this expression's.
|
java.util.List<Expression> |
findExpression(Expression expr)
Returns a list of subexpressions of this expression that match
expr using its equals method.
|
java.util.List<Traversable> |
getChildren()
Provides access to the children of this object as a list.
|
Traversable |
getParent()
Provides access to the parent of this object.
|
Statement |
getStatement()
Get the parent Statement containing this Expression.
|
int |
hashCode()
Returns the hash code of the expression.
|
boolean |
needsParens()
Checks if the expression needs parentheses around itself when printed.
|
void |
print(java.io.PrintWriter o)
Prints the expression on the specified print writer.
|
void |
printSelf() |
void |
removeChild(Traversable child)
This operation is not allowed.
|
void |
setChild(int index,
Traversable t)
Sets the indexth child of this object to t.
|
void |
setParens(boolean f)
Sets whether the expression needs to have
an outer set of parentheses printed around it.
|
void |
setParent(Traversable t)
Sets the parent of this object.
|
void |
setPrintMethod(java.lang.reflect.Method m)
Overrides the print method for this object only.
|
void |
swapWith(Expression expr)
Swaps two expression on the IR tree.
|
java.lang.String |
toString()
Returns a string representation of the expression
|
void |
verify()
Verifies three properties of this object:
(1) All children are not null, (2) the parent object has this
object as a child, (3) all children have this object as the parent.
|
public Expression clone()
clone in class java.lang.Objectpublic int compareTo(Expression e)
compareTo in interface java.lang.Comparable<Expression>public boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to be compared with.o!=null, this.getClass()==o.getClass(),
and this.children.equals(o.children) ||
this.children==o.children==nullpublic int hashCode()
hashCode in class java.lang.Objectpublic java.util.List<Expression> findExpression(Expression expr)
expr - The subexpression sought.public java.util.List<Traversable> getChildren()
TraversablegetChildren in interface Traversablepublic Traversable getParent()
TraversablegetParent in interface Traversablepublic Statement getStatement()
public void print(java.io.PrintWriter o)
public void printSelf()
public void removeChild(Traversable child)
removeChild in interface Traversablechild - a reference to a child object that must match with ==.java.lang.UnsupportedOperationException - alwayspublic void setChild(int index,
Traversable t)
TraversablesetChild in interface TraversableNotAnOrphanException - if t has a parent object.java.lang.IllegalArgumentException - if index is out-of-range or
t is not an expression.public void setParens(boolean f)
f - True to use parens, false to not use parens.public boolean needsParens()
public void setParent(Traversable t)
TraversablesetParent in interface Traversablepublic void setPrintMethod(java.lang.reflect.Method m)
m - The new print method.public void swapWith(Expression expr)
expr - The expression with which to swap this expression.java.lang.IllegalArgumentException - if expr is null.java.lang.IllegalStateException - if the types of the expressions
are such that they would create inconsistent IR when swapped.public java.lang.String toString()
toString in class java.lang.Objectpublic void verify()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - if any of the properties are not true.