avrora.core.isdl.ast
Class Literal.IntExpr
java.lang.Object
avrora.core.isdl.ast.Expr
avrora.core.isdl.ast.Literal
avrora.core.isdl.ast.Literal.IntExpr
- Enclosing class:
- Literal
- public static class Literal.IntExpr
- extends Literal
The IntExpr inner class represents an integer literal
that has a known, constant value.
|
Field Summary |
int |
value
The value class stores the constant integer value of
this literal. |
| Fields inherited from class avrora.core.isdl.ast.Literal |
token |
| 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 |
Literal.IntExpr(Token v)
The constructor of the IntExpr class evaluates the
token's string value to an integer and stores it in the publicly
accessable value field, as well as storing a reference
to the original token. |
|
Method Summary |
Expr |
accept(CodeRebuilder r)
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. |
int |
getBitWidth()
The getBitWidth() method returns the known bit size
of this expression which is needed in computing the size of an
encoding. |
int |
getPrecedence()
The getPrecedence() method gets the binding precedence for
this expression. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
value
public final int value
- The
value class stores the constant integer value of
this literal.
Literal.IntExpr
public Literal.IntExpr(Token v)
- The constructor of the
IntExpr class evaluates the
token's string value to an integer and stores it in the publicly
accessable value field, as well as storing a reference
to the original token.
- Parameters:
v - the token representing the value of this integer
getBitWidth
public int getBitWidth()
- The
getBitWidth() method returns the known bit size
of this expression which is needed in computing the size of an
encoding. For integer literals, the known bit width is
only defined for binary constants (e.g. "0b0101011"), in which
case it is the number of bits after the "0b" prefix.
- Overrides:
getBitWidth in class Expr
- Returns:
- the width of this integer in bits if it is a binary literal; an error
otherwise
accept
public 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.
- Specified by:
accept in class Expr
- Parameters:
v - the visitor to accept
accept
public Expr accept(CodeRebuilder r)
- Description copied from class:
Expr
- The
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.
- Specified by:
accept in class Expr
- Parameters:
r - the rebuilder to accept
- Returns:
- the result of calling the appropriate
visit()
method of the rebuilder
toString
public java.lang.String toString()
getPrecedence
public int getPrecedence()
- Description copied from class:
Expr
- The
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.
- Specified by:
getPrecedence in class Expr
- Returns:
- an integer representing the precedence of this expression; higher
numbers are higher precedence