|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object minijava.typecheck.Type minijava.typecheck.Class
public class Class
This class represents a class type. It records a mapping of
identifiers to Type
s for the class' declared fields, a mapping of
identifiers to Method
objects, and a reference to a parent class if
this class extends any.
Method
Constructor Summary | |
---|---|
Class(java.lang.String clsym)
Creates a class object without parent reference. |
|
Class(java.lang.String clsym,
Class parent)
Creates a class object that extends another class. |
|
Class(Symbol clsym)
Creates a class object without parent reference. |
|
Class(Symbol clsym,
Class parent)
Creates a class object that extends another class. |
Method Summary | |
---|---|
boolean |
addField(Type type,
java.lang.String iden)
Adds a field declaration to this class. |
boolean |
addField(Type type,
Symbol iden)
Adds a field declaration to this class. |
boolean |
addMethod(java.lang.String sym,
Method method)
Adds a method object to this class' mapping of symbols to method objects. |
boolean |
addMethod(Symbol sym,
Method method)
Adds a method object to this class' mapping of symbols to method objects. |
boolean |
agrees(Type rhs)
Checks whether this Type "agrees" with the given argument. |
static Class |
getClass(Symbol sym)
Deprecated. rather than using its own table, access class objects in the general symbol table that contains its reference |
int |
getFieldOrder(java.lang.String iden)
Looks up the order number of the given field's identifier. |
int |
getFieldOrder(Symbol iden)
Looks up the order number of the given field's identifier. |
int |
getFieldsSize()
Returns the number of fields an object of this class would have. |
Type |
getFieldType(java.lang.String iden)
Looks up the type of this class' field by the given identifier. |
Type |
getFieldType(Symbol iden)
Looks up the type of this class' field by the given identifier. |
Method |
getMethod(java.lang.String iden)
Looks up a method in this class with the given identifier. |
Method |
getMethod(Symbol iden)
Looks up a method in this class with the given identifier. |
java.util.Set<Symbol> |
getMethodIdentifiers()
Returns the set of method identifiers (symbols) specific to this class (exluding the base class'). |
int |
getMethodOrder(java.lang.String iden)
Looks up the order number of the given method's identifier. |
int |
getMethodOrder(Symbol iden)
Looks up the order number of the given method's identifier. |
java.util.List<Symbol> |
getMethodSymbolsInOrder()
Returns a list of method symbols local to this class, in the order that they were added. |
Class |
getParent()
|
java.util.Set<Symbol> |
getVariableIdentifiers()
Returns the set of instance variable identifiers (symbols) specific to this class (excluding the base class'). |
void |
setParent(Class parent)
|
Methods inherited from class minijava.typecheck.Type |
---|
equals, getTypeName, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Class(Symbol clsym)
clsym
- the class identifierpublic Class(java.lang.String clsym)
clsym
- the class identifierpublic Class(Symbol clsym, Class parent)
clsym
- the class identifierparent
- the parent class of this classpublic Class(java.lang.String clsym, Class parent)
clsym
- the class identifierparent
- the parent class of this classMethod Detail |
---|
@Deprecated public static Class getClass(Symbol sym)
Class
object that is represented by
the parameter symbol. If one does not exist yet, creates one and stores
it in the internal repository, before returning it.
sym
- the symbol that represents a class identifier
public Class getParent()
public void setParent(Class parent)
parent
- the reference to parent class to this classpublic boolean addField(Type type, Symbol iden)
false
.
Note that a field by the same name declared in the super class of this
class counts as having been declared (an exception will be thrown).
type
- the type of the new fieldiden
- the field identifier to be added
true
if the field is successfully added to the classpublic boolean addField(Type type, java.lang.String iden)
false
.
Note that a field by the same name declared in the super class of this
class counts as having been declared (an exception will be thrown).
type
- the type of the new fieldiden
- the field identifier to be added
true
if the field is successfully added to the classpublic boolean addMethod(Symbol sym, Method method)
false
.
sym
- the identifier for the method namemethod
- the method object associated with the identifier
false
if a mapping of the identifier to a method
object already exists, true
otherwisepublic boolean addMethod(java.lang.String sym, Method method)
false
.
sym
- the identifier for the method namemethod
- the method object associated with the identifier
false
if a mapping of the identifier to a method
object already exists, true
otherwisepublic java.util.List<Symbol> getMethodSymbolsInOrder()
public int getMethodOrder(Symbol iden)
iden
- the method identifier
public int getMethodOrder(java.lang.String iden)
iden
- the method identifier
public Type getFieldType(Symbol iden)
iden
- the field identifier
null
if no such field identifier existspublic Type getFieldType(java.lang.String iden)
iden
- the field identifier
null
if no such field identifier existspublic int getFieldOrder(Symbol iden)
iden
- the field identifier
public int getFieldOrder(java.lang.String iden)
iden
- the field identifier
public int getFieldsSize()
public java.util.Set<Symbol> getVariableIdentifiers()
public Method getMethod(Symbol iden)
iden
- the method identifier
null
if no such mapping existspublic Method getMethod(java.lang.String iden)
iden
- the method identifier
null
if no such mapping existspublic java.util.Set<Symbol> getMethodIdentifiers()
public boolean agrees(Type rhs)
Type
Type
"agrees" with the given argument.
Two types are agreeable if they are equal primitives or, if they
are class types, rhs
is a subclass/subtype of this type.
agrees
in class Type
rhs
- the right hand side in the equivalence test
true
if type(this) == type(rhs)
, or ig
type(this) == supertype(rhs)
, and
false
otherwise
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |