Package: BreakpointManager

BreakpointManager

nameinstructionbranchcomplexitylinemethod
BreakpointManager()
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%
evalBreakpointCondition(PExp, Context)
M: 19 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getBreakpoint(INode)
M: 5 C: 14
74%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 4
80%
M: 0 C: 1
100%
getBreakpoint(PExp)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getBreakpoint(PStm)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
setBreakpoint(PExp, Breakpoint)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setBreakpoint(PStm, Breakpoint)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
shouldStop(PExp, Context)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: package org.overture.interpreter.debug;
2:
3: import java.util.HashMap;
4: import java.util.Map;
5:
6: import org.overture.ast.analysis.AnalysisException;
7: import org.overture.ast.expressions.PExp;
8: import org.overture.ast.node.INode;
9: import org.overture.ast.statements.PStm;
10: import org.overture.interpreter.ast.expressions.BreakpointExpression;
11: import org.overture.interpreter.runtime.Breakpoint;
12: import org.overture.interpreter.runtime.Context;
13: import org.overture.interpreter.runtime.ValueException;
14: import org.overture.interpreter.runtime.VdmRuntime;
15: import org.overture.interpreter.values.Value;
16:
17: public class BreakpointManager
18: {
19:
20:         static final Map<PExp, Breakpoint> expressionMap = new HashMap<PExp, Breakpoint>();
21:         static final Map<PStm, Breakpoint> statementMap = new HashMap<PStm, Breakpoint>();
22:         
23:         public static Breakpoint getBreakpoint(INode node) throws AnalysisException
24:         {
25:•                if(node instanceof PExp)
26:                 {
27:                         return getBreakpoint((PExp)node);
28:•                }else if(node instanceof PStm)
29:                 {
30:                         return getBreakpoint((PStm)node);
31:                 }
32:                 throw new AnalysisException("Unsupported breakpoint node");
33:         }
34:
35:         public static Breakpoint getBreakpoint(PExp exp)
36:         {
37:•                if (!expressionMap.containsKey(exp))
38:                 {
39:                         expressionMap.put(exp, new Breakpoint(exp.getLocation()));
40:                 }
41:                 return expressionMap.get(exp);
42:         }
43:
44:         public static Breakpoint getBreakpoint(PStm stmt)
45:         {
46:•                if (!statementMap.containsKey(stmt))
47:                 {
48:                         statementMap.put(stmt, new Breakpoint(stmt.getLocation()));
49:                 }
50:                 return statementMap.get(stmt);
51:         }
52:
53:         public static void setBreakpoint(PStm stmt, Breakpoint breakpoint)
54:         {
55:                 statementMap.put(stmt, breakpoint);
56:         }
57:
58:         public static void setBreakpoint(PExp exp, Breakpoint breakpoint)
59:         {
60:                 expressionMap.put(exp, breakpoint);
61:         }
62:
63:         public static boolean shouldStop(PExp exp, Context ctxt)
64:                         throws ValueException
65:         {
66:                 return evalBreakpointCondition(exp, ctxt).boolValue(ctxt);
67:         }
68:
69:         public static Value evalBreakpointCondition(PExp exp, Context ctxt)
70:         {
71:•                if (exp instanceof BreakpointExpression)
72:                 {
73:                         return ((BreakpointExpression) exp).eval(ctxt);
74:                 }
75:                 try
76:                 {
77:                         return exp.apply(VdmRuntime.getExpressionEvaluator(), ctxt);
78:                 } catch (AnalysisException e)
79:                 {
80:                         e.printStackTrace();
81:                 }
82:
83:                 return null;
84:         }
85: }