Class DeriveSymTypeOfBSCommonExpressions

java.lang.Object
de.monticore.types.check.AbstractDeriveFromExpression
de.monticore.types.check.DeriveSymTypeOfBSCommonExpressions
All Implemented Interfaces:
CommonExpressionsHandler, CommonExpressionsVisitor2, de.monticore.visitor.IHandler, de.monticore.visitor.IVisitor
Direct Known Subclasses:
DeriveSymTypeOfCommonExpressions

@Deprecated public class DeriveSymTypeOfBSCommonExpressions extends AbstractDeriveFromExpression implements CommonExpressionsVisitor2, CommonExpressionsHandler
Deprecated.
part of typecheck1, use TypeCheck3 instead.
This Visitor can calculate a SymTypeExpression (type) for the expressions in CommonExpressions The BS stands for BasicSymbols. Therefore, the class should not be used in an OO-context as it does not know OO concepts such as the modifiers static, public or private. For an OO language, use DeriveSymTypeOfCommonExpressions instead, which extends the functionality of this class so that it may be used in an OO-context as well. It can be combined with other expressions in your language by creating a DelegatorVisitor
  • Field Details

  • Constructor Details

    • DeriveSymTypeOfBSCommonExpressions

      public DeriveSymTypeOfBSCommonExpressions()
      Deprecated.
    • DeriveSymTypeOfBSCommonExpressions

      public DeriveSymTypeOfBSCommonExpressions(SubExprNameExtractor subExprNameExtractor, DefiningSymbolSetter definingSymbolSetter)
      Deprecated.
  • Method Details

    • getTraverser

      public CommonExpressionsTraverser getTraverser()
      Deprecated.
      Specified by:
      getTraverser in interface CommonExpressionsHandler
      Specified by:
      getTraverser in interface de.monticore.visitor.IHandler
      Specified by:
      getTraverser in class AbstractDeriveFromExpression
    • setTraverser

      public void setTraverser(CommonExpressionsTraverser traverser)
      Deprecated.
      Specified by:
      setTraverser in interface CommonExpressionsHandler
    • getSubExprNameExtractor

      public SubExprNameExtractor getSubExprNameExtractor()
      Deprecated.
    • setSubExprNameExtractor

      public void setSubExprNameExtractor(SubExprNameExtractor subExprNameExtractor)
      Deprecated.
    • getDefiningSymbolSetter

      public DefiningSymbolSetter getDefiningSymbolSetter()
      Deprecated.
    • setDefiningSymbolSetter

      public void setDefiningSymbolSetter(DefiningSymbolSetter definingSymboLSetter)
      Deprecated.
    • traverse

      public void traverse(ASTPlusPrefixExpression expr)
      Deprecated.
      Specified by:
      traverse in interface CommonExpressionsHandler
    • traverse

      public void traverse(ASTMinusPrefixExpression expr)
      Deprecated.
      Specified by:
      traverse in interface CommonExpressionsHandler
    • numericPrefix

      protected SymTypeExpression numericPrefix(ASTExpression expr, String op, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • numericPrefix

      protected SymTypeExpression numericPrefix(SymTypeExpression inner, String op, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTPlusExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculatePlusExpression

      protected SymTypeExpression calculatePlusExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTMultExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateMultExpression

      protected SymTypeExpression calculateMultExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTDivideExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateDivideExpression

      protected SymTypeExpression calculateDivideExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTMinusExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateMinusExpression

      protected SymTypeExpression calculateMinusExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTModuloExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateModuloExpression

      protected SymTypeExpression calculateModuloExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTLessEqualExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • lessEqual

      protected SymTypeExpression lessEqual(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTGreaterEqualExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • greaterEqual

      protected SymTypeExpression greaterEqual(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTLessThanExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • less

      protected SymTypeExpression less(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTGreaterThanExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateGreaterThanExpression

      protected SymTypeExpression calculateGreaterThanExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTEqualsExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateEqualsExpression

      protected SymTypeExpression calculateEqualsExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTNotEqualsExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateNotEqualsExpression

      protected SymTypeExpression calculateNotEqualsExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTBooleanAndOpExpression expr)
      Deprecated.
      We use traverse to collect the results of the two parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateBooleanAndOpExpression

      protected SymTypeExpression calculateBooleanAndOpExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTBooleanOrOpExpression expr)
      Deprecated.
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateBooleanOrOpExpression

      protected SymTypeExpression calculateBooleanOrOpExpression(SymTypeExpression left, SymTypeExpression right, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • calculateLogicalOrOpAndOp

      protected SymTypeExpression calculateLogicalOrOpAndOp(SymTypeExpression left, SymTypeExpression right, String op, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTLogicalNotExpression expr)
      Deprecated.
      We use traverse to collect the result of the inner part of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • derive

      protected SymTypeExpression derive(ASTLogicalNotExpression expr)
      Deprecated.
    • logicalNot

      protected SymTypeExpression logicalNot(SymTypeExpression inner, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTConditionalExpression expr)
      Deprecated.
      We use traverse to collect the results of the three parts of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateConditionalExpressionType

      protected SymTypeExpression calculateConditionalExpressionType(ASTConditionalExpression expr, SymTypeExpression conditionResult, SymTypeExpression trueResult, SymTypeExpression falseResult)
      Deprecated.
    • traverse

      public void traverse(ASTBooleanNotExpression expr)
      Deprecated.
      We use traverse to collect the result of the inner part of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • derive

      protected SymTypeExpression derive(ASTBooleanNotExpression expr)
      Deprecated.
    • booleanNot

      protected SymTypeExpression booleanNot(SymTypeExpression inner, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTFieldAccessExpression expr)
      Deprecated.
      We use traverse to collect the result of the inner part of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateNamingChainFieldAccess

      protected void calculateNamingChainFieldAccess(ASTFieldAccessExpression expr, List<ExprToNamePair> nameParts)
      Deprecated.
      Calculate the type result of FieldAccessExpressions that represent qualified names and cascading field accesses. E.g., pac.kage.Type.staticMember, or, localField.innerField.furtherNestedField. But not: pac.kage.Type.staticMethod().innerField, as here innerField is not only qualified by names, but it is based on the access of a value returned by a CallExpression.
      Parameters:
      expr - The only valid sub expressions of the FieldAccessExpression are other FieldAccessExpressions, and a ASTNameExpression that is the end of the field access chain.
    • calculateArithmeticFieldAccessExpression

      protected void calculateArithmeticFieldAccessExpression(ASTFieldAccessExpression expr)
      Deprecated.
      Calculate the type result of FieldAccessExpressions that do not represent qualified names. (E.g. `new Foo().bar`)
    • calculateFieldAccess

      protected void calculateFieldAccess(ASTFieldAccessExpression expr, boolean quiet)
      Deprecated.
      Calculates the type result of the field access expression, given that the type result of the accessed entity's owner has already been computed (and is accessible via getTypeCheckResult()).
      Parameters:
      quiet - Prevents the logging of errors if no entity is found that could be accessed, i.e., if the field access is invalid and the calculation of a result is not possible.
    • getCorrectFieldsFromInnerType

      protected List<VariableSymbol> getCorrectFieldsFromInnerType(SymTypeExpression innerResult, ASTFieldAccessExpression expr)
      Deprecated.
      Hookpoint for object oriented languages to get the correct variables/fields from a type based on their modifiers
    • checkModifierType

      protected boolean checkModifierType(TypeSymbol typeSymbol)
      Deprecated.
      Hookpoint for object oriented languages that offer modifiers like static, public, private, ...
    • filterModifiersVariables

      protected List<VariableSymbol> filterModifiersVariables(List<VariableSymbol> variableSymbols)
      Deprecated.
      Hookpoint for object oriented languages that offer modifiers like static, public, private, ...
    • calculatedQualifiedEntity

      protected void calculatedQualifiedEntity(List<ExprToNamePair> nameParts)
      Deprecated.
      Tries to resolve the given name parts to a variable, type variable, or type and if a symbol is found, then it(s type) is set as the current type check result. If no symbol is found, then nothing happens (no error logged, no altering of the type check result). If multiple fields are found, then the result is set to obscure, and an error is logged. Variables take precedence over types variables that take precedence over types.
      Parameters:
      nameParts - Expressions that represent a qualified identification of a VariableSymbol, TypeVarSymbol, or TypeSymbol. Therefore, the list that must contain a NameExpression at the beginning, followed only by FieldAccessExpressions.
    • traverse

      public void traverse(ASTCallExpression expr)
      Deprecated.
      We use traverse to collect the result of the inner part of the expression and calculate the result for the whole expression
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateNamingChainCallExpression

      protected void calculateNamingChainCallExpression(ASTCallExpression expr, List<ExprToNamePair> nameParts, List<SymTypeExpression> argTypes)
      Deprecated.
      Calculate the type result of call expressions that represent fully qualified method calls (like when calling a static method: pac.kage.Type.staticMethod()) and methodCalls on cascading field accesses (e.g., localField.innerField.instanceMethod()). But not: pac.kage.Type.staticMethod().innerField.instanceMethod(), as here instanceMethod is not only qualified by names, but it is based on the access of a value returned by a CallExpression.
      Parameters:
      expr - The call expression itself
      nameParts - The name parts of the method in their order of appearance. Provide both their AST version, and their String version!
      argTypes - the types of the arguments of the method
    • calculateArithmeticCallExpression

      protected void calculateArithmeticCallExpression(ASTCallExpression expr, String methodName, List<ExprToOptNamePair> methodCallParts, List<SymTypeExpression> argTypes)
      Deprecated.
      Calculates the type result of the expression, given that it is not a simple, or qualified method access. E.g., this method calculates the result of "FooBar".substring(0, 3), or ( foo ? new LinkedList<String>() : new ArrayList<String>() ).add("bar"). On the other hand, this method is not suited for pac.kage.Owner.staticMethod(), or isInt() (a local Method name). Use calculateNamingChainCallExpression(ASTCallExpression, List, List) in these cases.
    • calculateOwnedCallExpression

      protected void calculateOwnedCallExpression(ASTCallExpression expr, String methodName, List<SymTypeExpression> args)
      Deprecated.
      Calculates the type result of the call expression, given that the type result of the method owner has already been computed (and is accessible via getTypeCheckResult()), and that the type of its arguments has already been computed.
    • calculateQualifiedMethod

      protected void calculateQualifiedMethod(String qualName, ASTCallExpression callExpr, List<SymTypeExpression> argTypes)
      Deprecated.
      Checks whether there exists a method symbol with the name given by qualName with matching argument types. If such a method exists, it's return type is set as the type check result.
      Parameters:
      qualName - Qualified name of the method symbol to look for. Can also be a simple name without qualification.
      callExpr - The call expression of the method call. Needed as entry point to the symbol table to resolve method symbols.
      argTypes - The types of the method arguments. Are allowed to be obscure, but in this case the method will also always set *obscure* to be the method's type. Nevertheless, this method may print errors, if there is no method symbol of the given name at all, regardless of matching argument types.
    • calculateFunctionReturnTypeBasedOnSignature

      protected void calculateFunctionReturnTypeBasedOnSignature(List<SymTypeOfFunction> candidates, ASTCallExpression callExpr, List<SymTypeExpression> argTypes)
      Deprecated.
    • calculateFunctionReturnTypeBasedOnSignature

      protected void calculateFunctionReturnTypeBasedOnSignature(List<SymTypeOfFunction> candidates, ASTCallExpression callExpr, List<SymTypeExpression> argTypes, Map<SymTypeOfFunction,FunctionSymbol> definingSymbols)
      Deprecated.
      Checks whether any of the candidates functions that the callExpr may represent match the given argTypes signature. If there are multiple candidates remaining and the callExpr has bounds on the types that it may represent, then the candidate with the matching return type is chosen. The chosen candidate's return type is then set as the current type check result.
      Parameters:
      argTypes - The types of the method arguments. Are allowed to be obscure, but in this case the function will also always set *obscure* to be the method's type. Nevertheless, this method may print errors, if there is no method symbol of the given name at all, regardless of matching argument types.
      definingSymbols - if one candidate is found the corresponding symbol is set as the defining symbol, if applicable.
    • calculateMethodReturnTypeBasedOnSignature

      protected void calculateMethodReturnTypeBasedOnSignature(List<FunctionSymbol> candidates, ASTCallExpression callExpr, List<SymTypeExpression> argTypes)
      Deprecated.
      Checks whether any of the candidates methods that the callExpr may represent match the given argTypes signature. If there are multiple candidates remaining and the callExpr has bounds on the types that it may represent, then the candidate with the matching return type is chosen. The chosen candidate's return type is then set as the current type check result.
      Parameters:
      argTypes - The types of the method arguments. Are allowed to be obscure, but in this case the method will also always set *obscure* to be the method's type. Nevertheless, this method may print errors, if there is no method symbol of the given name at all, regardless of matching argument types.
    • calculateArguments

      protected List<SymTypeExpression> calculateArguments(ASTCallExpression expr)
      Deprecated.
    • checkForReturnType

      protected void checkForReturnType(ASTCallExpression expr, List<FunctionSymbol> fittingMethods)
      Deprecated.
    • checkForReturnType

      protected void checkForReturnType(List<SymTypeOfFunction> fittingFunctions, ASTCallExpression expr)
      Deprecated.
    • getCorrectMethodsFromInnerType

      protected List<FunctionSymbol> getCorrectMethodsFromInnerType(SymTypeExpression innerResult, ASTCallExpression expr, String name)
      Deprecated.
      Hookpoint for object oriented languages to get the correct functions/methods from a type based on their modifiers
    • getFittingFunctions

      protected List<SymTypeOfFunction> getFittingFunctions(List<SymTypeOfFunction> candidates, ASTCallExpression expr, List<SymTypeExpression> args)
      Deprecated.
    • chooseMostSpecificFunction

      protected List<SymTypeOfFunction> chooseMostSpecificFunction(List<SymTypeOfFunction> candidates, List<SymTypeExpression> args, ASTCallExpression expr)
      Deprecated.
    • filterModifiersFunctions

      protected List<FunctionSymbol> filterModifiersFunctions(List<FunctionSymbol> functionSymbols)
      Deprecated.
      Hookpoint for object oriented languages that offer modifiers like static, public, private, ...
    • calculateTypeCompare

      protected SymTypeExpression calculateTypeCompare(SymTypeExpression left, SymTypeExpression right, String op, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
      helper method for <=, >=, <, > -> calculates the result of these expressions
    • calculateTypeLogical

      protected SymTypeExpression calculateTypeLogical(SymTypeExpression left, SymTypeExpression right, String op, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
      helper method for ==, != calculates the result of these expressions
    • getBinaryNumericPromotion

      protected SymTypeExpression getBinaryNumericPromotion(SymTypeExpression leftResult, SymTypeExpression rightResult)
      Deprecated.
      return the result for the five basic arithmetic operations (+,-,*,/,%)
    • calculateArithmeticExpression

      protected SymTypeExpression calculateArithmeticExpression(SymTypeExpression left, SymTypeExpression right, String op, de.se_rwth.commons.SourcePosition pos)
      Deprecated.
    • traverse

      public void traverse(ASTArrayAccessExpression node)
      Deprecated.
      Specified by:
      traverse in interface CommonExpressionsHandler
    • calculateArrayExpression

      protected SymTypeExpression calculateArrayExpression(ASTArrayAccessExpression node, SymTypeExpression arrayTypeResult, SymTypeExpression indexResult)
      Deprecated.
    • getCorrectResultArrayExpression

      protected SymTypeExpression getCorrectResultArrayExpression(IExpressionsBasisScope scope, SymTypeExpression indexResult, SymTypeExpression arrayTypeResult, SymTypeArray arrayResult)
      Deprecated.
    • replaceTypeVariables

      protected SymTypeExpression replaceTypeVariables(SymTypeExpression wholeResult, List<SymTypeExpression> typeArgs, List<SymTypeExpression> argumentList)
      Deprecated.