public class ArrayDeclaration extends TypeDeclaration implements ArrayType
ArrayType
. As the only attribute of
an array has been the length attribute, it has been handled in a
different way than members of usual classes. As we need some implicit
fields for array creation and initialisation, the special handling of
arrays is not any longer practicable.
So, this class introduce a 'virtual' declaration for array types
containing all required members. Please not the array fields accessed
by an index are not included, so arrays of different lengths with same base
type belong to the same array declaration.
Attention: In contrast to the other type declaration, array
declarations may be added at runtime.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
altNameRepresentation |
private TypeReference |
basetype
reference to the type the elements of this array must subclass
|
private int |
dim
dimension of the array
|
private KeYJavaType |
superType |
fullName, isLibrary, members, name, parentIsInterfaceDeclaration
modArray
Modifier | Constructor and Description |
---|---|
|
ArrayDeclaration(ExtList children,
TypeReference baseType,
KeYJavaType superType)
ArrayDeclaration
|
private |
ArrayDeclaration(ExtList children,
TypeReference baseType,
ProgramElementName name,
KeYJavaType superType) |
Modifier and Type | Method and Description |
---|---|
private static ExtList |
addLength(ExtList children,
KeYJavaType superType) |
static ProgramElementName |
createName(TypeReference basetype) |
private int |
dimension()
computes the dimension of this array
|
java.lang.String |
getAlternativeNameRepresentation()
full name of the array in alternative form, i.e.
|
TypeReference |
getBaseType()
Get the element/base type.
|
ProgramElement |
getChildAt(int index)
Returns the child at the specified index in this node's "virtual"
child array
|
int |
getChildCount()
Returns the number of children of this node.
|
Literal |
getDefaultValue()
returns the default value of the given type
according to JLS Sect. 4.5.5
|
int |
getDimension()
return the dimension of this array
|
ImmutableList<KeYJavaType> |
getSupertypes()
returns the local declared supertypes
|
boolean |
isInterface()
Arrays are never interfaces (but may have interface types as
element types)
|
boolean |
isStrictFp()
Arrays are never strictfp.
|
boolean |
isTransient()
Arrays are never transient.
|
boolean |
isVolatile()
Arrays are never volatile.
|
FieldDeclaration |
length() |
void |
prettyPrint(PrettyPrinter p)
pretty prints an array declaration
|
java.lang.String |
toString()
toString
|
void |
visit(Visitor v)
calls the corresponding method of a visitor in order to
perform some action/transformation on this element
|
equals, getAllFields, getAllMethods, getAllSupertypes, getAllTypes, getConstructors, getFields, getFirstElement, getFullName, getLastElement, getMembers, getMethods, getName, getPackage, getProgramElementName, getTypeDeclarationAt, getTypeDeclarationCount, getTypes, isAbstract, isFinal, isLibraryClass, isPrivate, isProtected, isPublic, isStatic
getModifiers, getStateCount, getVisibilityModifier, isGhost, isModel, isNative, isSynchronized
compatibleBlockSize, computeHashCode, equalsModRenaming, getArrayPos, match, matchChildren
getComments, hashCode, prettyPrintMain, reuseSignature
getEndPosition, getFirstElementIncludingBlocks, getParentClass, getPositionInfo, getRelativePosition, getStartPosition, setParentClass, toSource, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getFullName, getName
getModifiers
getComments, match
equalsModRenaming, getEndPosition, getFirstElementIncludingBlocks, getPositionInfo, getRelativePosition, getStartPosition
private final TypeReference basetype
private final int dim
private final KeYJavaType superType
private java.lang.String altNameRepresentation
private ArrayDeclaration(ExtList children, TypeReference baseType, ProgramElementName name, KeYJavaType superType)
public ArrayDeclaration(ExtList children, TypeReference baseType, KeYJavaType superType)
children
- an ExtList with the basetype and member
declarations of this typeprivate static ExtList addLength(ExtList children, KeYJavaType superType)
public int getChildCount()
getChildCount
in interface NonTerminalProgramElement
public FieldDeclaration length()
public ProgramElement getChildAt(int index)
getChildAt
in interface NonTerminalProgramElement
index
- an index into this node's "virtual" child arrayjava.lang.ArrayIndexOutOfBoundsException
- if index is out
of boundspublic TypeReference getBaseType()
getBaseType
in interface ArrayType
public boolean isStrictFp()
isStrictFp
in interface Member
isStrictFp
in interface MemberDeclaration
isStrictFp
in class TypeDeclaration
true
if this member is strictfp,
false
otherwise.public boolean isTransient()
isTransient
in class JavaDeclaration
public boolean isVolatile()
isVolatile
in class JavaDeclaration
public boolean isInterface()
isInterface
in interface ClassType
true
if this object represents an interface,
false
if it is an ordinary class.public int getDimension()
getDimension
in interface ArrayType
public Literal getDefaultValue()
getDefaultValue
in interface Type
getDefaultValue
in class TypeDeclaration
private int dimension()
public static ProgramElementName createName(TypeReference basetype)
public java.lang.String getAlternativeNameRepresentation()
ArrayType
int[]
instead of [I
getAlternativeNameRepresentation
in interface ArrayType
public ImmutableList<KeYJavaType> getSupertypes()
getSupertypes
in interface ClassType
getSupertypes
in class TypeDeclaration
public void visit(Visitor v)
visit
in interface SourceElement
v
- the Visitorpublic void prettyPrint(PrettyPrinter p) throws java.io.IOException
prettyPrint
in interface SourceElement
prettyPrint
in class JavaProgramElement
p
- a pretty printer.java.io.IOException
- occasionally thrown.public java.lang.String toString()
toString
in class JavaSourceElement