Package: ExpressionFinder

ExpressionFinder

nameinstructionbranchcomplexitylinemethod
ExpressionFinder(IInterpreterAssistantFactory)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
caseAAssignmentDefinition(AAssignmentDefinition, Integer)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAClassInvariantDefinition(AClassInvariantDefinition, Integer)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAEqualsDefinition(AEqualsDefinition, Integer)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAExplicitFunctionDefinition(AExplicitFunctionDefinition, Integer)
M: 39 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
caseAExplicitOperationDefinition(AExplicitOperationDefinition, Integer)
M: 39 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
caseAImplicitFunctionDefinition(AImplicitFunctionDefinition, Integer)
M: 44 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
caseAImplicitOperationDefinition(AImplicitOperationDefinition, Integer)
M: 70 C: 0
0%
M: 16 C: 0
0%
M: 9 C: 0
0%
M: 16 C: 0
0%
M: 1 C: 0
0%
caseAInstanceVariableDefinition(AInstanceVariableDefinition, Integer)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAPerSyncDefinition(APerSyncDefinition, Integer)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseAStateDefinition(AStateDefinition, Integer)
M: 42 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
caseAThreadDefinition(AThreadDefinition, Integer)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseATypeDefinition(ATypeDefinition, Integer)
M: 97 C: 0
0%
M: 28 C: 0
0%
M: 15 C: 0
0%
M: 21 C: 0
0%
M: 1 C: 0
0%
caseAValueDefinition(AValueDefinition, Integer)
M: 9 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, 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%
defaultPDefinition(PDefinition, 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%
defaultSClassDefinition(SClassDefinition, 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.definition;
2:
3: import org.overture.ast.analysis.AnalysisException;
4: import org.overture.ast.analysis.QuestionAnswerAdaptor;
5: import org.overture.ast.definitions.AAssignmentDefinition;
6: import org.overture.ast.definitions.AClassInvariantDefinition;
7: import org.overture.ast.definitions.AEqualsDefinition;
8: import org.overture.ast.definitions.AExplicitFunctionDefinition;
9: import org.overture.ast.definitions.AExplicitOperationDefinition;
10: import org.overture.ast.definitions.AImplicitFunctionDefinition;
11: import org.overture.ast.definitions.AImplicitOperationDefinition;
12: import org.overture.ast.definitions.AInstanceVariableDefinition;
13: import org.overture.ast.definitions.APerSyncDefinition;
14: import org.overture.ast.definitions.AStateDefinition;
15: import org.overture.ast.definitions.AThreadDefinition;
16: import org.overture.ast.definitions.ATypeDefinition;
17: import org.overture.ast.definitions.AValueDefinition;
18: import org.overture.ast.definitions.PDefinition;
19: import org.overture.ast.definitions.SClassDefinition;
20: import org.overture.ast.expressions.AEqualsBinaryExp;
21: import org.overture.ast.expressions.PExp;
22: import org.overture.ast.node.INode;
23: import org.overture.ast.statements.AErrorCase;
24: import org.overture.interpreter.assistant.IInterpreterAssistantFactory;
25:
26: /***************************************
27: * This method finds a expession within a definition.
28: *
29: * @author gkanos
30: ****************************************/
31: public class ExpressionFinder extends QuestionAnswerAdaptor<Integer, PExp>
32: {
33:         protected IInterpreterAssistantFactory af;
34:
35:         public ExpressionFinder(IInterpreterAssistantFactory af)
36:         {
37:                 this.af = af;
38:         }
39:
40:         @Override
41:         public PExp caseAAssignmentDefinition(AAssignmentDefinition def,
42:                         Integer lineno) throws AnalysisException
43:         {
44:                 return af.createPExpAssistant().findExpression(def.getExpression(), lineno);
45:
46:         }
47:
48:         @Override
49:         public PExp caseAClassInvariantDefinition(AClassInvariantDefinition def,
50:                         Integer lineno) throws AnalysisException
51:         {
52:                 return af.createPExpAssistant().findExpression(def.getExpression(), lineno);
53:
54:         }
55:
56:         @Override
57:         public PExp defaultSClassDefinition(SClassDefinition def, Integer lineno)
58:                         throws AnalysisException
59:         {
60:                 return af.createSClassDefinitionAssistant().findExpression(def, lineno);
61:         }
62:
63:         @Override
64:         public PExp caseAEqualsDefinition(AEqualsDefinition def, Integer lineno)
65:                         throws AnalysisException
66:         {
67:                 return af.createPExpAssistant().findExpression(def.getTest(), lineno);
68:
69:         }
70:
71:         @Override
72:         public PExp caseAExplicitFunctionDefinition(
73:                         AExplicitFunctionDefinition def, Integer lineno)
74:                         throws AnalysisException
75:         {
76:•                if (def.getPredef() != null)
77:                 {
78:                         PExp found = def.getPredef().apply(THIS, lineno);
79:•                        if (found != null)
80:                         {
81:                                 return found;
82:                         }
83:                 }
84:
85:•                if (def.getPostdef() != null)
86:                 {
87:                         PExp found = def.getPostdef().apply(THIS, lineno);
88:•                        if (found != null)
89:                         {
90:                                 return found;
91:                         }
92:                 }
93:
94:                 return af.createPExpAssistant().findExpression(def.getBody(), lineno);
95:
96:         }
97:
98:         @Override
99:         public PExp caseAExplicitOperationDefinition(
100:                         AExplicitOperationDefinition def, Integer lineno)
101:                         throws AnalysisException
102:         {
103:•                if (def.getPredef() != null)
104:                 {
105:                         PExp found = def.getPredef().apply(THIS, lineno);
106:•                        if (found != null)
107:                         {
108:                                 return found;
109:                         }
110:                 }
111:
112:•                if (def.getPostdef() != null)
113:                 {
114:                         PExp found = def.getPostdef().apply(THIS, lineno);
115:•                        if (found != null)
116:                         {
117:                                 return found;
118:                         }
119:                 }
120:
121:                 return af.createPStmAssistant().findExpression(def.getBody(), lineno);
122:         }
123:
124:         @Override
125:         public PExp caseAImplicitFunctionDefinition(
126:                         AImplicitFunctionDefinition def, Integer lineno)
127:                         throws AnalysisException
128:         {
129:•                if (def.getPredef() != null)
130:                 {
131:                         PExp found = def.getPredef().apply(THIS, lineno);
132:•                        if (found != null)
133:                         {
134:                                 return found;
135:                         }
136:                 }
137:
138:•                if (def.getPostdef() != null)
139:                 {
140:                         PExp found = def.getPostdef().apply(THIS, lineno);
141:•                        if (found != null)
142:                         {
143:                                 return found;
144:                         }
145:                 }
146:•                return def.getBody() == null ? null
147:                                 : af.createPExpAssistant().findExpression(def.getBody(), lineno);
148:         }
149:
150:         @Override
151:         public PExp caseAImplicitOperationDefinition(
152:                         AImplicitOperationDefinition def, Integer lineno)
153:                         throws AnalysisException
154:         {
155:•                if (def.getPredef() != null)
156:                 {
157:                         PExp found = def.getPredef().apply(THIS, lineno);
158:•                        if (found != null)
159:                         {
160:                                 return found;
161:                         }
162:                 }
163:
164:•                if (def.getPostdef() != null)
165:                 {
166:                         PExp found = def.getPostdef().apply(THIS, lineno);
167:•                        if (found != null)
168:                         {
169:                                 return found;
170:                         }
171:                 }
172:
173:•                if (def.getErrors() != null)
174:                 {
175:•                        for (AErrorCase err : def.getErrors())
176:                         {
177:                                 PExp found = err.apply(THIS, lineno);// AErrorCaseAssistantInterpreter.findExpression(err, lineno);
178:•                                if (found != null)
179:                                 {
180:                                         return found;
181:                                 }
182:                         }
183:                 }
184:
185:•                return def.getBody() == null ? null
186:                                 : af.createPStmAssistant().findExpression(def.getBody(), lineno);
187:         }
188:
189:         @Override
190:         public PExp caseAInstanceVariableDefinition(
191:                         AInstanceVariableDefinition def, Integer lineno)
192:                         throws AnalysisException
193:         {
194:                 return af.createPExpAssistant().findExpression(def.getExpression(), lineno);
195:         }
196:
197:         @Override
198:         public PExp caseAPerSyncDefinition(APerSyncDefinition def, Integer lineno)
199:                         throws AnalysisException
200:         {
201:                 return af.createPExpAssistant().findExpression(def.getGuard(), lineno);
202:         }
203:
204:         @Override
205:         public PExp caseAStateDefinition(AStateDefinition def, Integer lineno)
206:                         throws AnalysisException
207:         {
208:•                if (def.getInvExpression() != null)
209:                 {
210:                         PExp found = af.createPExpAssistant().findExpression(def.getInvExpression(), lineno);
211:•                        if (found != null)
212:                         {
213:                                 return found;
214:                         }
215:                 }
216:
217:•                if (def.getInitExpression() != null)
218:                 {
219:•                        if (def.getInitExpression() instanceof AEqualsBinaryExp)
220:                         {
221:                                 AEqualsBinaryExp ee = (AEqualsBinaryExp) def.getInitExpression();
222:                                 PExp found = af.createPExpAssistant().findExpression(ee.getRight(), lineno);
223:•                                if (found != null)
224:                                 {
225:                                         return found;
226:                                 }
227:                         }
228:                 }
229:
230:                 return null;
231:         }
232:
233:         @Override
234:         public PExp caseAThreadDefinition(AThreadDefinition def, Integer lineno)
235:                         throws AnalysisException
236:         {
237:                 return af.createPStmAssistant().findExpression(def.getStatement(), lineno);
238:         }
239:
240:         @Override
241:         public PExp caseATypeDefinition(ATypeDefinition def, Integer lineno)
242:                         throws AnalysisException
243:         {
244:•                if (def.getInvdef() != null)
245:                 {
246:                         PExp found = def.getInvdef().apply(THIS, lineno);
247:•                        if (found != null)
248:                         {
249:                                 return found;
250:                         }
251:                 }
252:
253:•                if (def.getEqRelation() != null && def.getEqRelation().getRelDef() != null)
254:                 {
255:                         PExp found = def.getEqRelation().getRelDef().apply(THIS, lineno);
256:•                        if (found != null)
257:                         {
258:                                 return found;
259:                         }
260:                 }
261:
262:•                if (def.getOrdRelation() != null && def.getOrdRelation().getRelDef() != null)
263:                 {
264:                         PExp found = def.getOrdRelation().getRelDef().apply(THIS, lineno);
265:•                        if (found != null)
266:                         {
267:                                 return found;
268:                         }
269:                 }
270:
271:•                if (def.getOrdRelation() != null && def.getOrdRelation().getMinDef() != null)
272:                 {
273:                         PExp found = def.getOrdRelation().getMinDef().apply(THIS, lineno);
274:•                        if (found != null)
275:                         {
276:                                 return found;
277:                         }
278:                 }
279:
280:•                if (def.getOrdRelation() != null && def.getOrdRelation().getMaxDef() != null)
281:                 {
282:                         PExp found = def.getOrdRelation().getMaxDef().apply(THIS, lineno);
283:•                        if (found != null)
284:                         {
285:                                 return found;
286:                         }
287:                 }
288:
289:                 return null;
290:         }
291:
292:         @Override
293:         public PExp caseAValueDefinition(AValueDefinition def, Integer lineno)
294:                         throws AnalysisException
295:         {
296:                 return af.createPExpAssistant().findExpression(def.getExpression(), lineno);
297:         }
298:
299:         @Override
300:         public PExp defaultPDefinition(PDefinition node, Integer question)
301:                         throws AnalysisException
302:         {
303:                 return null;
304:         }
305:
306:         @Override
307:         public PExp createNewReturnValue(INode node, Integer question)
308:                         throws AnalysisException
309:         {
310:                 // TODO Auto-generated method stub
311:                 return null;
312:         }
313:
314:         @Override
315:         public PExp createNewReturnValue(Object node, Integer question)
316:                         throws AnalysisException
317:         {
318:                 // TODO Auto-generated method stub
319:                 return null;
320:         }
321:
322: }