public class Conditional_c extends Expr_c implements Conditional
Conditional is a representation of a Java ternary
expression. That is, (cond ? consequent : alternative).Term.Instance| Modifier and Type | Field and Description |
|---|---|
protected Expr |
alternative |
protected Expr |
cond |
protected Expr |
consequent |
exceptions, reachable| Constructor and Description |
|---|
Conditional_c(Position pos,
Expr cond,
Expr consequent,
Expr alternative) |
Conditional_c(Position pos,
Expr cond,
Expr consequent,
Expr alternative,
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.
|
Expr |
alternative()
Get the expression to evaluate when the condition is false.
|
Conditional |
alternative(Expr alternative)
Set the expression to evaluate when the condition is false.
|
protected <N extends Conditional_c> |
alternative(N n,
Expr alternative) |
Type |
childExpectedType(Expr child,
AscriptionVisitor av)
Get the expected type of a child expression of
this. |
Expr |
cond()
Get the condition to test.
|
Conditional |
cond(Expr cond)
Set the condition to test.
|
protected <N extends Conditional_c> |
cond(N n,
Expr cond) |
Expr |
consequent()
Get the expression to evaluate when the condition is true.
|
Conditional |
consequent(Expr consequent)
Set the expression to evaluate when the condition is true.
|
protected <N extends Conditional_c> |
consequent(N n,
Expr consequent) |
java.lang.Object |
constantValue(Lang lang)
Return the constant value of the expression, if any.
|
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
Term |
firstChild()
Return the first direct subterm performed when evaluating this term.
|
boolean |
isConstant(Lang lang)
Return whether the expression evaluates to a constant.
|
Precedence |
precedence()
Get the precedence of the expression.
|
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given
CodeWriter. |
protected <N extends Conditional_c> |
reconstruct(N n,
Expr cond,
Expr consequent,
Expr alternative)
Reconstruct the expression.
|
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, constantValueSet, doubleValue, dump, extRewrite, floatValue, intValue, isConstant, isTypeChecked, lastLang, longValue, printSubExpr, printSubExpr, shortValue, stringValue, type, type, typeexceptionCheck, exceptions, exceptions, exceptions, listChild, reachable, reachable, reachableaddDecls, 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, throwTypes, translate, typeCheckEnter, typeCheckOverride, visit, visitChild, visitEdge, visitListclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitconstantValue, constantValueSet, isConstant, printSubExpr, printSubExpr, typedel, del, dump, error, error, ext, ext, ext, ext, isDisambiguated, isTypeChecked, position, position, visit, visitEdgeaddDecls, buildTypes, buildTypesEnter, checkConstants, copy, disambiguate, disambiguateEnter, disambiguateOverride, dump, dump, dump, dump, enterChildScope, enterScope, exceptionCheck, exceptionCheckEnter, extRewrite, extRewriteEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, throwTypes, translate, typeCheckEnter, typeCheckOverride, visitChild, visitListexceptions, exceptions, reachable, reachableprotected Expr cond
protected Expr consequent
protected Expr alternative
public Precedence precedence()
Exprprecedence in interface Exprprecedence in class Expr_cpublic Expr cond()
Conditionalcond in interface Conditionalpublic Conditional cond(Expr cond)
Conditionalcond in interface Conditionalprotected <N extends Conditional_c> N cond(N n, Expr cond)
public Expr consequent()
Conditionalconsequent in interface Conditionalpublic Conditional consequent(Expr consequent)
Conditionalconsequent in interface Conditionalprotected <N extends Conditional_c> N consequent(N n, Expr consequent)
public Expr alternative()
Conditionalalternative in interface Conditionalpublic Conditional alternative(Expr alternative)
Conditionalalternative in interface Conditionalprotected <N extends Conditional_c> N alternative(N n, Expr alternative)
protected <N extends Conditional_c> N reconstruct(N n, Expr cond, Expr consequent, Expr alternative)
public Node visitChildren(NodeVisitor v)
NodeOpsvisitChildren in interface NodeOpsvisitChildren in class Node_cv - The visitor that will traverse/rewrite the AST.this.public Node typeCheck(TypeChecker tc) throws SemanticException
NodeOpsleave() 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 NodeOpstypeCheck in class Node_ctc - The type checking visitor.SemanticExceptionpublic Type childExpectedType(Expr child, AscriptionVisitor av)
NodeOpsthis.
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 NodeOpschildExpectedType in class Node_cchild - A child expression of this node.av - An ascription visitor.child.public void prettyPrint(CodeWriter w, PrettyPrinter tr)
Node_cCodeWriter.prettyPrint in interface NodeOpsprettyPrint in class Node_cw - The code writer to which to write.tr - The pretty printer. This is not a visitor.public Term firstChild()
TermOpsfirstChild in interface TermOpsfirstChild in class Term_cpublic <T> java.util.List<T> acceptCFG(CFGBuilder<?> v, java.util.List<T> succs)
TermOpspublic boolean isConstant(Lang lang)
ExprOpsconstantValueSet() is true.isConstant in interface ExprOpsisConstant in class Expr_cpublic java.lang.Object constantValue(Lang lang)
ExprOpsisConstant() is true.constantValue in interface ExprOpsconstantValue in class Expr_c