Package: TraceSupportedAnalysis

TraceSupportedAnalysis

nameinstructionbranchcomplexitylinemethod
TraceSupportedAnalysis(ANamedTraceDeclIR)
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%
caseASuperCallStmIR(ASuperCallStmIR)
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getReason()
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%
isUnsupported()
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%
isWithinTrace(INode)
M: 10 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
run()
M: 0 C: 5
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.codegen.traces;
2:
3: import org.overture.codegen.ir.INode;
4: import org.overture.codegen.ir.analysis.AnalysisException;
5: import org.overture.codegen.ir.analysis.DepthFirstAnalysisAdaptor;
6: import org.overture.codegen.ir.declarations.ANamedTraceDeclIR;
7: import org.overture.codegen.ir.statements.ASuperCallStmIR;
8:
9: /**
10: * This analysis determines if a named trace can be code generated. Code generation of traces currently does not support
11: * call object statements which contain explicit field module names different from the name of the enclosing class.
12: * Example: A quoted method call is only supported if the explicit module name is equal to that of the enclosing class.
13: * Say A is a sub class of S and 'a' is an instance of A then a.A`op(); is allowed (although it is the same as a.op()).
14: * However, a.S`op(); is not allowed. This is already reported as unsupported at the IR level so there is no need for
15: * this analysis to detect this case. The super call statement is, however, not supported by the code generator when it
16: * does appear in traces. Therefore, this analysis will detect this case.
17: *
18: * @author pvj
19: */
20: public class TraceSupportedAnalysis extends DepthFirstAnalysisAdaptor
21: {
22:         private ANamedTraceDeclIR trace;
23:         private boolean isUnsupported = false;
24:         private String reason;
25:
26:         public TraceSupportedAnalysis(ANamedTraceDeclIR trace)
27:         {
28:                 this.trace = trace;
29:         }
30:
31:         @Override
32:         public void caseASuperCallStmIR(ASuperCallStmIR node)
33:                         throws AnalysisException
34:         {
35:•                if (!isWithinTrace(node))
36:                 {
37:                         return;
38:                 }
39:
40:                 reason = "The super call statement is not supported in traces,"
41:                                 + "and as a consequence the trace is not generated.";
42:                 isUnsupported = true;
43:         }
44:
45:         public void run() throws AnalysisException
46:         {
47:                 trace.apply(this);
48:         }
49:
50:         public String getReason()
51:         {
52:                 return reason;
53:         }
54:
55:         private boolean isWithinTrace(INode node)
56:         {
57:•                return node.getAncestor(ANamedTraceDeclIR.class) == trace;
58:         }
59:
60:         public boolean isUnsupported()
61:         {
62:                 return isUnsupported;
63:         }
64: }