edu.ksu.cis.projects.bogor.ast.checker
Class ExpChecker

java.lang.Object
  extended by edu.ksu.cis.projects.bogor.ast.ASTVisitor
      extended by edu.ksu.cis.projects.bogor.ast.checker.ExpChecker

public final class ExpChecker
extends ASTVisitor

This class is used to deduce the type of expressions.

Version:
CVS $Revision: 1.5 $ $Date: 2005/05/26 18:23:13 $
Author:
Matt Hoosier

Method Summary
static Type checkExp(Exp node, boolean allowHighLevel, boolean inSideEffectFreeContext, Map<String,Type> bindingMap, edu.ksu.cis.projects.bogor.ast.checker.TypeChecker ttc, SymbolTable st, FSMSymbolTable fsmSt)
          Calculate the type of an expression.
protected  RecordType findLUB(String rid, String oldRId)
           
protected  Type[] inferExtTypeArguments(ExtSymbolTable st, ExtExp node, Type[] extArgTypes)
           
protected  boolean inferType(HashMap<String,Type> map, Type parameterType, Type type)
           
protected  boolean putType(HashMap<String,Type> map, String id, Type type)
           
protected  void visitApplyExp(ApplyExp node)
          Type checks an apply exp.
protected  void visitArrayAccessExp(ArrayAccessExp node)
          Type checks an array access.
protected  void visitAtomicExp(AtomicExp node)
          Type checks an atomic expression
protected  void visitBinaryExp(BinaryExp node)
          Type checks a binary exp.
protected  void visitBooleanLiteral(BooleanLiteral node)
          Type checks a boolean literal.
protected  void visitCastExp(CastExp node)
          Type checks a cast exp.
protected  void visitConditionalExp(ConditionalExp node)
          Type checks a conditional exp.
protected  void visitDoubleLiteral(DoubleLiteral node)
          Type checks a double literal.
protected  void visitExtExp(ExtExp node)
          Type checks an ext exp.
protected  void visitFieldAccessExp(FieldAccessExp node)
          Type checks a field access.
protected  void visitFloatLiteral(FloatLiteral node)
          Type checks a float literal.
protected  void visitIdExp(IdExp node)
          Type checks an id exp.
protected  void visitInstanceofExp(InstanceofExp node)
          Type checks an instanceof exp.
protected  void visitIntLiteral(IntLiteral node)
          Type checks an integer literal.
protected  void visitInvokeExp(InvokeExp node)
          Type checks an invoke exp.
protected  void visitKindofExp(KindofExp node)
          Type checks an kindof exp.
protected  void visitLetExp(LetExp node)
          Type checks a let exp.
protected  void visitLockTestExp(LockTestExp node)
          Type checks a lock test.
protected  void visitLongLiteral(LongLiteral node)
          Type checks a long literal.
protected  void visitNewArrayExp(NewArrayExp node)
          Type checks a new array exp.
protected  void visitNewLockExp(NewLockExp node)
          Type checks a new record exp.
protected  void visitNewRecordExp(NewRecordExp node)
          Type checks a new record exp.
protected  void visitNullLiteral(NullLiteral node)
          Type checks a null literal.
protected  void visitParenExp(ParenExp node)
          Type checks a parenthesis exp.
protected  void visitStartThreadExp(StartThreadExp node)
          Type checks a start thread exp.
protected  void visitStringLiteral(StringLiteral node)
          Type checks a string literal.
protected  void visitThreadTestExp(ThreadTestExp node)
          Type checks a thread test exp.
protected  void visitUnaryExp(UnaryExp node)
          Type checks a unary node.
 
Methods inherited from class edu.ksu.cis.projects.bogor.ast.ASTVisitor
visitActionExtension, visitActionStatement, visitAssertAction, visitAssignAction, visitAssumeAction, visitASTArrayType, visitASTBooleanType, visitASTDoubleType, visitASTExtType, visitASTFloatType, visitASTFunType, visitASTIntRangeType, visitASTIntType, visitASTLockType, visitASTLongRangeType, visitASTLongType, visitASTStringType, visitASTThreadIdType, visitAtomicActionStatement, visitAtomicStatement, visitBlockStatement, visitBlockTransformation, visitBooleanConstant, visitCatch, visitChooseStatement, visitConstantDefinition, visitDoubleConstant, visitEnumDefinition, visitExitThreadAction, visitExpAction, visitExpExtension, visitExtensionDefinition, visitField, visitFloatConstant, visitFSM, visitFun, visitGlobal, visitGotoNextState, visitIdPrintArg, visitIdType, visitIfStatement, visitInitialValue, visitIntConstant, visitInvokeAction, visitInvokeTransformation, visitLiteralExp, visitLiveSet, visitLocal, visitLocation, visitLockAction, visitLongConstant, visitParam, visitPrintAction, visitRecordDefinition, visitReturnNextState, visitReturnStatement, visitSkipStatement, visitStringConstant, visitStringPrintArg, visitSystem, visitThrowAction, visitTryCatchStatement, visitTypeAliasDefinition, visitTypedId, visitTypeExtension, visitVirtualTableDefinition, visitWhileStatement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkExp

public static Type checkExp(Exp node,
                            boolean allowHighLevel,
                            boolean inSideEffectFreeContext,
                            Map<String,Type> bindingMap,
                            edu.ksu.cis.projects.bogor.ast.checker.TypeChecker ttc,
                            SymbolTable st,
                            FSMSymbolTable fsmSt)
Calculate the type of an expression.

Parameters:
node - The expression whose type should be found
allowHighLevel - Switch enabling nested function application and other high-level BIR language features
inSideEffectFreeContext - tracks whether node is a sub-node of some guard expression
bindingMap - The set of bound variable ID's (e.g., from "let" constructs) mapped to their types
ttc - Utility to convert AST type nodes into interal bogor types
st - System-wide symbol table
fsmSt - Optional FSM-specific symbol table; should be non-null if node lives inside an FSM.
Returns:
The calculated type of the expression, or null if an errors occurs. If the return value is non-null, then it is also set as the Exp.TYPE property on node

visitApplyExp

protected void visitApplyExp(ApplyExp node)
Type checks an apply exp.

Generates an error if:

Overrides:
visitApplyExp in class ASTVisitor
Parameters:
node - The array access. Non-null.

visitArrayAccessExp

protected void visitArrayAccessExp(ArrayAccessExp node)
Type checks an array access.

Generates an error if:

Overrides:
visitArrayAccessExp in class ASTVisitor
Parameters:
node - The array access. Non-null.

visitAtomicExp

protected void visitAtomicExp(AtomicExp node)
Type checks an atomic expression

Generates an error if:

Overrides:
visitAtomicExp in class ASTVisitor
Parameters:
node - The atomic exp. Non-null.

visitBinaryExp

protected void visitBinaryExp(BinaryExp node)
Type checks a binary exp.

Generates an error if:

Overrides:
visitBinaryExp in class ASTVisitor
Parameters:
node - The binary exp. Non-null.

visitBooleanLiteral

protected void visitBooleanLiteral(BooleanLiteral node)
Type checks a boolean literal.

Overrides:
visitBooleanLiteral in class ASTVisitor
Parameters:
node - The boolean literal. Non-null.

visitCastExp

protected void visitCastExp(CastExp node)
Type checks a cast exp.

Generates an error if:

Overrides:
visitCastExp in class ASTVisitor
Parameters:
node - The cast exp. Non-null.

visitConditionalExp

protected void visitConditionalExp(ConditionalExp node)
Type checks a conditional exp.

Generates an error if:

Overrides:
visitConditionalExp in class ASTVisitor
Parameters:
node - The conditional exp. Non-null.

visitDoubleLiteral

protected void visitDoubleLiteral(DoubleLiteral node)
Type checks a double literal.

Overrides:
visitDoubleLiteral in class ASTVisitor
Parameters:
node - The double literal. Non-null.

visitExtExp

protected void visitExtExp(ExtExp node)
Type checks an ext exp.

Overrides:
visitExtExp in class ASTVisitor
Parameters:
node - The ext exp. Non-null.

visitFieldAccessExp

protected void visitFieldAccessExp(FieldAccessExp node)
Type checks a field access.

Generates an error if:

Overrides:
visitFieldAccessExp in class ASTVisitor
Parameters:
node - The field access. Non-null.

visitFloatLiteral

protected void visitFloatLiteral(FloatLiteral node)
Type checks a float literal.

Overrides:
visitFloatLiteral in class ASTVisitor
Parameters:
node - The float literal. Non-null.

visitIdExp

protected void visitIdExp(IdExp node)
Type checks an id exp.

Generates an error if:

Overrides:
visitIdExp in class ASTVisitor
Parameters:
node - The id exp. Non-null.

visitInstanceofExp

protected void visitInstanceofExp(InstanceofExp node)
Type checks an instanceof exp.

Generates an error if:

Overrides:
visitInstanceofExp in class ASTVisitor
Parameters:
node - The instanceof exp. Non-null.

visitIntLiteral

protected void visitIntLiteral(IntLiteral node)
Type checks an integer literal.

Overrides:
visitIntLiteral in class ASTVisitor
Parameters:
node - The integer literal. Non-null.

visitInvokeExp

protected void visitInvokeExp(InvokeExp node)
Type checks an invoke exp.

Generates an error if:

Overrides:
visitInvokeExp in class ASTVisitor
Parameters:
node - The invoke exp. Non-null.

visitKindofExp

protected void visitKindofExp(KindofExp node)
Type checks an kindof exp.

Generates an error if:

Overrides:
visitKindofExp in class ASTVisitor
Parameters:
node - The kindof exp. Non-null.

visitLetExp

protected void visitLetExp(LetExp node)
Type checks a let exp.

Generates an error if:

Overrides:
visitLetExp in class ASTVisitor
Parameters:
node - The invoke transformation. Non-null.

visitLockTestExp

protected void visitLockTestExp(LockTestExp node)
Type checks a lock test.

Generates an error if:

Overrides:
visitLockTestExp in class ASTVisitor
Parameters:
node - The lock test. Non-null.

visitLongLiteral

protected void visitLongLiteral(LongLiteral node)
Type checks a long literal.

Overrides:
visitLongLiteral in class ASTVisitor
Parameters:
node - The long literal. Non-null.

visitNewArrayExp

protected void visitNewArrayExp(NewArrayExp node)
Type checks a new array exp.

Generates an error if:

Overrides:
visitNewArrayExp in class ASTVisitor
Parameters:
node - The new array exp. Non-null.

visitNewLockExp

protected void visitNewLockExp(NewLockExp node)
Type checks a new record exp.

Overrides:
visitNewLockExp in class ASTVisitor
Parameters:
node - The new lock exp. Non-null.

visitNewRecordExp

protected void visitNewRecordExp(NewRecordExp node)
Type checks a new record exp.

Generates an error if:

Overrides:
visitNewRecordExp in class ASTVisitor
Parameters:
node - The new record exp. Non-null.

visitNullLiteral

protected void visitNullLiteral(NullLiteral node)
Type checks a null literal.

Overrides:
visitNullLiteral in class ASTVisitor
Parameters:
node - The null literal. Non-null.

visitParenExp

protected void visitParenExp(ParenExp node)
Type checks a parenthesis exp.

Overrides:
visitParenExp in class ASTVisitor
Parameters:
node - The parenthesis exp. Non-null.

visitStartThreadExp

protected void visitStartThreadExp(StartThreadExp node)
Type checks a start thread exp.

Generates an error if:

Overrides:
visitStartThreadExp in class ASTVisitor
Parameters:
node - The start thread exp.

visitStringLiteral

protected void visitStringLiteral(StringLiteral node)
Type checks a string literal.

Overrides:
visitStringLiteral in class ASTVisitor
Parameters:
node - The string literal. Non-null.

visitThreadTestExp

protected void visitThreadTestExp(ThreadTestExp node)
Type checks a thread test exp.

Generates an error if:

Overrides:
visitThreadTestExp in class ASTVisitor
Parameters:
node - The thread test exp. Non-null.

visitUnaryExp

protected void visitUnaryExp(UnaryExp node)
Type checks a unary node.

Generates an error if:

Overrides:
visitUnaryExp in class ASTVisitor
Parameters:
node - The unary node. Non-null.

inferExtTypeArguments

protected Type[] inferExtTypeArguments(ExtSymbolTable st,
                                       ExtExp node,
                                       Type[] extArgTypes)

inferType

protected boolean inferType(HashMap<String,Type> map,
                            Type parameterType,
                            Type type)

putType

protected boolean putType(HashMap<String,Type> map,
                          String id,
                          Type type)

findLUB

protected RecordType findLUB(String rid,
                             String oldRId)