Package: UpdatableChecker

UpdatableChecker

nameinstructionbranchcomplexitylinemethod
UpdatableChecker(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%
caseAAssignmentDefinition(AAssignmentDefinition)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAExternalDefinition(AExternalDefinition)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAImportedDefinition(AImportedDefinition)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAInheritedDefinition(AInheritedDefinition)
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%
caseAInstanceVariableDefinition(AInstanceVariableDefinition)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseALocalDefinition(ALocalDefinition)
M: 0 C: 22
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseARenamedDefinition(ARenamedDefinition)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createNewReturnValue(INode)
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
createNewReturnValue(Object)
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
defaultPDefinition(PDefinition)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 2 C: 6
75%
M: 1 C: 1
50%
M: 1 C: 1
50%
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.AnswerAdaptor;
26: import org.overture.ast.definitions.AAssignmentDefinition;
27: import org.overture.ast.definitions.AExternalDefinition;
28: import org.overture.ast.definitions.AImportedDefinition;
29: import org.overture.ast.definitions.AInheritedDefinition;
30: import org.overture.ast.definitions.AInstanceVariableDefinition;
31: import org.overture.ast.definitions.ALocalDefinition;
32: import org.overture.ast.definitions.ARenamedDefinition;
33: import org.overture.ast.definitions.PDefinition;
34: import org.overture.ast.node.INode;
35: import org.overture.ast.typechecker.NameScope;
36: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
37:
38: /**
39: * This class implements a way to check if a definition is updatable from a node in the AST
40: *
41: * @author kel
42: */
43:
44:•public class UpdatableChecker extends AnswerAdaptor<Boolean>
45: {
46:
47:         protected ITypeCheckerAssistantFactory af;
48:
49:         public UpdatableChecker(ITypeCheckerAssistantFactory af)
50:         {
51:                 this.af = af;
52:         }
53:
54:         @Override
55:         public Boolean caseAAssignmentDefinition(AAssignmentDefinition node)
56:                         throws AnalysisException
57:         {
58:                 return true;
59:         }
60:
61:         @Override
62:         public Boolean caseAInstanceVariableDefinition(
63:                         AInstanceVariableDefinition node) throws AnalysisException
64:         {
65:                 return true;
66:         }
67:
68:         @Override
69:         public Boolean caseAExternalDefinition(AExternalDefinition node)
70:                         throws AnalysisException
71:         {
72:                 return true;
73:         }
74:
75:         @Override
76:         public Boolean caseAImportedDefinition(AImportedDefinition node)
77:                         throws AnalysisException
78:         {
79:                 return node.getDef().apply(THIS);
80:         }
81:
82:         @Override
83:         public Boolean caseAInheritedDefinition(AInheritedDefinition node)
84:                         throws AnalysisException
85:         {
86:                 return node.getSuperdef().apply(THIS);
87:         }
88:
89:         @Override
90:         public Boolean caseALocalDefinition(ALocalDefinition node)
91:                         throws AnalysisException
92:         {
93:•                return node.getNameScope().matches(NameScope.STATE)
94:•                                || af.createPTypeAssistant().isClass(af.createPDefinitionAssistant().getType(node), null, null);
95:         }
96:
97:         @Override
98:         public Boolean caseARenamedDefinition(ARenamedDefinition node)
99:                         throws AnalysisException
100:         {
101:                 return node.getDef().apply(THIS);
102:         }
103:
104:         @Override
105:         public Boolean defaultPDefinition(PDefinition node)
106:                         throws AnalysisException
107:         {
108:                 return false;
109:         }
110:
111:         @Override
112:         public Boolean createNewReturnValue(INode node)
113:         {
114:•                assert false : "should not happen";
115:                 return null;
116:         }
117:
118:         @Override
119:         public Boolean createNewReturnValue(Object node)
120:         {
121:•                assert false : "should not happen";
122:                 return null;
123:         }
124:
125: }