Semant
Class Type.CLASS

java.lang.Object
  extended by Semant.Type
      extended by Semant.Type.CLASS
Enclosing class:
Type

public static class Type.CLASS
extends Type

A class encapsulates static (class) fields and methods, may extend a parent class, and describes the structure of its instances.


Nested Class Summary
 
Nested classes/interfaces inherited from class Semant.Type
Type.ARRAY, Type.CLASS, Type.FUN, Type.INSTANCE, Type.Print, Type.RECORD<T extends Type>, Type.Visitor
 
Field Summary
 Type.RECORD<Type> fields
          The static (class) fields.
 Type.INSTANCE instance
           
 boolean isFinal
          Flag indicating if class is final.
 Type.RECORD<Type.FUN> methods
          The static (class) methods.
 java.lang.String name
           
 Type.CLASS parent
           
 
Fields inherited from class Semant.Type
BOOLEAN, INT, NIL, STRING, SYSTEM, VOID
 
Constructor Summary
Type.CLASS(java.lang.String n)
          A class.
 
Method Summary
 void accept(Type.Visitor v)
          A type must accept a visitor
 boolean coerceTo(Type t)
          Classes coerce only if they are identical.
 boolean equals(Type t)
          Classes are equal only if they are identical.
 Type field(java.lang.String n)
          Implementation of field for classes.
 boolean isLoop()
          Check for inheritance cycles.
 Type.FUN method(java.lang.String n)
          Implementation of method for classes.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final java.lang.String name

parent

public Type.CLASS parent

instance

public final Type.INSTANCE instance

fields

public final Type.RECORD<Type> fields
The static (class) fields.


methods

public Type.RECORD<Type.FUN> methods
The static (class) methods.


isFinal

public boolean isFinal
Flag indicating if class is final.

Constructor Detail

Type.CLASS

public Type.CLASS(java.lang.String n)
A class.

Parameters:
n - class name
Method Detail

field

public Type field(java.lang.String n)
Implementation of field for classes. Classes can access both local and inherited static fields.

Overrides:
field in class Type
Parameters:
n - name of the field
Returns:
type of the field

method

public Type.FUN method(java.lang.String n)
Implementation of method for classes. Classes can access both local and inherited static methods.

Overrides:
method in class Type
Parameters:
n - name of the method
Returns:
type of the method

isLoop

public boolean isLoop()
Check for inheritance cycles.

Returns:
true if class forms part of an inheritance cycle.

equals

public boolean equals(Type t)
Classes are equal only if they are identical.

Specified by:
equals in class Type
Parameters:
t - target type
Returns:
true if types are equivalent, false otherwise

coerceTo

public boolean coerceTo(Type t)
Classes coerce only if they are identical.

Specified by:
coerceTo in class Type
Parameters:
t - target type
Returns:
true if this coerces to t, false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

accept

public void accept(Type.Visitor v)
Description copied from class: Type
A type must accept a visitor

Specified by:
accept in class Type
Parameters:
v - the visitor