Package: IRInfo

IRInfo

nameinstructionbranchcomplexitylinemethod
IRInfo()
M: 0 C: 74
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 16
100%
M: 0 C: 1
100%
addClass(SClassDeclIR)
M: 0 C: 9
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
addModule(AModuleDeclIR)
M: 0 C: 9
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
addTransformationWarning(INode, String)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addUnsupportedNode(INode, String)
M: 1 C: 29
97%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 6
86%
M: 0 C: 1
100%
clear()
M: 0 C: 22
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
clearClasses()
M: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
clearModules()
M: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
clearNodes()
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%
clearTransformationWarnings()
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%
getAssistantManager()
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%
getBindAssistant()
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%
getBindVisitor()
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%
getClassVisitor()
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%
getClasses()
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%
getDeclAssistant()
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%
getDeclVisitor()
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%
getExpAssistant()
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%
getExpVisitor()
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%
getExportVisitor()
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%
getExportsVisitor()
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%
getIdStateDesignatorDefs()
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%
getImportVisitor()
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%
getImportsVisitor()
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%
getInstantiatedClasses()
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%
getLocationAssistant()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getModifierVisitor()
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%
getModuleVisitor()
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%
getModules()
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%
getMultipleBindVisitor()
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%
getNodeAssistant()
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%
getObjectDesignatorVisitor()
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%
getPatternAssistant()
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%
getPatternVisitor()
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%
getQuoteValues()
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%
getSettings()
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%
getStateDesignatorVisitor()
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%
getStmAssistant()
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%
getStmVisitor()
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%
getTcFactory()
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%
getTempVarNameGen()
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%
getTermVisitor()
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%
getTraceCoreDeclVisitor()
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%
getTraceDeclVisitor()
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%
getTransformationWarnings()
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%
getTypeAssistant()
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%
getTypeVisitor()
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%
getUnsupportedNodes()
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%
isSlStateRead(SVarExpIR)
M: 0 C: 19
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
registerQuoteValue(String)
M: 6 C: 20
77%
M: 3 C: 5
63%
M: 3 C: 2
40%
M: 2 C: 5
71%
M: 0 C: 1
100%
registerSlStateRead(SVarExpIR)
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%
removeClass(String)
M: 30 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
removeModule(String)
M: 1 C: 29
97%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 1 C: 8
89%
M: 0 C: 1
100%
setIdStateDesignatorDefs(Map)
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%
setSettings(IRSettings)
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%

Coverage

1: /*
2: * #%~
3: * VDM Code Generator
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.codegen.ir;
23:
24: import java.util.HashMap;
25: import java.util.HashSet;
26: import java.util.LinkedList;
27: import java.util.List;
28: import java.util.Map;
29: import java.util.Set;
30:
31: import org.apache.log4j.Logger;
32: import org.overture.ast.definitions.PDefinition;
33: import org.overture.ast.node.INode;
34: import org.overture.ast.statements.AIdentifierStateDesignator;
35: import org.overture.codegen.assistant.AssistantManager;
36: import org.overture.codegen.assistant.BindAssistantIR;
37: import org.overture.codegen.assistant.DeclAssistantIR;
38: import org.overture.codegen.assistant.ExpAssistantIR;
39: import org.overture.codegen.assistant.LocationAssistantIR;
40: import org.overture.codegen.assistant.NodeAssistantIR;
41: import org.overture.codegen.assistant.PatternAssistantIR;
42: import org.overture.codegen.assistant.StmAssistantIR;
43: import org.overture.codegen.assistant.TypeAssistantIR;
44: import org.overture.codegen.ir.declarations.AModuleDeclIR;
45: import org.overture.codegen.ir.declarations.SClassDeclIR;
46: import org.overture.codegen.ir.expressions.SVarExpIR;
47: import org.overture.codegen.visitor.IRVisitor;
48: import org.overture.codegen.visitor.VisitorManager;
49: import org.overture.typechecker.assistant.TypeCheckerAssistantFactory;
50:
51: public class IRInfo
52: {
53:         // Visitors
54:         private VisitorManager visitorManager;
55:
56:         // Assistants
57:         private AssistantManager assistantManager;
58:
59:         // VDM assistant factory
60:         private TypeCheckerAssistantFactory tcFactory;
61:
62:         // Quotes:
63:         private List<String> quoteVaues;
64:
65:         // Unsupported VDM nodes
66:         private Set<VdmNodeInfo> unsupportedNodes;
67:
68:         // Transformation warnings
69:         private Set<IrNodeInfo> transformationWarnings;
70:
71:         // For generating variable names
72:         private ITempVarGen tempVarNameGen;
73:
74:         // For configuring code generation
75:         private IRSettings settings;
76:
77:         // Definitions for identifier state designators
78:         private Map<AIdentifierStateDesignator, PDefinition> idStateDesignatorDefs;
79:
80:         // IR classes
81:         private List<SClassDeclIR> classes;
82:
83:         // IR modules
84:         private List<AModuleDeclIR> modules;
85:
86:         // SL state reads
87:         private List<SVarExpIR> slStateReads;
88:         
89:         // Names of classes that are instantiated
90:         private Set<String> instantiatedClasses;
91:
92:         private Logger log = Logger.getLogger(this.getClass().getName());
93:
94:         public IRInfo()
95:         {
96:                 super();
97:
98:                 this.visitorManager = new VisitorManager();
99:                 this.assistantManager = new AssistantManager();
100:                 this.tcFactory = new TypeCheckerAssistantFactory();
101:                 this.quoteVaues = new LinkedList<String>();
102:                 this.unsupportedNodes = new HashSet<VdmNodeInfo>();
103:                 this.transformationWarnings = new HashSet<IrNodeInfo>();
104:                 this.tempVarNameGen = new TempVarNameGen();
105:
106:                 this.settings = new IRSettings();
107:
108:                 this.idStateDesignatorDefs = new HashMap<AIdentifierStateDesignator, PDefinition>();
109:                 this.classes = new LinkedList<SClassDeclIR>();
110:                 this.modules = new LinkedList<AModuleDeclIR>();
111:                 this.slStateReads = new LinkedList<>();
112:                 this.instantiatedClasses = new HashSet<>();
113:         }
114:
115:         public AssistantManager getAssistantManager()
116:         {
117:                 return assistantManager;
118:         }
119:
120:         public IRVisitor<SClassDeclIR> getClassVisitor()
121:         {
122:                 return visitorManager.getClassVisitor();
123:         }
124:
125:         public IRVisitor<AModuleDeclIR> getModuleVisitor()
126:         {
127:                 return visitorManager.getModuleVisitor();
128:         }
129:
130:         public IRVisitor<SImportsIR> getImportsVisitor()
131:         {
132:                 return visitorManager.getImportsVisitor();
133:         }
134:
135:         public IRVisitor<SImportIR> getImportVisitor()
136:         {
137:                 return visitorManager.getImportVisitor();
138:         }
139:
140:         public IRVisitor<SExportsIR> getExportsVisitor()
141:         {
142:                 return visitorManager.getExportsVisitor();
143:         }
144:
145:         public IRVisitor<SExportIR> getExportVisitor()
146:         {
147:                 return visitorManager.getExportVisitor();
148:         }
149:
150:         public IRVisitor<SDeclIR> getDeclVisitor()
151:         {
152:                 return visitorManager.getDeclVisitor();
153:         }
154:
155:         public IRVisitor<SExpIR> getExpVisitor()
156:         {
157:                 return visitorManager.getExpVisitor();
158:         }
159:
160:         public IRVisitor<STypeIR> getTypeVisitor()
161:         {
162:                 return visitorManager.getTypeVisitor();
163:         }
164:
165:         public IRVisitor<SStmIR> getStmVisitor()
166:         {
167:                 return visitorManager.getStmVisitor();
168:         }
169:
170:         public IRVisitor<SStateDesignatorIR> getStateDesignatorVisitor()
171:         {
172:                 return visitorManager.getStateDesignatorVisitor();
173:         }
174:
175:         public IRVisitor<SObjectDesignatorIR> getObjectDesignatorVisitor()
176:         {
177:                 return visitorManager.getObjectDesignatorVisitor();
178:         }
179:
180:         public IRVisitor<SMultipleBindIR> getMultipleBindVisitor()
181:         {
182:                 return visitorManager.getMultipleBindVisitor();
183:         }
184:
185:         public IRVisitor<SBindIR> getBindVisitor()
186:         {
187:                 return visitorManager.getBindVisitor();
188:         }
189:
190:         public IRVisitor<SPatternIR> getPatternVisitor()
191:         {
192:                 return visitorManager.getPatternVisitor();
193:         }
194:
195:         public IRVisitor<SModifierIR> getModifierVisitor()
196:         {
197:                 return visitorManager.getModifierVisitor();
198:         }
199:
200:         public IRVisitor<STermIR> getTermVisitor()
201:         {
202:                 return visitorManager.getTermVisitor();
203:         }
204:
205:         public IRVisitor<STraceDeclIR> getTraceDeclVisitor()
206:         {
207:                 return visitorManager.getTraceDeclVisitor();
208:         }
209:
210:         public IRVisitor<STraceCoreDeclIR> getTraceCoreDeclVisitor()
211:         {
212:                 return visitorManager.getTraceCoreDeclVisitor();
213:         }
214:
215:         public NodeAssistantIR getNodeAssistant()
216:         {
217:                 return assistantManager.getNodeAssistant();
218:         }
219:
220:         public ExpAssistantIR getExpAssistant()
221:         {
222:                 return assistantManager.getExpAssistant();
223:         }
224:
225:         public DeclAssistantIR getDeclAssistant()
226:         {
227:                 return assistantManager.getDeclAssistant();
228:         }
229:
230:         public StmAssistantIR getStmAssistant()
231:         {
232:                 return assistantManager.getStmAssistant();
233:         }
234:
235:         public TypeAssistantIR getTypeAssistant()
236:         {
237:                 return assistantManager.getTypeAssistant();
238:         }
239:
240:         public LocationAssistantIR getLocationAssistant()
241:         {
242:                 return assistantManager.getLocationAssistant();
243:         }
244:
245:         public BindAssistantIR getBindAssistant()
246:         {
247:                 return assistantManager.getBindAssistant();
248:         }
249:
250:         public PatternAssistantIR getPatternAssistant()
251:         {
252:                 return assistantManager.getPatternAssistant();
253:         }
254:
255:         public void registerQuoteValue(String value)
256:         {
257:                 // Illegal quote types are used internally so ignore it.
258:•                if ("?".equals(value))
259:                 {
260:                         return;
261:                 }
262:
263:•                if (value == null || value.isEmpty())
264:                 {
265:                         log.error("Tried to register invalid qoute value");
266:                 } else
267:                 {
268:•                        if (!quoteVaues.contains(value))
269:                         {
270:                                 quoteVaues.add(value);
271:                         }
272:                 }
273:         }
274:
275:         public TypeCheckerAssistantFactory getTcFactory()
276:         {
277:                 return tcFactory;
278:         }
279:
280:         public List<String> getQuoteValues()
281:         {
282:                 return quoteVaues;
283:         }
284:
285:         public void clearNodes()
286:         {
287:                 unsupportedNodes.clear();
288:         }
289:
290:         public void addUnsupportedNode(INode node, String reason)
291:         {
292:•                for (VdmNodeInfo info : unsupportedNodes)
293:                 {
294:•                        if (VdmNodeInfo.matches(info, node, reason))
295:                         {
296:                                 return;
297:                         }
298:                 }
299:
300:                 VdmNodeInfo info = new VdmNodeInfo(node, reason);
301:                 unsupportedNodes.add(info);
302:         }
303:
304:         public Set<VdmNodeInfo> getUnsupportedNodes()
305:         {
306:                 return unsupportedNodes;
307:         }
308:
309:         public void clearTransformationWarnings()
310:         {
311:                 transformationWarnings.clear();
312:         }
313:
314:         public void addTransformationWarning(org.overture.codegen.ir.INode node,
315:                         String warning)
316:         {
317:                 IrNodeInfo info = new IrNodeInfo(node, warning);
318:                 transformationWarnings.add(info);
319:         }
320:
321:         public Set<IrNodeInfo> getTransformationWarnings()
322:         {
323:                 return transformationWarnings;
324:         }
325:
326:         public ITempVarGen getTempVarNameGen()
327:         {
328:                 return tempVarNameGen;
329:         }
330:
331:         public void clear()
332:         {
333:                 quoteVaues.clear();
334:                 unsupportedNodes.clear();
335:                 transformationWarnings.clear();
336:                 tempVarNameGen.clear();
337:                 idStateDesignatorDefs.clear();
338:                 classes.clear();
339:                 modules.clear();
340:         }
341:
342:         public IRSettings getSettings()
343:         {
344:                 return settings;
345:         }
346:
347:         public void setSettings(IRSettings settings)
348:         {
349:                 this.settings = settings;
350:         }
351:
352:         public Map<AIdentifierStateDesignator, PDefinition> getIdStateDesignatorDefs()
353:         {
354:                 return idStateDesignatorDefs;
355:         }
356:
357:         public void setIdStateDesignatorDefs(
358:                         Map<AIdentifierStateDesignator, PDefinition> idDefs)
359:         {
360:                 this.idStateDesignatorDefs = idDefs;
361:         }
362:
363:         public List<SClassDeclIR> getClasses()
364:         {
365:                 return classes;
366:         }
367:
368:         public void addClass(SClassDeclIR irClass)
369:         {
370:•                if (this.classes != null)
371:                 {
372:                         this.classes.add(irClass);
373:                 }
374:         }
375:
376:         public void removeClass(String name)
377:         {
378:                 SClassDeclIR classToRemove = null;
379:
380:•                for (SClassDeclIR clazz : classes)
381:                 {
382:•                        if (clazz.getName().equals(name))
383:                         {
384:                                 classToRemove = clazz;
385:                                 break;
386:                         }
387:                 }
388:
389:•                if (classToRemove != null)
390:                 {
391:                         classes.remove(classToRemove);
392:                 }
393:         }
394:
395:         public void clearClasses()
396:         {
397:•                if (this.classes != null)
398:                 {
399:                         this.classes.clear();
400:                 }
401:         }
402:
403:         public List<AModuleDeclIR> getModules()
404:         {
405:                 return modules;
406:         }
407:
408:         public void addModule(AModuleDeclIR irModule)
409:         {
410:•                if (this.modules != null)
411:                 {
412:                         this.modules.add(irModule);
413:                 }
414:         }
415:
416:         public void removeModule(String name)
417:         {
418:                 AModuleDeclIR moduleToRemove = null;
419:
420:•                for (AModuleDeclIR module : modules)
421:                 {
422:•                        if (module.getName().equals(name))
423:                         {
424:                                 moduleToRemove = module;
425:                                 break;
426:                         }
427:                 }
428:
429:•                if (moduleToRemove != null)
430:                 {
431:                         modules.remove(moduleToRemove);
432:                 }
433:         }
434:
435:         public void clearModules()
436:         {
437:•                if (this.modules != null)
438:                 {
439:                         this.modules.clear();
440:                 }
441:         }
442:
443:         public void registerSlStateRead(SVarExpIR var)
444:         {
445:                 this.slStateReads.add(var);
446:         }
447:
448:         public boolean isSlStateRead(SVarExpIR var)
449:         {
450:•                for (SVarExpIR v : slStateReads)
451:                 {
452:•                        if (v == var)
453:                         {
454:                                 return true;
455:                         }
456:                 }
457:
458:                 return false;
459:         }
460:         
461:         public Set<String> getInstantiatedClasses()
462:         {
463:                 return instantiatedClasses;
464:         }
465: }