Package: VdmRuntime

VdmRuntime

nameinstructionbranchcomplexitylinemethod
VdmRuntime()
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%
getExpressionEvaluator()
M: 1 C: 4
80%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
getNodeState(AExplicitFunctionDefinition)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getNodeState(AImplicitFunctionDefinition)
M: 18 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getNodeState(AModuleModules, ITypeCheckerAssistantFactory)
M: 0 C: 20
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 5
100%
M: 0 C: 1
100%
getNodeState(AStateDefinition)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getNodeState(IInterpreterAssistantFactory, ASystemClassDefinition)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getNodeState(IInterpreterAssistantFactory, SClassDefinition)
M: 0 C: 20
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getNodeState(INode)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getStatementEvaluator()
M: 1 C: 4
80%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
initialize()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
initialize(IQuestionAnswer)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
setNodeState(INode, IRuntimeState)
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%
static {...}
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%

Coverage

1: package org.overture.interpreter.runtime;
2:
3: import java.util.HashMap;
4: import java.util.Map;
5:
6: import org.overture.ast.analysis.intf.IQuestionAnswer;
7: import org.overture.ast.definitions.AExplicitFunctionDefinition;
8: import org.overture.ast.definitions.AImplicitFunctionDefinition;
9: import org.overture.ast.definitions.AStateDefinition;
10: import org.overture.ast.definitions.ASystemClassDefinition;
11: import org.overture.ast.definitions.SClassDefinition;
12: import org.overture.ast.modules.AModuleModules;
13: import org.overture.ast.node.INode;
14: import org.overture.interpreter.assistant.IInterpreterAssistantFactory;
15: import org.overture.interpreter.eval.DelegateStatementEvaluator;
16: import org.overture.interpreter.runtime.state.AExplicitFunctionDefinitionRuntimeState;
17: import org.overture.interpreter.runtime.state.AImplicitFunctionDefinitionRuntimeState;
18: import org.overture.interpreter.runtime.state.AModuleModulesRuntime;
19: import org.overture.interpreter.runtime.state.ASystemClassDefinitionRuntime;
20: import org.overture.interpreter.runtime.state.SClassDefinitionRuntime;
21: import org.overture.interpreter.runtime.state.StateDefinitionRuntimeState;
22: import org.overture.interpreter.values.Value;
23: import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;
24:
25: /**
26: * The runtime class must be re-initialized before an execution.
27: *
28: * @author pvj
29: */
30: public class VdmRuntime
31: {
32:         private static IQuestionAnswer<Context, Value> expressionRuntime;
33:         private static IQuestionAnswer<Context, Value> statementRuntime;
34:
35:         final private static Map<INode, IRuntimeState> runtimeState = new HashMap<INode, IRuntimeState>();
36:
37:         static
38:         {
39:                 initialize();
40:         }
41:
42:         public static void initialize()
43:         {
44:                 expressionRuntime = new DelegateStatementEvaluator();
45:                 statementRuntime = expressionRuntime;
46:                 runtimeState.clear();
47:         }
48:
49:         public static void initialize(
50:                         IQuestionAnswer<Context, Value> expressionRuntime)
51:         {
52:                 VdmRuntime.expressionRuntime = expressionRuntime;
53:                 VdmRuntime.statementRuntime = expressionRuntime;
54:                 VdmRuntime.runtimeState.clear();
55:         }
56:
57:         public static IQuestionAnswer<Context, Value> getExpressionEvaluator()
58:         {
59:•                if (expressionRuntime == null)
60:                 {
61:                         initialize();
62:                 }
63:
64:                 return expressionRuntime;
65:         }
66:
67:         public static IQuestionAnswer<Context, Value> getStatementEvaluator()
68:         {
69:•                if (statementRuntime == null)
70:                 {
71:                         initialize();
72:                 }
73:
74:                 return statementRuntime;
75:         }
76:
77:         public static void setNodeState(INode node, IRuntimeState state)
78:         {
79:                 runtimeState.put(node, state);
80:         }
81:
82:         public static IRuntimeState getNodeState(INode node)
83:         {
84:                 return runtimeState.get(node);
85:         }
86:
87:         public static StateDefinitionRuntimeState getNodeState(AStateDefinition node)
88:         {
89:                 return (StateDefinitionRuntimeState) runtimeState.get(node);
90:         }
91:
92:         public static AModuleModulesRuntime getNodeState(AModuleModules node,
93:                         ITypeCheckerAssistantFactory af)
94:         {
95:                 AModuleModulesRuntime state = (AModuleModulesRuntime) runtimeState.get(node);
96:
97:•                if (state == null)
98:                 {
99:                         state = new AModuleModulesRuntime(node, af);
100:                         runtimeState.put(node, state);
101:                 }
102:
103:                 return state;
104:         }
105:
106:         public static SClassDefinitionRuntime getNodeState(
107:                         IInterpreterAssistantFactory assistantFactory, SClassDefinition node)
108:         {
109:                 SClassDefinitionRuntime state = (SClassDefinitionRuntime) runtimeState.get(node);
110:
111:•                if (state == null)
112:                 {
113:                         state = new SClassDefinitionRuntime(assistantFactory, node);
114:                         runtimeState.put(node, state);
115:                 }
116:
117:                 return state;
118:         }
119:
120:         public static ASystemClassDefinitionRuntime getNodeState(
121:                         IInterpreterAssistantFactory assistantFactory,
122:                         ASystemClassDefinition node)
123:         {
124:                 ASystemClassDefinitionRuntime state = (ASystemClassDefinitionRuntime) runtimeState.get(node);
125:
126:•                if (state == null)
127:                 {
128:                         state = new ASystemClassDefinitionRuntime(assistantFactory, node);
129:                         runtimeState.put(node, state);
130:                 }
131:
132:                 return state;
133:         }
134:
135:         public static AImplicitFunctionDefinitionRuntimeState getNodeState(
136:                         AImplicitFunctionDefinition node)
137:         {
138:                 AImplicitFunctionDefinitionRuntimeState state = (AImplicitFunctionDefinitionRuntimeState) runtimeState.get(node);
139:
140:•                if (state == null)
141:                 {
142:                         state = new AImplicitFunctionDefinitionRuntimeState();
143:                         runtimeState.put(node, state);
144:                 }
145:
146:                 return state;
147:         }
148:
149:         public static AExplicitFunctionDefinitionRuntimeState getNodeState(
150:                         AExplicitFunctionDefinition node)
151:         {
152:                 AExplicitFunctionDefinitionRuntimeState state = (AExplicitFunctionDefinitionRuntimeState) runtimeState.get(node);
153:
154:•                if (state == null)
155:                 {
156:                         state = new AExplicitFunctionDefinitionRuntimeState();
157:                         runtimeState.put(node, state);
158:                 }
159:
160:                 return state;
161:         }
162:
163: }