edu.rice.cs.javalanglevels
Class SpecialTypeChecker

java.lang.Object
  extended by edu.rice.cs.javalanglevels.tree.JExpressionIFDepthFirstVisitor<TypeData>
      extended by edu.rice.cs.javalanglevels.TypeChecker
          extended by edu.rice.cs.javalanglevels.SpecialTypeChecker
All Implemented Interfaces:
JExpressionIFVisitor<TypeData>
Direct Known Subclasses:
BodyTypeChecker, ClassBodyTypeChecker, ExpressionTypeChecker, InterfaceBodyTypeChecker

public class SpecialTypeChecker
extends TypeChecker

SpecialTypeChecker is a base class for specialized type checkers such as BodyTypeChecker, ClassBodyTypeChecker, ExpressionTypeChecker, etc. SpecialTypeChecker maintains the context.


Nested Class Summary
static class SpecialTypeChecker.BobTest
          Test the methods defined in the enclosing class.
 
Nested classes/interfaces inherited from class edu.rice.cs.javalanglevels.TypeChecker
TypeChecker.TypeCheckerTest
 
Field Summary
protected  Data _data
          The context of this type checking--i.e.
protected  LinkedList<Pair<SymbolData,JExpression>> _thrown
          The list of SymbolDatas corresponding to exceptions thrown in this body.
protected  LinkedList<VariableData> _vars
          An incremental list of fields used because forward references among fields are not allowed.
protected  LinkedList<VariableData> thingsThatHaveBeenAssigned
          Stores what variable datas have been newly given a value in this scope.
 
Fields inherited from class edu.rice.cs.javalanglevels.TypeChecker
_abstractMav, _finalMav, _finalPublicMav, _log, _packageMav, _privateMav, _protectedMav, _publicAbstractMav, _publicMav, _publicStaticMav, NONE, NULL_LITERAL
 
Constructor Summary
SpecialTypeChecker(Data data, File file, String packageName, LinkedList<String> importedFiles, LinkedList<String> importedPackages, LinkedList<VariableData> vars, LinkedList<Pair<SymbolData,JExpression>> thrown)
          Constructor for SpecialTypeChecker.
 
Method Summary
protected  Data _getData()
          The top level type checker does not have a data
protected  boolean canBeAssigned(VariableData vd)
          A variable data can be assigned to if it is not final or if it does not have a value.
protected  SymbolData findClassReference(TypeData lhs, String namePiece, JExpression jexpr)
          Return the symbol data corresponding to the lhs and the namePiece, if possible.
 TypeData forArrayInitializerHelper(ArrayInitializer that, SymbolData type)
          Makes sure that the specified type is an array type, and then examines the elements in the array initializer and makes sure each has a type assignable to the elementType of the specified array type.
 TypeData forBody(Body that)
          Visit each of the items in the body and make sure that none throw uncaught exceptions
 TypeData forBracedBody(BracedBody that)
          Delegate to forBody
 TypeData forExpressionStatement(ExpressionStatement that)
          Visits the expression with a new ExpressionTypeChecker, and return the result of that visitation.
 TypeData forFormalParameter(FormalParameter that)
          Process an instance of FormalParameter.
 TypeData forInitializedVariableDeclarator(InitializedVariableDeclarator that)
          If the VariableDeclarator is initialized, things get a little bit more complicated.
 TypeData forInitializedVariableDeclaratorOnly(InitializedVariableDeclarator that, TypeData typeRes, TypeData nameRes, TypeData initializer_result)
          Makes sure that the initializedvariable declarator is correct (the types match) Also, add the Variable Data corresponding to this initializiation to the _vars list, so that it can be referenced within this scope.
 TypeData forInnerClassDef(InnerClassDef that)
          Look up the SymbolData for this InnerClass within the enclosing data, check for cyclic inheritance, and then visit everything inside the inner class.
 TypeData forInnerInterfaceDef(InnerInterfaceDef that)
          Look for the inner interface inside of the enclosing data.
 TypeData forInstanceInitializer(InstanceInitializer that)
          Process an instance of InstanceInitializer.
 TypeData forLabeledStatement(LabeledStatement that)
          Process an instance of LabeledStatement.
 TypeData forStaticInitializer(StaticInitializer that)
          Process an instance of StaticInitializer.
 TypeData forSynchronizedStatement(SynchronizedStatement that)
          Process an instance of SynchronizedStatement.
 TypeData forThrowStatement(ThrowStatement that)
          Visit the ThrowStatement's expression to determine what type of Exception is being thrown.
 TypeData forThrowStatementOnly(ThrowStatement that, TypeData thrown_result)
          Make sure that what is being thrown is an instantiation of a class, not a class name, and that it extends Throwable.
 TypeData forUnbracedBody(UnbracedBody that)
          Delegate to forBody
 TypeData forUninitializedVariableDeclarator(UninitializedVariableDeclarator that)
          If this VariableDeclarator is uninitialized, make sure its type can be resolved and visit its name.
 TypeData forVariableDeclaration(VariableDeclaration that)
          Visit each of the declarators of this declaration.
protected  InstanceData[] getArgTypesForInvocation(ParenthesizedExpressionList pel)
          Given a ParenthesizedExpressionList, extract its expression array and return an array with InstanceDatas for each type of the arguments.
protected  void handleMethodInvocation(MethodData md, JExpression jexpr)
          TODO: Move this code to where it is needed? Do any extra processing of this MethodInvocation, based on what level it is found at.
 void handleUncheckedException(SymbolData sd, JExpression j)
          If an exception is thrown but not caught, throw the appropriate error, based on the JExpression.
protected  boolean inStaticMethod()
           
 boolean isCheckedException(SymbolData sd, JExpression that)
          Returns whether the sd is a checked exception, i.e.
 boolean isUncaughtCheckedException(SymbolData sd, JExpression that)
          Return true if the Exception is a checked exception yet is not caught or declared to be thrown, and false otherwise.
 
Methods inherited from class edu.rice.cs.javalanglevels.TypeChecker
_addError, _checkAbstractMethods, _getMatchingMethods, _isAssignableFrom, _isAssignableFromWithoutAutoboxing, _lookupMethod, _lookupMethodHelper, _lookupMethodHelper, assertFound, assertInstanceType, checkAccess, checkAccess, checkAccess, checkForCyclicInheritance, cloneVariableDataList, defaultCase, defineTestCaseClass, forBlockOnly, forBreakStatementOnly, forCastExpression, forClassDef, forClassDefOnly, forClassImportStatement, forConcreteMethodDefOnly, forContinueStatementOnly, forExpressionStatementOnly, forInnerClassDefOnly, forInnerInterfaceDefOnly, forInstanceInitializerOnly, forInterfaceDef, forInterfaceDefOnly, forLabeledStatementOnly, forMethodDefOnly, forPackageStatement, forPrimitiveType, forReturnStatementOnly, forStaticInitializerOnly, forSwitchStatementOnly, forTryCatchStatementOnly, getCommonSuperTypeBaseCase, getFieldOrVariable, getFieldOrVariable, getFieldOrVariable, getFieldOrVariable, getQualifiedClassName, getSymbolData, getSymbolData, getSymbolData, getSymbolData, makeArrayOfRetType, notRightPackage
 
Methods inherited from class edu.rice.cs.javalanglevels.tree.JExpressionIFDepthFirstVisitor
forAbstractMethodDef, forAbstractMethodDefOnly, forAndExpression, forAndExpressionOnly, forAnonymousClassInstantiationOnly, forArrayAccess, forArrayAccessOnly, forArrayInitializer, forArrayInitializerOnly, forArrayInstantiationOnly, forArrayType, forArrayTypeOnly, forAssignmentExpressionOnly, forBinaryExpressionOnly, forBitwiseAndAssignmentExpression, forBitwiseAndAssignmentExpressionOnly, forBitwiseAndExpression, forBitwiseAndExpressionOnly, forBitwiseAssignmentExpressionOnly, forBitwiseBinaryExpressionOnly, forBitwiseNotExpression, forBitwiseNotExpressionOnly, forBitwiseOrAssignmentExpression, forBitwiseOrAssignmentExpressionOnly, forBitwiseOrExpression, forBitwiseOrExpressionOnly, forBitwiseXorAssignmentExpression, forBitwiseXorAssignmentExpressionOnly, forBitwiseXorExpression, forBitwiseXorExpressionOnly, forBlock, forBlockOnly, forBodyOnly, forBooleanExpressionOnly, forBooleanLiteral, forBooleanLiteralOnly, forBracedBodyOnly, forCastExpressionOnly, forCatchBlock, forCatchBlockOnly, forCharLiteral, forCharLiteralOnly, forClassImportStatementOnly, forClassInstantiationOnly, forClassLiteral, forClassLiteralOnly, forClassOrInterfaceType, forClassOrInterfaceTypeOnly, forComparisonExpressionOnly, forComplexAnonymousClassInstantiation, forComplexAnonymousClassInstantiationOnly, forComplexInitializedArrayInstantiation, forComplexInitializedArrayInstantiationOnly, forComplexMethodInvocation, forComplexMethodInvocationOnly, forComplexNamedClassInstantiation, forComplexNamedClassInstantiationOnly, forComplexNameReference, forComplexNameReferenceOnly, forComplexSuperConstructorInvocation, forComplexSuperConstructorInvocationOnly, forComplexSuperReference, forComplexSuperReferenceOnly, forComplexThisConstructorInvocation, forComplexThisConstructorInvocationOnly, forComplexThisReference, forComplexThisReferenceOnly, forComplexUninitializedArrayInstantiation, forComplexUninitializedArrayInstantiationOnly, forCompoundWord, forCompoundWordOnly, forConcreteMethodDef, forConcreteMethodDefOnly, forConditionalExpression, forConditionalExpressionOnly, forConstructorDef, forConstructorDefOnly, forDefaultCase, forDefaultCaseOnly, forDimensionExpressionList, forDimensionExpressionListOnly, forDivideAssignmentExpression, forDivideAssignmentExpressionOnly, forDivideExpression, forDivideExpressionOnly, forDoStatement, forDoStatementOnly, forDoubleLiteral, forDoubleLiteralOnly, forEmptyExpression, forEmptyExpressionOnly, forEmptyForCondition, forEmptyForConditionOnly, forEmptyStatement, forEmptyStatementOnly, forEqualityExpressionOnly, forEqualsExpression, forEqualsExpressionOnly, forExpressionListOnly, forExpressionOnly, forFloatLiteral, forFloatLiteralOnly, forFormalParameterOnly, forForStatement, forForStatementOnly, forFunctionInvocationOnly, forGreaterThanExpression, forGreaterThanExpressionOnly, forGreaterThanOrEqualExpression, forGreaterThanOrEqualExpressionOnly, forIfThenElseStatement, forIfThenElseStatementOnly, forIfThenStatement, forIfThenStatementOnly, forImportStatementOnly, forIncrementExpressionOnly, forInitializedArrayInstantiationOnly, forInitializerOnly, forInstanceofExpression, forInstanceofExpressionOnly, forInstantiationOnly, forIntegerLiteral, forIntegerLiteralOnly, forJExpressionOnly, forLabeledBreakStatement, forLabeledBreakStatementOnly, forLabeledCase, forLabeledCaseOnly, forLabeledContinueStatement, forLabeledContinueStatementOnly, forLabeledStatementOnly, forLeftShiftAssignmentExpression, forLeftShiftAssignmentExpressionOnly, forLeftShiftExpression, forLeftShiftExpressionOnly, forLessThanExpression, forLessThanExpressionOnly, forLessThanOrEqualExpression, forLessThanOrEqualExpressionOnly, forLexicalLiteralOnly, forLongLiteral, forLongLiteralOnly, forMemberType, forMemberTypeOnly, forMethodDefOnly, forMethodInvocationOnly, forMinusAssignmentExpression, forMinusAssignmentExpressionOnly, forMinusExpression, forMinusExpressionOnly, forModAssignmentExpression, forModAssignmentExpressionOnly, forModExpression, forModExpressionOnly, forModifiersAndVisibility, forModifiersAndVisibilityOnly, forMultiplyAssignmentExpression, forMultiplyAssignmentExpressionOnly, forMultiplyExpression, forMultiplyExpressionOnly, forNamedClassInstantiationOnly, forNameReferenceOnly, forNegativeExpression, forNegativeExpressionOnly, forNegativePostfixIncrementExpression, forNegativePostfixIncrementExpressionOnly, forNegativePrefixIncrementExpression, forNegativePrefixIncrementExpressionOnly, forNoOpExpression, forNoOpExpressionOnly, forNormalTryCatchStatement, forNormalTryCatchStatementOnly, forNotEqualExpression, forNotEqualExpressionOnly, forNotExpression, forNotExpressionOnly, forNullLiteral, forNullLiteralOnly, forNumericAssignmentExpressionOnly, forNumericBinaryExpressionOnly, forNumericUnaryExpressionOnly, forOrExpression, forOrExpressionOnly, forPackageImportStatement, forPackageImportStatementOnly, forPackageStatementOnly, forParenthesized, forParenthesizedExpressionList, forParenthesizedExpressionListOnly, forParenthesizedOnly, forPlusAssignmentExpression, forPlusAssignmentExpressionOnly, forPlusExpression, forPlusExpressionOnly, forPositiveExpression, forPositiveExpressionOnly, forPositivePostfixIncrementExpression, forPositivePostfixIncrementExpressionOnly, forPositivePrefixIncrementExpression, forPositivePrefixIncrementExpressionOnly, forPostfixIncrementExpressionOnly, forPrefixIncrementExpressionOnly, forPrimaryOnly, forPrimitiveTypeOnly, forReferenceTypeOnly, forRightSignedShiftAssignmentExpression, forRightSignedShiftAssignmentExpressionOnly, forRightSignedShiftExpression, forRightSignedShiftExpressionOnly, forRightUnsignedShiftAssignmentExpression, forRightUnsignedShiftAssignmentExpressionOnly, forRightUnsignedShiftExpression, forRightUnsignedShiftExpressionOnly, forShiftAssignmentExpressionOnly, forShiftBinaryExpressionOnly, forSimpleAnonymousClassInstantiation, forSimpleAnonymousClassInstantiationOnly, forSimpleAssignmentExpression, forSimpleAssignmentExpressionOnly, forSimpleInitializedArrayInstantiation, forSimpleInitializedArrayInstantiationOnly, forSimpleMethodInvocation, forSimpleMethodInvocationOnly, forSimpleNamedClassInstantiation, forSimpleNamedClassInstantiationOnly, forSimpleNameReference, forSimpleNameReferenceOnly, forSimpleSuperConstructorInvocation, forSimpleSuperConstructorInvocationOnly, forSimpleSuperReference, forSimpleSuperReferenceOnly, forSimpleThisConstructorInvocation, forSimpleThisConstructorInvocationOnly, forSimpleThisReference, forSimpleThisReferenceOnly, forSimpleUninitializedArrayInstantiation, forSimpleUninitializedArrayInstantiationOnly, forSourceFile, forSourceFileOnly, forStatementOnly, forStringLiteral, forStringLiteralOnly, forSuperConstructorInvocationOnly, forSuperReferenceOnly, forSwitchCaseOnly, forSwitchStatement, forSynchronizedStatementOnly, forThisConstructorInvocationOnly, forThisReferenceOnly, forTryCatchFinallyStatement, forTryCatchFinallyStatementOnly, forTypeDefBaseOnly, forTypeOnly, forTypeParameter, forTypeParameterOnly, forTypeVariable, forTypeVariableOnly, forUnaryExpressionOnly, forUnbracedBodyOnly, forUninitializedArrayInstantiationOnly, forUninitializedVariableDeclaratorOnly, forUnlabeledBreakStatement, forUnlabeledBreakStatementOnly, forUnlabeledContinueStatement, forUnlabeledContinueStatementOnly, forUnparenthesizedExpressionList, forUnparenthesizedExpressionListOnly, forValueReturnStatement, forValueReturnStatementOnly, forVariableDeclarationOnly, forVariableDeclaratorOnly, forVariableReferenceOnly, forVoidReturn, forVoidReturnOnly, forVoidReturnStatement, forVoidReturnStatementOnly, forWhileStatement, forWhileStatementOnly, forWord, forWordOnly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.rice.cs.javalanglevels.tree.JExpressionIFVisitor
forAbstractMethodDef, forAndExpression, forArrayAccess, forArrayInitializer, forArrayType, forBitwiseAndAssignmentExpression, forBitwiseAndExpression, forBitwiseNotExpression, forBitwiseOrAssignmentExpression, forBitwiseOrExpression, forBitwiseXorAssignmentExpression, forBitwiseXorExpression, forBlock, forBooleanLiteral, forCatchBlock, forCharLiteral, forClassLiteral, forClassOrInterfaceType, forComplexAnonymousClassInstantiation, forComplexInitializedArrayInstantiation, forComplexMethodInvocation, forComplexNamedClassInstantiation, forComplexNameReference, forComplexSuperConstructorInvocation, forComplexSuperReference, forComplexThisConstructorInvocation, forComplexThisReference, forComplexUninitializedArrayInstantiation, forCompoundWord, forConcreteMethodDef, forConditionalExpression, forConstructorDef, forDefaultCase, forDimensionExpressionList, forDivideAssignmentExpression, forDivideExpression, forDoStatement, forDoubleLiteral, forEmptyExpression, forEmptyForCondition, forEmptyStatement, forEqualsExpression, forFloatLiteral, forForStatement, forGreaterThanExpression, forGreaterThanOrEqualExpression, forIfThenElseStatement, forIfThenStatement, forInstanceofExpression, forIntegerLiteral, forLabeledBreakStatement, forLabeledCase, forLabeledContinueStatement, forLeftShiftAssignmentExpression, forLeftShiftExpression, forLessThanExpression, forLessThanOrEqualExpression, forLongLiteral, forMemberType, forMinusAssignmentExpression, forMinusExpression, forModAssignmentExpression, forModExpression, forModifiersAndVisibility, forMultiplyAssignmentExpression, forMultiplyExpression, forNegativeExpression, forNegativePostfixIncrementExpression, forNegativePrefixIncrementExpression, forNoOpExpression, forNormalTryCatchStatement, forNotEqualExpression, forNotExpression, forNullLiteral, forOrExpression, forPackageImportStatement, forParenthesized, forParenthesizedExpressionList, forPlusAssignmentExpression, forPlusExpression, forPositiveExpression, forPositivePostfixIncrementExpression, forPositivePrefixIncrementExpression, forRightSignedShiftAssignmentExpression, forRightSignedShiftExpression, forRightUnsignedShiftAssignmentExpression, forRightUnsignedShiftExpression, forSimpleAnonymousClassInstantiation, forSimpleAssignmentExpression, forSimpleInitializedArrayInstantiation, forSimpleMethodInvocation, forSimpleNamedClassInstantiation, forSimpleNameReference, forSimpleSuperConstructorInvocation, forSimpleSuperReference, forSimpleThisConstructorInvocation, forSimpleThisReference, forSimpleUninitializedArrayInstantiation, forSourceFile, forStringLiteral, forSwitchStatement, forTryCatchFinallyStatement, forTypeParameter, forTypeVariable, forUnlabeledBreakStatement, forUnlabeledContinueStatement, forUnparenthesizedExpressionList, forValueReturnStatement, forVoidReturn, forVoidReturnStatement, forWhileStatement, forWord
 

Field Detail

_vars

protected LinkedList<VariableData> _vars
An incremental list of fields used because forward references among fields are not allowed.


thingsThatHaveBeenAssigned

protected LinkedList<VariableData> thingsThatHaveBeenAssigned
Stores what variable datas have been newly given a value in this scope.


_data

protected Data _data
The context of this type checking--i.e. the data of the enclosing body.


_thrown

protected LinkedList<Pair<SymbolData,JExpression>> _thrown
The list of SymbolDatas corresponding to exceptions thrown in this body.

Constructor Detail

SpecialTypeChecker

public SpecialTypeChecker(Data data,
                          File file,
                          String packageName,
                          LinkedList<String> importedFiles,
                          LinkedList<String> importedPackages,
                          LinkedList<VariableData> vars,
                          LinkedList<Pair<SymbolData,JExpression>> thrown)
Constructor for SpecialTypeChecker.

Parameters:
data - The data that represents the context.
file - The file that corresponds to the source file
packageName - The string representing the package name
importedFiles - The list of file names that have been specifically imported
importedPackages - The list of package names that have been specifically imported
vars - The list of fields that have been assigned up to the point where SpecialTypeChecker is called.
thrown - The list of exceptions that the context is declared to throw
Method Detail

_getData

protected Data _getData()
Description copied from class: TypeChecker
The top level type checker does not have a data

Overrides:
_getData in class TypeChecker
Returns:
the enclosing data

inStaticMethod

protected boolean inStaticMethod()
Returns:
true iff the first enclosing MethodData or SymbolData is a static method.

findClassReference

protected SymbolData findClassReference(TypeData lhs,
                                        String namePiece,
                                        JExpression jexpr)
Return the symbol data corresponding to the lhs and the namePiece, if possible. Otherwise, return null.

Parameters:
lhs - The left hand side of this complex reference, or null if this is a simple reference
namePiece - The String right hand side of this reference
jexpr - The JExpression corresponding to this class reference

handleMethodInvocation

protected void handleMethodInvocation(MethodData md,
                                      JExpression jexpr)
TODO: Move this code to where it is needed? Do any extra processing of this MethodInvocation, based on what level it is found at. Here, check if the MethodData is declared to throw any exceptions, add them to the list of Exceptions

Parameters:
md - The MethodData of the method being invoked
jexpr - The jexpression corresponding to where this method is being invoked from.

getArgTypesForInvocation

protected InstanceData[] getArgTypesForInvocation(ParenthesizedExpressionList pel)
Given a ParenthesizedExpressionList, extract its expression array and return an array with InstanceDatas for each type of the arguments. Throw an error if a non-instance type is passed as an argument.

Parameters:
pel - The ParenthesizedExpressionList the arguments are stored in.
Returns:
The InstanceData[] corresponding to the types of the arguments

forInitializedVariableDeclaratorOnly

public TypeData forInitializedVariableDeclaratorOnly(InitializedVariableDeclarator that,
                                                     TypeData typeRes,
                                                     TypeData nameRes,
                                                     TypeData initializer_result)
Makes sure that the initializedvariable declarator is correct (the types match) Also, add the Variable Data corresponding to this initializiation to the _vars list, so that it can be referenced within this scope. Assumes typeRes is a SymbolData.

Overrides:
forInitializedVariableDeclaratorOnly in class JExpressionIFDepthFirstVisitor<TypeData>
Parameters:
that - The InitializedVariableDeclarator being visited
typeRes - The TypeData (should be a SymbolData) corresponding to the type on the lhs of the assignment
nameRes - Not used.
initializer_result - The type of what we are initializing the varaible with

forInstanceInitializer

public TypeData forInstanceInitializer(InstanceInitializer that)
Description copied from interface: JExpressionIFVisitor
Process an instance of InstanceInitializer.

Specified by:
forInstanceInitializer in interface JExpressionIFVisitor<TypeData>
Overrides:
forInstanceInitializer in class JExpressionIFDepthFirstVisitor<TypeData>

forStaticInitializer

public TypeData forStaticInitializer(StaticInitializer that)
Description copied from interface: JExpressionIFVisitor
Process an instance of StaticInitializer.

Specified by:
forStaticInitializer in interface JExpressionIFVisitor<TypeData>
Overrides:
forStaticInitializer in class JExpressionIFDepthFirstVisitor<TypeData>

forLabeledStatement

public TypeData forLabeledStatement(LabeledStatement that)
Description copied from interface: JExpressionIFVisitor
Process an instance of LabeledStatement.

Specified by:
forLabeledStatement in interface JExpressionIFVisitor<TypeData>
Overrides:
forLabeledStatement in class JExpressionIFDepthFirstVisitor<TypeData>

forExpressionStatement

public TypeData forExpressionStatement(ExpressionStatement that)
Visits the expression with a new ExpressionTypeChecker, and return the result of that visitation. Keep track of what variables get values within the expression.

Specified by:
forExpressionStatement in interface JExpressionIFVisitor<TypeData>
Overrides:
forExpressionStatement in class JExpressionIFDepthFirstVisitor<TypeData>
Parameters:
that - The ExpressionStatement we are visiting.
Returns:
The result of visiting the expression with the ExpressionTypeChecker.

forThrowStatement

public TypeData forThrowStatement(ThrowStatement that)
Visit the ThrowStatement's expression to determine what type of Exception is being thrown. Add the corresponding SymbolData to _thrown.

Specified by:
forThrowStatement in interface JExpressionIFVisitor<TypeData>
Overrides:
forThrowStatement in class JExpressionIFDepthFirstVisitor<TypeData>

forThrowStatementOnly

public TypeData forThrowStatementOnly(ThrowStatement that,
                                      TypeData thrown_result)
Make sure that what is being thrown is an instantiation of a class, not a class name, and that it extends Throwable. Otherwise, give an error.

Overrides:
forThrowStatementOnly in class JExpressionIFDepthFirstVisitor<TypeData>
Parameters:
that - The throw statement we are visiting
thrown_result - The TypeData result of visiting the throw statement. It should be an InstanceData, unless there is an error in the student's code.

forSynchronizedStatement

public TypeData forSynchronizedStatement(SynchronizedStatement that)
Description copied from interface: JExpressionIFVisitor
Process an instance of SynchronizedStatement.

Specified by:
forSynchronizedStatement in interface JExpressionIFVisitor<TypeData>
Overrides:
forSynchronizedStatement in class JExpressionIFDepthFirstVisitor<TypeData>

forFormalParameter

public TypeData forFormalParameter(FormalParameter that)
Description copied from interface: JExpressionIFVisitor
Process an instance of FormalParameter.

Specified by:
forFormalParameter in interface JExpressionIFVisitor<TypeData>
Overrides:
forFormalParameter in class JExpressionIFDepthFirstVisitor<TypeData>

forVariableDeclaration

public TypeData forVariableDeclaration(VariableDeclaration that)
Visit each of the declarators of this declaration.

Specified by:
forVariableDeclaration in interface JExpressionIFVisitor<TypeData>
Overrides:
forVariableDeclaration in class JExpressionIFDepthFirstVisitor<TypeData>
Parameters:
that - The VariableDeclaration we are visiting.

forUninitializedVariableDeclarator

public TypeData forUninitializedVariableDeclarator(UninitializedVariableDeclarator that)
If this VariableDeclarator is uninitialized, make sure its type can be resolved and visit its name.

Specified by:
forUninitializedVariableDeclarator in interface JExpressionIFVisitor<TypeData>
Overrides:
forUninitializedVariableDeclarator in class JExpressionIFDepthFirstVisitor<TypeData>
Parameters:
that - The UninitializedVariableDeclarator we are visiting.

forInitializedVariableDeclarator

public TypeData forInitializedVariableDeclarator(InitializedVariableDeclarator that)
If the VariableDeclarator is initialized, things get a little bit more complicated. Resolve the type and visit the name, like we do for the uninitilized case. Then, check to see if the initializer is an array initializer. If so, delegate. Otherwise, just visit it with an ExpressionTypeChecker.

Specified by:
forInitializedVariableDeclarator in interface JExpressionIFVisitor<TypeData>
Overrides:
forInitializedVariableDeclarator in class JExpressionIFDepthFirstVisitor<TypeData>
Parameters:
that - The InitializedVariableDeclarator we are visiting.

canBeAssigned

protected boolean canBeAssigned(VariableData vd)
A variable data can be assigned to if it is not final or if it does not have a value. (i.e. final variables that already have a value cannot be assigned to. Everything else can be).


forArrayInitializerHelper

public TypeData forArrayInitializerHelper(ArrayInitializer that,
                                          SymbolData type)
Makes sure that the specified type is an array type, and then examines the elements in the array initializer and makes sure each has a type assignable to the elementType of the specified array type. Returns an instance data corresponding to the type of the array.


forInnerClassDef

public TypeData forInnerClassDef(InnerClassDef that)
Look up the SymbolData for this InnerClass within the enclosing data, check for cyclic inheritance, and then visit everything inside the inner class.

Specified by:
forInnerClassDef in interface JExpressionIFVisitor<TypeData>
Overrides:
forInnerClassDef in class JExpressionIFDepthFirstVisitor<TypeData>
Parameters:
that - The InnerClassDef we're visiting

forInnerInterfaceDef

public TypeData forInnerInterfaceDef(InnerInterfaceDef that)
Look for the inner interface inside of the enclosing data. Then, visit everything that needs to be visited.

Specified by:
forInnerInterfaceDef in interface JExpressionIFVisitor<TypeData>
Overrides:
forInnerInterfaceDef in class JExpressionIFDepthFirstVisitor<TypeData>
Parameters:
that - The InnerInterfaceDef that is being visited.

handleUncheckedException

public void handleUncheckedException(SymbolData sd,
                                     JExpression j)
If an exception is thrown but not caught, throw the appropriate error, based on the JExpression.


isCheckedException

public boolean isCheckedException(SymbolData sd,
                                  JExpression that)
Returns whether the sd is a checked exception, i.e. one that needs to be caught or declared to be thrown. This is defined as all subclasses of java.lang.Throwable except for subclasses of java.lang.RuntimeException


isUncaughtCheckedException

public boolean isUncaughtCheckedException(SymbolData sd,
                                          JExpression that)
Return true if the Exception is a checked exception yet is not caught or declared to be thrown, and false otherwise. An exception is a checked if it does not extend either java.lang.RuntimeException or java.lang.Error, and is not declared to be thrown by the enclosing method.

Parameters:
sd - The SymbolData of the Exception we are checking.
that - The JExpression passed to getSymbolData for error purposes.

forBody

public TypeData forBody(Body that)
Visit each of the items in the body and make sure that none throw uncaught exceptions


forBracedBody

public TypeData forBracedBody(BracedBody that)
Delegate to forBody

Specified by:
forBracedBody in interface JExpressionIFVisitor<TypeData>
Overrides:
forBracedBody in class JExpressionIFDepthFirstVisitor<TypeData>

forUnbracedBody

public TypeData forUnbracedBody(UnbracedBody that)
Delegate to forBody

Specified by:
forUnbracedBody in interface JExpressionIFVisitor<TypeData>
Overrides:
forUnbracedBody in class JExpressionIFDepthFirstVisitor<TypeData>