public class ArrayInitializer extends ProtoExpression
VOID_ASSIGNMENTS| Modifier and Type | Method and Description |
|---|---|
Expression |
array() |
void |
compile(Compiler compiler)
To compile an ArrayInitializer, we:
compile the array,
compile the dimensions (ints are systematically boxed so that the value of
a dimension's indexable is always popped off the object stack),
compile the number of dimensions,
compile the extension depth,
generate an ARRAY_INITIALIZE.
|
static Let |
construct(Type elementType,
java.util.AbstractList dimension,
Expression array)
Returns a Let wrapping a new array initializer
constructed with the specified parameters.
|
Expression |
copy()
Returns a deep copy of this expression.
|
Expression[] |
dimension() |
Type |
elementType() |
int |
numberOfSubexpressions()
Returns the number of subexpressions
|
void |
setCheckedType()
This method sets the final unambiguously checked type of this expression, possibly
along with other final information that may be needed by the compiler for
generating code.
|
Expression |
setSubexpression(int n,
Expression expression)
Returns this expression after setting its n-th subexpression to the specified
expression; if there is no subexpression at the given position, this throws a
NoSuchSubexpressionException
|
Expression |
subexpression(int n)
Returns the n-th subexpression of this expression; if there is no subexpression
at the given position, this throws a NoSuchSubexpressionException
|
java.lang.String |
toString() |
void |
typeCheck(TypeChecker typeChecker)
Type-checking proceeds as follows:
each dimension expression is type-checked to have an index set type;
this is then checked as an array type corresponding to the element type
and the dimensions' types;
the array is type-checked to be an array of the same number of dimensions
as this,
each dimension type is verified to be such that:
where this dimension type is int, that of the array must be int too;
where this dimension type is set, that of the array must be either
int, or set of same base type;
where this dimension type is int range, that of the array must be
either int, int range, or a set of int.
|
Expression |
typedCopy()
Returns a deep copy of this expression this and all its subexpressions share the
same type as their copy's counterparts.
|
checkedType, setCheckedType, setType, type, typeRefaddType, addTypes, boxSort, containsFreeName, enclosingScope, extent, getEnd, getStart, isConstant, isEquality, isFalse, isHiddenSlicing, isNull, isSelector, isSlicing, isTrue, isVoid, locationString, otherTypes, parameters, sanitizeNames, sanitizeSorts, setCheckedTypeLocked, setEnd, setExtent, setOtherTypes, setStart, shiftOffsets, shiftOffsets, sort, substitute, typeCheck, typeCheck, typeCheckLockedpublic final Expression copy()
Expressioncopy in class Expressionpublic final Expression typedCopy()
ExpressiontypedCopy in class Expressionpublic static final Let construct(Type elementType, java.util.AbstractList dimension, Expression array)
public final int numberOfSubexpressions()
ExpressionnumberOfSubexpressions in class Expressionpublic final Expression subexpression(int n) throws NoSuchSubexpressionException
Expressionsubexpression in class ExpressionNoSuchSubexpressionExceptionpublic final Expression setSubexpression(int n, Expression expression) throws NoSuchSubexpressionException
ExpressionsetSubexpression in class ExpressionNoSuchSubexpressionExceptionpublic final Type elementType()
public final Expression[] dimension()
public final Expression array()
public final void setCheckedType()
ExpressionsetCheckedType in class Expressionpublic final void typeCheck(TypeChecker typeChecker) throws TypingErrorException
typeCheck in class ExpressionTypingErrorExceptionpublic final void compile(Compiler compiler)
compile in class Expressionpublic final java.lang.String toString()
toString in class java.lang.Object