public class Binary_c extends Expr_c implements Binary
Binary
represents a Java binary expression, an
immutable pair of expressions combined with an operator.Binary.Operator
Term.Instance
Modifier and Type | Field and Description |
---|---|
protected Expr |
left |
protected Binary.Operator |
op |
protected Precedence |
precedence |
protected Expr |
right |
exceptions, reachable
Constructor and Description |
---|
Binary_c(Position pos,
Expr left,
Binary.Operator op,
Expr right) |
Binary_c(Position pos,
Expr left,
Binary.Operator op,
Expr right,
Ext ext) |
Modifier and Type | Method and Description |
---|---|
<T> java.util.List<T> |
acceptCFG(CFGBuilder<?> v,
java.util.List<T> succs)
Visit this term in evaluation order, calling v.edge() for each successor
in succs, if data flows on that edge.
|
Type |
childExpectedType(Expr child,
AscriptionVisitor av)
Get the expected type of a child expression of
this . |
java.lang.Object |
constantValue(Lang lang)
Return the constant value of the expression, if any.
|
boolean |
constantValueSet(Lang lang)
Return true iff the compiler has determined whether this expression has a
constant value.
|
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
void |
dump(CodeWriter w)
Dump the AST node for debugging purposes.
|
Term |
firstChild()
Return the first direct subterm performed when evaluating this term.
|
boolean |
isConstant(Lang lang)
Return whether the expression evaluates to a constant.
|
Expr |
left()
Left child of the binary.
|
Binary |
left(Expr left)
Set the left child of the binary.
|
protected <N extends Binary_c> |
left(N n,
Expr left) |
Binary.Operator |
operator()
The binary's operator.
|
Binary |
operator(Binary.Operator op)
Set the binary's operator.
|
protected <N extends Binary_c> |
operator(N n,
Binary.Operator op) |
Precedence |
precedence()
Get the precedence of the expression.
|
protected <N extends Binary_c> |
precedence(N n,
Precedence precedence) |
Binary |
precedence(Precedence precedence)
Set the precedence of the expression.
|
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given
CodeWriter . |
protected <N extends Binary_c> |
reconstruct(N n,
Expr left,
Expr right)
Reconstruct the expression.
|
Expr |
right()
Right child of the binary.
|
Binary |
right(Expr right)
Set the right child of the binary.
|
protected <N extends Binary_c> |
right(N n,
Expr right) |
boolean |
throwsArithmeticException()
Returns true if the binary might throw an arithmetic exception,
such as division by zero.
|
java.util.List<Type> |
throwTypes(TypeSystem ts)
List of Types of exceptions that might get thrown.
|
java.lang.String |
toString() |
Node |
typeCheck(TypeChecker tc)
Type check the AST.
|
Node |
visitChildren(NodeVisitor v)
Visit the children of the node.
|
booleanValue, buildTypes, byteValue, charValue, constantValue, constantValueSet, doubleValue, extRewrite, floatValue, intValue, isConstant, isTypeChecked, lastLang, longValue, printSubExpr, printSubExpr, shortValue, stringValue, type, type, type
exceptionCheck, exceptions, exceptions, exceptions, listChild, reachable, reachable, reachable
addDecls, buildTypesEnter, checkConstants, 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, print, printBlock, printSubStmt, translate, typeCheckEnter, typeCheckOverride, visit, visitChild, visitEdge, visitList
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
constantValue, constantValueSet, isConstant, printSubExpr, printSubExpr, type
del, del, error, error, ext, ext, ext, ext, isDisambiguated, isTypeChecked, position, position, visit, visitEdge
addDecls, buildTypes, buildTypesEnter, checkConstants, copy, disambiguate, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, enterScope, exceptionCheck, exceptionCheckEnter, extRewrite, extRewriteEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, translate, typeCheckEnter, typeCheckOverride, visitChild, visitList
exceptions, exceptions, reachable, reachable
protected Expr left
protected Binary.Operator op
protected Expr right
protected Precedence precedence
public Binary_c(Position pos, Expr left, Binary.Operator op, Expr right)
public Binary_c(Position pos, Expr left, Binary.Operator op, Expr right, Ext ext)
public Binary left(Expr left)
Binary
public Binary.Operator operator()
Binary
public Binary operator(Binary.Operator op)
Binary
protected <N extends Binary_c> N operator(N n, Binary.Operator op)
public Binary right(Expr right)
Binary
public Precedence precedence()
Expr
precedence
in interface Expr
precedence
in class Expr_c
public Binary precedence(Precedence precedence)
Binary
precedence
in interface Binary
protected <N extends Binary_c> N precedence(N n, Precedence precedence)
protected <N extends Binary_c> N reconstruct(N n, Expr left, Expr right)
public Node visitChildren(NodeVisitor v)
NodeOps
visitChildren
in interface NodeOps
visitChildren
in class Node_c
v
- The visitor that will traverse/rewrite the AST.this
.public boolean constantValueSet(Lang lang)
ExprOps
isConstant()
is valid only if
constantValueSet()
is true.constantValueSet
in interface ExprOps
constantValueSet
in class Expr_c
public boolean isConstant(Lang lang)
ExprOps
constantValueSet()
is true.isConstant
in interface ExprOps
isConstant
in class Expr_c
public java.lang.Object constantValue(Lang lang)
ExprOps
isConstant()
is true.constantValue
in interface ExprOps
constantValue
in class Expr_c
public Node typeCheck(TypeChecker tc) 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.typeCheck
in interface NodeOps
typeCheck
in class Node_c
tc
- The type checking visitor.SemanticException
public Type childExpectedType(Expr child, AscriptionVisitor av)
NodeOps
this
.
The expected type is determined by the context in that the child occurs
(e.g., for x = e
, the expected type of e
is
the declared type of x
.
The expected type should impose the least constraints on the child's
type that are allowed by the parent node.childExpectedType
in interface NodeOps
childExpectedType
in class Node_c
child
- A child expression of this node.av
- An ascription visitor.child
.public boolean throwsArithmeticException()
Binary
throwsArithmeticException
in interface Binary
public void prettyPrint(CodeWriter w, PrettyPrinter tr)
Node_c
CodeWriter
.prettyPrint
in interface NodeOps
prettyPrint
in class Node_c
w
- The code writer to which to write.tr
- The pretty printer. This is not a visitor.public void dump(CodeWriter w)
Node
public Term firstChild()
TermOps
firstChild
in interface TermOps
firstChild
in class Term_c
public <T> java.util.List<T> acceptCFG(CFGBuilder<?> v, java.util.List<T> succs)
TermOps
public java.util.List<Type> throwTypes(TypeSystem ts)
NodeOps
throwTypes
in interface NodeOps
throwTypes
in class Node_c