|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.core.isdl.ast.Expr avrora.core.isdl.ast.BitExpr
The BitExpr
class represents an access of an individual bit within a value. In the IR,
individual bits of values can be addressed for both reading and writing.
Field Summary | |
Expr |
bit
The bit field stores a reference to an expression that when evaluated indicates which bit
to read. |
Expr |
expr
The expr field stores a reference to the expression whose value the bit will be extracted
from. |
Fields inherited from class avrora.core.isdl.ast.Expr |
PREC_A_ADD, PREC_A_AND, PREC_A_MUL, PREC_A_OR, PREC_A_SHIFT, PREC_A_XOR, PREC_L_AND, PREC_L_EQU, PREC_L_OR, PREC_L_REL, PREC_L_XOR, PREC_TERM, PREC_UN |
Constructor Summary | |
BitExpr(Expr e,
Expr b)
The constructor of the BitExpr class simply initializes the references to the expression
and the bit. |
Method Summary | |
Expr |
accept(CodeRebuilder r,
java.lang.Object env)
The accept() method implements one half of the visitor pattern for rebuilding of
expressions. |
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. |
void |
accept(ExprVisitor 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. |
int |
getBitWidth()
The getBitWidth() method gets the number of bits needed to represent this value. |
int |
getPrecedence()
The getPrecedence() method gets the binding precedence for this expression. |
boolean |
isConstantExpr()
The isConstantExpr() method tests whether this expression is a constant expression (i.e.
|
java.lang.String |
toString()
The toString() method recursively converts this expression to a string. |
Methods inherited from class avrora.core.isdl.ast.Expr |
innerString, isBitRangeExpr, isLiteral, isMap, isVariable, tokenToBool, tokenToInt |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public final Expr expr
expr
field stores a reference to the expression whose value the bit will be extracted
from.
public final Expr bit
bit
field stores a reference to an expression that when evaluated indicates which bit
to read.
Constructor Detail |
public BitExpr(Expr e, Expr b)
BitExpr
class simply initializes the references to the expression
and the bit.
e
- the expression representing the value to extract the bit fromb
- the expression representing the number of the bit to extractMethod Detail |
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. For a BitExpr
, only one bit is required, so this method
returns 1.
getBitWidth
in class Expr
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).
isConstantExpr
in class Expr
public void accept(ExprVisitor 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.
accept
in class Expr
v
- the visitor to acceptpublic 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.
accept
in class Expr
v
- the visitor to acceptpublic 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.
accept
in class Expr
r
- the rebuilder to accept
visit()
method of the rebuilderpublic java.lang.String toString()
toString()
method recursively converts this expression to a string. For binary
operations, inner expressions will be nested within parentheses if their precedence is lower than the
precedence of the parent expression.
public 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.
getPrecedence
in class Expr
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |