public final class InitializedArrayCreation extends CallableOperation
Operation representing the construction of a
one-dimensional array with a given element type and length. The InitializedArrayCreation
operation requires a list of elements in an initializer. For instance, new int[2] is the
InitializedArrayCreation in the initializationint[] x = new int[2] { 3, 7 }; In terms of the notation used for the Operation class, a creation of an array of
elements of type e with length n has a signature [ e,...,e] → t,
where [e,...,e] is a list of length n, and t is the array type.
InitializedArrayCreation objects are immutable.
| Modifier and Type | Field and Description |
|---|---|
private Type |
elementType |
private int |
length |
| Constructor and Description |
|---|
InitializedArrayCreation(ArrayType arrayType,
int length)
Creates an object representing the construction of an array that holds values of the element
type and has the given length.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendCode(Type declaringType,
TypeTuple inputTypes,
Type outputType,
java.util.List<Variable> inputVars,
java.lang.StringBuilder b)
Produces a Java source code representation of this statement and appends it to the given
StringBuilder.
|
boolean |
equals(@Nullable java.lang.Object o) |
ExecutionOutcome |
execute(java.lang.Object[] statementInput)
Performs this operation using the array of input values.
|
int |
getLength()
Returns the length of created array.
|
java.lang.String |
getName()
Returns the name for the operation.
|
int |
hashCode() |
static TypedOperation |
parse(java.lang.String str)
Parses an array declaration in a string descriptor in the form generated by
toParsableString(Type, TypeTuple, Type). |
java.lang.String |
toParsableString(Type declaringType,
TypeTuple inputTypes,
Type outputType)
Returns a string representation of this Operation (not an invocation of this Operation), which
can be read by the static parse method for the class in which the method is defined.
|
java.lang.String |
toString() |
getArgumentString, getReflectionObject, getValue, isConstantField, isConstructorCall, isMessage, isMethodCall, isNonreceivingValue, isStatic, isUncheckedCast, satisfiesprivate final int length
private final Type elementType
InitializedArrayCreation(ArrayType arrayType, int length)
length - number of objects allowed in the arrayarrayType - the type of array this operation createspublic int getLength()
public ExecutionOutcome execute(java.lang.Object[] statementInput)
execute in class CallableOperationstatementInput - array containing appropriate inputs to operationNormalExecution object containing constructed arraypublic java.lang.String toString()
toString in class java.lang.Objectpublic void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, java.util.List<Variable> inputVars, java.lang.StringBuilder b)
appendCode in class CallableOperationdeclaringType - the declaring type for this operationinputTypes - the input types for this operationoutputType - the output type for this operationinputVars - the list of variables that are inputs to operationb - the StringBuilder to which code is addedpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(@Nullable java.lang.Object o)
equals in class java.lang.Objectpublic java.lang.String toParsableString(Type declaringType, TypeTuple inputTypes, Type outputType)
Creates string of the form TYPE[NUMELEMS] where TYPE is the type of the array, and NUMELEMS is the number of elements.
Example: int[3]
toParsableString in class CallableOperationdeclaringType - the declaring type for this operationinputTypes - the input types for this operationoutputType - the output type for this operationpublic java.lang.String getName()
Operationpublic static TypedOperation parse(java.lang.String str) throws OperationParseException
toParsableString(Type, TypeTuple, Type).str - the string to be parsed for the InitializedArrayCreationOperationParseException - if string does not have expected formOperationParser.parse(String)