SFE.Compiler
Class Type

java.lang.Object
  extended by SFE.Compiler.Type
Direct Known Subclasses:
BooleanType, BusType, IntType, ParentType

public abstract class Type
extends java.lang.Object

Abstract class for representing types that can be defined in the program. This class also functions as a type table for the defined types in the programs.


Constructor Summary
Type()
           
 
Method Summary
static void defineName(java.lang.String newTypeName, Type newType)
          Associates the specified newTypeName with the specified newType.
static Type fromName(java.lang.String typeName)
          Returns the object representing the type of the specified type name, or null if there was no such type defined for this type name.
 java.util.Vector getDerivedLvalues(Lvalue base)
          Returns a vector of all the derived lvalue of this type.
 boolean hasDerives()
          Returns false, types that derive other types.
abstract  int size()
          Returns the size of this type object in bits.
abstract  java.lang.String toFormat()
          Returns a String representing this object as it should appear in the format file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Type

public Type()
Method Detail

size

public abstract int size()
Returns the size of this type object in bits.

Returns:
an integer representing size of this type object in bits.

fromName

public static Type fromName(java.lang.String typeName)
Returns the object representing the type of the specified type name, or null if there was no such type defined for this type name.

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

defineName

public static void defineName(java.lang.String newTypeName,
                              Type newType)
                       throws java.lang.IllegalArgumentException
Associates the specified newTypeName with the specified newType.

Parameters:
newTypeName - the new Type name with which the specified Type is to be associated.
newType - the Type to be associated with the specified newTypeName.
Throws:
java.lang.IllegalArgumentException - if the newTypeName is already defined.

toFormat

public abstract java.lang.String toFormat()
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.

getDerivedLvalues

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

Parameters:
base - the lavalue that call the this method (base.type == this)

hasDerives

public boolean hasDerives()
Returns false, types that derive other types. For example, struct type should override this method.

Returns:
false.