polyglot.ast
Interface Expr

All Superinterfaces:
java.lang.Cloneable, Copy, JL, Node, NodeOps, Prefix, Receiver, Term, Typed
All Known Subinterfaces:
AmbAssign, AmbExpr, ArrayAccess, ArrayAccessAssign, ArrayInit, Assign, Binary, BooleanLit, Call, Cast, CharLit, ClassLit, Conditional, Field, FieldAssign, FloatLit, Instanceof, IntLit, Lit, Local, LocalAssign, New, NewArray, NullLit, NumLit, Special, StringLit, Unary, Variable
All Known Implementing Classes:
AmbAssign_c, AmbExpr_c, ArrayAccess_c, ArrayAccessAssign_c, ArrayInit_c, Assign_c, Binary_c, BooleanLit_c, Call_c, Cast_c, CharLit_c, ClassLit_c, Conditional_c, Expr_c, Field_c, FieldAssign_c, FloatLit_c, Instanceof_c, IntLit_c, Lit_c, Local_c, LocalAssign_c, New_c, NewArray_c, NullLit_c, NumLit_c, Special_c, StringLit_c, Unary_c

public interface Expr
extends Receiver, Term

An Expr represents any Java expression. All expressions must be subtypes of Expr.


Method Summary
 java.lang.Object constantValue()
          Returns the constant value of the expression, if any.
 boolean isConstant()
          Return whether the expression evaluates to a constant.
 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.
 Expr type(Type type)
          Return an equivalent expression, but with the type type.
 
Methods inherited from interface polyglot.ast.Node
childExpectedType, del, del, dump, ext, ext, ext, ext, position, position, visit, visitChild, visitEdge, visitList
 
Methods inherited from interface polyglot.ast.JL
init, node
 
Methods inherited from interface polyglot.ast.NodeOps
addDecls, addMembers, addMembersEnter, buildTypes, buildTypesEnter, disambiguate, disambiguateEnter, enterScope, enterScope, exceptionCheck, exceptionCheckEnter, prettyPrint, throwTypes, translate, typeCheck, typeCheckEnter, visitChildren
 
Methods inherited from interface polyglot.util.Copy
copy
 
Methods inherited from interface polyglot.ast.Typed
type
 
Methods inherited from interface polyglot.ast.Term
acceptCFG, entry, exceptions, exceptions, reachable, reachable
 

Method Detail

type

Expr type(Type type)
Return an equivalent expression, but with the type type.


precedence

Precedence precedence()
Get the precedence of the expression.


isConstant

boolean isConstant()
Return whether the expression evaluates to a constant. This is not valid until after disambiguation.


constantValue

java.lang.Object constantValue()
Returns the constant value of the expression, if any.


printSubExpr

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. If the sub-expression has the same precedence as this expression we parenthesize if the sub-expression does not associate; e.g., we parenthesis the right sub-expression of a left-associative operator.


printSubExpr

void printSubExpr(Expr expr,
                  CodeWriter w,
                  PrettyPrinter pp)
Correctly parenthesize the subexpression expr based on its precedence and the precedence of this expression. This is equivalent to printSubexpr(expr, true, w, pp)