Package: TypeCheckVisitor

TypeCheckVisitor

nameinstructionbranchcomplexitylinemethod
TypeCheckVisitor()
M: 0 C: 50
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
caseAAnnotationAnnotation(AAnnotationAnnotation, TypeCheckInfo)
M: 24 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseAModuleModules(AModuleModules, TypeCheckInfo)
M: 31 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
defaultINode(INode, TypeCheckInfo)
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPAlternativeStm(PAlternativeStm, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPDefinition(PDefinition, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPExp(PExp, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPExport(PExport, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPImport(PImport, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPMultipleBind(PMultipleBind, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPObjectDesignator(PObjectDesignator, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPPatternBind(PPatternBind, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPRelation(PRelation, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPStateDesignator(PStateDesignator, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPStm(PStm, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPStmtAlternative(PStmtAlternative, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPTraceCoreDefinition(PTraceCoreDefinition, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultPTraceDefinition(PTraceDefinition, TypeCheckInfo)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%~
3: * The VDM Type Checker
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.typechecker.visitor;
23:
24: import org.overture.ast.analysis.AnalysisException;
25: import org.overture.ast.annotations.AAnnotationAnnotation;
26: import org.overture.ast.definitions.PDefinition;
27: import org.overture.ast.definitions.relations.PRelation;
28: import org.overture.ast.definitions.traces.PTraceCoreDefinition;
29: import org.overture.ast.definitions.traces.PTraceDefinition;
30: import org.overture.ast.expressions.PExp;
31: import org.overture.ast.modules.AModuleModules;
32: import org.overture.ast.modules.PExport;
33: import org.overture.ast.modules.PImport;
34: import org.overture.ast.node.INode;
35: import org.overture.ast.patterns.PMultipleBind;
36: import org.overture.ast.patterns.PPatternBind;
37: import org.overture.ast.statements.PAlternativeStm;
38: import org.overture.ast.statements.PObjectDesignator;
39: import org.overture.ast.statements.PStateDesignator;
40: import org.overture.ast.statements.PStm;
41: import org.overture.ast.statements.PStmtAlternative;
42: import org.overture.ast.types.PType;
43: import org.overture.typechecker.TypeCheckInfo;
44: import org.overture.typechecker.TypeCheckerErrors;
45:
46: public class TypeCheckVisitor extends AbstractTypeCheckVisitor
47: {
48:
49:         private AbstractTypeCheckVisitor tcStm = new TypeCheckerStmVisitor(this);
50:         private AbstractTypeCheckVisitor tcExp = new TypeCheckerExpVisitor(this);
51:         private AbstractTypeCheckVisitor tcDefinition = new TypeCheckerDefinitionVisitor(this);
52:         private AbstractTypeCheckVisitor patternDefinition = new TypeCheckerPatternVisitor(this);
53:         private AbstractTypeCheckVisitor tcImports = new TypeCheckerImportsVisitor(this);
54:         private AbstractTypeCheckVisitor tcExports = new TypeCheckerExportsVisitor(this);
55:         private AbstractTypeCheckVisitor tcOthers = new TypeCheckerOthersVisitor(this);
56:
57:         public TypeCheckerErrors tcErrors = new TypeCheckerErrors();
58:
59:         @Override
60:         public PType defaultPPatternBind(PPatternBind node, TypeCheckInfo question)
61:                         throws AnalysisException
62:         {
63:                 return node.apply(tcOthers, question);
64:         }
65:
66:         @Override
67:         public PType defaultPStateDesignator(PStateDesignator node,
68:                         TypeCheckInfo question) throws AnalysisException
69:         {
70:                 return node.apply(tcOthers, question);
71:         }
72:
73:         @Override
74:         public PType defaultPObjectDesignator(PObjectDesignator node,
75:                         TypeCheckInfo question) throws AnalysisException
76:         {
77:                 return node.apply(tcOthers, question);
78:         }
79:
80:         @Override
81:         public PType defaultPImport(PImport node, TypeCheckInfo question)
82:                         throws AnalysisException
83:         {
84:                 return node.apply(tcImports, question);
85:         }
86:
87:         @Override
88:         public PType defaultPExport(PExport node, TypeCheckInfo question)
89:                         throws AnalysisException
90:         {
91:                 return node.apply(tcExports, question);
92:         }
93:
94:         @Override
95:         public PType defaultPStm(PStm node, TypeCheckInfo question)
96:                         throws AnalysisException
97:         {
98:                 return node.apply(tcStm, question);
99:         }
100:
101:         @Override
102:         public PType defaultPAlternativeStm(PAlternativeStm node,
103:                         TypeCheckInfo question) throws AnalysisException
104:         {
105:                 return node.apply(tcStm, question);
106:         }
107:
108:         @Override
109:         public PType defaultPExp(PExp node, TypeCheckInfo question)
110:                         throws AnalysisException
111:         {
112:                 return node.apply(tcExp, question);
113:         }
114:
115:         @Override
116:         public PType defaultPDefinition(PDefinition node, TypeCheckInfo question)
117:                         throws AnalysisException
118:         {
119:                 return node.apply(tcDefinition, question);
120:         }
121:
122:
123:         @Override
124:         public PType defaultPRelation(PRelation node, TypeCheckInfo question)
125:                         throws AnalysisException {
126:                 return node.apply(tcDefinition, question);
127:         }
128:
129:         @Override
130:         public PType caseAModuleModules(AModuleModules node, TypeCheckInfo question)
131:                         throws AnalysisException
132:         {
133:                 beforeAnnotations(node.getAnnotations(), node, question);
134:                 
135:•                for (PDefinition def : node.getDefs())
136:                 {
137:                         def.apply(this, question);
138:                 }
139:
140:                 afterAnnotations(node.getAnnotations(), node, question);
141:                 return null;
142:         }
143:         
144:         @Override
145:         public PType caseAAnnotationAnnotation(AAnnotationAnnotation node, TypeCheckInfo question)
146:                         throws AnalysisException
147:         {
148:•                if (node.getImpl().typecheckArgs())
149:                 {
150:•                        for (PExp arg: node.getArgs())
151:                         {
152:                                 arg.apply(THIS, question);
153:                         }
154:                 }
155:                 
156:                 return null;        // No type for the annotation as such
157:         }
158:
159:         @Override
160:         public PType defaultPMultipleBind(PMultipleBind node, TypeCheckInfo question)
161:                         throws AnalysisException
162:         {
163:                 return node.apply(patternDefinition, question);
164:         }
165:
166:         @Override
167:         public PType defaultPStmtAlternative(PStmtAlternative node,
168:                         TypeCheckInfo question) throws AnalysisException
169:         {
170:                 return node.apply(tcStm, question);
171:         }
172:
173:         public PType defaultPTraceDefinition(PTraceDefinition node,
174:                         TypeCheckInfo question) throws AnalysisException
175:         {
176:                 return node.apply(tcDefinition, question);
177:         }
178:
179:         public PType defaultPTraceCoreDefinition(PTraceCoreDefinition node,
180:                         TypeCheckInfo question) throws AnalysisException
181:         {
182:                 return node.apply(tcDefinition, question);
183:         }
184:
185:         @Override
186:         public PType defaultINode(INode node, TypeCheckInfo question)
187:                         throws AnalysisException
188:         {
189:                 return null;// we dont want an infinit loop
190:         }
191: }