|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectpolyglot.ast.Node_c
polyglot.ast.Term_c
polyglot.ast.Expr_c
polyglot.ast.New_c
public class New_c
A 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.
| Field Summary | |
|---|---|
protected ParsedClassType |
anonType
|
protected java.util.List |
arguments
|
protected ClassBody |
body
|
protected ConstructorInstance |
ci
|
protected Expr |
qualifier
|
protected TypeNode |
tn
|
| Fields inherited from class polyglot.ast.Expr_c |
|---|
type |
| Fields inherited from class polyglot.ast.Term_c |
|---|
exceptions, reachable |
| Fields inherited from class polyglot.ast.Node_c |
|---|
del, error, ext, position |
| Fields inherited from interface polyglot.ast.Term |
|---|
ENTRY, EXIT |
| Fields inherited from interface polyglot.ast.Term |
|---|
ENTRY, EXIT |
| Constructor Summary | |
|---|---|
New_c(Position pos,
Expr qualifier,
TypeNode tn,
java.util.List arguments,
ClassBody body)
|
|
| Method Summary | |
|---|---|
java.util.List |
acceptCFG(CFGBuilder v,
java.util.List succs)
Visit this term in evaluation order. |
ParsedClassType |
anonType()
The type object for anonymous classes, or null. |
New |
anonType(ParsedClassType anonType)
Set the type object for anonymous classes. |
java.util.List |
arguments()
Actual arguments to pass to the constructor. |
ProcedureCall |
arguments(java.util.List arguments)
Set the actual arguments to pass to the constructor. |
ClassBody |
body()
The class body for anonymous classes, or null. |
New |
body(ClassBody body)
Set the class body for anonymous classes. |
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. |
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. |
protected New |
findQualifier(AmbiguityRemover ar,
ClassType ct)
|
Term |
firstChild()
Return the first direct subterm performed when evaluating this term. |
TypeNode |
objectType()
Get the type we are instantiating. |
New |
objectType(TypeNode tn)
Set the type we are instantiating. |
Precedence |
precedence()
Get the precedence of the expression. |
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given CodeWriter. |
protected void |
printArgs(CodeWriter w,
PrettyPrinter tr)
|
protected void |
printBody(CodeWriter w,
PrettyPrinter tr)
|
protected void |
printQualifier(CodeWriter w,
PrettyPrinter tr)
|
ProcedureInstance |
procedureInstance()
The type object of the method we are calling. |
Expr |
qualifier()
Get the qualifier expression of the allocation. |
New |
qualifier(Expr qualifier)
Set the qualifier expression of the allocation. |
protected New_c |
reconstruct(Expr qualifier,
TypeNode tn,
java.util.List arguments,
ClassBody body)
Reconstruct the expression. |
java.util.List |
throwTypes(TypeSystem ts)
List of Types of exceptions that might get thrown. |
java.lang.String |
toString()
|
Node |
typeCheck(TypeChecker tc)
Type check the AST. |
protected void |
typeCheckFlags(TypeChecker tc)
|
protected void |
typeCheckNested(TypeChecker tc)
|
Node |
typeCheckOverride(Node parent,
TypeChecker tc)
Type check the AST. |
Node |
visitChildren(NodeVisitor v)
Visit the children of the expression. |
| Methods inherited from class polyglot.ast.Expr_c |
|---|
booleanValue, byteValue, charValue, constantValue, constantValueSet, doubleValue, dump, floatValue, intValue, isConstant, isTypeChecked, longValue, printSubExpr, printSubExpr, shortValue, stringValue, type, type |
| Methods inherited from class polyglot.ast.Term_c |
|---|
exceptions, exceptions, listChild, reachable, reachable |
| Methods inherited from class polyglot.ast.Node_c |
|---|
addDecls, checkConstants, copy, copy, del, del, disambiguateEnter, dump, dump, enterScope, error, error, exceptionCheckEnter, ext, ext, ext, ext, init, isDisambiguated, node, position, position, prettyPrint, prettyPrint, print, printBlock, printSubStmt, translate, typeCheckEnter, visit, visitChild, visitEdge, visitList |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface polyglot.ast.Expr |
|---|
constantValue, constantValueSet, isConstant, printSubExpr, printSubExpr, type |
| Methods inherited from interface polyglot.ast.Node |
|---|
del, del, dump, error, error, ext, ext, ext, ext, isDisambiguated, isTypeChecked, position, position, visit, visitChild, visitEdge, visitList |
| Methods inherited from interface polyglot.ast.JL |
|---|
init, node |
| Methods inherited from interface polyglot.ast.NodeOps |
|---|
addDecls, checkConstants, copy, disambiguateEnter, dump, dump, enterScope, exceptionCheckEnter, prettyPrint, prettyPrint, translate, typeCheckEnter |
| Methods inherited from interface polyglot.util.Copy |
|---|
copy |
| Methods inherited from interface polyglot.ast.Typed |
|---|
type |
| Methods inherited from interface polyglot.ast.Term |
|---|
exceptions, exceptions, reachable, reachable |
| Methods inherited from interface polyglot.ast.Term |
|---|
exceptions, exceptions, reachable, reachable |
| Field Detail |
|---|
protected Expr qualifier
protected TypeNode tn
protected java.util.List arguments
protected ClassBody body
protected ConstructorInstance ci
protected ParsedClassType anonType
| Constructor Detail |
|---|
public New_c(Position pos,
Expr qualifier,
TypeNode tn,
java.util.List arguments,
ClassBody body)
| Method Detail |
|---|
public Expr qualifier()
qualifier in interface Newpublic New qualifier(Expr qualifier)
qualifier in interface Newpublic TypeNode objectType()
objectType in interface Newpublic New objectType(TypeNode tn)
objectType in interface Newpublic ParsedClassType anonType()
New
anonType in interface Newpublic New anonType(ParsedClassType anonType)
New
anonType in interface Newpublic ProcedureInstance procedureInstance()
ProcedureCall
procedureInstance in interface ProcedureCallpublic ConstructorInstance constructorInstance()
New
constructorInstance in interface Newpublic New constructorInstance(ConstructorInstance ci)
New
constructorInstance in interface Newpublic java.util.List arguments()
New
arguments in interface Newarguments in interface ProcedureCallExpr.public ProcedureCall arguments(java.util.List arguments)
New
arguments in interface Newarguments in interface ProcedureCallarguments - A list of Expr.public ClassBody body()
New
body in interface Newpublic New body(ClassBody body)
New
body in interface New
protected New_c reconstruct(Expr qualifier,
TypeNode tn,
java.util.List arguments,
ClassBody body)
public Node visitChildren(NodeVisitor v)
visitChildren in interface NodeOpsvisitChildren in class Node_cv - The visitor that will traverse/rewrite the AST.
this.
public Context enterChildScope(Node child,
Context c)
Node_cchild.
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 Context
Context to be used for visiting node
child
public 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.
SemanticException
public 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.
SemanticException
public 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.
SemanticException
public 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.
SemanticException
protected New findQualifier(AmbiguityRemover ar,
ClassType ct)
throws SemanticException
ar - ct -
SemanticException
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.
SemanticException
protected void typeCheckNested(TypeChecker tc)
throws SemanticException
SemanticException
protected void typeCheckFlags(TypeChecker tc)
throws SemanticException
SemanticException
public Type childExpectedType(Expr child,
AscriptionVisitor av)
Nodethis.
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 NodechildExpectedType 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 Precedence precedence()
precedence in interface Exprprecedence in class Expr_cpublic java.lang.String toString()
toString in class Node_c
protected void printQualifier(CodeWriter w,
PrettyPrinter tr)
protected void printArgs(CodeWriter w,
PrettyPrinter tr)
protected 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()
Term
firstChild in interface Term
public java.util.List acceptCFG(CFGBuilder v,
java.util.List succs)
Term_c
acceptCFG in interface TermacceptCFG in class Term_cpublic java.util.List throwTypes(TypeSystem ts)
NodeOps
throwTypes in interface NodeOpsthrowTypes in class Node_c
public Node typeCheckOverride(Node parent,
TypeChecker tc)
throws SemanticException
Node_c
typeCheckOverride in interface NodeOpstypeCheckOverride in class Node_cparent - tc -
SemanticExceptionpublic Node copy(NodeFactory nf)
NodeOps
copy in interface NodeOpscopy in class Node_c
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||