Package: StatementExpressionFinder

StatementExpressionFinder

nameinstructionbranchcomplexitylinemethod
StatementExpressionFinder(IInterpreterAssistantFactory)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
caseAAlwaysStm(AAlwaysStm, Integer)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAAnnotatedStm(AAnnotatedStm, Integer)
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%
caseAAssignmentStm(AAssignmentStm, Integer)
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%
caseAAtomicStm(AAtomicStm, Integer)
M: 26 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
caseACallObjectStm(ACallObjectStm, Integer)
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%
caseACallStm(ACallStm, Integer)
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%
caseACasesStm(ACasesStm, Integer)
M: 27 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
caseACyclesStm(ACyclesStm, Integer)
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%
caseADurationStm(ADurationStm, Integer)
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%
caseAElseIfStm(AElseIfStm, Integer)
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%
caseAExitStm(AExitStm, Integer)
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
caseAForAllStm(AForAllStm, Integer)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAForIndexStm(AForIndexStm, Integer)
M: 44 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
caseAForPatternBindStm(AForPatternBindStm, Integer)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAIfStm(AIfStm, Integer)
M: 48 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
caseALetBeStStm(ALetBeStStm, Integer)
M: 23 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
caseALetStm(ALetStm, Integer)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAReturnStm(AReturnStm, Integer)
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
caseAStartStm(AStartStm, Integer)
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%
caseAStopStm(AStopStm, Integer)
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%
caseATixeStm(ATixeStm, Integer)
M: 37 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
caseATrapStm(ATrapStm, Integer)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAWhileStm(AWhileStm, Integer)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
createNewReturnValue(INode, Integer)
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%
createNewReturnValue(Object, Integer)
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%
defaultPStm(PStm, Integer)
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%
defaultSSimpleBlockStm(SSimpleBlockStm, Integer)
M: 26 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
defaultSUnaryExp(SUnaryExp, Integer)
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%

Coverage

1: package org.overture.interpreter.utilities.statement;
2:
3: import org.overture.ast.analysis.AnalysisException;
4: import org.overture.ast.analysis.QuestionAnswerAdaptor;
5: import org.overture.ast.expressions.PExp;
6: import org.overture.ast.expressions.SUnaryExp;
7: import org.overture.ast.node.INode;
8: import org.overture.ast.statements.AAlwaysStm;
9: import org.overture.ast.statements.AAnnotatedStm;
10: import org.overture.ast.statements.AAssignmentStm;
11: import org.overture.ast.statements.AAtomicStm;
12: import org.overture.ast.statements.ACallObjectStm;
13: import org.overture.ast.statements.ACallStm;
14: import org.overture.ast.statements.ACaseAlternativeStm;
15: import org.overture.ast.statements.ACasesStm;
16: import org.overture.ast.statements.ACyclesStm;
17: import org.overture.ast.statements.ADurationStm;
18: import org.overture.ast.statements.AElseIfStm;
19: import org.overture.ast.statements.AExitStm;
20: import org.overture.ast.statements.AForAllStm;
21: import org.overture.ast.statements.AForIndexStm;
22: import org.overture.ast.statements.AForPatternBindStm;
23: import org.overture.ast.statements.AIfStm;
24: import org.overture.ast.statements.ALetBeStStm;
25: import org.overture.ast.statements.ALetStm;
26: import org.overture.ast.statements.AReturnStm;
27: import org.overture.ast.statements.AStartStm;
28: import org.overture.ast.statements.AStopStm;
29: import org.overture.ast.statements.ATixeStm;
30: import org.overture.ast.statements.ATixeStmtAlternative;
31: import org.overture.ast.statements.ATrapStm;
32: import org.overture.ast.statements.AWhileStm;
33: import org.overture.ast.statements.PStm;
34: import org.overture.ast.statements.SSimpleBlockStm;
35: import org.overture.interpreter.assistant.IInterpreterAssistantFactory;
36:
37: /***************************************
38: * This method finds an Expression in a statement.
39: *
40: * @author gkanos
41: ****************************************/
42:
43: public class StatementExpressionFinder extends
44:                 QuestionAnswerAdaptor<Integer, PExp>
45: {
46:         protected static IInterpreterAssistantFactory af;
47:
48:         @SuppressWarnings("static-access")
49:         public StatementExpressionFinder(IInterpreterAssistantFactory af)
50:         {
51:                 this.af = af;
52:         }
53:         
54:         @Override
55:         public PExp caseAAnnotatedStm(AAnnotatedStm node, Integer question)        throws AnalysisException
56:         {
57:                 return node.getStmt().apply(THIS, question);
58:         }
59:         
60:         @Override
61:         public PExp caseAAlwaysStm(AAlwaysStm stm, Integer lineno)
62:                         throws AnalysisException
63:         {
64:                 PExp found = stm.getAlways().apply(THIS, lineno);
65:•                if (found != null)
66:                 {
67:                         return found;
68:                 }
69:
70:                 return stm.getBody().apply(THIS, lineno);
71:         }
72:
73:         @Override
74:         public PExp caseAAssignmentStm(AAssignmentStm stm, Integer lineno)
75:                         throws AnalysisException
76:         {
77:                 return af.createPExpAssistant().findExpression(stm.getExp(), lineno);
78:         }
79:
80:         @Override
81:         public PExp caseAAtomicStm(AAtomicStm stm, Integer lineno)
82:                         throws AnalysisException
83:         {
84:                 PExp found = null;
85:
86:•                for (AAssignmentStm stmt : stm.getAssignments())
87:                 {
88:                         found = stmt.apply(THIS, lineno);
89:•                        if (found != null)
90:                         {
91:                                 break;
92:                         }
93:                 }
94:
95:                 return found;
96:         }
97:
98:         @Override
99:         public PExp caseACallStm(ACallStm stm, Integer lineno)
100:                         throws AnalysisException
101:         {
102:                 return af.createPExpAssistant().findExpression(stm.getArgs(), lineno);
103:         }
104:
105:         @Override
106:         public PExp caseACallObjectStm(ACallObjectStm stm, Integer lineno)
107:                         throws AnalysisException
108:         {
109:                 return af.createPExpAssistant().findExpression(stm.getArgs(), lineno);
110:         }
111:
112:         @Override
113:         public PExp caseACasesStm(ACasesStm stm, Integer lineno)
114:                         throws AnalysisException
115:         {
116:                 PExp found = null;
117:
118:•                for (ACaseAlternativeStm stmt : stm.getCases())
119:                 {
120:                         found = stmt.getResult().apply(THIS, lineno);
121:•                        if (found != null)
122:                         {
123:                                 break;
124:                         }
125:                 }
126:
127:                 return found;
128:         }
129:
130:         @Override
131:         public PExp caseACyclesStm(ACyclesStm stm, Integer lineno)
132:                         throws AnalysisException
133:         {
134:                 return stm.getStatement().apply(THIS, lineno);
135:         }
136:
137:         @Override
138:         public PExp caseADurationStm(ADurationStm stm, Integer lineno)
139:                         throws AnalysisException
140:         {
141:                 return stm.getStatement().apply(THIS, lineno);
142:
143:         }
144:
145:         @Override
146:         public PExp caseAElseIfStm(AElseIfStm stm, Integer lineno)
147:                         throws AnalysisException
148:         {
149:                 return af.createPExpAssistant().findExpression(stm.getElseIf(), lineno);
150:         }
151:
152:         @Override
153:         public PExp caseAExitStm(AExitStm stm, Integer lineno)
154:                         throws AnalysisException
155:         {
156:•                return stm.getExpression() == null ? null
157:                                 : af.createPExpAssistant().findExpression(stm.getExpression(), lineno);
158:         }
159:
160:         @Override
161:         public PExp caseAForAllStm(AForAllStm stm, Integer lineno)
162:                         throws AnalysisException
163:         {
164:                 PExp found = af.createPExpAssistant().findExpression(stm.getSet(), lineno);
165:•                if (found != null)
166:                 {
167:                         return found;
168:                 }
169:                 return stm.getStatement().apply(THIS, lineno);
170:         }
171:
172:         @Override
173:         public PExp caseAForIndexStm(AForIndexStm stm, Integer lineno)
174:                         throws AnalysisException
175:         {
176:                 PExp found = af.createPExpAssistant().findExpression(stm.getFrom(), lineno);
177:•                if (found != null)
178:                 {
179:                         return found;
180:                 }
181:                 found = stm.getTo().apply(THIS, lineno);
182:•                if (found != null)
183:                 {
184:                         return found;
185:                 }
186:                 found = af.createPExpAssistant().findExpression(stm.getBy(), lineno);
187:•                if (found != null)
188:                 {
189:                         return found;
190:                 }
191:                 return stm.getStatement().apply(THIS, lineno);
192:         }
193:
194:         @Override
195:         public PExp caseAForPatternBindStm(AForPatternBindStm stm, Integer lineno)
196:                         throws AnalysisException
197:         {
198:                 PExp found = af.createPExpAssistant().findExpression(stm.getExp(), lineno);
199:•                if (found != null)
200:                 {
201:                         return found;
202:                 }
203:                 return stm.getStatement().apply(THIS, lineno);
204:         }
205:
206:         @Override
207:         public PExp caseAIfStm(AIfStm stm, Integer lineno) throws AnalysisException
208:         {
209:                 PExp found = stm.getThenStm().apply(THIS, lineno);
210:•                if (found != null)
211:                 {
212:                         return found;
213:                 }
214:
215:•                for (AElseIfStm stmt : stm.getElseIf())
216:                 {
217:                         found = stmt.apply(THIS, lineno);
218:•                        if (found != null)
219:                         {
220:                                 return found;
221:                         }
222:                 }
223:
224:•                if (stm.getElseStm() != null)
225:                 {
226:                         found = stm.getElseStm().apply(THIS, lineno);
227:                 }
228:
229:                 return found;
230:         }
231:
232:         @Override
233:         public PExp caseALetBeStStm(ALetBeStStm stm, Integer lineno)
234:                         throws AnalysisException
235:         {
236:•                if (stm.getSuchThat() != null)
237:                 {
238:                         PExp found = af.createPExpAssistant().findExpression(stm.getSuchThat(), lineno);
239:•                        if (found != null)
240:                         {
241:                                 return found;
242:                         }
243:                 }
244:
245:                 return stm.getStatement().apply(THIS, lineno);
246:         }
247:
248:         @Override
249:         public PExp caseALetStm(ALetStm stm, Integer lineno)
250:                         throws AnalysisException
251:         {
252:                 PExp found = af.createPDefinitionListAssistant().findExpression(stm.getLocalDefs(), lineno);
253:•                if (found != null)
254:                 {
255:                         return found;
256:                 }
257:
258:                 return stm.getStatement().apply(THIS, lineno);
259:         }
260:
261:         @Override
262:         public PExp caseAReturnStm(AReturnStm stm, Integer lineno)
263:                         throws AnalysisException
264:         {
265:•                return stm.getExpression() == null ? null
266:                                 : af.createPExpAssistant().findExpression(stm.getExpression(), lineno);
267:         }
268:
269:         @Override
270:         public PExp defaultSSimpleBlockStm(SSimpleBlockStm stm, Integer lineno)
271:                         throws AnalysisException
272:         {
273:                 PExp found = null;
274:
275:•                for (PStm stmt : stm.getStatements())
276:                 {
277:                         found = stmt.apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(stmt, lineno);
278:•                        if (found != null)
279:                         {
280:                                 break;
281:                         }
282:                 }
283:
284:                 return found;
285:         }
286:
287:         @Override
288:         public PExp caseAStartStm(AStartStm stm, Integer lineno)
289:                         throws AnalysisException
290:         {
291:                 return af.createPExpAssistant().findExpression(stm.getObj(), lineno);
292:         }
293:
294:         @Override
295:         public PExp caseAStopStm(AStopStm stm, Integer lineno)
296:                         throws AnalysisException
297:         {
298:                 return af.createPExpAssistant().findExpression(stm.getObj(), lineno);
299:         }
300:
301:         @Override
302:         public PExp caseATixeStm(ATixeStm stm, Integer lineno)
303:                         throws AnalysisException
304:         {
305:                 PExp found = stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(stm.getBody(),
306:                                                                                                                 // lineno);
307:•                if (found != null)
308:                 {
309:                         return found;
310:                 }
311:
312:•                for (ATixeStmtAlternative tsa : stm.getTraps())
313:                 {
314:                         found = tsa.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(tsa.getStatement(),
315:                                                                                                                         // lineno);
316:•                        if (found != null)
317:                         {
318:                                 break;
319:                         }
320:                 }
321:
322:                 return found;
323:         }
324:
325:         @Override
326:         public PExp caseATrapStm(ATrapStm stm, Integer lineno)
327:                         throws AnalysisException
328:         {
329:                 PExp found = stm.getBody().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(stm.getBody(),
330:                                                                                                                 // lineno);
331:•                if (found != null)
332:                 {
333:                         return found;
334:                 }
335:                 return stm.getWith().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(stm.getWith(), lineno);
336:         }
337:
338:         @Override
339:         public PExp caseAWhileStm(AWhileStm stm, Integer lineno)
340:                         throws AnalysisException
341:         {
342:                 PExp found = af.createPExpAssistant().findExpression(stm.getExp(), lineno);
343:•                if (found != null)
344:                 {
345:                         return found;
346:                 }
347:                 return stm.getStatement().apply(THIS, lineno);// PStmAssistantInterpreter.findExpression(stm.getStatement(),
348:                                                                                                                 // lineno);
349:         }
350:
351:         @Override
352:         public PExp defaultPStm(PStm stm, Integer lineno) throws AnalysisException
353:         {
354:                 return null;
355:         }
356:         
357:         @Override
358:         public PExp defaultSUnaryExp(SUnaryExp node, Integer question) throws AnalysisException
359:         {
360:                 return node.getExp().apply(THIS, question);
361:         }
362:
363:         @Override
364:         public PExp createNewReturnValue(INode node, Integer question)
365:                         throws AnalysisException
366:         {
367:                 // TODO Auto-generated method stub
368:                 return null;
369:         }
370:
371:         @Override
372:         public PExp createNewReturnValue(Object node, Integer question)
373:                         throws AnalysisException
374:         {
375:                 // TODO Auto-generated method stub
376:                 return null;
377:         }
378:
379: }