tudresden.ocl.check
Class TypeChecker
java.lang.Object
tudresden.ocl.parser.analysis.AnalysisAdapter
tudresden.ocl.parser.analysis.DepthFirstAdapter
tudresden.ocl.check.TypeChecker
- All Implemented Interfaces:
- Analysis, NameBoundQueryable, Switch, TypeQueryable
- public class TypeChecker
- extends DepthFirstAdapter
- implements NameBoundQueryable, TypeQueryable
Methods inherited from class tudresden.ocl.parser.analysis.DepthFirstAdapter |
caseAActualParameterList, caseAActualParameterListTail, caseAAdditiveExpressionTail, caseAAndLogicalOperator, caseAArrowPostfixExpressionTailBegin, caseABagCollectionKind, caseABagCollectionType, caseABarFcpHelper, caseABooleanLiteral, caseAClassifierContext, caseAClassifierContextBody, caseAClassifierHead, caseACollectionCollectionKind, caseACollectionCollectionType, caseACollectionTypeName, caseAColonFcpHelper, caseACommaFcpHelper, caseAConcreteFeatureCallParameters, caseAConstraint, caseAConstraintBody, caseAContextDeclaration, caseADeclaratorTail, caseADeclaratorTypeDeclaration, caseADivMultiplyOperator, caseADotPostfixExpressionTailBegin, caseAEmptyFeatureCallParameters, caseAEnumerationType, caseAEnumerationTypeTail, caseAEnumLiteral, caseAEnumSimpleTypeSpecifier, caseAEqualRelationalOperator, caseAExpressionListOrRange, caseAExpressionListTail, caseAFeatureCall, caseAFeatureCallParameters, caseAFormalParameter, caseAFormalParameterList, caseAFormalParameterListTail, caseAGteqRelationalOperator, caseAGtRelationalOperator, caseAIfExpression, caseAIfPrimaryExpression, caseAImpliesLogicalOperator, caseAIntegerLiteral, caseAInvStereotype, caseAIterateDeclarator, caseAIterateFcpHelper, caseALetExpression, caseALetExpressionTypeDeclaration, caseAListExpressionListOrRangeTail, caseALitColPrimaryExpression, caseALiteralCollection, caseALiteralPrimaryExpression, caseALogicalExpression, caseALogicalExpressionTail, caseALteqRelationalOperator, caseALtRelationalOperator, caseAMinusAddOperator, caseAMinusUnaryOperator, caseAMultiplicativeExpression, caseAMultiplicativeExpressionTail, caseAMultMultiplyOperator, caseANamePathNameBegin, caseANamePathNameEnd, caseANEqualRelationalOperator, caseANonCollectionTypeName, caseANotUnaryOperator, caseAOperationContext, caseAOperationContextBody, caseAOrLogicalOperator, caseAParenthesesPrimaryExpression, caseAPathName, caseAPathNameTail, caseAPathSimpleTypeSpecifier, caseAPathTypeName, caseAPathTypeNameTail, caseAPlusAddOperator, caseAPostfixExpressionTail, caseAPostfixUnaryExpression, caseAPostStereotype, caseAPreStereotype, caseAQualifiers, caseARangeExpressionListOrRangeTail, caseARealLiteral, caseARelationalExpression, caseARelationalExpressionTail, caseAReturnTypeDeclaration, caseASequenceCollectionKind, caseASequenceCollectionType, caseASetCollectionKind, caseASetCollectionType, caseAStandardDeclarator, caseAStringLiteral, caseATimeExpression, caseATypeNamePathNameBegin, caseATypeNamePathNameEnd, caseAUnaryUnaryExpression, caseAXorLogicalOperator, caseStart, defaultIn, defaultOut, inAActualParameterList, inAActualParameterListTail, inAAdditiveExpression, inAAdditiveExpressionTail, inAAndLogicalOperator, inAArrowPostfixExpressionTailBegin, inABagCollectionKind, inABagCollectionType, inABarFcpHelper, inABooleanLiteral, inAClassifierContext, inAClassifierContextBody, inAClassifierHead, inACollectionCollectionKind, inACollectionCollectionType, inAColonFcpHelper, inACommaFcpHelper, inAConcreteFeatureCallParameters, inAConstraintBody, inAContextDeclaration, inADeclaratorTail, inADeclaratorTypeDeclaration, inADivMultiplyOperator, inADotPostfixExpressionTailBegin, inAEmptyFeatureCallParameters, inAEnumerationType, inAEnumerationTypeTail, inAEnumLiteral, inAEnumSimpleTypeSpecifier, inAEqualRelationalOperator, inAExpression, inAExpressionListOrRange, inAExpressionListTail, inAFeatureCallParameters, inAFeaturePrimaryExpression, inAFormalParameter, inAFormalParameterList, inAFormalParameterListTail, inAGteqRelationalOperator, inAGtRelationalOperator, inAIfExpression, inAIfPrimaryExpression, inAImpliesLogicalOperator, inAIntegerLiteral, inAInvStereotype, inAIterateDeclarator, inAIterateFcpHelper, inALetExpression, inALetExpressionTypeDeclaration, inAListExpressionListOrRangeTail, inALitColPrimaryExpression, inALiteralCollection, inALiteralPrimaryExpression, inALogicalExpression, inALogicalExpressionTail, inALteqRelationalOperator, inALtRelationalOperator, inAMinusAddOperator, inAMinusUnaryOperator, inAMultiplicativeExpression, inAMultiplicativeExpressionTail, inAMultMultiplyOperator, inANamePathNameBegin, inANamePathNameEnd, inANEqualRelationalOperator, inANotUnaryOperator, inAOperationContext, inAOperationContextBody, inAOrLogicalOperator, inAParenthesesPrimaryExpression, inAPathName, inAPathNameTail, inAPathSimpleTypeSpecifier, inAPathTypeName, inAPathTypeNameTail, inAPlusAddOperator, inAPostfixExpression, inAPostfixExpressionTail, inAPostfixUnaryExpression, inAPostStereotype, inAPreStereotype, inAQualifiers, inARangeExpressionListOrRangeTail, inARealLiteral, inARelationalExpression, inARelationalExpressionTail, inAReturnTypeDeclaration, inASequenceCollectionKind, inASequenceCollectionType, inASetCollectionKind, inASetCollectionType, inAStandardDeclarator, inAStringLiteral, inATimeExpression, inATypeNamePathNameBegin, inATypeNamePathNameEnd, inAUnaryUnaryExpression, inAXorLogicalOperator, outAActualParameterList, outAActualParameterListTail, outAAdditiveExpression, outAAdditiveExpressionTail, outAAndLogicalOperator, outAArrowPostfixExpressionTailBegin, outABagCollectionKind, outABagCollectionType, outABarFcpHelper, outAClassifierContext, outAClassifierContextBody, outAClassifierHead, outACollectionCollectionKind, outACollectionCollectionType, outACollectionTypeName, outAColonFcpHelper, outACommaFcpHelper, outAConcreteFeatureCallParameters, outAConstraint, outAContextDeclaration, outADeclaratorTail, outADeclaratorTypeDeclaration, outADivMultiplyOperator, outADotPostfixExpressionTailBegin, outAEmptyFeatureCallParameters, outAEnumerationType, outAEnumerationTypeTail, outAEnumSimpleTypeSpecifier, outAEqualRelationalOperator, outAExpression, outAExpressionListTail, outAFeatureCall, outAFeatureCallParameters, outAFeaturePrimaryExpression, outAFormalParameter, outAFormalParameterList, outAFormalParameterListTail, outAGteqRelationalOperator, outAGtRelationalOperator, outAImpliesLogicalOperator, outAInvStereotype, outAIterateDeclarator, outAIterateFcpHelper, outALetExpression, outALetExpressionTypeDeclaration, outAListExpressionListOrRangeTail, outALogicalExpressionTail, outALteqRelationalOperator, outALtRelationalOperator, outAMinusAddOperator, outAMinusUnaryOperator, outAMultiplicativeExpressionTail, outAMultMultiplyOperator, outANamePathNameBegin, outANamePathNameEnd, outANEqualRelationalOperator, outANonCollectionTypeName, outANotUnaryOperator, outAOperationContext, outAOperationContextBody, outAOrLogicalOperator, outAPathName, outAPathNameTail, outAPathTypeNameTail, outAPlusAddOperator, outAPostfixExpression, outAPostfixExpressionTail, outAPostStereotype, outAPreStereotype, outAQualifiers, outARangeExpressionListOrRangeTail, outARelationalExpressionTail, outAReturnTypeDeclaration, outASequenceCollectionKind, outASequenceCollectionType, outASetCollectionKind, outASetCollectionType, outAStandardDeclarator, outATimeExpression, outATypeNamePathNameEnd, outAXorLogicalOperator, outStart |
Methods inherited from class tudresden.ocl.parser.analysis.AnalysisAdapter |
caseEOF, caseTAnd, caseTApostroph, caseTArrow, caseTAt, caseTBar, caseTBlank, caseTBool, caseTChannel, caseTColon, caseTComma, caseTComment, caseTContext, caseTDcolon, caseTDdot, caseTDiv, caseTDot, caseTEndif, caseTEnum, caseTEqual, caseTGt, caseTGteq, caseTImplies, caseTInt, caseTLBrace, caseTLBracket, caseTLPar, caseTLt, caseTLteq, caseTMinus, caseTMult, caseTName, caseTNEqual, caseTNewLine, caseTNot, caseTOr, caseTPlus, caseTRBrace, caseTRBracket, caseTReal, caseTRPar, caseTSemicolon, caseTSimpleTypeName, caseTStringLit, caseTTab, caseTTBag, caseTTCollection, caseTTElse, caseTTIf, caseTTIn, caseTTInv, caseTTLet, caseTTPost, caseTTPre, caseTTSequence, caseTTSet, caseTTThen, caseTXor, defaultCase, getIn, getOut, setIn, setOut |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ntm
NodeTypeMap ntm
types
TypeFactory types
environs
NodeEnvironmentMap environs
defaultContexts
HashMap defaultContexts
tree
OclTree tree
setOfIteratingMethodNames
public static HashSet setOfIteratingMethodNames
- contains the name of all OCL collection operations that change the
default context
TypeChecker
public TypeChecker(OclTree tree,
TypeFactory tf)
inStart
public void inStart(Start s)
- Overrides:
inStart
in class DepthFirstAdapter
inAConstraint
public void inAConstraint(AConstraint c)
- Overrides:
inAConstraint
in class DepthFirstAdapter
outAConstraintBody
public void outAConstraintBody(AConstraintBody cb)
- Overrides:
outAConstraintBody
in class DepthFirstAdapter
caseAExpression
public void caseAExpression(AExpression e)
- Specified by:
caseAExpression
in interface Analysis
- Overrides:
caseAExpression
in class DepthFirstAdapter
outAIfExpression
public void outAIfExpression(AIfExpression ie)
- Overrides:
outAIfExpression
in class DepthFirstAdapter
outALogicalExpression
public void outALogicalExpression(ALogicalExpression le)
- Overrides:
outALogicalExpression
in class DepthFirstAdapter
outARelationalExpression
public void outARelationalExpression(ARelationalExpression re)
- Overrides:
outARelationalExpression
in class DepthFirstAdapter
caseAAdditiveExpression
public void caseAAdditiveExpression(AAdditiveExpression ae)
- case-method overwritten since type of first operand required for
analysis ( '-' is also defined for Sets)
- Specified by:
caseAAdditiveExpression
in interface Analysis
- Overrides:
caseAAdditiveExpression
in class DepthFirstAdapter
outAMultiplicativeExpression
public void outAMultiplicativeExpression(AMultiplicativeExpression me)
- Overrides:
outAMultiplicativeExpression
in class DepthFirstAdapter
outAPostfixUnaryExpression
public void outAPostfixUnaryExpression(APostfixUnaryExpression ue)
- Overrides:
outAPostfixUnaryExpression
in class DepthFirstAdapter
outAUnaryUnaryExpression
public void outAUnaryUnaryExpression(AUnaryUnaryExpression ue)
- Overrides:
outAUnaryUnaryExpression
in class DepthFirstAdapter
caseAPostfixExpression
public void caseAPostfixExpression(APostfixExpression poex)
- Specified by:
caseAPostfixExpression
in interface Analysis
- Overrides:
caseAPostfixExpression
in class DepthFirstAdapter
navigateCollect
protected Collection navigateCollect(Collection oldCollection,
Type paramType)
inAFeatureCall
public void inAFeatureCall(AFeatureCall fc)
- This method is implemented to update the default context for the
FeatureCall's FeatureCallParameter node if the feature call is a
call to an iterating method.
- Overrides:
inAFeatureCall
in class DepthFirstAdapter
inIteratingFeatureCall
protected void inIteratingFeatureCall(AFeatureCall fc)
computeTypeOfPreviousPostfixExpressionElement
protected Type computeTypeOfPreviousPostfixExpressionElement(AFeatureCall fc)
getQualifierTypes
protected Type[] getQualifierTypes(PQualifiers qual)
addIteratorNamesToList
protected void addIteratorNamesToList(AStandardDeclarator asd,
ArrayList names)
outALitColPrimaryExpression
public void outALitColPrimaryExpression(ALitColPrimaryExpression lce)
- Overrides:
outALitColPrimaryExpression
in class DepthFirstAdapter
outALiteralPrimaryExpression
public void outALiteralPrimaryExpression(ALiteralPrimaryExpression lpe)
- Overrides:
outALiteralPrimaryExpression
in class DepthFirstAdapter
caseAFeaturePrimaryExpression
public void caseAFeaturePrimaryExpression(AFeaturePrimaryExpression fpe)
- Specified by:
caseAFeaturePrimaryExpression
in interface Analysis
- Overrides:
caseAFeaturePrimaryExpression
in class DepthFirstAdapter
getTypeOfPathName
protected Type getTypeOfPathName(APathName pn,
AFeaturePrimaryExpression fpe)
- Returns:
- the result type of the path name if the path name contains a type
name; otherwise, return null
outAParenthesesPrimaryExpression
public void outAParenthesesPrimaryExpression(AParenthesesPrimaryExpression ppe)
- Overrides:
outAParenthesesPrimaryExpression
in class DepthFirstAdapter
outAIfPrimaryExpression
public void outAIfPrimaryExpression(AIfPrimaryExpression ipe)
- Overrides:
outAIfPrimaryExpression
in class DepthFirstAdapter
outAStringLiteral
public void outAStringLiteral(AStringLiteral sl)
- Overrides:
outAStringLiteral
in class DepthFirstAdapter
outARealLiteral
public void outARealLiteral(ARealLiteral rl)
- Overrides:
outARealLiteral
in class DepthFirstAdapter
outAIntegerLiteral
public void outAIntegerLiteral(AIntegerLiteral il)
- Overrides:
outAIntegerLiteral
in class DepthFirstAdapter
outABooleanLiteral
public void outABooleanLiteral(ABooleanLiteral bl)
- Overrides:
outABooleanLiteral
in class DepthFirstAdapter
outAEnumLiteral
public void outAEnumLiteral(AEnumLiteral el)
- Overrides:
outAEnumLiteral
in class DepthFirstAdapter
outALiteralCollection
public void outALiteralCollection(ALiteralCollection lc)
- Overrides:
outALiteralCollection
in class DepthFirstAdapter
outAExpressionListOrRange
public void outAExpressionListOrRange(AExpressionListOrRange elor)
- Overrides:
outAExpressionListOrRange
in class DepthFirstAdapter
outAPathSimpleTypeSpecifier
public void outAPathSimpleTypeSpecifier(APathSimpleTypeSpecifier psts)
- Overrides:
outAPathSimpleTypeSpecifier
in class DepthFirstAdapter
outAPathTypeName
public void outAPathTypeName(APathTypeName ptn)
- Overrides:
outAPathTypeName
in class DepthFirstAdapter
inACollectionTypeName
public void inACollectionTypeName(ACollectionTypeName ctn)
- Overrides:
inACollectionTypeName
in class DepthFirstAdapter
inANonCollectionTypeName
public void inANonCollectionTypeName(ANonCollectionTypeName nctn)
- Overrides:
inANonCollectionTypeName
in class DepthFirstAdapter
outATypeNamePathNameBegin
public void outATypeNamePathNameBegin(ATypeNamePathNameBegin tnpnb)
- Overrides:
outATypeNamePathNameBegin
in class DepthFirstAdapter
getEnvironmentCopy
protected TypeEnvironment getEnvironmentCopy(Node n)
- Returns:
- a copy of the surrounding type environment of the given node
getParentEnvNode
protected Node getParentEnvNode(Node n)
- Returns:
- the Node that defines the parent environment for
the Node given as parameter
getEnvironmentFor
protected TypeEnvironment getEnvironmentFor(Node n)
addParamTypesToList
protected void addParamTypesToList(AActualParameterList apl,
List list,
boolean recurse)
- adds all expression types of an AActualParameterList to a List
- Parameters:
recurse
- apply(this)
is called for all these expressions
assertElementType
protected void assertElementType(Collection coll,
String msg)
isNameBound
public boolean isNameBound(String name,
Node node)
- Specified by:
isNameBound
in interface NameBoundQueryable
- Returns:
- true if the given String denotes a OCL variable in the given
node and namespace
getBoundNames
public HashSet getBoundNames(Node n)
- Specified by:
getBoundNames
in interface NameBoundQueryable
- Returns:
- all names that are bound in the given node
getDefaultContext
public String getDefaultContext(Node n)
- Specified by:
getDefaultContext
in interface NameBoundQueryable
- Returns:
- a String representing the default context in the given node,
which is either "self" or the name of an iterator; returns null
if there is no default context, e.g. the iterator is not named
changeNotify
public void changeNotify(Node n)
- Description copied from interface:
NameBoundQueryable
- notify the NameBoundQueryable that the ASTs subtree starting at the
node given as parameter may have changed
- Specified by:
changeNotify
in interface NameBoundQueryable
getNodeType
public Type getNodeType(Node n)
- Specified by:
getNodeType
in interface TypeQueryable
getTypeFor
public Type getTypeFor(String name,
Node node)
- Specified by:
getTypeFor
in interface TypeQueryable
- Returns:
- the type of the variable bound to the given name, or
null
if the name is not bound
Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.