Package: ExitTypeCollector

ExitTypeCollector

nameinstructionbranchcomplexitylinemethod
ExitTypeCollector(ITypeCheckerAssistantFactory)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAAlwaysStm(AAlwaysStm, Environment)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseAApplyExp(AApplyExp, Environment)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAAssignmentStm(AAssignmentStm, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseABlockSimpleBlockStm(ABlockSimpleBlockStm, Environment)
M: 0 C: 36
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseACallObjectStm(ACallObjectStm, Environment)
M: 26 C: 87
77%
M: 5 C: 15
75%
M: 4 C: 7
64%
M: 4 C: 19
83%
M: 0 C: 1
100%
caseACallStm(ACallStm, Environment)
M: 0 C: 116
100%
M: 0 C: 20
100%
M: 0 C: 11
100%
M: 0 C: 23
100%
M: 0 C: 1
100%
caseACaseAlternativeStm(ACaseAlternativeStm, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseACasesExp(ACasesExp, Environment)
M: 0 C: 45
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
caseACasesStm(ACasesStm, Environment)
M: 0 C: 31
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseADefExp(ADefExp, Environment)
M: 0 C: 46
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 8
100%
M: 0 C: 1
100%
caseAElseIfExp(AElseIfExp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAElseIfStm(AElseIfStm, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAExists1Exp(AExists1Exp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAExistsExp(AExistsExp, Environment)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAExitStm(AExitStm, Environment)
M: 0 C: 33
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
caseAFieldExp(AFieldExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAFieldNumberExp(AFieldNumberExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAForAllExp(AForAllExp, Environment)
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAForAllStm(AForAllStm, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAForIndexStm(AForIndexStm, Environment)
M: 0 C: 43
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseAForPatternBindStm(AForPatternBindStm, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAFuncInstatiationExp(AFuncInstatiationExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAIfExp(AIfExp, Environment)
M: 0 C: 54
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 8
100%
M: 0 C: 1
100%
caseAIfStm(AIfStm, Environment)
M: 0 C: 54
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
caseAIotaExp(AIotaExp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAIsExp(AIsExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAIsOfBaseClassExp(AIsOfBaseClassExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAIsOfClassExp(AIsOfClassExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseALambdaExp(ALambdaExp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseALetBeStExp(ALetBeStExp, Environment)
M: 0 C: 33
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseALetBeStStm(ALetBeStStm, Environment)
M: 12 C: 46
79%
M: 2 C: 8
80%
M: 2 C: 4
67%
M: 2 C: 7
78%
M: 0 C: 1
100%
caseALetDefExp(ALetDefExp, Environment)
M: 0 C: 41
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 8
100%
M: 0 C: 1
100%
caseALetStm(ALetStm, Environment)
M: 0 C: 41
100%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 8
100%
M: 0 C: 1
100%
caseAMapCompMapExp(AMapCompMapExp, Environment)
M: 0 C: 32
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseAMapEnumMapExp(AMapEnumMapExp, Environment)
M: 0 C: 29
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseAMapletExp(AMapletExp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAMkBasicExp(AMkBasicExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAMkTypeExp(AMkTypeExp, Environment)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAMuExp(AMuExp, Environment)
M: 0 C: 39
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
caseANarrowExp(ANarrowExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseANewExp(ANewExp, Environment)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseANotYetSpecifiedStm(ANotYetSpecifiedStm, Environment)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAPostOpExp(APostOpExp, Environment)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAReturnStm(AReturnStm, Environment)
M: 0 C: 17
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseASameBaseClassExp(ASameBaseClassExp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseASameClassExp(ASameClassExp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseASeqBind(ASeqBind, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASeqCompSeqExp(ASeqCompSeqExp, Environment)
M: 0 C: 33
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseASeqEnumSeqExp(ASeqEnumSeqExp, Environment)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASeqMultipleBind(ASeqMultipleBind, Environment)
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%
caseASetBind(ASetBind, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASetCompSetExp(ASetCompSetExp, Environment)
M: 0 C: 35
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseASetEnumSetExp(ASetEnumSetExp, Environment)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASetMultipleBind(ASetMultipleBind, Environment)
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%
caseASetRangeSetExp(ASetRangeSetExp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseASubclassResponsibilityStm(ASubclassResponsibilityStm, Environment)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseASubseqExp(ASubseqExp, Environment)
M: 0 C: 30
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseATixeStm(ATixeStm, Environment)
M: 0 C: 37
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
caseATrapStm(ATrapStm, Environment)
M: 0 C: 28
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseATupleExp(ATupleExp, Environment)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAWhileStm(AWhileStm, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
createNewReturnValue(INode, Environment)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
createNewReturnValue(Object, Environment)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
defaultPExp(PExp, Environment)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
defaultPStm(PStm, Environment)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
defaultSBinaryExp(SBinaryExp, Environment)
M: 0 C: 20
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
defaultSSimpleBlockStm(SSimpleBlockStm, Environment)
M: 0 C: 29
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
defaultSUnaryExp(SUnaryExp, Environment)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
exitCheck(ATixeStmtAlternative, Environment)
M: 0 C: 8
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.utilities;
23:
24: import org.overture.ast.analysis.AnalysisException;
25: import org.overture.ast.analysis.QuestionAnswerAdaptor;
26: import org.overture.ast.definitions.AAssignmentDefinition;
27: import org.overture.ast.definitions.AEqualsDefinition;
28: import org.overture.ast.definitions.AExplicitOperationDefinition;
29: import org.overture.ast.definitions.AImplicitOperationDefinition;
30: import org.overture.ast.definitions.APrivateAccess;
31: import org.overture.ast.definitions.AValueDefinition;
32: import org.overture.ast.definitions.PDefinition;
33: import org.overture.ast.expressions.AApplyExp;
34: import org.overture.ast.expressions.ACaseAlternative;
35: import org.overture.ast.expressions.ACasesExp;
36: import org.overture.ast.expressions.ADefExp;
37: import org.overture.ast.expressions.AElseIfExp;
38: import org.overture.ast.expressions.AExists1Exp;
39: import org.overture.ast.expressions.AExistsExp;
40: import org.overture.ast.expressions.AFieldExp;
41: import org.overture.ast.expressions.AFieldNumberExp;
42: import org.overture.ast.expressions.AForAllExp;
43: import org.overture.ast.expressions.AFuncInstatiationExp;
44: import org.overture.ast.expressions.AIfExp;
45: import org.overture.ast.expressions.AIotaExp;
46: import org.overture.ast.expressions.AIsExp;
47: import org.overture.ast.expressions.AIsOfBaseClassExp;
48: import org.overture.ast.expressions.AIsOfClassExp;
49: import org.overture.ast.expressions.ALambdaExp;
50: import org.overture.ast.expressions.ALetBeStExp;
51: import org.overture.ast.expressions.ALetDefExp;
52: import org.overture.ast.expressions.AMapCompMapExp;
53: import org.overture.ast.expressions.AMapEnumMapExp;
54: import org.overture.ast.expressions.AMapletExp;
55: import org.overture.ast.expressions.AMkBasicExp;
56: import org.overture.ast.expressions.AMkTypeExp;
57: import org.overture.ast.expressions.AMuExp;
58: import org.overture.ast.expressions.ANarrowExp;
59: import org.overture.ast.expressions.ANewExp;
60: import org.overture.ast.expressions.APostOpExp;
61: import org.overture.ast.expressions.ARecordModifier;
62: import org.overture.ast.expressions.ASameBaseClassExp;
63: import org.overture.ast.expressions.ASameClassExp;
64: import org.overture.ast.expressions.ASeqCompSeqExp;
65: import org.overture.ast.expressions.ASeqEnumSeqExp;
66: import org.overture.ast.expressions.ASetCompSetExp;
67: import org.overture.ast.expressions.ASetEnumSetExp;
68: import org.overture.ast.expressions.ASetRangeSetExp;
69: import org.overture.ast.expressions.ASubseqExp;
70: import org.overture.ast.expressions.ATupleExp;
71: import org.overture.ast.expressions.PExp;
72: import org.overture.ast.expressions.SBinaryExp;
73: import org.overture.ast.expressions.SUnaryExp;
74: import org.overture.ast.factory.AstFactory;
75: import org.overture.ast.lex.Dialect;
76: import org.overture.ast.node.INode;
77: import org.overture.ast.patterns.ASeqBind;
78: import org.overture.ast.patterns.ASeqMultipleBind;
79: import org.overture.ast.patterns.ASetBind;
80: import org.overture.ast.patterns.ASetMultipleBind;
81: import org.overture.ast.statements.AAlwaysStm;
82: import org.overture.ast.statements.AAssignmentStm;
83: import org.overture.ast.statements.ABlockSimpleBlockStm;
84: import org.overture.ast.statements.ACallObjectStm;
85: import org.overture.ast.statements.ACallStm;
86: import org.overture.ast.statements.ACaseAlternativeStm;
87: import org.overture.ast.statements.ACasesStm;
88: import org.overture.ast.statements.AElseIfStm;
89: import org.overture.ast.statements.AExitStm;
90: import org.overture.ast.statements.AForAllStm;
91: import org.overture.ast.statements.AForIndexStm;
92: import org.overture.ast.statements.AForPatternBindStm;
93: import org.overture.ast.statements.AIfStm;
94: import org.overture.ast.statements.ALetBeStStm;
95: import org.overture.ast.statements.ALetStm;
96: import org.overture.ast.statements.ANotYetSpecifiedStm;
97: import org.overture.ast.statements.AReturnStm;
98: import org.overture.ast.statements.ASubclassResponsibilityStm;
99: import org.overture.ast.statements.ATixeStm;
100: import org.overture.ast.statements.ATixeStmtAlternative;
101: import org.overture.ast.statements.ATrapStm;
102: import org.overture.ast.statements.AWhileStm;
103: import org.overture.ast.statements.PStm;
104: import org.overture.ast.statements.SSimpleBlockStm;
105: import org.overture.ast.typechecker.NameScope;
106: import org.overture.ast.util.PTypeSet;
107: import org.overture.config.Settings;
108: import org.overture.typechecker.Environment;
109: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
110:
111: /**
112: * This class implements a way collect the exit types of a statement. This is to be used with exception handling in VDM
113: *
114: * @author kel
115: */
116: public class ExitTypeCollector extends QuestionAnswerAdaptor<Environment, PTypeSet>
117: {
118:         protected ITypeCheckerAssistantFactory af;
119:
120:         public ExitTypeCollector(ITypeCheckerAssistantFactory af)
121:         {
122:                 this.af = af;
123:         }
124:
125:         @Override
126:         public PTypeSet caseAAlwaysStm(AAlwaysStm statement, Environment env)
127:                         throws AnalysisException
128:         {
129:                 PTypeSet types = new PTypeSet(af);
130:                 types.addAll(statement.getBody().apply(THIS, env));
131:                 types.addAll(statement.getAlways().apply(THIS, env));
132:                 return types;
133:         }
134:
135:         @Override
136:         public PTypeSet caseAAssignmentStm(AAssignmentStm statement, Environment env)
137:                         throws AnalysisException
138:         {
139:                 return statement.getExp().apply(THIS, env);
140:         }
141:
142:         @Override
143:         public PTypeSet caseACallStm(ACallStm statement, Environment env) throws AnalysisException
144:         {
145:                 PTypeSet result = af.createPExpAssistant(af).exitCheck(statement.getArgs(), env);
146:
147:                 PDefinition opdef = env.findName(statement.getName(), NameScope.GLOBAL);
148:•                boolean overridable = Settings.dialect != Dialect.VDM_SL &&
149:•                                opdef != null && !(opdef.getAccess().getAccess() instanceof APrivateAccess);
150:
151:•                if (opdef != null && !overridable)
152:                 {
153:•                        if (opdef instanceof AExplicitOperationDefinition)
154:                         {
155:                                 AExplicitOperationDefinition explop = (AExplicitOperationDefinition)opdef;
156:
157:•                                if (explop.getPossibleExceptions() == null)
158:                                 {
159:                                         explop.setPossibleExceptions(new PTypeSet(af));
160:                                         explop.setPossibleExceptions(explop.getBody().apply(THIS, env));
161:                                 }
162:
163:                                 result.addAll(explop.getPossibleExceptions());
164:                                 return result;
165:                         }
166:•                        else if (opdef instanceof AImplicitOperationDefinition)
167:                         {
168:                                 AImplicitOperationDefinition implop = (AImplicitOperationDefinition)opdef;
169:
170:•                                if (implop.getPossibleExceptions() == null)
171:                                 {
172:•                                        if (implop.getBody() != null)
173:                                         {
174:                                                 implop.setPossibleExceptions(new PTypeSet(af));
175:                                                 implop.setPossibleExceptions(implop.getBody().apply(THIS, env));
176:                                         }
177:                                         else
178:                                         {
179:                                                 return new PTypeSet(af);
180:                                         }
181:                                 }
182:
183:                                 result.addAll(implop.getPossibleExceptions());
184:                                 return result;
185:                         }
186:                 }
187:
188:                 result.add(AstFactory.newAUnknownType(statement.getLocation()));
189:                 return result;
190:         }
191:
192:         @Override
193:         public PTypeSet caseACallObjectStm(ACallObjectStm statement, Environment env)
194:                         throws AnalysisException
195:         {
196:                 PTypeSet result = af.createPExpAssistant(af).exitCheck(statement.getArgs(), env);
197:
198:                 PDefinition fdef = statement.getFieldDef();
199:•                boolean overridable = Settings.dialect != Dialect.VDM_SL &&
200:•                                fdef != null && !(fdef.getAccess().getAccess() instanceof APrivateAccess);
201:
202:•                if (fdef != null && !overridable)
203:                 {
204:•                        if (fdef instanceof AExplicitOperationDefinition)
205:                         {
206:                                 AExplicitOperationDefinition explop = (AExplicitOperationDefinition)fdef;
207:
208:•                                if (explop.getPossibleExceptions() == null)
209:                                 {
210:                                         explop.setPossibleExceptions(new PTypeSet(af));
211:                                         explop.setPossibleExceptions(explop.getBody().apply(THIS, env));
212:                                 }
213:
214:                                 result.addAll(explop.getPossibleExceptions());
215:                                 return result;
216:                         }
217:•                        else if (fdef instanceof AImplicitOperationDefinition)
218:                         {
219:                                 AImplicitOperationDefinition implop = (AImplicitOperationDefinition)fdef;
220:
221:•                                if (implop.getPossibleExceptions() == null)
222:                                 {
223:•                                        if (implop.getBody() != null)
224:                                         {
225:                                                 implop.setPossibleExceptions(new PTypeSet(af));
226:                                                 implop.setPossibleExceptions(implop.getBody().apply(THIS, env));
227:                                         }
228:                                         else
229:                                         {
230:                                                 return new PTypeSet(af);
231:                                         }
232:                                 }
233:
234:                                 result.addAll(implop.getPossibleExceptions());
235:                                 return result;
236:                         }
237:                 }
238:
239:                 result.add(AstFactory.newAUnknownType(statement.getLocation()));
240:                 return result;
241:         }
242:
243:         @Override
244:         public PTypeSet caseACasesStm(ACasesStm statement, Environment env) throws AnalysisException
245:         {
246:                 PTypeSet types = statement.getExp().apply(THIS, env);
247:
248:•                for (ACaseAlternativeStm c : statement.getCases())
249:                 {
250:                         types.addAll(c.apply(THIS, env));
251:                 }
252:
253:                 return types;
254:         }
255:
256:         @Override
257:         public PTypeSet caseACaseAlternativeStm(ACaseAlternativeStm statement, Environment env)
258:                         throws AnalysisException
259:         {
260:                 return statement.getResult().apply(THIS, env);
261:         }
262:
263:         @Override
264:         public PTypeSet caseAElseIfStm(AElseIfStm statement, Environment env)
265:                         throws AnalysisException
266:         {
267:                 PTypeSet result = statement.getElseIf().apply(THIS, env);
268:                 result.addAll(statement.getThenStm().apply(THIS, env));
269:                 return result;
270:         }
271:
272:         @Override
273:         public PTypeSet caseAExitStm(AExitStm statement, Environment env) throws AnalysisException
274:         {
275:                 PTypeSet types = new PTypeSet(af);
276:
277:•                if (statement.getExpression() == null)
278:                 {
279:                         types.add(AstFactory.newAVoidType(statement.getLocation()));
280:                 }
281:•                else if (statement.getExpType() == null)
282:                 {
283:                         types.add(AstFactory.newAUnknownType(statement.getLocation()));
284:                 }
285:                 else
286:                 {
287:                         types.add(statement.getExpType());
288:                 }
289:
290:                 return types;
291:         }
292:
293:         @Override
294:         public PTypeSet caseAForAllStm(AForAllStm statement, Environment env)
295:                         throws AnalysisException
296:         {
297:                 PTypeSet result = statement.getSet().apply(THIS, env);
298:                 result.addAll(statement.getStatement().apply(THIS, env));
299:                 return result;
300:         }
301:
302:         @Override
303:         public PTypeSet caseAForIndexStm(AForIndexStm statement, Environment env)
304:                         throws AnalysisException
305:         {
306:                 PTypeSet result = statement.getFrom().apply(THIS, env);
307:                 result.addAll(statement.getTo().apply(THIS, env));
308:•                if (statement.getBy() != null) result.addAll(statement.getBy().apply(THIS, env));
309:                 result.addAll(statement.getStatement().apply(THIS, env));
310:                 return result;
311:         }
312:
313:         @Override
314:         public PTypeSet caseAForPatternBindStm(AForPatternBindStm statement, Environment env)
315:                         throws AnalysisException
316:         {
317:                 PTypeSet result = statement.getExp().apply(THIS, env);
318:                 result.addAll(statement.getStatement().apply(THIS, env));
319:                 return result;
320:         }
321:
322:         @Override
323:         public PTypeSet caseAIfStm(AIfStm statement, Environment env) throws AnalysisException
324:         {
325:                 PTypeSet types = statement.getIfExp().apply(THIS, env);
326:                 types.addAll(statement.getThenStm().apply(THIS, env));
327:
328:•                for (AElseIfStm stmt : statement.getElseIf())
329:                 {
330:                         types.addAll(stmt.apply(THIS, env));
331:                 }
332:
333:•                if (statement.getElseStm() != null)
334:                 {
335:                         types.addAll(statement.getElseStm().apply(THIS, env));
336:                 }
337:
338:                 return types;
339:         }
340:         
341:         @Override
342:         public PTypeSet caseASubclassResponsibilityStm(ASubclassResponsibilityStm statement, Environment question)
343:                         throws AnalysisException
344:         {
345:                 return new PTypeSet(AstFactory.newAUnknownType(statement.getLocation()), af);
346:         }
347:         
348:         @Override
349:         public PTypeSet caseANotYetSpecifiedStm(ANotYetSpecifiedStm statement,
350:                         Environment question) throws AnalysisException
351:         {
352:                 return new PTypeSet(AstFactory.newAUnknownType(statement.getLocation()), af);
353:         }
354:
355:         @Override
356:         public PTypeSet caseALetBeStStm(ALetBeStStm statement, Environment env)
357:                         throws AnalysisException
358:         {
359:                 PTypeSet results = statement.getStatement().apply(THIS, env);
360:•                if (statement.getSuchThat() != null) results.addAll(statement.getSuchThat().apply(THIS, env));
361:
362:•                if (statement.getDef() != null && statement.getDef().getDefs() != null)
363:                 {
364:•                        for (PDefinition d: statement.getDef().getDefs())
365:                         {
366:•                                if (d instanceof AValueDefinition)
367:                                 {
368:                                         AValueDefinition vd = (AValueDefinition)d;
369:                                         results.addAll(vd.apply(THIS, env));
370:                                 }
371:                         }
372:                 }
373:
374:                 return results;
375:         }
376:
377:         @Override
378:         public PTypeSet caseALetStm(ALetStm statement, Environment env) throws AnalysisException
379:         {
380:                 PTypeSet results = statement.getStatement().apply(THIS, env);
381:
382:•                if (statement.getLocalDefs() != null)
383:                 {
384:•                        for (PDefinition d: statement.getLocalDefs())
385:                         {
386:•                                if (d instanceof AValueDefinition)
387:                                 {
388:                                         AValueDefinition vd = (AValueDefinition)d;
389:                                         results.addAll(vd.getExpression().apply(THIS, env));
390:                                 }
391:                         }
392:                 }
393:
394:                 return results;
395:         }
396:
397:         @Override
398:         public PTypeSet caseAReturnStm(AReturnStm statement, Environment env)
399:                         throws AnalysisException
400:         {
401:•                if (statement.getExpression() != null)
402:                 {
403:                         return statement.getExpression().apply(THIS, env);
404:                 }
405:                 else
406:                 {
407:                         return new PTypeSet(af);
408:                 }
409:         }
410:
411:         @Override
412:         public PTypeSet caseABlockSimpleBlockStm(ABlockSimpleBlockStm node,
413:                         Environment question) throws AnalysisException
414:         {
415:                 PTypeSet types = super.caseABlockSimpleBlockStm(node, question);
416:
417:•                for (PDefinition d: node.getAssignmentDefs())
418:                 {
419:•                        if (d instanceof AAssignmentDefinition)
420:                         {
421:                                 AAssignmentDefinition ad = (AAssignmentDefinition)d;
422:                                 types.addAll(ad.getExpression().apply(THIS, question));
423:                         }
424:                 }
425:
426:                 return types;
427:         }
428:
429:         @Override
430:         public PTypeSet defaultSSimpleBlockStm(SSimpleBlockStm statement, Environment env)
431:                         throws AnalysisException
432:         {
433:                 PTypeSet types = new PTypeSet(af);
434:
435:•                for (PStm stmt : statement.getStatements())
436:                 {
437:                         types.addAll(stmt.apply(THIS, env));
438:                 }
439:
440:                 return types;
441:         }
442:
443:         @Override
444:         public PTypeSet caseATixeStm(ATixeStm statement, Environment env) throws AnalysisException
445:         {
446:                 PTypeSet types = new PTypeSet(af);
447:                 types.addAll(statement.getBody().apply(THIS, env));
448:
449:•                for (ATixeStmtAlternative tsa : statement.getTraps())
450:                 {
451:                         types.addAll(exitCheck(tsa, env));
452:                 }
453:
454:                 return types;
455:         }
456:
457:         private PTypeSet exitCheck(ATixeStmtAlternative tsa, Environment env)
458:                         throws AnalysisException
459:         {
460:                 return tsa.getStatement().apply(THIS, env);
461:         }
462:
463:         @Override
464:         public PTypeSet caseATrapStm(ATrapStm statement, Environment env) throws AnalysisException
465:         {
466:                 PTypeSet types = new PTypeSet(af);
467:                 types.addAll(statement.getBody().apply(THIS, env));
468:                 types.addAll(statement.getWith().apply(THIS, env));
469:                 return types;
470:         }
471:
472:         @Override
473:         public PTypeSet caseAWhileStm(AWhileStm statement, Environment env) throws AnalysisException
474:         {
475:                 PTypeSet result = statement.getExp().apply(THIS, env);
476:                 result.addAll(statement.getStatement().apply(THIS, env));
477:                 return result;
478:         }
479:         
480:         /**
481:          * Expressions below here...
482:          */
483:
484:         @Override
485:         public PTypeSet caseAApplyExp(AApplyExp exp, Environment env)
486:                         throws AnalysisException
487:         {
488:                 PTypeSet result = exp.getRoot().apply(THIS, env);
489:                 result.addAll(af.createPExpAssistant(af).exitCheck(exp.getArgs(), env));
490:                 return result;
491:         }
492:
493:         @Override
494:         public PTypeSet defaultSBinaryExp(SBinaryExp exp, Environment env)
495:                         throws AnalysisException
496:         {
497:                 PTypeSet result = exp.getLeft().apply(THIS, env);
498:                 result.addAll(exp.getRight().apply(THIS, env));
499:                 return result;
500:         }
501:
502:         @Override
503:         public PTypeSet caseACasesExp(ACasesExp exp, Environment env)
504:                         throws AnalysisException
505:         {
506:                 PTypeSet result = exp.getExpression().apply(THIS, env);
507:
508:•                for (ACaseAlternative c : exp.getCases())
509:                 {
510:                         result.addAll(c.getResult().apply(THIS, env));
511:                 }
512:
513:•                if (exp.getOthers() != null) result.addAll(exp.getOthers().apply(THIS, env));
514:                 return result;
515:         }
516:
517:         @Override
518:         public PTypeSet caseADefExp(ADefExp exp, Environment env)
519:                         throws AnalysisException
520:         {
521:                 PTypeSet result = new PTypeSet(af);
522:
523:•                for (PDefinition def: exp.getLocalDefs())
524:                 {
525:•                        if (def instanceof AEqualsDefinition)
526:                         {
527:                                 AEqualsDefinition eqdef = (AEqualsDefinition)def;
528:                                 result.addAll(eqdef.getTest().apply(THIS, env));
529:                         }
530:                 }
531:
532:                 result.addAll(exp.getExpression().apply(THIS, env));
533:                 return result;
534:         }
535:
536:         @Override
537:         public PTypeSet caseAElseIfExp(AElseIfExp exp, Environment env)
538:                         throws AnalysisException
539:         {
540:                 PTypeSet result = exp.getElseIf().apply(THIS, env);
541:                 result.addAll(exp.getThen().apply(THIS, env));
542:                 return result;
543:         }
544:
545:         @Override
546:         public PTypeSet caseAExistsExp(AExistsExp exp, Environment env)
547:                         throws AnalysisException
548:         {
549:                 PTypeSet result = af.createPExpAssistant(af).exitCheckMultipleBindList(exp.getBindList(), env);
550:                 result.addAll(exp.getPredicate().apply(THIS, env));
551:                 return result;
552:         }
553:
554:         @Override
555:         public PTypeSet caseAExists1Exp(AExists1Exp exp, Environment env)
556:                         throws AnalysisException
557:         {
558:                 PTypeSet result = exp.getBind().apply(THIS, env);
559:                 result.addAll(exp.getPredicate().apply(THIS, env));
560:                 return result;
561:         }
562:
563:         @Override
564:         public PTypeSet caseAFieldExp(AFieldExp exp, Environment env)
565:                         throws AnalysisException
566:         {
567:                 return exp.getObject().apply(THIS, env);
568:         }
569:
570:         @Override
571:         public PTypeSet caseAFieldNumberExp(AFieldNumberExp exp, Environment env)
572:                         throws AnalysisException
573:         {
574:                 return exp.getTuple().apply(THIS, env);
575:         }
576:
577:         @Override
578:         public PTypeSet caseAForAllExp(AForAllExp exp, Environment env)
579:                         throws AnalysisException
580:         {
581:                 PTypeSet result = af.createPExpAssistant(af).exitCheckMultipleBindList(exp.getBindList(), env);
582:                 result.addAll(exp.getPredicate().apply(THIS, env));
583:                 return result;
584:         }
585:
586:         @Override
587:         public PTypeSet caseAFuncInstatiationExp(AFuncInstatiationExp exp,
588:                         Environment env) throws AnalysisException
589:         {
590:                 return exp.getFunction().apply(THIS, env);
591:         }
592:
593:         @Override
594:         public PTypeSet caseAIfExp(AIfExp exp, Environment env) throws AnalysisException
595:         {
596:                 PTypeSet result = exp.getTest().apply(THIS, env);
597:                 result.addAll(exp.getThen().apply(THIS, env));
598:
599:•                for (AElseIfExp stmt : exp.getElseList())
600:                 {
601:                         result.addAll(stmt.apply(THIS, env));
602:                 }
603:
604:•                if (exp.getElse() != null)
605:                 {
606:                         result.addAll(exp.getElse().apply(THIS, env));
607:                 }
608:
609:                 return result;
610:         }
611:
612:         @Override
613:         public PTypeSet caseAIotaExp(AIotaExp exp, Environment env)
614:                         throws AnalysisException
615:         {
616:
617:                 PTypeSet result = exp.getBind().apply(THIS, env);
618:                 result.addAll(exp.getPredicate().apply(THIS, env));
619:                 return result;
620:         }
621:
622:         @Override
623:         public PTypeSet caseAIsExp(AIsExp exp, Environment env) throws AnalysisException
624:         {
625:                 return exp.getTest().apply(THIS, env);
626:         }
627:
628:         @Override
629:         public PTypeSet caseAIsOfBaseClassExp(AIsOfBaseClassExp exp, Environment env)
630:                         throws AnalysisException
631:         {
632:                 return exp.getExp().apply(THIS, env);
633:         }
634:
635:         @Override
636:         public PTypeSet caseAIsOfClassExp(AIsOfClassExp exp, Environment env)
637:                         throws AnalysisException
638:         {
639:                 return exp.getExp().apply(THIS, env);
640:         }
641:
642:         @Override
643:         public PTypeSet caseALambdaExp(ALambdaExp exp, Environment env)
644:                         throws AnalysisException
645:         {
646:                 PTypeSet result = exp.getExpression().apply(THIS, env);
647:                 result.addAll(exp.getExpression().apply(THIS, env));
648:                 return result;
649:         }
650:
651:         @Override
652:         public PTypeSet caseALetBeStExp(ALetBeStExp exp, Environment env)
653:                         throws AnalysisException
654:         {
655:                 PTypeSet result = exp.getBind().apply(THIS, env);
656:
657:•                if (exp.getSuchThat() != null)
658:                 {
659:                         result.addAll(exp.getSuchThat().apply(THIS, env));
660:                 }
661:
662:                 result.addAll(exp.getValue().apply(THIS, env));
663:                 return result;
664:         }
665:
666:         @Override
667:         public PTypeSet caseALetDefExp(ALetDefExp exp, Environment env)
668:                         throws AnalysisException
669:         {
670:                 PTypeSet results = exp.getExpression().apply(THIS, env);
671:
672:•                if (exp.getLocalDefs() != null)
673:                 {
674:•                        for (PDefinition d: exp.getLocalDefs())
675:                         {
676:•                                if (d instanceof AValueDefinition)
677:                                 {
678:                                         AValueDefinition vd = (AValueDefinition)d;
679:                                         results.addAll(vd.getExpression().apply(THIS, env));
680:                                 }
681:                         }
682:                 }
683:
684:                 return results;
685:         }
686:
687:         @Override
688:         public PTypeSet caseAMapletExp(AMapletExp node, Environment env) throws AnalysisException
689:         {
690:                 PTypeSet result = node.getLeft().apply(THIS, env);
691:                 result.addAll(node.getRight().apply(THIS, env));
692:                 return result;
693:         }
694:
695:         @Override
696:         public PTypeSet caseAMapCompMapExp(AMapCompMapExp exp, Environment env)
697:                         throws AnalysisException
698:         {
699:                 PTypeSet result = exp.getFirst().apply(THIS, env);
700:                 result.addAll(af.createPExpAssistant(af).exitCheckMultipleBindList(exp.getBindings(), env));
701:•                if (exp.getPredicate() != null) exp.getPredicate().apply(THIS, env);
702:                 return result;
703:         }
704:
705:         @Override
706:         public PTypeSet caseAMapEnumMapExp(AMapEnumMapExp exp, Environment env)
707:                         throws AnalysisException
708:         {
709:                 PTypeSet result = new PTypeSet(af);
710:
711:•                for (AMapletExp m : exp.getMembers())
712:                 {
713:                         result.addAll(m.apply(THIS, env));
714:                 }
715:
716:                 return result;
717:         }
718:
719:         @Override
720:         public PTypeSet caseAMkBasicExp(AMkBasicExp exp, Environment env)
721:                         throws AnalysisException
722:         {
723:                 return exp.getArg().apply(THIS, env);
724:         }
725:
726:         @Override
727:         public PTypeSet caseAMkTypeExp(AMkTypeExp exp, Environment env)
728:                         throws AnalysisException
729:         {
730:                 return af.createPExpAssistant(af).exitCheck(exp.getArgs(), env);
731:         }
732:
733:         @Override
734:         public PTypeSet caseAMuExp(AMuExp exp, Environment env) throws AnalysisException
735:         {
736:                 PTypeSet result = new PTypeSet(af);
737:
738:•                for (ARecordModifier rm: exp.getModifiers())
739:                 {
740:                         result.addAll(rm.apply(THIS, env));
741:                 }
742:
743:                 result.addAll(exp.getRecord().apply(THIS, env));
744:                 return result;
745:         }
746:
747:         @Override
748:         public PTypeSet caseANarrowExp(ANarrowExp exp, Environment env)
749:                         throws AnalysisException
750:         {
751:                 return exp.getTest().apply(THIS, env);
752:         }
753:
754:         @Override
755:         public PTypeSet caseANewExp(ANewExp exp, Environment env)
756:                         throws AnalysisException
757:         {
758:                 return af.createPExpAssistant(af).exitCheck(exp.getArgs(), env);
759:         }
760:
761:         @Override
762:         public PTypeSet caseAPostOpExp(APostOpExp exp, Environment env)
763:                         throws AnalysisException
764:         {
765:                 return exp.getPostexpression().apply(THIS, env);
766:         }
767:
768:         @Override
769:         public PTypeSet caseASameBaseClassExp(ASameBaseClassExp exp, Environment env)
770:                         throws AnalysisException
771:         {
772:                 PTypeSet result = exp.getLeft().apply(THIS, env);
773:                 result.addAll(exp.getRight().apply(THIS, env));
774:                 return result;
775:         }
776:
777:         @Override
778:         public PTypeSet caseASameClassExp(ASameClassExp exp, Environment env)
779:                         throws AnalysisException
780:         {
781:                 PTypeSet result = exp.getLeft().apply(THIS, env);
782:                 result.addAll(exp.getRight().apply(THIS, env));
783:                 return result;
784:         }
785:
786:         @Override
787:         public PTypeSet caseASeqCompSeqExp(ASeqCompSeqExp exp, Environment env)
788:                         throws AnalysisException
789:         {
790:                 PTypeSet result = exp.getFirst().apply(THIS, env);
791:                 result.addAll(exp.getBind().apply(THIS, env));
792:
793:•                if (exp.getPredicate() != null) result.addAll(exp.getPredicate().apply(THIS, env));
794:                 return result;
795:         }
796:
797:         @Override
798:         public PTypeSet caseASeqEnumSeqExp(ASeqEnumSeqExp exp, Environment env)
799:                         throws AnalysisException
800:         {
801:                 return af.createPExpAssistant(af).exitCheck(exp.getMembers(), env);
802:         }
803:
804:         @Override
805:         public PTypeSet caseASetCompSetExp(ASetCompSetExp exp, Environment env)
806:                         throws AnalysisException
807:         {
808:                 PTypeSet result = exp.getFirst().apply(THIS, env);
809:
810:                 result.addAll(af.createPExpAssistant(af).exitCheckMultipleBindList(exp.getBindings(), env));
811:
812:•                if (exp.getPredicate() != null) result.addAll(exp.getPredicate().apply(THIS, env));
813:                 return result;
814:         }
815:
816:         @Override
817:         public PTypeSet caseASetEnumSetExp(ASetEnumSetExp exp, Environment env)
818:                         throws AnalysisException
819:         {
820:                 return af.createPExpAssistant(af).exitCheck(exp.getMembers(), env);
821:         }
822:
823:         @Override
824:         public PTypeSet caseASetRangeSetExp(ASetRangeSetExp exp, Environment env)
825:                         throws AnalysisException
826:         {
827:                 PTypeSet result = exp.getFirst().apply(THIS, env);
828:                 result.addAll(exp.getLast().apply(THIS, env));
829:                 return result;
830:         }
831:
832:         @Override
833:         public PTypeSet caseASubseqExp(ASubseqExp exp, Environment env)
834:                         throws AnalysisException
835:         {
836:                 PTypeSet result = exp.getSeq().apply(THIS, env);
837:                 result.addAll(exp.getFrom().apply(THIS, env));
838:                 result.addAll(exp.getTo().apply(THIS, env));
839:                 return result;
840:         }
841:
842:         @Override
843:         public PTypeSet caseATupleExp(ATupleExp exp, Environment env)
844:                         throws AnalysisException
845:         {
846:                 return af.createPExpAssistant(af).exitCheck(exp.getArgs(), env);
847:         }
848:         
849:         @Override
850:         public PTypeSet caseASetMultipleBind(ASetMultipleBind node,        Environment env) throws AnalysisException
851:         {
852:                 return node.getSet().apply(this, env);
853:         }
854:         
855:         @Override
856:         public PTypeSet caseASeqMultipleBind(ASeqMultipleBind node,        Environment env) throws AnalysisException
857:         {
858:                 return node.getSeq().apply(this, env);
859:         }
860:
861:         @Override
862:         public PTypeSet caseASetBind(ASetBind node, Environment env) throws AnalysisException
863:         {
864:                 return node.getSet().apply(THIS, env);
865:         }
866:         
867:         @Override
868:         public PTypeSet caseASeqBind(ASeqBind node, Environment env) throws AnalysisException
869:         {
870:                 return node.getSeq().apply(THIS, env);
871:         }
872:         
873:         @Override
874:         public PTypeSet defaultSUnaryExp(SUnaryExp exp, Environment env)
875:                         throws AnalysisException
876:         {
877:                 return exp.getExp().apply(THIS, env);
878:         }
879:         
880:         @Override
881:         public PTypeSet defaultPStm(PStm statement, Environment env) throws AnalysisException
882:         {
883:                 return new PTypeSet(af);
884:         }
885:
886:         @Override
887:         public PTypeSet defaultPExp(PExp expression, Environment env) throws AnalysisException
888:         {
889:                 PTypeSet result = new PTypeSet(af);
890:                 result.add(AstFactory.newAUnknownType(expression.getLocation()));
891:                 return result;
892:         }
893:         
894:         @Override
895:         public PTypeSet createNewReturnValue(INode node, Environment env)
896:         {
897:                 return new PTypeSet(af);
898:         }
899:
900:         @Override
901:         public PTypeSet createNewReturnValue(Object node, Environment env)
902:         {
903:                 return new PTypeSet(af);
904:         }
905: }