slime.checks
Class Typecheck

java.lang.Object
  extended byslime.checks.Typecheck

public class Typecheck
extends java.lang.Object

Type checker for Slime programs

Version:
$Id: Typecheck.java,v 1.37 2002/07/18 08:35:14 swprakt Exp $

It consists of the various typecheck errors together with the type checker proper, which recurs over the abstract syntax.

The type checker is rather simple, in the first stage it does not attempt to infer types. As a consequence, the type checking is context-free, because vor variables we need not look up the type from some environment. It is implemented using the visitor pattern.

The class typecheck contains as inner classes the various cases. For each syntactic category, the visitor class has the matching name, suffixed with a ``V'', for instance ExprV for the visitor of absynt.Expr. Note that it is not possible to give it the same name.

Author:
Martin Steffen and Karsten Stahl.

Nested Class Summary
 class Typecheck.IncompleteDeclaration
           
 class Typecheck.MissingType
           
 class Typecheck.NonuniqueDeclaration
           
 class Typecheck.NoUsertype
           
 class Typecheck.TEnv
          The environment for type checking contains the association of variables to types.
 class Typecheck.TypecheckException
          General, non-specific exception when doing type checking.
 class Typecheck.TypeMismatch
           
 class Typecheck.UnbooleanGuard
           
 class Typecheck.UndeclaredVariable
           
 
Constructor Summary
Typecheck()
           
 
Method Summary
 Type check(Expr e)
          Type check routine for expressions, implemented as wrapper around the corresponding visitor.
 Type check(SFC s)
          Type check routine sfcs, internally implemented as wrapper around the visitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Typecheck

public Typecheck()
Method Detail

check

public Type check(SFC s)
           throws CheckException
Type check routine sfcs, internally implemented as wrapper around the visitor.

Returns:
The type of the sfc. There is only one type possible, which is the unit type. The unit type is not among the user-available types; it's used for the type checker only and means the sfc does not give back a value. Besides that, calling check has the side effect of building up the environment of variable-type bindings, when treating the list of declarations.
Throws:
CheckException

check

public Type check(Expr e)
           throws CheckException
Type check routine for expressions, implemented as wrapper around the corresponding visitor.

Returns:
Throws:
CheckException