SFE.Compiler
Class ArrayType

java.lang.Object
  extended by SFE.Compiler.Type
      extended by SFE.Compiler.ParentType
          extended by SFE.Compiler.ArrayType

public class ArrayType
extends ParentType

Class ArraType is used for representing an Array that was defined in the program.


Constructor Summary
ArrayType(Type type, int length)
          Constructs a new ArrayType object from a given length and base type.
 
Method Summary
 Type getBaseType()
          Returns the base type of this ArrayType.
 java.util.Vector getDerivedLvalues(Lvalue base)
          Returns a vector of all the derived lvalue (inluding this lvalue).
 int getLength()
          Returns the length of this array.
 java.lang.String getNameAt(java.lang.String baseName, int i)
          Returns the name of the bit at offset i in the array.
 int size()
          Returns the length of the this ArrayType in bits.
 java.lang.String toFormat()
          Returns a String representing this object as it should appear in the format file.
 java.lang.String toFormat(java.lang.String parentName, Function function)
          Returns a String representing this object as it should appear in the format file.
 java.lang.String toString()
          Returns a string representation of the this ArrayType.
 
Methods inherited from class SFE.Compiler.ParentType
hasDerives
 
Methods inherited from class SFE.Compiler.Type
defineName, fromName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayType

public ArrayType(Type type,
                 int length)
Constructs a new ArrayType object from a given length and base type.

Parameters:
type - the base type of this array.
length - the length of this array.
Method Detail

size

public int size()
Returns the length of the this ArrayType in bits.

Specified by:
size in class Type
Returns:
the length of the this ArrayType in bits.

getLength

public int getLength()
Returns the length of this array.

Returns:
the length of this array.

toString

public java.lang.String toString()
Returns a string representation of the this ArrayType.

Overrides:
toString in class java.lang.Object
Returns:
the string "array" as the string representation of this ArrayType.

toFormat

public java.lang.String toFormat()
Returns a String representing this object as it should appear in the format file.

Specified by:
toFormat in class Type
Returns:
empty string. This method will not be called when writing the format file.

getBaseType

public Type getBaseType()
Returns the base type of this ArrayType.

Returns:
the base type of this ArrayType.

getDerivedLvalues

public java.util.Vector getDerivedLvalues(Lvalue base)
Returns a vector of all the derived lvalue (inluding this lvalue). Basically, the vector will hold this lvalue and all the entries lvalue.

Specified by:
getDerivedLvalues in class ParentType
Parameters:
base - the lvalue that called the this method (base.type == this)

toFormat

public java.lang.String toFormat(java.lang.String parentName,
                                 Function function)
Returns a String representing this object as it should appear in the format file.

Returns:
a String representing this object as it should appear in the format file.

getNameAt

public java.lang.String getNameAt(java.lang.String baseName,
                                  int i)
Returns the name of the bit at offset i in the array.

Specified by:
getNameAt in class ParentType
Parameters:
baseName - the name of a child
i - the offset in bits of this object.
Returns:
the name of the bit at offset i in the array.