public class NewArray_c extends Expr_c implements NewArray
NewArray
represents a new array expression such as
new File[8][] { null }
. It consists of an element type (e.g.,
File
), a list of dimension expressions (e.g., 8), 0 or more
additional dimensions (e.g., 1 for []
), and an array initializer.
The dimensions of the array initializer must equal the number of additional
[]
dimensions.Term.Instance
Modifier and Type | Field and Description |
---|---|
protected int |
addDims |
protected TypeNode |
baseType |
protected java.util.List<Expr> |
dims |
protected ArrayInit |
init |
exceptions, reachable
Constructor and Description |
---|
NewArray_c(Position pos,
TypeNode baseType,
java.util.List<Expr> dims,
int addDims,
ArrayInit init) |
NewArray_c(Position pos,
TypeNode baseType,
java.util.List<Expr> dims,
int addDims,
ArrayInit init,
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.
|
int |
additionalDims()
The number of additional dimensions.
|
NewArray |
additionalDims(int addDims)
Set the number of additional dimensions.
|
protected <N extends NewArray_c> |
additionalDims(N n,
int addDims) |
protected ArrayType |
arrayOf(TypeSystem ts,
Type baseType,
int dims) |
TypeNode |
baseType()
The array's base type.
|
protected <N extends NewArray_c> |
baseType(N n,
TypeNode baseType) |
NewArray |
baseType(TypeNode baseType)
Set the array's base type.
|
Type |
childExpectedType(Expr child,
AscriptionVisitor av)
Get the expected type of a child expression of
this . |
Node |
copy(NodeFactory nf)
Produce a copy of this node using the given NodeFactory.
|
java.util.List<Expr> |
dims()
List of dimension expressions.
|
NewArray |
dims(java.util.List<Expr> dims)
Set the list of dimension expressions.
|
protected <N extends NewArray_c> |
dims(N n,
java.util.List<Expr> dims) |
Term |
firstChild()
Return the first direct subterm performed when evaluating this term.
|
ArrayInit |
init()
The array initializer, or null.
|
NewArray |
init(ArrayInit init)
Set the array initializer.
|
protected <N extends NewArray_c> |
init(N n,
ArrayInit init) |
int |
numDims()
The number of array dimensions.
|
void |
prettyPrint(CodeWriter w,
PrettyPrinter tr)
Pretty-print the AST using the given
CodeWriter . |
protected <N extends NewArray_c> |
reconstruct(N n,
TypeNode baseType,
java.util.List<Expr> dims,
ArrayInit init)
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.
|
Node |
visitChildren(NodeVisitor v)
Visit the children of the node.
|
booleanValue, buildTypes, byteValue, charValue, constantValue, constantValue, constantValueSet, constantValueSet, doubleValue, dump, extRewrite, floatValue, intValue, isConstant, isConstant, isTypeChecked, lastLang, longValue, precedence, 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, precedence, printSubExpr, printSubExpr, type
del, del, dump, 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 TypeNode baseType
protected java.util.List<Expr> dims
protected int addDims
protected ArrayInit init
public NewArray_c(Position pos, TypeNode baseType, java.util.List<Expr> dims, int addDims, ArrayInit init)
public TypeNode baseType()
NewArray
public NewArray baseType(TypeNode baseType)
NewArray
protected <N extends NewArray_c> N baseType(N n, TypeNode baseType)
public java.util.List<Expr> dims()
NewArray
public NewArray dims(java.util.List<Expr> dims)
NewArray
protected <N extends NewArray_c> N dims(N n, java.util.List<Expr> dims)
public int numDims()
NewArray
public int additionalDims()
NewArray
additionalDims
in interface NewArray
public NewArray additionalDims(int addDims)
NewArray
additionalDims
in interface NewArray
protected <N extends NewArray_c> N additionalDims(N n, int addDims)
public ArrayInit init()
NewArray
public NewArray init(ArrayInit init)
NewArray
protected <N extends NewArray_c> N init(N n, ArrayInit init)
protected <N extends NewArray_c> N reconstruct(N n, TypeNode baseType, java.util.List<Expr> dims, ArrayInit init)
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 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 ArrayType arrayOf(TypeSystem ts, Type baseType, int dims)
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 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 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