Package: SInvariantTypeAssistantInterpreter

SInvariantTypeAssistantInterpreter

nameinstructionbranchcomplexitylinemethod
SInvariantTypeAssistantInterpreter(IInterpreterAssistantFactory)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
findFunction(AExplicitFunctionDefinition, Context)
M: 6 C: 14
70%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 2 C: 4
67%
M: 0 C: 1
100%
getEquality(SInvariantType, Context)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getInvariant(SInvariantType, Context)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getOrder(SInvariantType, Context)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: package org.overture.interpreter.assistant.type;
2:
3: import org.overture.ast.assistant.IAstAssistant;
4: import org.overture.ast.definitions.AExplicitFunctionDefinition;
5: import org.overture.ast.types.SInvariantType;
6: import org.overture.interpreter.assistant.IInterpreterAssistantFactory;
7: import org.overture.interpreter.runtime.Context;
8: import org.overture.interpreter.runtime.ValueException;
9: import org.overture.interpreter.runtime.VdmRuntimeError;
10: import org.overture.interpreter.values.FunctionValue;
11: import org.overture.interpreter.values.Value;
12:
13: public class SInvariantTypeAssistantInterpreter implements IAstAssistant
14: {
15:         protected static IInterpreterAssistantFactory af;
16:
17:         @SuppressWarnings("static-access")
18:         public SInvariantTypeAssistantInterpreter(IInterpreterAssistantFactory af)
19:         {
20:                 this.af = af;
21:         }
22:
23:         public FunctionValue getInvariant(SInvariantType type, Context ctxt)
24:         {
25:                 return findFunction(type.getInvDef(), ctxt);
26:         }
27:
28:         public FunctionValue getEquality(SInvariantType type, Context ctxt)
29:         {
30:                 return findFunction(type.getEqDef(), ctxt);
31:         }
32:
33:         public FunctionValue getOrder(SInvariantType type, Context ctxt)
34:         {
35:                 return findFunction(type.getOrdDef(), ctxt);
36:         }
37:
38:         protected FunctionValue findFunction(AExplicitFunctionDefinition invdef, Context ctxt)
39:         {
40:•                if (invdef != null)
41:                 {
42:                         try
43:                         {
44:                                 Value v = ctxt.getGlobal().lookup(invdef.getName());
45:                                 return v.functionValue(ctxt);
46:                         }
47:                         catch (ValueException e)
48:                         {
49:                                 VdmRuntimeError.abort(invdef.getLocation(), e);
50:                         }
51:                 }
52:
53:                 return null;
54:         }
55:
56: }