Package: TraceDeclVisitorIR

TraceDeclVisitorIR

nameinstructionbranchcomplexitylinemethod
TraceDeclVisitorIR()
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%
caseAInstanceTraceDefinition(AInstanceTraceDefinition, IRInfo)
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%
caseALetBeStBindingTraceDefinition(ALetBeStBindingTraceDefinition, IRInfo)
M: 15 C: 56
79%
M: 2 C: 4
67%
M: 2 C: 2
50%
M: 3 C: 14
82%
M: 0 C: 1
100%
caseALetDefBindingTraceDefinition(ALetDefBindingTraceDefinition, IRInfo)
M: 0 C: 27
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
caseARepeatTraceDefinition(ARepeatTraceDefinition, IRInfo)
M: 0 C: 31
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
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.codegen.traces;
2:
3: import org.overture.ast.analysis.AnalysisException;
4: import org.overture.ast.definitions.traces.AInstanceTraceDefinition;
5: import org.overture.ast.definitions.traces.ALetBeStBindingTraceDefinition;
6: import org.overture.ast.definitions.traces.ALetDefBindingTraceDefinition;
7: import org.overture.ast.definitions.traces.ARepeatTraceDefinition;
8: import org.overture.ast.definitions.traces.PTraceCoreDefinition;
9: import org.overture.ast.definitions.traces.PTraceDefinition;
10: import org.overture.ast.expressions.PExp;
11: import org.overture.ast.patterns.ASetMultipleBind;
12: import org.overture.ast.patterns.PMultipleBind;
13: import org.overture.codegen.ir.IRInfo;
14: import org.overture.codegen.ir.SExpIR;
15: import org.overture.codegen.ir.SMultipleBindIR;
16: import org.overture.codegen.ir.STraceCoreDeclIR;
17: import org.overture.codegen.ir.STraceDeclIR;
18: import org.overture.codegen.ir.patterns.ASetMultipleBindIR;
19: import org.overture.codegen.ir.traces.ALetBeStBindingTraceDeclIR;
20: import org.overture.codegen.ir.traces.ALetDefBindingTraceDeclIR;
21: import org.overture.codegen.ir.traces.ARepeatTraceDeclIR;
22: import org.overture.codegen.visitor.AbstractVisitorIR;
23:
24:•public class TraceDeclVisitorIR extends AbstractVisitorIR<IRInfo, STraceDeclIR>
25: {
26:         @Override
27:         public STraceDeclIR caseAInstanceTraceDefinition(
28:                         AInstanceTraceDefinition node, IRInfo question)
29:                         throws AnalysisException
30:         {
31:•                assert false : "This node does not exist in the VDM AST";
32:                 return null;
33:         }
34:
35:         @Override
36:         public STraceDeclIR caseALetBeStBindingTraceDefinition(
37:                         ALetBeStBindingTraceDefinition node, IRInfo question)
38:                         throws AnalysisException
39:         {
40:                 PMultipleBind multipleBind = node.getBind();
41:
42:•                if (!(multipleBind instanceof ASetMultipleBind))
43:                 {
44:                         question.addUnsupportedNode(node, "Generation of the let be st trace definition"
45:                                         + " is only supported for a multiple set bind. Got: "
46:                                         + multipleBind);
47:                         return null;
48:                 }
49:
50:                 PTraceDefinition body = node.getBody();
51:                 PExp stExp = node.getStexp();
52:
53:                 SMultipleBindIR multipleBindCg = multipleBind.apply(question.getMultipleBindVisitor(), question);
54:
55:•                if (!(multipleBindCg instanceof ASetMultipleBindIR))
56:                 {
57:                         return null;
58:                 }
59:
60:                 STraceDeclIR bodyCg = body.apply(question.getTraceDeclVisitor(), question);
61:•                SExpIR stExpCg = stExp != null
62:                                 ? stExp.apply(question.getExpVisitor(), question) : null;
63:
64:                 ALetBeStBindingTraceDeclIR letBeSt = new ALetBeStBindingTraceDeclIR();
65:                 letBeSt.setBind((ASetMultipleBindIR) multipleBindCg);
66:                 letBeSt.setBody(bodyCg);
67:                 letBeSt.setStExp(stExpCg);
68:                 
69:
70:                 return letBeSt;
71:         }
72:
73:         @Override
74:         public STraceDeclIR caseALetDefBindingTraceDefinition(
75:                         ALetDefBindingTraceDefinition node, IRInfo question)
76:                         throws AnalysisException
77:         {
78:                 PTraceDefinition body = node.getBody();
79:
80:                 ALetDefBindingTraceDeclIR letDef = new ALetDefBindingTraceDeclIR();
81:
82:                 question.getDeclAssistant().setFinalLocalDefs(node.getLocalDefs(), letDef.getLocalDefs(), question);
83:
84:                 STraceDeclIR bodyCg = body.apply(question.getTraceDeclVisitor(), question);
85:                 letDef.setBody(bodyCg);
86:
87:                 return letDef;
88:         }
89:
90:         @Override
91:         public STraceDeclIR caseARepeatTraceDefinition(ARepeatTraceDefinition node,
92:                         IRInfo question) throws AnalysisException
93:         {
94:                 PTraceCoreDefinition core = node.getCore();
95:                 Long from = node.getFrom();
96:                 Long to = node.getTo();
97:
98:                 STraceCoreDeclIR coreCg = core.apply(question.getTraceCoreDeclVisitor(), question);
99:
100:                 ARepeatTraceDeclIR repeatTraceDecl = new ARepeatTraceDeclIR();
101:                 repeatTraceDecl.setCore(coreCg);
102:                 repeatTraceDecl.setFrom(from);
103:                 repeatTraceDecl.setTo(to);
104:
105:                 return repeatTraceDecl;
106:         }
107:
108: }