edu.rice.cs.javalanglevels
Class LanguageLevelVisitor

java.lang.Object
  extended by edu.rice.cs.javalanglevels.JExpressionIFPrunableDepthFirstVisitor
      extended by edu.rice.cs.javalanglevels.LanguageLevelVisitor
All Implemented Interfaces:
JExpressionIFVisitor<Void>
Direct Known Subclasses:
FullJavaVisitor, IntermediateVisitor

public class LanguageLevelVisitor
extends JExpressionIFPrunableDepthFirstVisitor

Top-level Language Level Visitor that implements the constraint checking and symbol table building that is common to first pass processing for the Functional and FullJava levels. There are two major complications in performing this pass. First, references to symbols appear in the signatures of type (class/interface) definitions that have not yet been defined. In the symbol table, the binding of these references must be deferred until a fixup list is executed after the first pass visit has finished. This visitor and its descendants maintain a FixUp list for this purpose. Second, the loading of signature information into the symbol table (called "resolving" in this documentation) is deferred for some symbols. A dummy entry called a "continuation" is created in the symbol table for each such symbol.


Nested Class Summary
static class LanguageLevelVisitor.LanguageLevelVisitorTest
          Test the methods defined in the above class.
 
Field Summary
 HashMap<String,SymbolData> _genericTypes
           
protected static Log _log
           
protected static LinkedList<Pair<String,JExpressionIF>> errors
          Errors we have encountered during this pass: string is the text of the error, JExpressionIF is the part of the AST where the error occurs.
static ModifiersAndVisibility FINAL_MAV
           
static ModifiersAndVisibility PACKAGE_MAV
           
static ModifiersAndVisibility PRIVATE_MAV
           
static ModifiersAndVisibility PROTECTED_MAV
           
static ModifiersAndVisibility PUBLIC_MAV
           
 Symboltable symbolTable
          Stores the classes we have referenced, and all their information, once they are resolved.
 
Constructor Summary
LanguageLevelVisitor(File file, String packageName, String enclosingClassName, LinkedList<String> importedFiles, LinkedList<String> importedPackages, HashSet<String> classesInThisFile, Hashtable<String,Triple<SourceInfo,LanguageLevelVisitor,SymbolData>> continuations, LinkedList<Command> fixUps)
          This constructor is used only in testing.
LanguageLevelVisitor(File file, String packageName, String enclosingClassName, LinkedList<String> importedFiles, LinkedList<String> importedPackages, HashSet<String> classesInThisFile, Hashtable<String,Triple<SourceInfo,LanguageLevelVisitor,SymbolData>> continuations, LinkedList<Command> fixUps, HashMap<String,SymbolData> genericTypes)
          This constructor is called from the subclasses of LanguageLevelVisitor.
 
Method Summary
protected static void _addAndIgnoreError(String message, JExpressionIF that)
          This method is called when an error should be added, but tree-walking should continue on this construct.
protected static void _addError(String message, JExpressionIF that)
          This method is called when an error should be added to the static LinkedList of errors.
 void _badModifiers(String first, String second, JExpressionIF that)
          Add an error explaining the modifiers' conflict.
protected static boolean _checkError()
          If _errorAdded is true, set it back to false and return true.
protected  SymbolData _getSymbolDataFromFileSystem(String qualifiedClassName, SourceInfo si, boolean resolve, boolean addError)
          Checks the file system for the class name, returning the corresponding SymbolData if there is an up-to-date match.
protected  SymbolData _identifyType(String name, SourceInfo si, String enclosingClassName)
          Identifies the SymbolData matching name in symbolTable.
protected  SymbolData _lookupTypeFromWithinClass(ReferenceType rt, String qualifiedClassName)
          Looks up the type with name rt (which is arbitrary source text for a type) from within the class name qualifiedClassName.
protected  void _resetNonStaticFields()
           
protected  VariableData[] _variableDeclaration2VariableData(VariableDeclaration vd, Data enclosing)
          This method assumes that the modifiers for this particular VariableDeclaration have already been checked.
protected static void addGeneratedMethod(SymbolData sd, MethodData md)
          If the method being generated already exists in the SymbolData, throw an error, because generated methods cannot be overwritten.
protected  SymbolData addInnerSymbolData(SourceInfo si, String qualifiedTypeName, Data enclosing)
           
 void anonymousClassInstantiationHelper(AnonymousClassInstantiation that, SymbolData enclosing, String superName)
          Do the common work for SimpleAnonymousClassInstantiations and ComplexAnonymousClassInstantiations and in FullJava and Functional Java.
static boolean arrayEquals(Object[] array1, Object[] array2)
          Determines whether array1 equals array2 using the equals method on Object[] arrays in java.util.Arrays.
protected static void createAccessors(SymbolData sd, File file)
          Create a method that is an accessor for each field in the class.
 void createConstructor(SymbolData sd)
          Creates the automatically generated constructor for this class.
protected  void createEquals(SymbolData sd)
          Creates a method called equals() that takes in an Object argument and returns a boolean.
protected  void createHashCode(SymbolData sd)
          Creates a method called hashCode that returns an int.
protected  SymbolData createImportedSymbolContinuation(String qualifiedTypeName, SourceInfo si)
          Create a continuation for imported class specified by qualifiedName if one does not already exist.
protected  MethodData createMethodData(MethodDef that, SymbolData sd)
          Creates a MethodData corresponding to the MethodDef within the context of the SymbolData sd.
protected  void createToString(SymbolData sd)
          Create a method called toString that returns type String.
protected  SymbolData defineAnonymousSymbolData(AnonymousClassInstantiation anonInst, String qualifiedAnonName, String superName)
          This method takes in an AnonymousClassInstantion, generates a SymbolData for it, and adds the name and SymbolData pair to the symbol table.
 ArrayData defineArraySymbolData(SymbolData eltSd, LanguageLevelVisitor llv, SourceInfo si)
           
protected  SymbolData defineInnerSymbolData(TypeDefBase typeDefBase, String relName, String qualifiedTypeName, Data enclosing)
          Takes in a TypeDefBase (which is either an InnerClassDef or an InnerInterfaceDef) and creates a SymbolData for it, either by converting a continuation to it or by creating a new symbol (if no continuationis present).
protected  SymbolData defineSymbolData(TypeDefBase typeDefBase, String qualifiedTypeName)
          Overloaded signature for defineSymbolData.
protected  SymbolData defineSymbolData(TypeDefBase typeDefBase, String qualifiedTypeName, String enclosingClassName)
          Given a TypeDefBase (which is either a ClassDef or an InterfaceDef) and the corresponding qualifiedTypeName, this method generates a SymbolData, and adds the name and SymbolData pair to the symbol table.
 Void forAbstractMethodDefDoFirst(AbstractMethodDef that)
          Makes sure that this abstract method def is not declared to be static.
 Void forBitwiseAndExpressionDoFirst(BitwiseAndExpression that)
           
 Void forBitwiseAssignmentExpressionDoFirst(BitwiseAssignmentExpression that)
           
 Void forBitwiseBinaryExpressionDoFirst(BitwiseBinaryExpression that)
           
 Void forBitwiseNotExpressionDoFirst(BitwiseNotExpression that)
           
 Void forBitwiseNotExpressionDoFirst(ShiftBinaryExpression that)
           
 Void forBitwiseOrExpressionDoFirst(BitwiseOrExpression that)
           
 Void forBitwiseXorExpressionDoFirst(BitwiseXorExpression that)
           
 Void forClassDefDoFirst(ClassDef that)
          Check for problems in ClassDefs.
 Void forClassImportStatementOnly(ClassImportStatement that)
          Make sure the class being imported has not already been imported.
 Void forComplexNameReference(ComplexNameReference that)
          Call the ResolveNameVisitor to see if this is a reference to a Type name.
 Void forConcreteMethodDefDoFirst(ConcreteMethodDef that)
          Makes sure that this concrete method def is not declared to be abstract.
 Void forEmptyExpressionDoFirst(EmptyExpression that)
          The EmptyExpression is a sign of an error.
 Void forInnerInterfaceDefDoFirst(InnerInterfaceDef that)
          Check for problems with InnerInterfaceDefs that are common to all language levels: specifically, they cannot be final.
 Void forInterfaceDefDoFirst(InterfaceDef that)
          Check for problems with InterfaceDefs: specifically, top level interfaces cannot be private or final.
protected  VariableData[] formalParameters2VariableData(FormalParameter[] fps, SymbolData enclosing)
          Convert the specified array of FormalParameters into an array of VariableDatas which is then returned.
 Void forMemberType(MemberType that)
          This is overwritten because we don't want to visit each half of MemberType recursively.
 Void forModifiersAndVisibilityDoFirst(ModifiersAndVisibility that)
          Check for problems with modifiers that are common to all language levels: duplicate modifiers and illegal combinations of modifiers.
 Void forNoOpExpressionDoFirst(NoOpExpression that)
          The NoOp expression signifies a missing binary operator that was encountered when the parser built the AST.
 Void forPackageImportStatementOnly(PackageImportStatement that)
          Check to make sure that this package import statement is not trying to import the current pacakge.
 Void forPackageStatementOnly(PackageStatement that)
          This sets the package name field in order to find other classes in the same package.
 Void forShiftAssignmentExpressionDoFirst(ShiftAssignmentExpression that)
          Bitwise operators are allowed in Full Java
 Void forShiftBinaryExpressionDoFirst(ShiftBinaryExpression that)
           
 Void forSimpleNamedClassInstantiation(SimpleNamedClassInstantiation that)
          Try to resolve the type of the instantiation, and make sure there are no errors
 Void forSimpleNameReference(SimpleNameReference that)
          Call the ResolveNameVisitor to see if this is a reference to a Type name.
 Void forSourceFile(SourceFile that)
          Check to make sure there aren't any immediate errors in this SourceFile by calling the doFirst method.
 Void forSourceFileDoFirst(SourceFile that)
          If a ClassDef defined in this source file is a TestCase class, make sure it is the only thing in the file.
 Void forStringLiteralOnly(StringLiteral that)
          Return the SymbolData for java.lang.String by default
 Void forVariableDeclaration(VariableDeclaration that)
          Do nothing.
static String getFieldAccessorName(String name)
           
 File getFile()
           
protected  String[] getFormalParameterMav(Data d)
          This method is factored out of formalParameters2VariableData so it can be overridden in FullJavaVisitor.
protected  String getQualifiedClassName(String className)
          The Qualified Class Name is the package, followed by a dot, followed by the rest of the class name.
static String getQualifiedClassName(String pkg, String className)
          If the specified package pkg is empty or pkg is a prefix of className, return className.
protected  SymbolData getQualifiedSymbolData(String qualClassName)
          Tries to find (or in some cases creates) the SymbolData for the fiven fully qualified class name.
protected  SymbolData getQualifiedSymbolData(String qualClassName, SourceInfo si)
          Tries to find (or in some cases creates) the SymbolData for the fiven fully qualified class name.
protected  SymbolData getQualifiedSymbolData(String qualClassName, SourceInfo si, boolean resolve)
          This method tries to find (or in some cases creates) the SymbolData for the fiven fully qualified class name.
protected  SymbolData getQualifiedSymbolData(String qualClassName, SourceInfo si, boolean resolve, boolean fromClassFile, boolean addError)
          This method tries to find (or in some cases creates) the SymbolData for the fiven fully qualified class name or class name.
protected  SymbolData getSymbolData(File file, String pkg, LinkedList<String> importedFiles, LinkedList<String> importedPackages, String enclosingClassName, String className, SourceInfo si, boolean addError, boolean checkImports)
          This method processes classNames which may or may not include qualifying prefixes.
 SymbolData getSymbolData(String className, SourceInfo si)
          Call getSymbolData with some default values.
protected  SymbolData getSymbolData(String className, SourceInfo si, boolean addError)
          Call getSymbolData with some default values.
protected  SymbolData getSymbolData(String className, SourceInfo si, boolean addError, boolean checkImports)
          Simple signature for getSymbol that uses the current context to fill in context information, i.e., it passes _file for file, _package for pkg, _importedFiles for importedFiles, _importedPackages for importedPackages, and _enclosingClass for enclosingClassName.
protected  SymbolData getSymbolData(TypeData lhs, String name, SourceInfo si, boolean addError)
          Try to look up name from the context of the lhs.
static String getUnqualifiedClassName(String className)
          Takes a classname and returns only the final segment of it.
protected  void identifyInnerClasses(TypeDefBase that)
          Processes the class body that.
protected  boolean isConstructor(Data d)
           
static boolean isDuplicateVariableData(LinkedList<VariableData> vds, VariableData toInsert)
           
static boolean isJavaLibraryClass(String className)
          Check to see if the specified classname is the name of a fully qualified java library class.
protected  SymbolData makeContinuation(SourceInfo si, String qualClassName)
          This method creates the specified continuation in the symbol table.
 LanguageLevelVisitor newClassBodyVisitor(SymbolData anonSD, String anonName)
          Factory method that constructs an appropriate class body visitor for this visitor class (either ClassBodyIntermediateVisitor or ClassBodyFullJavaVisitor).
protected  boolean prune(JExpressionIF node)
           
protected static String[] referenceType2String(ReferenceType[] rts)
          Convert the ReferenceType[] to a String[] with the names of the ReferenceTypes.
 SymbolData resolveSymbol(SourceInfo si, SymbolData cont)
          Resolves the continuation cont.
 
Methods inherited from class edu.rice.cs.javalanglevels.JExpressionIFPrunableDepthFirstVisitor
defaultCase, defaultDoFirst, forAbstractMethodDef, forAbstractMethodDefOnly, forAndExpression, forAndExpressionDoFirst, forAndExpressionOnly, forAnonymousClassInstantiationDoFirst, forAnonymousClassInstantiationOnly, forArrayAccess, forArrayAccessDoFirst, forArrayAccessOnly, forArrayInitializer, forArrayInitializerDoFirst, forArrayInitializerOnly, forArrayInstantiationDoFirst, forArrayInstantiationOnly, forArrayType, forArrayTypeDoFirst, forArrayTypeOnly, forAssignmentExpressionDoFirst, forAssignmentExpressionOnly, forBinaryExpressionDoFirst, forBinaryExpressionOnly, forBitwiseAndAssignmentExpression, forBitwiseAndAssignmentExpressionDoFirst, forBitwiseAndAssignmentExpressionOnly, forBitwiseAndExpression, forBitwiseAndExpressionOnly, forBitwiseAssignmentExpressionOnly, forBitwiseBinaryExpressionOnly, forBitwiseNotExpression, forBitwiseNotExpressionOnly, forBitwiseOrAssignmentExpression, forBitwiseOrAssignmentExpressionDoFirst, forBitwiseOrAssignmentExpressionOnly, forBitwiseOrExpression, forBitwiseOrExpressionOnly, forBitwiseXorAssignmentExpression, forBitwiseXorAssignmentExpressionDoFirst, forBitwiseXorAssignmentExpressionOnly, forBitwiseXorExpression, forBitwiseXorExpressionOnly, forBlock, forBlockDoFirst, forBlockOnly, forBodyDoFirst, forBodyOnly, forBooleanExpressionDoFirst, forBooleanExpressionOnly, forBooleanLiteral, forBooleanLiteralDoFirst, forBooleanLiteralOnly, forBracedBody, forBracedBodyDoFirst, forBracedBodyOnly, forBreakStatementDoFirst, forBreakStatementOnly, forCastExpression, forCastExpressionDoFirst, forCastExpressionOnly, forCatchBlock, forCatchBlockDoFirst, forCatchBlockOnly, forCharLiteral, forCharLiteralDoFirst, forCharLiteralOnly, forClassDef, forClassDefOnly, forClassImportStatement, forClassImportStatementDoFirst, forClassInstantiationDoFirst, forClassInstantiationOnly, forClassLiteral, forClassLiteralDoFirst, forClassLiteralOnly, forClassOrInterfaceType, forClassOrInterfaceTypeDoFirst, forClassOrInterfaceTypeOnly, forComparisonExpressionDoFirst, forComparisonExpressionOnly, forComplexAnonymousClassInstantiation, forComplexAnonymousClassInstantiationDoFirst, forComplexAnonymousClassInstantiationOnly, forComplexInitializedArrayInstantiation, forComplexInitializedArrayInstantiationDoFirst, forComplexInitializedArrayInstantiationOnly, forComplexMethodInvocation, forComplexMethodInvocationDoFirst, forComplexMethodInvocationOnly, forComplexNamedClassInstantiation, forComplexNamedClassInstantiationDoFirst, forComplexNamedClassInstantiationOnly, forComplexNameReferenceDoFirst, forComplexNameReferenceOnly, forComplexSuperConstructorInvocation, forComplexSuperConstructorInvocationDoFirst, forComplexSuperConstructorInvocationOnly, forComplexSuperReference, forComplexSuperReferenceDoFirst, forComplexSuperReferenceOnly, forComplexThisConstructorInvocation, forComplexThisConstructorInvocationDoFirst, forComplexThisConstructorInvocationOnly, forComplexThisReference, forComplexThisReferenceDoFirst, forComplexThisReferenceOnly, forComplexUninitializedArrayInstantiation, forComplexUninitializedArrayInstantiationDoFirst, forComplexUninitializedArrayInstantiationOnly, forCompoundWord, forCompoundWordDoFirst, forCompoundWordOnly, forConcreteMethodDef, forConcreteMethodDefOnly, forConditionalExpression, forConditionalExpressionDoFirst, forConditionalExpressionOnly, forConstructorDef, forConstructorDefDoFirst, forConstructorDefOnly, forContinueStatementDoFirst, forContinueStatementOnly, forDefaultCase, forDefaultCaseDoFirst, forDefaultCaseOnly, forDimensionExpressionList, forDimensionExpressionListDoFirst, forDimensionExpressionListOnly, forDivideAssignmentExpression, forDivideAssignmentExpressionDoFirst, forDivideAssignmentExpressionOnly, forDivideExpression, forDivideExpressionDoFirst, forDivideExpressionOnly, forDoStatement, forDoStatementDoFirst, forDoStatementOnly, forDoubleLiteral, forDoubleLiteralDoFirst, forDoubleLiteralOnly, forEmptyExpression, forEmptyExpressionOnly, forEmptyForCondition, forEmptyForConditionDoFirst, forEmptyForConditionOnly, forEmptyStatement, forEmptyStatementDoFirst, forEmptyStatementOnly, forEqualityExpressionDoFirst, forEqualityExpressionOnly, forEqualsExpression, forEqualsExpressionDoFirst, forEqualsExpressionOnly, forExpressionDoFirst, forExpressionListDoFirst, forExpressionListOnly, forExpressionOnly, forExpressionStatement, forExpressionStatementDoFirst, forExpressionStatementOnly, forFloatLiteral, forFloatLiteralDoFirst, forFloatLiteralOnly, forFormalParameter, forFormalParameterDoFirst, forFormalParameterOnly, forForStatement, forForStatementDoFirst, forForStatementOnly, forFunctionInvocationDoFirst, forFunctionInvocationOnly, forGreaterThanExpression, forGreaterThanExpressionDoFirst, forGreaterThanExpressionOnly, forGreaterThanOrEqualExpression, forGreaterThanOrEqualExpressionDoFirst, forGreaterThanOrEqualExpressionOnly, forIfThenElseStatement, forIfThenElseStatementDoFirst, forIfThenElseStatementOnly, forIfThenStatement, forIfThenStatementDoFirst, forIfThenStatementOnly, forImportStatementDoFirst, forImportStatementOnly, forIncrementExpressionDoFirst, forIncrementExpressionOnly, forInitializedArrayInstantiationDoFirst, forInitializedArrayInstantiationOnly, forInitializedVariableDeclarator, forInitializedVariableDeclaratorDoFirst, forInitializedVariableDeclaratorOnly, forInitializerDoFirst, forInitializerOnly, forInnerClassDef, forInnerClassDefDoFirst, forInnerClassDefOnly, forInnerInterfaceDef, forInnerInterfaceDefOnly, forInstanceInitializer, forInstanceInitializerDoFirst, forInstanceInitializerOnly, forInstanceofExpression, forInstanceofExpressionDoFirst, forInstanceofExpressionOnly, forInstantiationDoFirst, forInstantiationOnly, forIntegerLiteral, forIntegerLiteralDoFirst, forIntegerLiteralOnly, forInterfaceDef, forInterfaceDefOnly, forJExpressionDoFirst, forJExpressionOnly, forLabeledBreakStatement, forLabeledBreakStatementDoFirst, forLabeledBreakStatementOnly, forLabeledCase, forLabeledCaseDoFirst, forLabeledCaseOnly, forLabeledContinueStatement, forLabeledContinueStatementDoFirst, forLabeledContinueStatementOnly, forLabeledStatement, forLabeledStatementDoFirst, forLabeledStatementOnly, forLeftShiftAssignmentExpression, forLeftShiftAssignmentExpressionDoFirst, forLeftShiftAssignmentExpressionOnly, forLeftShiftExpression, forLeftShiftExpressionDoFirst, forLeftShiftExpressionOnly, forLessThanExpression, forLessThanExpressionDoFirst, forLessThanExpressionOnly, forLessThanOrEqualExpression, forLessThanOrEqualExpressionDoFirst, forLessThanOrEqualExpressionOnly, forLexicalLiteralDoFirst, forLexicalLiteralOnly, forLongLiteral, forLongLiteralDoFirst, forLongLiteralOnly, forMemberTypeDoFirst, forMemberTypeOnly, forMethodDefDoFirst, forMethodDefOnly, forMethodInvocationDoFirst, forMethodInvocationOnly, forMinusAssignmentExpression, forMinusAssignmentExpressionDoFirst, forMinusAssignmentExpressionOnly, forMinusExpression, forMinusExpressionDoFirst, forMinusExpressionOnly, forModAssignmentExpression, forModAssignmentExpressionDoFirst, forModAssignmentExpressionOnly, forModExpression, forModExpressionDoFirst, forModExpressionOnly, forModifiersAndVisibility, forModifiersAndVisibilityOnly, forMultiplyAssignmentExpression, forMultiplyAssignmentExpressionDoFirst, forMultiplyAssignmentExpressionOnly, forMultiplyExpression, forMultiplyExpressionDoFirst, forMultiplyExpressionOnly, forNamedClassInstantiationDoFirst, forNamedClassInstantiationOnly, forNameReferenceDoFirst, forNameReferenceOnly, forNegativeExpression, forNegativeExpressionDoFirst, forNegativeExpressionOnly, forNegativePostfixIncrementExpression, forNegativePostfixIncrementExpressionDoFirst, forNegativePostfixIncrementExpressionOnly, forNegativePrefixIncrementExpression, forNegativePrefixIncrementExpressionDoFirst, forNegativePrefixIncrementExpressionOnly, forNoOpExpression, forNoOpExpressionOnly, forNormalTryCatchStatement, forNormalTryCatchStatementDoFirst, forNormalTryCatchStatementOnly, forNotEqualExpression, forNotEqualExpressionDoFirst, forNotEqualExpressionOnly, forNotExpression, forNotExpressionDoFirst, forNotExpressionOnly, forNullLiteral, forNullLiteralDoFirst, forNullLiteralOnly, forNumericAssignmentExpressionDoFirst, forNumericAssignmentExpressionOnly, forNumericBinaryExpressionDoFirst, forNumericBinaryExpressionOnly, forNumericUnaryExpressionDoFirst, forNumericUnaryExpressionOnly, forOrExpression, forOrExpressionDoFirst, forOrExpressionOnly, forPackageImportStatement, forPackageImportStatementDoFirst, forPackageStatement, forPackageStatementDoFirst, forParenthesized, forParenthesizedDoFirst, forParenthesizedExpressionList, forParenthesizedExpressionListDoFirst, forParenthesizedExpressionListOnly, forParenthesizedOnly, forPlusAssignmentExpression, forPlusAssignmentExpressionDoFirst, forPlusAssignmentExpressionOnly, forPlusExpression, forPlusExpressionDoFirst, forPlusExpressionOnly, forPositiveExpression, forPositiveExpressionDoFirst, forPositiveExpressionOnly, forPositivePostfixIncrementExpression, forPositivePostfixIncrementExpressionDoFirst, forPositivePostfixIncrementExpressionOnly, forPositivePrefixIncrementExpression, forPositivePrefixIncrementExpressionDoFirst, forPositivePrefixIncrementExpressionOnly, forPostfixIncrementExpressionDoFirst, forPostfixIncrementExpressionOnly, forPrefixIncrementExpressionDoFirst, forPrefixIncrementExpressionOnly, forPrimaryDoFirst, forPrimaryOnly, forPrimitiveType, forPrimitiveTypeDoFirst, forPrimitiveTypeOnly, forReferenceTypeDoFirst, forReferenceTypeOnly, forReturnStatementDoFirst, forReturnStatementOnly, forRightSignedShiftAssignmentExpression, forRightSignedShiftAssignmentExpressionDoFirst, forRightSignedShiftAssignmentExpressionOnly, forRightSignedShiftExpression, forRightSignedShiftExpressionDoFirst, forRightSignedShiftExpressionOnly, forRightUnsignedShiftAssignmentExpression, forRightUnsignedShiftAssignmentExpressionDoFirst, forRightUnsignedShiftAssignmentExpressionOnly, forRightUnsignedShiftExpression, forRightUnsignedShiftExpressionDoFirst, forRightUnsignedShiftExpressionOnly, forShiftAssignmentExpressionOnly, forShiftBinaryExpressionOnly, forSimpleAnonymousClassInstantiation, forSimpleAnonymousClassInstantiationDoFirst, forSimpleAnonymousClassInstantiationOnly, forSimpleAssignmentExpression, forSimpleAssignmentExpressionDoFirst, forSimpleAssignmentExpressionOnly, forSimpleInitializedArrayInstantiation, forSimpleInitializedArrayInstantiationDoFirst, forSimpleInitializedArrayInstantiationOnly, forSimpleMethodInvocation, forSimpleMethodInvocationDoFirst, forSimpleMethodInvocationOnly, forSimpleNamedClassInstantiationDoFirst, forSimpleNamedClassInstantiationOnly, forSimpleNameReferenceDoFirst, forSimpleNameReferenceOnly, forSimpleSuperConstructorInvocation, forSimpleSuperConstructorInvocationDoFirst, forSimpleSuperConstructorInvocationOnly, forSimpleSuperReference, forSimpleSuperReferenceDoFirst, forSimpleSuperReferenceOnly, forSimpleThisConstructorInvocation, forSimpleThisConstructorInvocationDoFirst, forSimpleThisConstructorInvocationOnly, forSimpleThisReference, forSimpleThisReferenceDoFirst, forSimpleThisReferenceOnly, forSimpleUninitializedArrayInstantiation, forSimpleUninitializedArrayInstantiationDoFirst, forSimpleUninitializedArrayInstantiationOnly, forSourceFileOnly, forStatementDoFirst, forStatementOnly, forStaticInitializer, forStaticInitializerDoFirst, forStaticInitializerOnly, forStringLiteral, forStringLiteralDoFirst, forSuperConstructorInvocationDoFirst, forSuperConstructorInvocationOnly, forSuperReferenceDoFirst, forSuperReferenceOnly, forSwitchCaseDoFirst, forSwitchCaseOnly, forSwitchStatement, forSwitchStatementDoFirst, forSwitchStatementOnly, forSynchronizedStatement, forSynchronizedStatementDoFirst, forSynchronizedStatementOnly, forThisConstructorInvocationDoFirst, forThisConstructorInvocationOnly, forThisReferenceDoFirst, forThisReferenceOnly, forThrowStatement, forThrowStatementDoFirst, forThrowStatementOnly, forTryCatchFinallyStatement, forTryCatchFinallyStatementDoFirst, forTryCatchFinallyStatementOnly, forTryCatchStatementDoFirst, forTryCatchStatementOnly, forTypeDefBaseDoFirst, forTypeDefBaseOnly, forTypeDoFirst, forTypeOnly, forTypeParameter, forTypeParameterDoFirst, forTypeParameterOnly, forTypeVariable, forTypeVariableDoFirst, forTypeVariableOnly, forUnaryExpressionDoFirst, forUnaryExpressionOnly, forUnbracedBody, forUnbracedBodyDoFirst, forUnbracedBodyOnly, forUninitializedArrayInstantiationDoFirst, forUninitializedArrayInstantiationOnly, forUninitializedVariableDeclarator, forUninitializedVariableDeclaratorDoFirst, forUninitializedVariableDeclaratorOnly, forUnlabeledBreakStatement, forUnlabeledBreakStatementDoFirst, forUnlabeledBreakStatementOnly, forUnlabeledContinueStatement, forUnlabeledContinueStatementDoFirst, forUnlabeledContinueStatementOnly, forUnparenthesizedExpressionList, forUnparenthesizedExpressionListDoFirst, forUnparenthesizedExpressionListOnly, forValueReturnStatement, forValueReturnStatementDoFirst, forValueReturnStatementOnly, forVariableDeclarationDoFirst, forVariableDeclarationOnly, forVariableDeclaratorDoFirst, forVariableDeclaratorOnly, forVariableReferenceDoFirst, forVariableReferenceOnly, forVoidReturn, forVoidReturnDoFirst, forVoidReturnOnly, forVoidReturnStatement, forVoidReturnStatementDoFirst, forVoidReturnStatementOnly, forWhileStatement, forWhileStatementDoFirst, forWhileStatementOnly, forWord, forWordDoFirst, forWordOnly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLIC_MAV

public static final ModifiersAndVisibility PUBLIC_MAV

PROTECTED_MAV

public static final ModifiersAndVisibility PROTECTED_MAV

PRIVATE_MAV

public static final ModifiersAndVisibility PRIVATE_MAV

PACKAGE_MAV

public static final ModifiersAndVisibility PACKAGE_MAV

FINAL_MAV

public static final ModifiersAndVisibility FINAL_MAV

errors

protected static LinkedList<Pair<String,JExpressionIF>> errors
Errors we have encountered during this pass: string is the text of the error, JExpressionIF is the part of the AST where the error occurs.


symbolTable

public final Symboltable symbolTable
Stores the classes we have referenced, and all their information, once they are resolved. Bound to static field LanguageLevelConverter.symboltable.


_genericTypes

public HashMap<String,SymbolData> _genericTypes

_log

protected static final Log _log
Constructor Detail

LanguageLevelVisitor

public LanguageLevelVisitor(File file,
                            String packageName,
                            String enclosingClassName,
                            LinkedList<String> importedFiles,
                            LinkedList<String> importedPackages,
                            HashSet<String> classesInThisFile,
                            Hashtable<String,Triple<SourceInfo,LanguageLevelVisitor,SymbolData>> continuations,
                            LinkedList<Command> fixUps,
                            HashMap<String,SymbolData> genericTypes)
This constructor is called from the subclasses of LanguageLevelVisitor.

Parameters:
file - The File corresponding to the source file we are visiting
packageName - The name of the package corresponding to the file
importedFiles - The list of files (classes) imported by this source file
importedPackages - The list of packages imported by this source file
classesInThisFile - The list of names of classes defined in this file
continuations - The table of classes we have encountered but still need to resolve

LanguageLevelVisitor

public LanguageLevelVisitor(File file,
                            String packageName,
                            String enclosingClassName,
                            LinkedList<String> importedFiles,
                            LinkedList<String> importedPackages,
                            HashSet<String> classesInThisFile,
                            Hashtable<String,Triple<SourceInfo,LanguageLevelVisitor,SymbolData>> continuations,
                            LinkedList<Command> fixUps)
This constructor is used only in testing.

Parameters:
file - The File corresponding to the source file we are visiting
packageName - The name of the package corresponding to the file
importedFiles - The list of files (classes) imported by this source file
importedPackages - The list of packages imported by this source file
classesInThisFile - The list of names of classes defined in this file
continuations - The table of classes we have encountered but still need to resolve
Method Detail

_resetNonStaticFields

protected void _resetNonStaticFields()

getFieldAccessorName

public static String getFieldAccessorName(String name)
Returns:
the accessor name corresponding to given field name.

getFile

public File getFile()
Returns:
the source file

isConstructor

protected boolean isConstructor(Data d)
Returns:
true if this data is a constructor, i.e., it is a method data, its name and return type are the same, and its return type matches its enclosing sd.

newClassBodyVisitor

public LanguageLevelVisitor newClassBodyVisitor(SymbolData anonSD,
                                                String anonName)
Factory method that constructs an appropriate class body visitor for this visitor class (either ClassBodyIntermediateVisitor or ClassBodyFullJavaVisitor). This class and method should be abstract, but the LLV class is used concretely in testing and elswhere. The default choice is ClassBodyFullJavaVisitor.


getUnqualifiedClassName

public static String getUnqualifiedClassName(String className)
Takes a classname and returns only the final segment of it. This removes all the dots. Returns "" for anonymous class names. TODO: Do we need to fix this?


referenceType2String

protected static String[] referenceType2String(ReferenceType[] rts)
Convert the ReferenceType[] to a String[] with the names of the ReferenceTypes.


isJavaLibraryClass

public static boolean isJavaLibraryClass(String className)
Check to see if the specified classname is the name of a fully qualified java library class.


isDuplicateVariableData

public static boolean isDuplicateVariableData(LinkedList<VariableData> vds,
                                              VariableData toInsert)
Returns:
true if the specified VariableData overwrites one of the members of the list of VariableDatas and false otherwise. A VariableData is overwritten if its name is shadowed.

defineArraySymbolData

public ArrayData defineArraySymbolData(SymbolData eltSd,
                                       LanguageLevelVisitor llv,
                                       SourceInfo si)

_getSymbolDataFromFileSystem

protected SymbolData _getSymbolDataFromFileSystem(String qualifiedClassName,
                                                  SourceInfo si,
                                                  boolean resolve,
                                                  boolean addError)
Checks the file system for the class name, returning the corresponding SymbolData if there is an up-to-date match. If resolve is false but a corresponding source file is matched, a continuation is returned. If no source file is found but a class file is found, the symbol is resolved against the class file even if resolve is false. If resolve is true and a corresponding source file is found, the symbol is resolved against the corresponding class file provided it is up-to-date. If it is not up-to-date, the method throws an error message. If no source file or class file corresponding to the class is found, SymbolData.NOT_FOUND is returned.

Parameters:
qualifiedClassName - The name of the class we're looking up.
si - Information about where the class was called from.
resolve - true if we want to fully resolve the SymbolData.
addError - true if we want to throw errors. `

resolveSymbol

public SymbolData resolveSymbol(SourceInfo si,
                                SymbolData cont)
Resolves the continuation cont.


getSymbolData

public SymbolData getSymbolData(String className,
                                SourceInfo si)
Call getSymbolData with some default values. By default addError is true, since we want to display errors. By default checkImports is true, since we want to consider imported packages and classes.

Parameters:
className - The referenced name of the class to resolve.
si - The SourceInfo corresponding to the reference to the type

getSymbolData

protected SymbolData getSymbolData(String className,
                                   SourceInfo si,
                                   boolean addError)
Call getSymbolData with some default values. By default checkImports will be true, since we want to consider imported packages and classes initially.

Parameters:
className - The referenced name of the class to identify
si - The SourceInfo corresponding to the reference to the type
addError - true if we want to give an error if this class cannot be resolved.

getSymbolData

protected SymbolData getSymbolData(String className,
                                   SourceInfo si,
                                   boolean addError,
                                   boolean checkImports)
Simple signature for getSymbol that uses the current context to fill in context information, i.e., it passes _file for file, _package for pkg, _importedFiles for importedFiles, _importedPackages for importedPackages, and _enclosingClass for enclosingClassName. This version should be used in all contexts EXCEPT fixups which are executed outside of any context and must provide saved context information.


getSymbolData

protected SymbolData getSymbolData(File file,
                                   String pkg,
                                   LinkedList<String> importedFiles,
                                   LinkedList<String> importedPackages,
                                   String enclosingClassName,
                                   String className,
                                   SourceInfo si,
                                   boolean addError,
                                   boolean checkImports)
This method processes classNames which may or may not include qualifying prefixes. Array types are recognized and treated recursively. The raw className is initially compared with: * top-level classes defined in the this file; * fully qualified classes in the file system; * inner classes defined in the enclosing class; * classes in the same package defined in other files; * imported classes; and * classes in imported packages. Then className is decomposed in a prefix and an extension where prefixes are matched against symbols as described above. If a matching prefix is found, the remainder is matched against inner classes of the matched symbol. The protocol does not exactly match the one in the JLS. This results of method are relative to _file, _package, _importedFiles, _importedPackages, and _enclosingClassName. The external variables _classesInThisFile and _innerClassesInThisBody are used to reduce the number of fixups but should not affect the ultimate results (after fixups) of any searches. This method calls getQualifiedSymbolData to look up fully qualified class names in the symbol table; this process does not depend on anything but the contents of the symbol table.

Parameters:
file - The file containing the className reference.
package - The package corresponding to file.
importedFiles - The imported files for this file
importedPackages - The imported Packages for this file
enclosingClassName - The enclosing className
className - The referenced name of the class to lookup.
si - The SourceInfo of the reference to className used in case of an error.
addError - Whether to add errors or not
checkImports - Whether to try prepending the imported package names

getSymbolData

protected SymbolData getSymbolData(TypeData lhs,
                                   String name,
                                   SourceInfo si,
                                   boolean addError)
Try to look up name from the context of the lhs.

Parameters:
lhs - The TypeData corresponding to the enclosing of this name reference
name - The name piece to look up from the context of lhs
si - The SourceInfo corresponding to this reference
addError - true if an error should be added
Returns:
The SymbolData corresponding to this lookup, or NOT_FOUND or null if it could not be found

getQualifiedSymbolData

protected SymbolData getQualifiedSymbolData(String qualClassName)
Tries to find (or in some cases creates) the SymbolData for the fiven fully qualified class name. It searches imported files, primitive types, as well as types in the symbol table.


getQualifiedSymbolData

protected SymbolData getQualifiedSymbolData(String qualClassName,
                                            SourceInfo si)
Tries to find (or in some cases creates) the SymbolData for the fiven fully qualified class name. It searches imported files, primitive types, as well as types in the symbol table.


getQualifiedSymbolData

protected SymbolData getQualifiedSymbolData(String qualClassName,
                                            SourceInfo si,
                                            boolean resolve)
This method tries to find (or in some cases creates) the SymbolData for the fiven fully qualified class name. It searches imported files, primitive types, as well as types in the symbol table. If resolve is true, it loads the symbolTable with all of the requisite information about qualClassName.


getQualifiedSymbolData

protected SymbolData getQualifiedSymbolData(String qualClassName,
                                            SourceInfo si,
                                            boolean resolve,
                                            boolean fromClassFile,
                                            boolean addError)
This method tries to find (or in some cases creates) the SymbolData for the fiven fully qualified class name or class name. It uses _classesInThisFile to avoid returning null in some cases (eliminating the need for some fixups). Except for the _classesInThisFile optimization (which works uniformly if it is set to null during continuation resolution and fixups), this lookup only depends on the contents of the symbol table and the file system.

Parameters:
qualClassName - The fully qualified name of the class to lookup.
si - The SourceInfo of the reference to qualClassName used in case of an error.
resolve - Whether to return a continuation or fully parse the class.
fromClassFile - Whether this was called from the class file reader.
addError - Whether to add errors. We don't add errors when iterating through a qualified class name's package. (??)

getQualifiedClassName

protected String getQualifiedClassName(String className)
The Qualified Class Name is the package, followed by a dot, followed by the rest of the class name. If the provided className is already qualified, just return it. If the package is not empty, and the className does not start with the package, append the package name onto the className, and return it.

Parameters:
className - The className to qualify.

getQualifiedClassName

public static String getQualifiedClassName(String pkg,
                                           String className)
If the specified package pkg is empty or pkg is a prefix of className, return className. Otherwise return className qualified with the pkg prefix.

Parameters:
pkg - The package name to use as a prefix.
className - The className to qualify.

addInnerSymbolData

protected SymbolData addInnerSymbolData(SourceInfo si,
                                        String qualifiedTypeName,
                                        Data enclosing)

makeContinuation

protected SymbolData makeContinuation(SourceInfo si,
                                      String qualClassName)
This method creates the specified continuation in the symbol table. Assumes qualClassName is fully qualified.

Parameters:
si - The SourceInfo corresponding to this occurrence of the class symbol
referencedClassName - The referenced name for the class. In some cases, it is fully qualified.

_lookupTypeFromWithinClass

protected SymbolData _lookupTypeFromWithinClass(ReferenceType rt,
                                                String qualifiedClassName)
Looks up the type with name rt (which is arbitrary source text for a type) from within the class name qualifiedClassName. At top level, qualifiedClassName == null. The parameter qualifiedClassName is required becaue this method may be called in a fixup. TODO: consolidate with _identifyType.


defineSymbolData

protected SymbolData defineSymbolData(TypeDefBase typeDefBase,
                                      String qualifiedTypeName)
Overloaded signature for defineSymbolData. Passes _enclosingClassName for enclosingClassName and _classesInThisFile for classesInThisFile


defineSymbolData

protected SymbolData defineSymbolData(TypeDefBase typeDefBase,
                                      String qualifiedTypeName,
                                      String enclosingClassName)
Given a TypeDefBase (which is either a ClassDef or an InterfaceDef) and the corresponding qualifiedTypeName, this method generates a SymbolData, and adds the name and SymbolData pair to the symbol table. It checks that this class is not already in the symbol table. This error should never happen for an inner class or interface. Assumes that the defined class is top level. If used for inner class definition, the caller must be perform any special inner class initialization.

Parameters:
typeDefBase - The AST node for the class def, interface def, inner class def, or inner interface def.
qualifiedTypeName - The fully qualified name of the class or interface
Returns:
the defined SymbolData or null if the type has already been defined

defineInnerSymbolData

protected SymbolData defineInnerSymbolData(TypeDefBase typeDefBase,
                                           String relName,
                                           String qualifiedTypeName,
                                           Data enclosing)
Takes in a TypeDefBase (which is either an InnerClassDef or an InnerInterfaceDef) and creates a SymbolData for it, either by converting a continuation to it or by creating a new symbol (if no continuationis present).

Parameters:
typeDefBase - The AST node for the class def, interface def, inner class def, or inner interface def.
relName - The relative (unqualified) name of the symbol
qualifiedTypeName - The fully qualified name for the class; null if this definition is a duplicate
enclosing - The enclosing SymbolData or MethodData (for a local class defined within a method).

defineAnonymousSymbolData

protected SymbolData defineAnonymousSymbolData(AnonymousClassInstantiation anonInst,
                                               String qualifiedAnonName,
                                               String superName)
This method takes in an AnonymousClassInstantion, generates a SymbolData for it, and adds the name and SymbolData pair to the symbol table.

Parameters:
AnonymousClassInstantiation - The AST node for the anonymous class instantiation.
qualifiedTypeName - The fully qualified name of the class

getFormalParameterMav

protected String[] getFormalParameterMav(Data d)
This method is factored out of formalParameters2VariableData so it can be overridden in FullJavaVisitor.

Returns:
the formal parameter mav appropriate for the language level; "Functional level" is default.

formalParameters2VariableData

protected VariableData[] formalParameters2VariableData(FormalParameter[] fps,
                                                       SymbolData enclosing)
Convert the specified array of FormalParameters into an array of VariableDatas which is then returned. All formal parameters are automatically made final.

Parameters:
fps - The AST node for the parameter list
enclosing - The SymbolData for the enclosing class (not method!) NOTE: enclosing refers to the enclosing class rather than enclosing method because any new types defined in the method are not visible in the parameter list. TODO: At the advanced level, this may need to be overwritten?

createMethodData

protected MethodData createMethodData(MethodDef that,
                                      SymbolData sd)
Creates a MethodData corresponding to the MethodDef within the context of the SymbolData sd.


_variableDeclaration2VariableData

protected VariableData[] _variableDeclaration2VariableData(VariableDeclaration vd,
                                                           Data enclosing)
This method assumes that the modifiers for this particular VariableDeclaration have already been checked. It does no semantic checking. It simply converts the declarators to variable datas, by trying to resolve the types of each declarator. The VariableDeclaration may be a field declaration! The Data enclosing may be a MethodData!


_identifyType

protected SymbolData _identifyType(String name,
                                   SourceInfo si,
                                   String enclosingClassName)
Identifies the SymbolData matching name in symbolTable. Returns null if no match is found. Searches for typeName as a fully qualified Name and as a relative name within the enclosing class. enclosingClassName is null if type is part of the header for a class or interface. Methods can introduce local types. Make sure that we can match inner classes of the chain of enclosing datas. We need to use the relative inner class name to do this.


_addError

protected static void _addError(String message,
                                JExpressionIF that)
This method is called when an error should be added to the static LinkedList of errors. This version is called from the DoFirst methods in the LanguageLevelVisitors to halt parsing of the construct.


_addAndIgnoreError

protected static void _addAndIgnoreError(String message,
                                         JExpressionIF that)
This method is called when an error should be added, but tree-walking should continue on this construct. Generally, if the error is not added in the DoFirst, the _errorAdded flag is not checked anyway, so this version should be called.


prune

protected boolean prune(JExpressionIF node)
Overrides:
prune in class JExpressionIFPrunableDepthFirstVisitor

_checkError

protected static boolean _checkError()
If _errorAdded is true, set it back to false and return true. This will cause the current construct to be skipped, but will allow this first pass to otherwise continue unimpeded. Otherwise, return false, which will allow this first pass to continue normally.


_badModifiers

public void _badModifiers(String first,
                          String second,
                          JExpressionIF that)
Add an error explaining the modifiers' conflict.


forModifiersAndVisibilityDoFirst

public Void forModifiersAndVisibilityDoFirst(ModifiersAndVisibility that)
Check for problems with modifiers that are common to all language levels: duplicate modifiers and illegal combinations of modifiers.

Overrides:
forModifiersAndVisibilityDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forClassDefDoFirst

public Void forClassDefDoFirst(ClassDef that)
Check for problems in ClassDefs. Make sure that the top level class is not private, and that the class name has not already been imported.

Overrides:
forClassDefDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forInterfaceDefDoFirst

public Void forInterfaceDefDoFirst(InterfaceDef that)
Check for problems with InterfaceDefs: specifically, top level interfaces cannot be private or final.

Overrides:
forInterfaceDefDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forInnerInterfaceDefDoFirst

public Void forInnerInterfaceDefDoFirst(InnerInterfaceDef that)
Check for problems with InnerInterfaceDefs that are common to all language levels: specifically, they cannot be final.

Overrides:
forInnerInterfaceDefDoFirst in class JExpressionIFPrunableDepthFirstVisitor

anonymousClassInstantiationHelper

public void anonymousClassInstantiationHelper(AnonymousClassInstantiation that,
                                              SymbolData enclosing,
                                              String superName)
Do the common work for SimpleAnonymousClassInstantiations and ComplexAnonymousClassInstantiations and in FullJava and Functional Java.

Parameters:
that - The AnonymousClassInstantiation being visited.
enclosing - The SymbolData of the enclosing class.
superC - The super class being instantiated--i.e. new A() { ...}, would have a super class of A.

identifyInnerClasses

protected void identifyInnerClasses(TypeDefBase that)
Processes the class body that.


forPackageStatementOnly

public Void forPackageStatementOnly(PackageStatement that)
This sets the package name field in order to find other classes in the same package.

Overrides:
forPackageStatementOnly in class JExpressionIFPrunableDepthFirstVisitor

forClassImportStatementOnly

public Void forClassImportStatementOnly(ClassImportStatement that)
Make sure the class being imported has not already been imported. If there are no errors, add it to the list of imported files, and create a continuation for it. The class will be resolved later.

Overrides:
forClassImportStatementOnly in class JExpressionIFPrunableDepthFirstVisitor

createImportedSymbolContinuation

protected SymbolData createImportedSymbolContinuation(String qualifiedTypeName,
                                                      SourceInfo si)
Create a continuation for imported class specified by qualifiedName if one does not already exist.


forPackageImportStatementOnly

public Void forPackageImportStatementOnly(PackageImportStatement that)
Check to make sure that this package import statement is not trying to import the current pacakge.

Overrides:
forPackageImportStatementOnly in class JExpressionIFPrunableDepthFirstVisitor

forConcreteMethodDefDoFirst

public Void forConcreteMethodDefDoFirst(ConcreteMethodDef that)
Makes sure that this concrete method def is not declared to be abstract.

Overrides:
forConcreteMethodDefDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forAbstractMethodDefDoFirst

public Void forAbstractMethodDefDoFirst(AbstractMethodDef that)
Makes sure that this abstract method def is not declared to be static.

Overrides:
forAbstractMethodDefDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forShiftAssignmentExpressionDoFirst

public Void forShiftAssignmentExpressionDoFirst(ShiftAssignmentExpression that)
Bitwise operators are allowed in Full Java

Overrides:
forShiftAssignmentExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forBitwiseAssignmentExpressionDoFirst

public Void forBitwiseAssignmentExpressionDoFirst(BitwiseAssignmentExpression that)
Overrides:
forBitwiseAssignmentExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forBitwiseBinaryExpressionDoFirst

public Void forBitwiseBinaryExpressionDoFirst(BitwiseBinaryExpression that)
Overrides:
forBitwiseBinaryExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forBitwiseOrExpressionDoFirst

public Void forBitwiseOrExpressionDoFirst(BitwiseOrExpression that)
Overrides:
forBitwiseOrExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forBitwiseXorExpressionDoFirst

public Void forBitwiseXorExpressionDoFirst(BitwiseXorExpression that)
Overrides:
forBitwiseXorExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forBitwiseAndExpressionDoFirst

public Void forBitwiseAndExpressionDoFirst(BitwiseAndExpression that)
Overrides:
forBitwiseAndExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forBitwiseNotExpressionDoFirst

public Void forBitwiseNotExpressionDoFirst(BitwiseNotExpression that)
Overrides:
forBitwiseNotExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forShiftBinaryExpressionDoFirst

public Void forShiftBinaryExpressionDoFirst(ShiftBinaryExpression that)
Overrides:
forShiftBinaryExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forBitwiseNotExpressionDoFirst

public Void forBitwiseNotExpressionDoFirst(ShiftBinaryExpression that)

forEmptyExpressionDoFirst

public Void forEmptyExpressionDoFirst(EmptyExpression that)
The EmptyExpression is a sign of an error. It means that we were missing something we needed when the parser built the AST

Overrides:
forEmptyExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forNoOpExpressionDoFirst

public Void forNoOpExpressionDoFirst(NoOpExpression that)
The NoOp expression signifies a missing binary operator that was encountered when the parser built the AST.

Overrides:
forNoOpExpressionDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forSourceFileDoFirst

public Void forSourceFileDoFirst(SourceFile that)
If a ClassDef defined in this source file is a TestCase class, make sure it is the only thing in the file.

Overrides:
forSourceFileDoFirst in class JExpressionIFPrunableDepthFirstVisitor

forSourceFile

public Void forSourceFile(SourceFile that)
Check to make sure there aren't any immediate errors in this SourceFile by calling the doFirst method. Then, check to make sure that java.lang is imported, and if it is not, add it to the list of importedpackages, since it is imported by default. Make a list of all classes defined in this file. Then, visit them one by one.

Specified by:
forSourceFile in interface JExpressionIFVisitor<Void>
Overrides:
forSourceFile in class JExpressionIFPrunableDepthFirstVisitor

forSimpleNameReference

public Void forSimpleNameReference(SimpleNameReference that)
Call the ResolveNameVisitor to see if this is a reference to a Type name.

Specified by:
forSimpleNameReference in interface JExpressionIFVisitor<Void>
Overrides:
forSimpleNameReference in class JExpressionIFPrunableDepthFirstVisitor

forComplexNameReference

public Void forComplexNameReference(ComplexNameReference that)
Call the ResolveNameVisitor to see if this is a reference to a Type name.

Specified by:
forComplexNameReference in interface JExpressionIFVisitor<Void>
Overrides:
forComplexNameReference in class JExpressionIFPrunableDepthFirstVisitor

forVariableDeclaration

public Void forVariableDeclaration(VariableDeclaration that)
Do nothing. This is handled in the forVariableDeclarationOnly case.

Specified by:
forVariableDeclaration in interface JExpressionIFVisitor<Void>
Overrides:
forVariableDeclaration in class JExpressionIFPrunableDepthFirstVisitor

addGeneratedMethod

protected static void addGeneratedMethod(SymbolData sd,
                                         MethodData md)
If the method being generated already exists in the SymbolData, throw an error, because generated methods cannot be overwritten.


createConstructor

public void createConstructor(SymbolData sd)
Creates the automatically generated constructor for this class. It needs to take in the same arguments as its super class' constructor as well as its fields. If there are multiple constructors in the super class, pick the one with the least number of parameters. No constructor is created if this is an advanced level file (overridden at advanced level), because no code augmentation is done.


createAccessors

protected static void createAccessors(SymbolData sd,
                                      File file)
Create a method that is an accessor for each field in the class. File file is passed in so this can remain a static method TODO: should this be called AFTER all fixups have been performed? No method needs to be in symbol table.


createToString

protected void createToString(SymbolData sd)
Create a method called toString that returns type String. Overridden at the Advanced Level files, because n code augmentation is done for them so you don't want to create this method.


createHashCode

protected void createHashCode(SymbolData sd)
Creates a method called hashCode that returns an int. Overriden for FullJava files, because no code augmentation is done for them, so we don't want to create this method.


createEquals

protected void createEquals(SymbolData sd)
Creates a method called equals() that takes in an Object argument and returns a boolean. Overriden for FullJava files, because no code augmentation is done for them, so we don't want to create this method.


forMemberType

public Void forMemberType(MemberType that)
This is overwritten because we don't want to visit each half of MemberType recursively. Just take the whole thing and look for it in forMemberTypeOnly (calls forTypeOnly eventually to get looked up).

Specified by:
forMemberType in interface JExpressionIFVisitor<Void>
Overrides:
forMemberType in class JExpressionIFPrunableDepthFirstVisitor

forStringLiteralOnly

public Void forStringLiteralOnly(StringLiteral that)
Return the SymbolData for java.lang.String by default

Overrides:
forStringLiteralOnly in class JExpressionIFPrunableDepthFirstVisitor

forSimpleNamedClassInstantiation

public Void forSimpleNamedClassInstantiation(SimpleNamedClassInstantiation that)
Try to resolve the type of the instantiation, and make sure there are no errors

Specified by:
forSimpleNamedClassInstantiation in interface JExpressionIFVisitor<Void>
Overrides:
forSimpleNamedClassInstantiation in class JExpressionIFPrunableDepthFirstVisitor

arrayEquals

public static boolean arrayEquals(Object[] array1,
                                  Object[] array2)
Determines whether array1 equals array2 using the equals method on Object[] arrays in java.util.Arrays.

Returns:
true if the two array argument (which may be null) are equal.