Package: FlatEnvironment

FlatEnvironment

nameinstructionbranchcomplexitylinemethod
FlatEnvironment(ITypeCheckerAssistantFactory, Environment, Boolean, boolean)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
FlatEnvironment(ITypeCheckerAssistantFactory, List)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
FlatEnvironment(ITypeCheckerAssistantFactory, List, Environment)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
FlatEnvironment(ITypeCheckerAssistantFactory, PDefinition, Environment)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
add(PDefinition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
findClassDefinition()
M: 2 C: 7
78%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%
findMatches(ILexNameToken)
M: 0 C: 20
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 4
100%
M: 0 C: 1
100%
findName(ILexNameToken, NameScope)
M: 0 C: 32
100%
M: 0 C: 8
100%
M: 0 C: 5
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
findStateDefinition()
M: 4 C: 16
80%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 1 C: 3
75%
M: 0 C: 1
100%
findType(ILexNameToken, String)
M: 0 C: 24
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getDefinitions()
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%
isStatic()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isSystem()
M: 2 C: 7
78%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%
isVDMPP()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
markUsed()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setLimitStateScope(boolean)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
unusedCheck()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

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.ArrayList;
27: import java.util.List;
28: import java.util.Set;
29:
30: import org.overture.ast.definitions.AStateDefinition;
31: import org.overture.ast.definitions.PDefinition;
32: import org.overture.ast.definitions.SClassDefinition;
33: import org.overture.ast.intf.lex.ILexNameToken;
34: import org.overture.ast.typechecker.NameScope;
35: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
36:
37: /**
38: * Define the type checking environment for a list of definitions.
39: */
40:
41: public class FlatEnvironment extends Environment
42: {
43:         protected final List<PDefinition> definitions;
44:         private boolean limitStateScope = false;
45:
46:         public List<PDefinition> getDefinitions()
47:         {
48:                 return definitions;
49:         }
50:
51:         public FlatEnvironment(ITypeCheckerAssistantFactory af,
52:                         List<PDefinition> definitions)
53:         {
54:                 super(af, null);
55:                 this.definitions = definitions;
56:         }
57:
58:         public FlatEnvironment(ITypeCheckerAssistantFactory af,
59:                         List<PDefinition> definitions, Environment env)
60:         {
61:                 super(af, env);
62:                 this.definitions = definitions;
63:         }
64:
65:         public FlatEnvironment(ITypeCheckerAssistantFactory af, PDefinition one,
66:                         Environment env)
67:         {
68:                 super(af, env);
69:                 this.definitions = new ArrayList<PDefinition>();
70:                 this.definitions.add(one);
71:         }
72:
73:         public FlatEnvironment(ITypeCheckerAssistantFactory af, Environment env, Boolean functional, boolean errors)
74:         {
75:                 this(af, new ArrayList<PDefinition>(), env);
76:                 setFunctional(functional, errors);
77:         }
78:
79:         public void add(PDefinition one)
80:         {
81:                 definitions.add(one);
82:         }
83:
84:         @Override
85:         public PDefinition findName(ILexNameToken name, NameScope scope)
86:         {
87:                 PDefinition def = af.createPDefinitionListAssistant().findName(definitions, name, scope);
88:
89:•                if (def != null && !ExcludedDefinitions.isExcluded(def))
90:                 {
91:                         return def;
92:                 }
93:
94:•                if (outer == null)
95:                 {
96:                         return null;
97:                 } else
98:                 {
99:•                        if (limitStateScope)
100:                         {
101:                                 scope = NameScope.NAMES; // Limit NAMESAND(ANY)STATE
102:                         }
103:
104:                         return outer.findName(name, scope);
105:                 }
106:         }
107:
108:         @Override
109:         public PDefinition findType(ILexNameToken name, String fromModule)
110:         {
111:                 PDefinition def = af.createPDefinitionAssistant().findType(definitions, name, fromModule);
112:
113:•                if (def != null)
114:                 {
115:                         return def;
116:                 }
117:
118:•                return outer == null ? null : outer.findType(name, fromModule);
119:         }
120:
121:         @Override
122:         public AStateDefinition findStateDefinition()
123:         {
124:                 AStateDefinition def = af.createPDefinitionListAssistant().findStateDefinition(definitions);
125:
126:•                if (def != null)
127:                 {
128:                         return def;
129:                 }
130:
131:•                return outer == null ? null : outer.findStateDefinition();
132:         }
133:
134:         @Override
135:         public void unusedCheck()
136:         {
137:                 af.createPDefinitionListAssistant().unusedCheck(definitions);
138:         }
139:
140:         @Override
141:         public boolean isVDMPP()
142:         {
143:•                return outer == null ? false : outer.isVDMPP();
144:         }
145:
146:         @Override
147:         public boolean isSystem()
148:         {
149:•                return outer == null ? false : outer.isSystem();
150:         }
151:
152:         @Override
153:         public SClassDefinition findClassDefinition()
154:         {
155:•                return outer == null ? null : outer.findClassDefinition();
156:         }
157:
158:         @Override
159:         public boolean isStatic()
160:         {
161:•                return outer == null ? false : outer.isStatic();
162:         }
163:
164:         @Override
165:         public Set<PDefinition> findMatches(ILexNameToken name)
166:         {
167:                 Set<PDefinition> defs = af.createPDefinitionListAssistant().findMatches(definitions, name);
168:
169:•                if (outer != null)
170:                 {
171:                         defs.addAll(outer.findMatches(name));
172:                 }
173:
174:                 return defs;
175:         }
176:
177:         @Override
178:         public void markUsed()
179:         {
180:                 af.createPDefinitionListAssistant().markUsed(definitions);
181:         }
182:
183:         public void setLimitStateScope(boolean limitStateScope)
184:         {
185:                 this.limitStateScope = limitStateScope;
186:         }
187:
188: }