Package: LiteralEvaluator

LiteralEvaluator

nameinstructionbranchcomplexitylinemethod
LiteralEvaluator()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseABooleanConstExp(ABooleanConstExp, Context)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseACharLiteralExp(ACharLiteralExp, Context)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseAIntLiteralExp(AIntLiteralExp, Context)
M: 6 C: 12
67%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 2
50%
M: 0 C: 1
100%
caseAQuoteLiteralExp(AQuoteLiteralExp, Context)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
caseARealLiteralExp(ARealLiteralExp, Context)
M: 6 C: 12
67%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 2 C: 2
50%
M: 0 C: 1
100%
caseAStringLiteralExp(AStringLiteralExp, Context)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
createNewReturnValue(INode, 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%
createNewReturnValue(Object, 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%
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.eval;
2:
3: import org.overture.ast.analysis.AnalysisException;
4: import org.overture.ast.analysis.QuestionAnswerAdaptor;
5: import org.overture.ast.expressions.ABooleanConstExp;
6: import org.overture.ast.expressions.ACharLiteralExp;
7: import org.overture.ast.expressions.AIntLiteralExp;
8: import org.overture.ast.expressions.AQuoteLiteralExp;
9: import org.overture.ast.expressions.ARealLiteralExp;
10: import org.overture.ast.expressions.AStringLiteralExp;
11: import org.overture.ast.node.INode;
12: import org.overture.interpreter.debug.BreakpointManager;
13: import org.overture.interpreter.runtime.Context;
14: import org.overture.interpreter.runtime.ValueException;
15: import org.overture.interpreter.runtime.VdmRuntimeError;
16: import org.overture.interpreter.values.BooleanValue;
17: import org.overture.interpreter.values.CharacterValue;
18: import org.overture.interpreter.values.NumericValue;
19: import org.overture.interpreter.values.QuoteValue;
20: import org.overture.interpreter.values.SeqValue;
21: import org.overture.interpreter.values.Value;
22:
23:•public class LiteralEvaluator extends QuestionAnswerAdaptor<Context, Value>
24: {
25:
26:         @Override
27:         public Value caseAIntLiteralExp(AIntLiteralExp node, Context ctxt)
28:                         throws AnalysisException
29:         {
30:                 BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt);
31:
32:                 try
33:                 {
34:                         return NumericValue.valueOf(node.getValue().getValue(), ctxt);
35:                 } catch (ValueException e)
36:                 {
37:                         return VdmRuntimeError.abort(node.getLocation(), e);
38:                 }
39:         }
40:
41:         @Override
42:         public Value caseACharLiteralExp(ACharLiteralExp node, Context ctxt)
43:                         throws AnalysisException
44:         {
45:                 BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt);
46:                 return new CharacterValue(node.getValue().getValue());
47:         }
48:
49:         @Override
50:         public Value caseABooleanConstExp(ABooleanConstExp node, Context ctxt)
51:                         throws AnalysisException
52:         {
53:                 BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt);
54:                 return new BooleanValue(node.getValue().getValue());
55:         }
56:
57:         @Override
58:         public Value caseAQuoteLiteralExp(AQuoteLiteralExp node, Context ctxt)
59:                         throws AnalysisException
60:         {
61:                 BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt);
62:                 return new QuoteValue(node.getValue().getValue());
63:         }
64:
65:         @Override
66:         public Value caseARealLiteralExp(ARealLiteralExp node, Context ctxt)
67:                         throws AnalysisException
68:         {
69:                 BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt);
70:
71:                 try
72:                 {
73:                         return NumericValue.valueOf(node.getValue().getValue(), ctxt);
74:                 } catch (ValueException e)
75:                 {
76:                         return VdmRuntimeError.abort(node.getLocation(), e);
77:                 }
78:         }
79:
80:         @Override
81:         public Value caseAStringLiteralExp(AStringLiteralExp node, Context ctxt)
82:                         throws AnalysisException
83:         {
84:                 BreakpointManager.getBreakpoint(node).check(node.getLocation(), ctxt);
85:                 return new SeqValue(node.getValue().getValue());
86:         }
87:
88:         @Override
89:         public Value createNewReturnValue(INode node, Context question)
90:         {
91:•                assert false : "Should not happen";
92:                 return null;
93:         }
94:
95:         @Override
96:         public Value createNewReturnValue(Object node, Context question)
97:         {
98:•                assert false : "Should not happen";
99:                 return null;
100:         }
101: }