public abstract class Expr_c extends Term_c implements Expr, ExprOps
Expr
represents any Java expression. All expressions
must be subtypes of Expr.Term.Instance
Modifier and Type | Field and Description |
---|---|
protected Type |
type |
exceptions, reachable
Constructor and Description |
---|
Expr_c(Position pos)
Deprecated.
|
Expr_c(Position pos,
Ext ext) |
Modifier and Type | Method and Description |
---|---|
boolean |
booleanValue(Lang lang) |
Node |
buildTypes(TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node
and constructs type objects for these.
|
byte |
byteValue(Lang lang) |
char |
charValue(Lang lang) |
java.lang.Object |
constantValue()
Deprecated.
|
java.lang.Object |
constantValue(Lang lang)
Return the constant value of the expression, if any.
|
boolean |
constantValueSet()
Deprecated.
|
boolean |
constantValueSet(Lang lang)
Return true iff the compiler has determined whether this expression has a
constant value.
|
double |
doubleValue(Lang lang) |
void |
dump(CodeWriter w)
Dump the AST node for debugging purposes.
|
Node |
extRewrite(ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
float |
floatValue(Lang lang) |
int |
intValue(Lang lang) |
boolean |
isConstant()
Deprecated.
|
boolean |
isConstant(Lang lang)
Return whether the expression evaluates to a constant.
|
boolean |
isTypeChecked() |
protected Lang |
lastLang()
Deprecated.
|
long |
longValue(Lang lang) |
Precedence |
precedence()
Get the precedence of the expression.
|
void |
printSubExpr(Expr expr,
boolean associative,
CodeWriter w,
PrettyPrinter pp)
Correctly parenthesize the subexpression
expr
based on its precedence and the precedence of this expression. |
void |
printSubExpr(Expr expr,
CodeWriter w,
PrettyPrinter pp)
Correctly parenthesize the subexpression
expr
based on its precedence and the precedence of this expression. |
short |
shortValue(Lang lang) |
java.lang.String |
stringValue(Lang lang) |
Type |
type()
Get the type of the expression.
|
protected <N extends Expr_c> |
type(N n,
Type type) |
Expr |
type(Type type)
Return an equivalent expression, but with the type
type . |
acceptCFG, exceptionCheck, exceptions, exceptions, exceptions, firstChild, listChild, reachable, reachable, reachable
addDecls, buildTypesEnter, checkConstants, childExpectedType, copy, copy, copy, copyIfNeeded, del, del, disambiguate, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, enterScope, error, error, error, exceptionCheckEnter, ext, ext, ext, ext, extRewriteEnter, isDisambiguated, lang, position, position, position, prettyPrint, prettyPrint, prettyPrint, prettyPrint, prettyPrint, print, printBlock, printSubStmt, throwTypes, toString, translate, typeCheck, typeCheckEnter, typeCheckOverride, visit, visitChild, visitChildren, visitEdge, visitList
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
del, del, error, error, ext, ext, ext, ext, isDisambiguated, position, position, visit, visitEdge
addDecls, buildTypesEnter, checkConstants, childExpectedType, copy, copy, disambiguate, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, enterScope, exceptionCheck, exceptionCheckEnter, extRewriteEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, prettyPrint, throwTypes, translate, typeCheck, typeCheckEnter, typeCheckOverride, visitChild, visitChildren, visitList
exceptions, exceptions, reachable, reachable
protected Type type
@Deprecated public Expr_c(Position pos)
public Type type()
UnknownType
before type-checking, but should return the
correct type after type-checking.public Expr type(Type type)
Expr
type
.public void dump(CodeWriter w)
Node
public Precedence precedence()
Expr
precedence
in interface Expr
@Deprecated protected Lang lastLang()
@Deprecated public boolean constantValueSet()
Expr
isConstant()
is valid only if
constantValueSet()
is true.constantValueSet
in interface Expr
@Deprecated public boolean isConstant()
Expr
constantValueSet()
is true.isConstant
in interface Expr
@Deprecated public java.lang.Object constantValue()
Expr
isConstant()
is true.constantValue
in interface Expr
public boolean constantValueSet(Lang lang)
ExprOps
isConstant()
is valid only if
constantValueSet()
is true.constantValueSet
in interface ExprOps
public boolean isConstant(Lang lang)
ExprOps
constantValueSet()
is true.isConstant
in interface ExprOps
public java.lang.Object constantValue(Lang lang)
ExprOps
isConstant()
is true.constantValue
in interface ExprOps
public java.lang.String stringValue(Lang lang)
public boolean booleanValue(Lang lang)
public byte byteValue(Lang lang)
public short shortValue(Lang lang)
public char charValue(Lang lang)
public int intValue(Lang lang)
public long longValue(Lang lang)
public float floatValue(Lang lang)
public double doubleValue(Lang lang)
public boolean isTypeChecked()
isTypeChecked
in interface Node
isTypeChecked
in class Node_c
public Node buildTypes(TypeBuilder tb) throws SemanticException
NodeOps
TypeSystem
.
This method is called by the leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.buildTypes
in interface NodeOps
buildTypes
in class Node_c
tb
- The visitor which adds new type objects to the
TypeSystem
.SemanticException
public Node extRewrite(ExtensionRewriter rw) throws SemanticException
NodeOps
leave()
method of the
visitor. The method should perform work that should be done
after visiting the children of the node. The method may return
this
or a new copy of the node which will be
installed as a child of the node's parent.extRewrite
in interface NodeOps
extRewrite
in class Term_c
rw
- The visitor.SemanticException
public void printSubExpr(Expr expr, CodeWriter w, PrettyPrinter pp)
Expr
expr
based on its precedence and the precedence of this expression.
If the sub-expression has the same precedence as this expression
we do not parenthesize.
This is equivalent to printSubexpr(expr, true, w, pp)
printSubExpr
in interface Expr
expr
- The subexpression.w
- The output writer.pp
- The pretty printer.public void printSubExpr(Expr expr, boolean associative, CodeWriter w, PrettyPrinter pp)
Expr
expr
based on its precedence and the precedence of this expression.
If the sub-expression has the same precedence as this expression,
we parenthesize if the sub-expression does not associate. For example,
we parenthesize the right subexpression of a left-associative operator.printSubExpr
in interface Expr
expr
- The subexpression.associative
- Whether expr is the left (right) child of a left-
(right-) associative operator.w
- The output writer.pp
- The pretty printer.