public class New_c extends Expr_c implements New, NewOps
New is an immutable representation of the use of the
new operator to create a new instance of a class. In
addition to the type of the class being created, a New has a
list of arguments to be passed to the constructor of the object and an
optional ClassBody used to support anonymous classes.Term.Instance| Modifier and Type | Field and Description |
|---|---|
protected ParsedClassType |
anonType |
protected java.util.List<Expr> |
arguments |
protected ClassBody |
body |
protected ConstructorInstance |
ci |
protected TypeNode |
objectType |
protected Expr |
qualifier |
protected boolean |
qualifierImplicit |
exceptions, reachable| Constructor and Description |
|---|
New_c(Position pos,
Expr qualifier,
TypeNode tn,
java.util.List<Expr> arguments,
ClassBody body) |
New_c(Position pos,
Expr qualifier,
TypeNode tn,
java.util.List<Expr> arguments,
ClassBody body,
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.
|
ParsedClassType |
anonType()
The type object for anonymous classes, or null.
|
protected <N extends New_c> |
anonType(N n,
ParsedClassType anonType) |
New |
anonType(ParsedClassType anonType)
Set the type object for anonymous classes.
|
java.util.List<Expr> |
arguments()
Actual arguments to pass to the constructor.
|
New |
arguments(java.util.List<Expr> arguments)
Set the actual arguments to pass to the constructor.
|
protected <N extends New_c> |
arguments(N n,
java.util.List<Expr> arguments) |
ClassBody |
body()
The class body for anonymous classes, or null.
|
New |
body(ClassBody body)
Set the class body for anonymous classes.
|
protected <N extends New_c> |
body(N n,
ClassBody body) |
Node |
buildTypes(TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node
and constructs type objects for these.
|
NodeVisitor |
buildTypesEnter(TypeBuilder tb)
Collects classes, methods, and fields from the AST rooted at this node
and constructs type objects for these.
|
Type |
childExpectedType(Expr child,
AscriptionVisitor av)
Get the expected type of a child expression of
this. |
ConstructorInstance |
constructorInstance()
The constructor invoked by this expression.
|
New |
constructorInstance(ConstructorInstance ci)
Set the constructor invoked by this expression.
|
protected <N extends New_c> |
constructorInstance(N n,
ConstructorInstance ci) |
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
Node |
disambiguate(AmbiguityRemover ar)
Remove any remaining ambiguities from the AST.
|
Node |
disambiguateOverride(Node parent,
AmbiguityRemover ar)
Disambiguate the AST.
|
Context |
enterChildScope(Node child,
Context c)
Push a new scope for visiting the child node
child. |
Node |
exceptionCheck(ExceptionChecker ec)
Check that exceptions are properly propagated throughout the AST.
|
Node |
extRewrite(ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
NodeVisitor |
extRewriteEnter(ExtensionRewriter rw)
Rewrite the AST for the compilation in this language.
|
ClassType |
findEnclosingClass(Context c,
ClassType ct) |
TypeNode |
findQualifiedTypeNode(AmbiguityRemover ar,
ClassType outer,
TypeNode objectType) |
Expr |
findQualifier(AmbiguityRemover ar,
ClassType ct) |
Term |
firstChild()
Return the first direct subterm performed when evaluating this term.
|
boolean |
isQualifierImplicit()
Is the qualifier implicit?
|
TypeNode |
objectType()
The type we are creating, possibly qualified by qualifier.
|
protected <N extends New_c> |
objectType(N n,
TypeNode objectType) |
New |
objectType(TypeNode objectType)
Set the type we are creating.
|
Precedence |
precedence()
Get the precedence of the expression.
|
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given
CodeWriter. |
void |
printArgs(CodeWriter w,
PrettyPrinter tr) |
void |
printBody(CodeWriter w,
PrettyPrinter tr) |
void |
printQualifier(CodeWriter w,
PrettyPrinter tr) |
void |
printShortObjectType(CodeWriter w,
PrettyPrinter tr) |
ProcedureInstance |
procedureInstance()
The type object of the procedure we are calling.
|
Expr |
qualifier()
The qualifier expression for the type, or null.
|
New |
qualifier(Expr qualifier)
Set the qualifier expression for the type.
|
protected <N extends New_c> |
qualifier(N n,
Expr qualifier) |
New |
qualifierImplicit(boolean implicit)
Set whether the qualifier of this New is implicit.
|
protected <N extends New_c> |
qualifierImplicit(N n,
boolean implicit) |
protected <N extends New_c> |
reconstruct(N n,
Expr qualifier,
TypeNode tn,
java.util.List<Expr> arguments,
ClassBody body)
Reconstruct the expression.
|
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.
|
void |
typeCheckFlags(TypeChecker tc) |
protected void |
typeCheckFlags(TypeChecker tc,
Flags classFlags) |
void |
typeCheckNested(TypeChecker tc) |
Node |
typeCheckOverride(Node parent,
TypeChecker tc)
Type check the AST.
|
Node |
visitChildren(NodeVisitor v)
Visit the children of the node.
|
booleanValue, byteValue, charValue, constantValue, constantValue, constantValueSet, constantValueSet, doubleValue, dump, floatValue, intValue, isConstant, isConstant, isTypeChecked, lastLang, longValue, printSubExpr, printSubExpr, shortValue, stringValue, type, type, typeexceptions, exceptions, exceptions, listChild, reachable, reachable, reachableaddDecls, checkConstants, copy, copy, copyIfNeeded, del, del, disambiguateEnter, dump, dump, dump, dump, enterScope, error, error, error, exceptionCheckEnter, ext, ext, ext, ext, isDisambiguated, lang, position, position, position, prettyPrint, prettyPrint, prettyPrint, prettyPrint, print, printBlock, printSubStmt, translate, typeCheckEnter, 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, checkConstants, copy, disambiguateEnter, dump, dump, dump, dump, enterScope, exceptionCheckEnter, lang, prettyPrint, prettyPrint, prettyPrint, prettyPrint, translate, typeCheckEnter, visitChild, visitListexceptions, exceptions, reachable, reachableconstantValue, constantValueSet, isConstantprotected Expr qualifier
protected TypeNode objectType
protected java.util.List<Expr> arguments
protected ClassBody body
protected ConstructorInstance ci
protected ParsedClassType anonType
protected boolean qualifierImplicit
public New_c(Position pos, Expr qualifier, TypeNode tn, java.util.List<Expr> arguments, ClassBody body)
public Expr qualifier()
Newpublic New qualifier(Expr qualifier)
Newpublic boolean isQualifierImplicit()
NewisQualifierImplicit in interface Newpublic New qualifierImplicit(boolean implicit)
NewqualifierImplicit in interface Newprotected <N extends New_c> N qualifierImplicit(N n, boolean implicit)
public TypeNode objectType()
NewobjectType in interface Newpublic New objectType(TypeNode objectType)
NewobjectType in interface Newpublic ParsedClassType anonType()
Newpublic New anonType(ParsedClassType anonType)
Newprotected <N extends New_c> N anonType(N n, ParsedClassType anonType)
public ProcedureInstance procedureInstance()
ProcedureCallprocedureInstance in interface ProcedureCallpublic ConstructorInstance constructorInstance()
NewconstructorInstance in interface Newpublic New constructorInstance(ConstructorInstance ci)
NewconstructorInstance in interface Newprotected <N extends New_c> N constructorInstance(N n, ConstructorInstance ci)
public java.util.List<Expr> arguments()
Newarguments in interface Newarguments in interface ProcedureCallExpr.public New arguments(java.util.List<Expr> arguments)
Newarguments in interface Newarguments in interface ProcedureCallarguments - A list of Expr.public ClassBody body()
Newpublic New body(ClassBody body)
Newprotected <N extends New_c> N reconstruct(N n, Expr qualifier, TypeNode tn, java.util.List<Expr> arguments, ClassBody body)
public Node visitChildren(NodeVisitor v)
NodeOpsvisitChildren in interface NodeOpsvisitChildren in class Node_cv - The visitor that will traverse/rewrite the AST.this.public Context enterChildScope(Node child, Context c)
NodeOpschild.
The default behavior is to delegate the call to the child node, and let
it add appropriate declarations that should be in scope. However,
this method gives parent nodes have the ability to modify this behavior.enterChildScope in interface NodeOpsenterChildScope in class Node_cchild - the child node about to be entered.c - the current ContextContext to be used for visiting node
childpublic NodeVisitor buildTypesEnter(TypeBuilder tb) throws SemanticException
NodeOpsTypeSystem.
This method is called by the enter() method of the
visitor. The * method should perform work that should be done
before visiting the children of the node. The method may return
this or a new copy of the node on which
visitChildren() and leave() will be
invoked.buildTypesEnter in interface NodeOpsbuildTypesEnter in class Node_ctb - The visitor which adds new type objects to the
TypeSystem.SemanticExceptionpublic Node buildTypes(TypeBuilder tb) throws SemanticException
NodeOpsTypeSystem.
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 NodeOpsbuildTypes in class Expr_ctb - The visitor which adds new type objects to the
TypeSystem.SemanticExceptionpublic Node disambiguateOverride(Node parent, AmbiguityRemover ar) throws SemanticException
NodeOpsoverride() method of the
visitor. If this method returns non-null, the node's children
will not be visited automatically. Thus, the method should check
both the node this and it's children, usually by
invoking visitChildren with tc or
with another visitor, returning a non-null node. OR, the method
should do nothing and simply return null to allow
enter, visitChildren, and leave
to be invoked on the node.
The default implementation returns null.
Overriding of this method is discouraged, but sometimes necessary.disambiguateOverride in interface NodeOpsdisambiguateOverride in class Node_car - The visitor which disambiguates.SemanticExceptionpublic TypeNode findQualifiedTypeNode(AmbiguityRemover ar, ClassType outer, TypeNode objectType) throws SemanticException
findQualifiedTypeNode in interface NewOpsSemanticExceptionpublic Node disambiguate(AmbiguityRemover ar) 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.
The node should not assume that its children have been disambiguated.
If it depends on a child being disambiguated,
it may just return this without doing any work.disambiguate in interface NodeOpsdisambiguate in class Node_car - The visitor which disambiguates.SemanticExceptionpublic Expr findQualifier(AmbiguityRemover ar, ClassType ct) throws SemanticException
findQualifier in interface NewOpsSemanticExceptionpublic 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 void typeCheckNested(TypeChecker tc) throws SemanticException
typeCheckNested in interface NewOpsSemanticExceptionpublic ClassType findEnclosingClass(Context c, ClassType ct)
findEnclosingClass in interface NewOpspublic void typeCheckFlags(TypeChecker tc) throws SemanticException
typeCheckFlags in interface NewOpsSemanticExceptionprotected void typeCheckFlags(TypeChecker tc, Flags classFlags) throws SemanticException
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 Node exceptionCheck(ExceptionChecker ec) 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.exceptionCheck in interface NodeOpsexceptionCheck in class Term_cec - The visitor.SemanticExceptionpublic NodeVisitor extRewriteEnter(ExtensionRewriter rw) throws SemanticException
NodeOpsenter() method of the
visitor. The method should perform work that should be done
before visiting the children of the node. The method may return
this or a new copy of the node on which
visitChildren() and leave() will be
invoked.extRewriteEnter in interface NodeOpsextRewriteEnter in class Node_crw - The visitor.SemanticExceptionpublic Node extRewrite(ExtensionRewriter rw) 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.extRewrite in interface NodeOpsextRewrite in class Expr_crw - The visitor.SemanticExceptionpublic Precedence precedence()
Exprprecedence in interface Exprprecedence in class Expr_cpublic void printQualifier(CodeWriter w, PrettyPrinter tr)
printQualifier in interface NewOpspublic void printShortObjectType(CodeWriter w, PrettyPrinter tr)
printShortObjectType in interface NewOpspublic void printArgs(CodeWriter w, PrettyPrinter tr)
printArgs in interface ProcedureCallOpspublic void printBody(CodeWriter w, PrettyPrinter tr)
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 java.util.List<Type> throwTypes(TypeSystem ts)
NodeOpsthrowTypes in interface NodeOpsthrowTypes in class Node_cpublic Node typeCheckOverride(Node parent, TypeChecker tc) throws SemanticException
Node_ctypeCheckOverride in interface NodeOpstypeCheckOverride in class Node_ctc - The type checking visitor.SemanticException