|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.core.isdl.ast.Expr
The Expr
class represents an expression in the IR. Expressions are evaluated and produce a
value that can be assigned to locals, globalMap, maps, used in if statements, and passed as parameters.
Field Summary | |
static int |
PREC_A_ADD
|
static int |
PREC_A_AND
|
static int |
PREC_A_MUL
|
static int |
PREC_A_OR
|
static int |
PREC_A_SHIFT
|
static int |
PREC_A_XOR
|
static int |
PREC_L_AND
|
static int |
PREC_L_EQU
|
static int |
PREC_L_OR
|
static int |
PREC_L_REL
|
static int |
PREC_L_XOR
|
static int |
PREC_TERM
|
static int |
PREC_UN
|
Constructor Summary | |
Expr()
|
Method Summary | |
abstract Expr |
accept(CodeRebuilder r,
java.lang.Object env)
The accept() method implements one half of the visitor pattern for rebuilding of
expressions. |
abstract void |
accept(CodeVisitor v)
The accept() method implements one half of the visitor pattern so that client visitors can
traverse the syntax tree easily and in an extensible way. |
abstract void |
accept(ExprVisitor v)
The accept() method implements half of the visitor pattern for expression visitors. |
int |
getBitWidth()
The getBitWidth() method gets the number of bits needed to represent this value. |
abstract int |
getPrecedence()
The getPrecedence() method gets the binding precedence for this expression. |
java.lang.String |
innerString(Expr e)
The innerString() method is a utility to embed an expression in parentheses only if its
precedence is less than the precedence of this expression. |
boolean |
isBitRangeExpr()
The isBitRangeExpr() method tests whether the expression is an access of a range of bits.
|
boolean |
isConstantExpr()
The isConstantExpr() method tests whether this expression is a constant expression (i.e.
|
boolean |
isLiteral()
The isLiteral() method tests whether this expression is a known constant directly (i.e. a
literal). |
boolean |
isMap()
The isMap() method tests whether this expression is a reference to an element of a map.
|
boolean |
isVariable()
The isVariable() method tests whether this expression is a single variable use. |
static boolean |
tokenToBool(Token i)
The tokenToBool() static method is a utility to evaluate a token as a boolean literal. |
static int |
tokenToInt(Token i)
The tokenToInt() static method is a utility to evaluate a token as an integer. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int PREC_L_OR
public static final int PREC_L_XOR
public static final int PREC_L_AND
public static final int PREC_A_OR
public static final int PREC_A_XOR
public static final int PREC_A_AND
public static final int PREC_L_EQU
public static final int PREC_L_REL
public static final int PREC_A_SHIFT
public static final int PREC_A_ADD
public static final int PREC_A_MUL
public static final int PREC_UN
public static final int PREC_TERM
Constructor Detail |
public Expr()
Method Detail |
public boolean isVariable()
isVariable()
method tests whether this expression is a single variable use.
public boolean isLiteral()
isLiteral()
method tests whether this expression is a known constant directly (i.e. a
literal).
public boolean isConstantExpr()
isConstantExpr()
method tests whether this expression is a constant expression (i.e.
it is reducable to a constant and has no references to variables, maps, etc).
public boolean isMap()
isMap()
method tests whether this expression is a reference to an element of a map.
This is used in pattern matching in some parts of the tools that work on abstract syntax trees.
public boolean isBitRangeExpr()
isBitRangeExpr()
method tests whether the expression is an access of a range of bits.
This is used in pattern matching in some parts of the code.
public int getBitWidth()
getBitWidth()
method gets the number of bits needed to represent this value. This is
needed in the case of encoding formats, which need to compute the size of an instruction based on the
width of its internal fields.
public abstract int getPrecedence()
getPrecedence()
method gets the binding precedence for this expression. This is used
to compute when inner expressions must be nested within parentheses in order to preserve the implied
order of evaluation.
public static int tokenToInt(Token i)
tokenToInt()
static method is a utility to evaluate a token as an integer.
i
- the value of the integer as a token
public static boolean tokenToBool(Token i)
tokenToBool()
static method is a utility to evaluate a token as a boolean literal.
i
- the value of the boolean as a token
public abstract void accept(ExprVisitor v)
accept()
method implements half of the visitor pattern for expression visitors.
v
- the visitor to acceptpublic abstract void accept(CodeVisitor v)
accept()
method implements one half of the visitor pattern so that client visitors can
traverse the syntax tree easily and in an extensible way.
v
- the visitor to acceptpublic abstract Expr accept(CodeRebuilder r, java.lang.Object env)
accept()
method implements one half of the visitor pattern for rebuilding of
expressions. This visitor allows code to be slightly modified while only writing visit methods for the
parts of the syntax tree affected.
r
- the rebuilder to accept
visit()
method of the rebuilderpublic java.lang.String innerString(Expr e)
innerString()
method is a utility to embed an expression in parentheses only if its
precedence is less than the precedence of this expression. This is useful in converting nested
expressions into strings
e
- the expression nested inside of this expression
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |