|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpolyglot.ext.jl.ast.Node_c
polyglot.ext.jl.ast.Term_c
polyglot.ext.jl.ast.Expr_c
polyglot.ext.jl.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.ext.jl.ast.Expr_c |
---|
type |
Fields inherited from class polyglot.ext.jl.ast.Term_c |
---|
exceptions, reachable |
Fields inherited from class polyglot.ext.jl.ast.Node_c |
---|
del, ext, position |
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 |
disambiguate(AmbiguityRemover ar)
Remove any remaining ambiguities from the AST. |
NodeVisitor |
disambiguateEnter(AmbiguityRemover ar)
Remove any remaining ambiguities from the AST. |
protected TypeNode |
disambiguateTypeNode(TypeChecker tc,
ClassType ct)
|
Context |
enterScope(Node child,
Context c)
Push a new scope for visiting the child node child . |
Term |
entry()
Return the first (sub)term performed when evaluating this term. |
Node |
exceptionCheck(ExceptionChecker ec)
Check that exceptions are properly propagated throughout the AST. |
TypeNode |
objectType()
Get the type we are instantiating. |
New |
objectType(TypeNode tn)
Set the type we are instantiating. |
protected TypeNode |
partialDisambTypeNode(TypeNode tn,
TypeChecker tc,
ClassType outer)
|
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()
|
void |
translate(CodeWriter w,
Translator tr)
Translate the AST using the given CodeWriter . |
Node |
typeCheck(TypeChecker tc)
Type check the AST. |
protected ClassBody |
typeCheckBody(TypeChecker tc,
ClassType superType)
|
NodeVisitor |
typeCheckEnter(TypeChecker tc)
Type check the AST. |
protected Node |
typeCheckEpilogue(TypeChecker tc)
|
Node |
visitChildren(NodeVisitor v)
Visit the children of the expression. |
Methods inherited from class polyglot.ext.jl.ast.Expr_c |
---|
booleanValue, byteValue, charValue, constantValue, doubleValue, dump, floatValue, intValue, isConstant, longValue, printSubExpr, printSubExpr, shortValue, stringValue, type, type |
Methods inherited from class polyglot.ext.jl.ast.Term_c |
---|
exceptions, exceptions, listEntry, reachable, reachable |
Methods inherited from class polyglot.ext.jl.ast.Node_c |
---|
addDecls, addMembers, addMembersEnter, addMembersOverride, buildTypesOverride, copy, del, del, disambiguateOverride, enterScope, exceptionCheckEnter, exceptionCheckOverride, ext, ext, ext, ext, init, node, position, position, print, printBlock, printSubStmt, typeCheckOverride, 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, isConstant, printSubExpr, printSubExpr, type |
Methods inherited from interface polyglot.ast.Node |
---|
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, enterScope, exceptionCheckEnter |
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 New
public New qualifier(Expr qualifier)
qualifier
in interface New
public TypeNode objectType()
objectType
in interface New
public New objectType(TypeNode tn)
objectType
in interface New
public ParsedClassType anonType()
New
anonType
in interface New
public New anonType(ParsedClassType anonType)
New
anonType
in interface New
public ProcedureInstance procedureInstance()
ProcedureCall
procedureInstance
in interface ProcedureCall
public ConstructorInstance constructorInstance()
New
constructorInstance
in interface New
public New constructorInstance(ConstructorInstance ci)
New
constructorInstance
in interface New
public java.util.List arguments()
New
arguments
in interface New
arguments
in interface ProcedureCall
Expr
.public ProcedureCall arguments(java.util.List arguments)
New
arguments
in interface New
arguments
in interface ProcedureCall
arguments
- A list of Expr
.public ClassBody body()
New
body
in interface New
public 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 NodeOps
visitChildren
in class Node_c
v
- The visitor that will traverse/rewrite the AST.
this
.public Context enterScope(Node child, Context c)
Node_c
child
.
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.
enterScope
in interface NodeOps
enterScope
in class Node_c
child
- 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
NodeOps
TypeSystem
.
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 NodeOps
buildTypesEnter
in class Node_c
tb
- The visitor which adds new type objects to the
TypeSystem
.
SemanticException
public Node buildTypes(TypeBuilder tb) throws SemanticException
NodeOps
TypeSystem
.
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 NodeOps
buildTypes
in class Expr_c
tb
- The visitor which adds new type objects to the
TypeSystem
.
SemanticException
public NodeVisitor disambiguateEnter(AmbiguityRemover ar) throws SemanticException
NodeOps
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.
disambiguateEnter
in interface NodeOps
disambiguateEnter
in class Node_c
ar
- The visitor which disambiguates.
SemanticException
public Node disambiguate(AmbiguityRemover ar) 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.
disambiguate
in interface NodeOps
disambiguate
in class Node_c
ar
- The visitor which disambiguates.
SemanticException
public NodeVisitor typeCheckEnter(TypeChecker tc) throws SemanticException
NodeOps
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.
typeCheckEnter
in interface NodeOps
typeCheckEnter
in class Node_c
tc
- The type checking visitor.
SemanticException
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
protected Node typeCheckEpilogue(TypeChecker tc) throws SemanticException
SemanticException
protected TypeNode partialDisambTypeNode(TypeNode tn, TypeChecker tc, ClassType outer) throws SemanticException
SemanticException
protected TypeNode disambiguateTypeNode(TypeChecker tc, ClassType ct) throws SemanticException
SemanticException
protected ClassBody typeCheckBody(TypeChecker tc, ClassType superType) throws SemanticException
SemanticException
public Type childExpectedType(Expr child, AscriptionVisitor av)
Node
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 Node
childExpectedType
in class Node_c
child
- A child expression of this node.av
- An ascription visitor.
child
.public Node exceptionCheck(ExceptionChecker ec) 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.
exceptionCheck
in interface NodeOps
exceptionCheck
in class Term_c
ec
- The visitor.
SemanticException
public Precedence precedence()
precedence
in interface Expr
precedence
in class Expr_c
public 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_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 translate(CodeWriter w, Translator tr)
Node_c
CodeWriter
.
translate
in interface NodeOps
translate
in class Node_c
w
- The code writer to which to write.tr
- The translation pass. This is not a visitor.public Term entry()
Term_c
entry
in interface Term
entry
in class Term_c
public java.util.List acceptCFG(CFGBuilder v, java.util.List succs)
Term_c
acceptCFG
in interface Term
acceptCFG
in class Term_c
public java.util.List throwTypes(TypeSystem ts)
NodeOps
throwTypes
in interface NodeOps
throwTypes
in class Node_c
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |