Package: ModuleEnvironment

ModuleEnvironment

nameinstructionbranchcomplexitylinemethod
ModuleEnvironment(ITypeCheckerAssistantFactory, AModuleModules)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
findClassDefinition()
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%
findMatches(ILexNameToken)
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%
findName(ILexNameToken, NameScope)
M: 0 C: 33
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
findStateDefinition()
M: 0 C: 14
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
findType(ILexNameToken, String)
M: 0 C: 30
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
getDefinitions()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isStatic()
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%
isSystem()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isVDMPP()
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%
toString()
M: 30 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
unusedCheck()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (c) 2008 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.typechecker;
25:
26: import java.util.List;
27: import java.util.Set;
28:
29: import org.overture.ast.definitions.AStateDefinition;
30: import org.overture.ast.definitions.PDefinition;
31: import org.overture.ast.definitions.SClassDefinition;
32: import org.overture.ast.intf.lex.ILexNameToken;
33: import org.overture.ast.modules.AModuleModules;
34: import org.overture.ast.typechecker.NameScope;
35: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
36:
37: /**
38: * Define the type checking environment for a modular specification.
39: */
40:
41: public class ModuleEnvironment extends Environment
42: {
43:         private final AModuleModules module;
44:
45:         public List<PDefinition> getDefinitions()
46:         {
47:                 return module.getDefs();
48:         }
49:
50:         public ModuleEnvironment(ITypeCheckerAssistantFactory af,
51:                         AModuleModules module)
52:         {
53:                 super(af, null);
54:                 this.module = module;
55:                 dupHideCheck(module.getDefs(), NameScope.NAMESANDSTATE);
56:         }
57:
58:         @Override
59:         public String toString()
60:         {
61:                 StringBuilder sb = new StringBuilder();
62:
63:•                for (PDefinition d : module.getDefs())
64:                 {
65:                         sb.append(d.getName().getFullName());
66:                         sb.append("\n");
67:                 }
68:
69:                 return sb.toString();
70:         }
71:
72:         @Override
73:         public PDefinition findName(ILexNameToken name, NameScope scope)
74:         {
75:                 PDefinition def = af.createPDefinitionListAssistant().findName(module.getDefs(), name, scope);
76:
77:•                if (def != null && !ExcludedDefinitions.isExcluded(def))
78:                 {
79:                         return def;
80:                 }
81:
82:                 def = af.createPDefinitionListAssistant().findName(module.getImportdefs(), name, scope);
83:
84:•                if (def != null)
85:                 {
86:                         return def;
87:                 }
88:
89:                 return null; // Modules are always bottom of the env chain
90:         }
91:
92:         @Override
93:         public PDefinition findType(ILexNameToken name, String fromModule)
94:         {
95:                 PDefinition def = af.createPDefinitionAssistant().findType(module.getDefs(), name, fromModule);
96:
97:•                if (def != null)
98:                 {
99:                         return def;
100:                 }
101:
102:                 def = af.createPDefinitionAssistant().findType(module.getImportdefs(), name, fromModule);
103:
104:•                if (def != null)
105:                 {
106:                         return def;
107:                 }
108:
109:                 return null; // Modules are always bottom of the env chain
110:         }
111:
112:         @Override
113:         public Set<PDefinition> findMatches(ILexNameToken name)
114:         {
115:                 Set<PDefinition> defs = af.createPDefinitionListAssistant().findMatches(module.getDefs(), name);
116:                 defs.addAll(af.createPDefinitionListAssistant().findMatches(module.getImportdefs(), name));
117:                 return defs;
118:         }
119:
120:         @Override
121:         public void unusedCheck()
122:         {
123:                 // The usage of all modules is checked at the end of the type check
124:                 // phase. Only flat environments implement this check, for unused
125:                 // local definitions introduced by expressions and statements.
126:         }
127:
128:         @Override
129:         public AStateDefinition findStateDefinition()
130:         {
131:                 AStateDefinition def = af.createPDefinitionListAssistant().findStateDefinition(module.getDefs());
132:
133:•                if (def != null)
134:                 {
135:                         return def;
136:                 }
137:
138:                 return null; // Modules are always bottom of the env chain
139:         }
140:
141:         @Override
142:         public boolean isVDMPP()
143:         {
144:                 return false;
145:         }
146:
147:         @Override
148:         public boolean isSystem()
149:         {
150:                 return false;
151:         }
152:
153:         @Override
154:         public SClassDefinition findClassDefinition()
155:         {
156:                 return null;
157:         }
158:
159:         @Override
160:         public boolean isStatic()
161:         {
162:                 return false;
163:         }
164:
165: }