public interface ArrayInitializer extends Expression
Expression
subinterface for array initializers. The array
initialization expression has a few interesting features. Notice, the
argument is Object
. The contract is that the Object
must be
of runtime-type Expression
or, more likely, Object[]
. If the
type is Object[]
, then each element of that array will recursively be
introspected, checking again to see if the type is Expression
or
Object[]
. In this manner, one can arbitrarily nest expressions. This
is the only way I know how to accomplish this behavior (ie not knowing the
dimensionality of an argument at compile-time).
For example, say we wanted to make the array: int[][] aai = 1, 2
, {
3, 4 }}; } One could do this by:
Expression[] a1 = new Expression[2]; a1[0] = new IntLiteralImpl(1); a1[1] = new IntLiteralImpl(2); Expression[] a2 = new Expression[2]; a2[0] = new IntLiteralImpl(3); a2[1] = new IntLiteralImpl(4); Object[] a3 = new Object[2]; a3[0] = a1; a3[1] = a2; ArrayDeclarationStatement asd = new ArrayDeclarationStatementImpl(); // fictional // implementation asd.setInitialization(a3);
Modifier and Type | Method and Description |
---|---|
Object |
getArgs()
Gets the array initialization expressions.
|
ArrayInitializer |
setArgs(Object o)
Sets the array initialization expressions as an arbitrarily nested array
of
Expression[] or as a single Expression . |
getType
applyStyle, cast, getComment, isActive, isBlockWithAbruptCompletion, setComment, toCode, visit, vm
Object getArgs()
ArrayInitializer setArgs(Object o)
Expression[]
or as a single Expression
.Copyright © 2000–2018 jenesis4java. All rights reserved.