Package: NamedValueLister

NamedValueLister

nameinstructionbranchcomplexitylinemethod
NamedValueLister(IInterpreterAssistantFactory)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAAssignmentDefinition(AAssignmentDefinition, Context)
M: 12 C: 28
70%
M: 2 C: 2
50%
M: 1 C: 2
67%
M: 4 C: 4
50%
M: 0 C: 1
100%
caseAEqualsDefinition(AEqualsDefinition, Context)
M: 113 C: 83
42%
M: 16 C: 6
27%
M: 9 C: 3
25%
M: 27 C: 16
37%
M: 0 C: 1
100%
caseAExplicitFunctionDefinition(AExplicitFunctionDefinition, Context)
M: 16 C: 131
89%
M: 1 C: 19
95%
M: 1 C: 10
91%
M: 1 C: 20
95%
M: 0 C: 1
100%
caseAExplicitOperationDefinition(AExplicitOperationDefinition, Context)
M: 0 C: 109
100%
M: 0 C: 8
100%
M: 0 C: 5
100%
M: 0 C: 16
100%
M: 0 C: 1
100%
caseAImplicitFunctionDefinition(AImplicitFunctionDefinition, Context)
M: 28 C: 118
81%
M: 6 C: 14
70%
M: 5 C: 6
55%
M: 1 C: 20
95%
M: 0 C: 1
100%
caseAImplicitOperationDefinition(AImplicitOperationDefinition, Context)
M: 0 C: 109
100%
M: 0 C: 8
100%
M: 0 C: 5
100%
M: 0 C: 16
100%
M: 0 C: 1
100%
caseAImportedDefinition(AImportedDefinition, Context)
M: 40 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
caseAInheritedDefinition(AInheritedDefinition, Context)
M: 16 C: 41
72%
M: 3 C: 3
50%
M: 2 C: 2
50%
M: 2 C: 6
75%
M: 0 C: 1
100%
caseAInstanceVariableDefinition(AInstanceVariableDefinition, Context)
M: 13 C: 28
68%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 6 C: 4
40%
M: 0 C: 1
100%
caseALocalDefinition(ALocalDefinition, Context)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseARenamedDefinition(ARenamedDefinition, Context)
M: 0 C: 40
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
caseAThreadDefinition(AThreadDefinition, Context)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseATypeDefinition(ATypeDefinition, Context)
M: 100 C: 40
29%
M: 12 C: 6
33%
M: 8 C: 2
20%
M: 8 C: 9
53%
M: 0 C: 1
100%
caseAUntypedDefinition(AUntypedDefinition, Context)
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
caseAValueDefinition(AValueDefinition, Context)
M: 15 C: 30
67%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 6 C: 4
40%
M: 0 C: 1
100%
createNewReturnValue(INode, Context)
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, Context)
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, Context)
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%
static {...}
M: 2 C: 6
75%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
100%
M: 0 C: 1
100%

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.AEqualsDefinition;
7: import org.overture.ast.definitions.AExplicitFunctionDefinition;
8: import org.overture.ast.definitions.AExplicitOperationDefinition;
9: import org.overture.ast.definitions.AImplicitFunctionDefinition;
10: import org.overture.ast.definitions.AImplicitOperationDefinition;
11: import org.overture.ast.definitions.AImportedDefinition;
12: import org.overture.ast.definitions.AInheritedDefinition;
13: import org.overture.ast.definitions.AInstanceVariableDefinition;
14: import org.overture.ast.definitions.ALocalDefinition;
15: import org.overture.ast.definitions.ARenamedDefinition;
16: import org.overture.ast.definitions.AThreadDefinition;
17: import org.overture.ast.definitions.ATypeDefinition;
18: import org.overture.ast.definitions.AUntypedDefinition;
19: import org.overture.ast.definitions.AValueDefinition;
20: import org.overture.ast.definitions.PDefinition;
21: import org.overture.ast.lex.Dialect;
22: import org.overture.ast.node.INode;
23: import org.overture.config.Settings;
24: import org.overture.interpreter.assistant.IInterpreterAssistantFactory;
25: import org.overture.interpreter.runtime.Context;
26: import org.overture.interpreter.runtime.PatternMatchException;
27: import org.overture.interpreter.runtime.ValueException;
28: import org.overture.interpreter.runtime.VdmRuntime;
29: import org.overture.interpreter.runtime.VdmRuntimeError;
30: import org.overture.interpreter.values.FunctionValue;
31: import org.overture.interpreter.values.NameValuePair;
32: import org.overture.interpreter.values.NameValuePairList;
33: import org.overture.interpreter.values.OperationValue;
34: import org.overture.interpreter.values.Value;
35: import org.overture.interpreter.values.ValueList;
36: import org.overture.interpreter.values.ValueSet;
37:
38: /***************************************
39: * @author gkanos
40: ****************************************/
41:•public class NamedValueLister extends
42:                 QuestionAnswerAdaptor<Context, NameValuePairList>
43: {
44:         protected IInterpreterAssistantFactory af;
45:
46:         public NamedValueLister(IInterpreterAssistantFactory af)
47:         {
48:                 this.af = af;
49:         }
50:
51:         @Override
52:         public NameValuePairList caseAAssignmentDefinition(
53:                         AAssignmentDefinition def, Context initialContext)
54:                         throws AnalysisException
55:         {
56:                 try
57:                 {
58:                         Value v = def.getExpression().apply(VdmRuntime.getExpressionEvaluator(), initialContext);
59:
60:•                        if (!v.isUndefined())
61:                         {
62:                                 v = v.convertTo(def.getType(), initialContext);
63:                         }
64:
65:                         return new NameValuePairList(new NameValuePair(def.getName(), v.getUpdatable(null)));
66:                 } catch (AnalysisException e)
67:                 {
68:•                        if (e instanceof ValueException)
69:                         {
70:                                 VdmRuntimeError.abort(def.getLocation(), (ValueException) e);
71:                         }
72:                         return null;
73:                 }
74:         }
75:
76:         @Override
77:         public NameValuePairList caseAEqualsDefinition(AEqualsDefinition def,
78:                         Context initialContext) throws AnalysisException
79:         {
80:                 Value v;
81:                 try
82:                 {
83:                         v = def.getTest().apply(VdmRuntime.getExpressionEvaluator(), initialContext);
84:                 } catch (AnalysisException e1)
85:                 {
86:•                        if (e1 instanceof ValueException)
87:                         {
88:                                 VdmRuntimeError.abort(def.getLocation(), (ValueException) e1);
89:                         }
90:                         return null;
91:                 }
92:
93:                 NameValuePairList nvpl = null;
94:
95:•                if (def.getPattern() != null)
96:                 {
97:                         try
98:                         {
99:                                 nvpl = af.createPPatternAssistant(def.getLocation().getModule()).getNamedValues(def.getPattern(), v, initialContext);
100:                         } catch (PatternMatchException e)
101:                         {
102:                                 VdmRuntimeError.abort(e, initialContext);
103:                         }
104:                 }
105:•                else if (def.getTypebind() != null)
106:                 {
107:                         try
108:                         {
109:                                 Value converted = v.convertTo(def.getTypebind().getType(), initialContext);
110:                                 nvpl = af.createPPatternAssistant(def.getLocation().getModule()).getNamedValues(def.getTypebind().getPattern(), converted, initialContext);
111:                         } catch (PatternMatchException e)
112:                         {
113:                                 VdmRuntimeError.abort(e, initialContext);
114:                         } catch (ValueException e)
115:                         {
116:                                 VdmRuntimeError.abort(def.getLocation(), e);
117:                         }
118:                 }
119:•                else if (def.getSetbind() != null)
120:                 {
121:                         try
122:                         {
123:                                 ValueSet set = def.getSetbind().getSet().apply(VdmRuntime.getExpressionEvaluator(), initialContext).setValue(initialContext);
124:
125:•                                if (!set.contains(v))
126:                                 {
127:                                         VdmRuntimeError.abort(def.getLocation(), 4002, "Expression value is not in set bind", initialContext);
128:                                 }
129:
130:                                 nvpl = af.createPPatternAssistant(def.getLocation().getModule()).getNamedValues(def.getSetbind().getPattern(), v, initialContext);
131:                         }
132:                         catch (AnalysisException e)
133:                         {
134:•                                if (e instanceof PatternMatchException)
135:                                 {
136:                                         VdmRuntimeError.abort((PatternMatchException) e, initialContext);
137:                                 }
138:
139:•                                if (e instanceof ValueException)
140:                                 {
141:                                         VdmRuntimeError.abort(def.getLocation(), (ValueException) e);
142:                                 }
143:                         }
144:                 }
145:•                else if (def.getSeqbind() != null)
146:                 {
147:                         try
148:                         {
149:                                 ValueList seq = def.getSeqbind().getSeq().apply(VdmRuntime.getExpressionEvaluator(), initialContext).seqValue(initialContext);
150:
151:•                                if (!seq.contains(v))
152:                                 {
153:                                         VdmRuntimeError.abort(def.getLocation(), 4002, "Expression value is not in seq bind", initialContext);
154:                                 }
155:
156:                                 nvpl = af.createPPatternAssistant(def.getLocation().getModule()).getNamedValues(def.getSeqbind().getPattern(), v, initialContext);
157:                         }
158:                         catch (AnalysisException e)
159:                         {
160:•                                if (e instanceof PatternMatchException)
161:                                 {
162:                                         VdmRuntimeError.abort((PatternMatchException) e, initialContext);
163:                                 }
164:
165:•                                if (e instanceof ValueException)
166:                                 {
167:                                         VdmRuntimeError.abort(def.getLocation(), (ValueException) e);
168:                                 }
169:                         }
170:                 }
171:
172:                 return nvpl;
173:         }
174:
175:         @Override
176:         public NameValuePairList caseAExplicitFunctionDefinition(
177:                         AExplicitFunctionDefinition def, Context initialContext)
178:                         throws AnalysisException
179:         {
180:                 NameValuePairList nvl = new NameValuePairList();
181:                 Context free = initialContext.getVisibleVariables();
182:
183:•                FunctionValue prefunc = def.getPredef() == null ? null
184:                                 : new FunctionValue(def.getPredef(), null, null, free);
185:
186:•                FunctionValue postfunc = def.getPostdef() == null ? null
187:                                 : new FunctionValue(def.getPostdef(), null, null, free);
188:
189:                 FunctionValue func = new FunctionValue(def, prefunc, postfunc, free);
190:                 func.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess());
191:•                func.uninstantiated = !def.getTypeParams().isEmpty();
192:                 nvl.add(new NameValuePair(def.getName(), func));
193:
194:•                if (def.getPredef() != null)
195:                 {
196:                         nvl.add(new NameValuePair(def.getPredef().getName(), prefunc));
197:•                        prefunc.uninstantiated = !def.getTypeParams().isEmpty();
198:                 }
199:
200:•                if (def.getPostdef() != null)
201:                 {
202:                         nvl.add(new NameValuePair(def.getPostdef().getName(), postfunc));
203:•                        postfunc.uninstantiated = !def.getTypeParams().isEmpty();
204:                 }
205:                 
206:•                if (def.getMeasureDef() != null && def.getMeasureDef().getName().toString().startsWith("measure_"))
207:                 {
208:                         nvl.add(new NameValuePair(def.getMeasureName(), new FunctionValue(def.getMeasureDef(), null, null, null)));
209:                 }
210:
211:•                if (Settings.dialect == Dialect.VDM_SL)
212:                 {
213:                         // This is needed for recursive local functions
214:                         free.putList(nvl);
215:                 }
216:
217:                 return nvl;
218:         }
219:
220:         @Override
221:         public NameValuePairList caseAExplicitOperationDefinition(
222:                         AExplicitOperationDefinition def, Context initialContext)
223:                         throws AnalysisException
224:         {
225:                 NameValuePairList nvl = new NameValuePairList();
226:
227:•                FunctionValue prefunc = def.getPredef() == null ? null
228:                                 : new FunctionValue(def.getPredef(), null, null, null);
229:
230:•                FunctionValue postfunc = def.getPostdef() == null ? null
231:                                 : new FunctionValue(def.getPostdef(), null, null, null);
232:
233:                 OperationValue op = new OperationValue(def, prefunc, postfunc, def.getState(), af);
234:                 op.isConstructor = def.getIsConstructor();
235:                 op.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess());
236:                 nvl.add(new NameValuePair(def.getName(), op));
237:
238:•                if (def.getPredef() != null)
239:                 {
240:                         prefunc.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess());
241:                         nvl.add(new NameValuePair(def.getPredef().getName(), prefunc));
242:                 }
243:
244:•                if (def.getPostdef() != null)
245:                 {
246:                         postfunc.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess());
247:                         nvl.add(new NameValuePair(def.getPostdef().getName(), postfunc));
248:                 }
249:
250:                 return nvl;
251:         }
252:
253:         @Override
254:         public NameValuePairList caseAImplicitFunctionDefinition(
255:                         AImplicitFunctionDefinition def, Context initialContext)
256:                         throws AnalysisException
257:         {
258:                 NameValuePairList nvl = new NameValuePairList();
259:                 Context free = initialContext.getVisibleVariables();
260:
261:•                FunctionValue prefunc = def.getPredef() == null ? null
262:                                 : new FunctionValue(def.getPredef(), null, null, free);
263:
264:•                FunctionValue postfunc = def.getPostdef() == null ? null
265:                                 : new FunctionValue(def.getPostdef(), null, null, free);
266:
267:                 // Note, body may be null if it is really implicit. This is caught
268:                 // when the function is invoked. The value is needed to implement
269:                 // the pre_() expression for implicit functions.
270:
271:                 FunctionValue func = new FunctionValue(def, prefunc, postfunc, free);
272:                 func.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess());
273:•                func.uninstantiated = !def.getTypeParams().isEmpty();
274:                 nvl.add(new NameValuePair(def.getName(), func));
275:
276:•                if (def.getPredef() != null)
277:                 {
278:                         nvl.add(new NameValuePair(def.getPredef().getName(), prefunc));
279:•                        prefunc.uninstantiated = !def.getTypeParams().isEmpty();
280:                 }
281:
282:•                if (def.getPostdef() != null)
283:                 {
284:                         nvl.add(new NameValuePair(def.getPostdef().getName(), postfunc));
285:•                        postfunc.uninstantiated = !def.getTypeParams().isEmpty();
286:                 }
287:                 
288:•                if (def.getMeasureDef() != null && def.getMeasureName().toString().startsWith("measure_"))
289:                 {
290:                         nvl.add(new NameValuePair(def.getMeasureName(), new FunctionValue(def.getMeasureDef(), null, null, null)));
291:                 }
292:
293:•                if (Settings.dialect == Dialect.VDM_SL)
294:                 {
295:                         // This is needed for recursive local functions
296:                         free.putList(nvl);
297:                 }
298:
299:                 return nvl;
300:         }
301:
302:         @Override
303:         public NameValuePairList caseAImplicitOperationDefinition(
304:                         AImplicitOperationDefinition def, Context initialContext)
305:                         throws AnalysisException
306:         {
307:                 NameValuePairList nvl = new NameValuePairList();
308:
309:•                FunctionValue prefunc = def.getPredef() == null ? null
310:                                 : new FunctionValue(def.getPredef(), null, null, null);
311:
312:•                FunctionValue postfunc = def.getPostdef() == null ? null
313:                                 : new FunctionValue(def.getPostdef(), null, null, null);
314:
315:                 // Note, body may be null if it is really implicit. This is caught
316:                 // when the function is invoked. The value is needed to implement
317:                 // the pre_() expression for implicit functions.
318:
319:                 OperationValue op = new OperationValue(def, prefunc, postfunc, def.getState(), af);
320:                 op.isConstructor = def.getIsConstructor();
321:                 op.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess());
322:                 nvl.add(new NameValuePair(def.getName(), op));
323:
324:•                if (def.getPredef() != null)
325:                 {
326:                         prefunc.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess());
327:                         nvl.add(new NameValuePair(def.getPredef().getName(), prefunc));
328:                 }
329:
330:•                if (def.getPostdef() != null)
331:                 {
332:                         postfunc.isStatic = af.createPAccessSpecifierAssistant().isStatic(def.getAccess());
333:                         nvl.add(new NameValuePair(def.getPostdef().getName(), postfunc));
334:                 }
335:
336:                 return nvl;
337:         }
338:
339:         @Override
340:         public NameValuePairList caseAImportedDefinition(AImportedDefinition def,
341:                         Context initialContext) throws AnalysisException
342:         {
343:                 NameValuePairList renamed = new NameValuePairList();
344:
345:•                for (NameValuePair nv : af.createPDefinitionAssistant().getNamedValues(def.getDef(), initialContext))
346:                 {
347:•                        if (nv.name.equals(def.getDef().getName())) // NB. excludes pre/post/inv functions
348:                         {
349:                                 renamed.add(new NameValuePair(def.getName(), nv.value));
350:                         }
351:                 }
352:
353:                 return renamed;
354:         }
355:
356:         @Override
357:         public NameValuePairList caseAInheritedDefinition(AInheritedDefinition def,
358:                         Context initialContext) throws AnalysisException
359:         {
360:                 NameValuePairList renamed = new NameValuePairList();
361:
362:•                if (def.getSuperdef() instanceof AUntypedDefinition)
363:                 {
364:•                        if (def.getClassDefinition() != null)
365:                         {
366:                                 def.setSuperdef(af.createPDefinitionAssistant().findName(def.getClassDefinition(), def.getSuperdef().getName(), def.getNameScope()));
367:                         }
368:                 }
369:
370:•                for (NameValuePair nv : af.createPDefinitionAssistant().getNamedValues(def.getSuperdef(), initialContext))
371:                 {
372:                         renamed.add(new NameValuePair(nv.name.getModifiedName(def.getName().getModule()), nv.value));
373:                 }
374:
375:                 return renamed;
376:         }
377:
378:         @Override
379:         public NameValuePairList caseAInstanceVariableDefinition(
380:                         AInstanceVariableDefinition def, Context initialContext)
381:                         throws AnalysisException
382:         {
383:                 try
384:                 {
385:                         Value v = def.getExpression().apply(VdmRuntime.getExpressionEvaluator(), initialContext);
386:
387:•                        if (!v.isUndefined())
388:                         {
389:                                 v = v.convertTo(def.getType(), initialContext);
390:                         }
391:
392:                         return new NameValuePairList(new NameValuePair(def.getName(), v.getUpdatable(null)));
393:                 } catch (ValueException e)
394:                 {
395:                         VdmRuntimeError.abort(def.getLocation(), e);
396:                         return null;
397:                 } catch (AnalysisException e)
398:                 {
399:                         // TODO Auto-generated catch block
400:                         e.printStackTrace();
401:                         return null;
402:                 }
403:         }
404:
405:         @Override
406:         public NameValuePairList caseALocalDefinition(ALocalDefinition def,
407:                         Context initialContext) throws AnalysisException
408:         {
409:                 NameValuePair nvp = new NameValuePair(def.getName(), initialContext.lookup(def.getName()));
410:                 return new NameValuePairList(nvp);
411:         }
412:
413:         @Override
414:         public NameValuePairList caseARenamedDefinition(ARenamedDefinition def,
415:                         Context initialContext) throws AnalysisException
416:         {
417:                 NameValuePairList renamed = new NameValuePairList();
418:
419:•                for (NameValuePair nv : af.createPDefinitionAssistant().getNamedValues(def.getDef(), initialContext))
420:                 {
421:                         // We exclude any name from the definition other than the one
422:                         // explicitly renamed. Otherwise, generated names like pre_f
423:                         // come through and are not renamed.
424:
425:•                        if (nv.name.equals(def.getDef().getName()))
426:                         {
427:                                 renamed.add(new NameValuePair(def.getName(), nv.value));
428:                         }
429:                 }
430:
431:                 return renamed;
432:         }
433:
434:         @Override
435:         public NameValuePairList caseAThreadDefinition(AThreadDefinition def,
436:                         Context initialContext) throws AnalysisException
437:         {
438:                 return def.getOperationDef().apply(THIS, initialContext);
439:         }
440:
441:         @Override
442:         public NameValuePairList caseATypeDefinition(ATypeDefinition def,
443:                                                                                                  Context initialContext) throws AnalysisException
444:         {
445:                 NameValuePairList nvl = new NameValuePairList();
446:
447:•                if (def.getInvdef() != null)
448:                 {
449:                         FunctionValue invfunc = new FunctionValue(def.getInvdef(), null, null, initialContext);
450:                         nvl.add(new NameValuePair(def.getInvdef().getName(), invfunc));
451:                 }
452:
453:•                if (def.getEqRelation() != null && def.getEqRelation().getRelDef() != null)
454:                 {
455:                         FunctionValue func = new FunctionValue(def.getEqRelation().getRelDef(), null, null, initialContext);
456:                         nvl.add(new NameValuePair(def.getEqRelation().getRelDef().getName(), func));
457:                 }
458:
459:•                if (def.getOrdRelation() != null && def.getOrdRelation().getRelDef() != null)
460:                 {
461:                         FunctionValue func = new FunctionValue(def.getOrdRelation().getRelDef(), null, null, initialContext);
462:                         nvl.add(new NameValuePair(def.getOrdRelation().getRelDef().getName(), func));
463:                 }
464:
465:•                if (def.getOrdRelation() != null && def.getOrdRelation().getMinDef() != null)
466:                 {
467:                         FunctionValue func = new FunctionValue(def.getOrdRelation().getMinDef(), null, null, initialContext);
468:                         nvl.add(new NameValuePair(def.getOrdRelation().getMinDef().getName(), func));
469:                 }
470:
471:•                if (def.getOrdRelation() != null && def.getOrdRelation().getMaxDef() != null)
472:                 {
473:                         FunctionValue func = new FunctionValue(def.getOrdRelation().getMaxDef(), null, null, initialContext);
474:                         nvl.add(new NameValuePair(def.getOrdRelation().getMaxDef().getName(), func));
475:                 }
476:
477:                 return nvl;
478:         }
479:
480:         @Override
481:         public NameValuePairList caseAUntypedDefinition(AUntypedDefinition def,
482:                         Context initialContext) throws AnalysisException
483:         {
484:•                assert false : "Can't get name/values of untyped definition?";
485:                 return null;
486:         }
487:
488:         @Override
489:         public NameValuePairList caseAValueDefinition(AValueDefinition def,
490:                         Context initialContext) throws AnalysisException
491:         {
492:                 Value v = null;
493:
494:                 try
495:                 {
496:                         // UpdatableValues are constantized as they cannot be updated.
497:                         v = def.getExpression().apply(VdmRuntime.getExpressionEvaluator(), initialContext).convertTo(af.createPDefinitionAssistant().getType(def), initialContext).getConstant();
498:                         return af.createPPatternAssistant(def.getLocation().getModule()).getNamedValues(def.getPattern(), v, initialContext);
499:                 } catch (ValueException e)
500:                 {
501:                         VdmRuntimeError.abort(def.getLocation(), e);
502:                 } catch (PatternMatchException e)
503:                 {
504:                         VdmRuntimeError.abort(e, initialContext);
505:                 } catch (AnalysisException e)
506:                 {
507:
508:                 }
509:
510:                 return null;
511:         }
512:
513:         @Override
514:         public NameValuePairList defaultPDefinition(PDefinition def,
515:                         Context initialContext) throws AnalysisException
516:         {
517:                 return new NameValuePairList(); // Overridden
518:         }
519:
520:         @Override
521:         public NameValuePairList createNewReturnValue(INode node, Context question)
522:                         throws AnalysisException
523:         {
524:                 // TODO Auto-generated method stub
525:                 return null;
526:         }
527:
528:         @Override
529:         public NameValuePairList createNewReturnValue(Object node, Context question)
530:                         throws AnalysisException
531:         {
532:                 // TODO Auto-generated method stub
533:                 return null;
534:         }
535:
536: }