SFE.Compiler
Class StructType

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

public class StructType
extends ParentType

Class StructType is used for representing a Struct that was defined in the program. An object of StructType contains a vector containing the field that were defined a the data member of this StructType.


Constructor Summary
StructType()
          Constructs a new empty StructType object.
 
Method Summary
 void addField(java.lang.String fieldName, Type type)
          Adds a new field as a data member to this StructType.
 Type fromFieldName(java.lang.String fieldName)
          Return the object representing the type of the specified field name, or null if there was no such field defined for this StructType.
 java.util.Vector getDerivedLvalues(Lvalue base)
          Returns a vector of all the derived lvalue (inluding this lvalue).
 java.util.Vector getFields()
          Returns a Set with all this struct's field names.
 java.lang.String getNameAt(java.lang.String baseName, int i)
          Returns the name of the bit at offset i in the struct.
 int size()
          Returns the length of the this Struct type in bits.
 java.lang.String toFormat()
          DAMMY 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 struct type.
 
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

StructType

public StructType()
Constructs a new empty StructType object.

Method Detail

size

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

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

addField

public void addField(java.lang.String fieldName,
                     Type type)
Adds a new field as a data member to this StructType.

Parameters:
fieldName - the name of the new field.
type - the type of the new field.

toString

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

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

fromFieldName

public Type fromFieldName(java.lang.String fieldName)
Return the object representing the type of the specified field name, or null if there was no such field defined for this StructType.

Parameters:
fieldName - the field name whose associated type is to be returned.
Returns:
the object representing the type of the specified field name, or null if there was no such field defined for this StructType.

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.

getFields

public java.util.Vector getFields()
Returns a Set with all this struct's field names.

Returns:
a Set with all this struct's field names.

toFormat

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

Specified by:
toFormat in class Type
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 struct.

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 struct.

getDerivedLvalues

public java.util.Vector getDerivedLvalues(Lvalue base)
Returns a vector of all the derived lvalue (inluding this lvalue). lvalue that shold return more then this in the vector must overide this method.

Specified by:
getDerivedLvalues in class ParentType
Parameters:
base - the lavalue that call the this method (base.type == this)
Returns:
Vector of all the lvalues