Package: JmlUnionTypeTrans

JmlUnionTypeTrans

nameinstructionbranchcomplexitylinemethod
JmlUnionTypeTrans(TransAssistantIR, UnionTypeVarPrefixes, List, StateDesInfo)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
caseAAssignToExpStmIR(AAssignToExpStmIR)
M: 4 C: 36
90%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 11
92%
M: 0 C: 1
100%
castFieldObj(AAssignToExpStmIR, AFieldExpIR, STypeIR)
M: 4 C: 24
86%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 4
80%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.vdm2jml.trans;
2:
3: import java.util.List;
4:
5: import org.apache.log4j.Logger;
6: import org.overture.codegen.ir.INode;
7: import org.overture.codegen.ir.STypeIR;
8: import org.overture.codegen.ir.analysis.AnalysisException;
9: import org.overture.codegen.ir.declarations.AVarDeclIR;
10: import org.overture.codegen.ir.expressions.AFieldExpIR;
11: import org.overture.codegen.ir.expressions.AIdentifierVarExpIR;
12: import org.overture.codegen.ir.statements.AAssignToExpStmIR;
13: import org.overture.codegen.ir.types.AUnionTypeIR;
14: import org.overture.codegen.runtime.traces.Pair;
15: import org.overture.codegen.trans.assistants.TransAssistantIR;
16: import org.overture.codegen.trans.uniontypes.UnionTypeTrans;
17: import org.overture.codegen.trans.uniontypes.UnionTypeVarPrefixes;
18: import org.overture.codegen.vdm2jml.data.StateDesInfo;
19:
20: public class JmlUnionTypeTrans extends UnionTypeTrans
21: {
22:         private StateDesInfo stateDesInfo;
23:
24:         private Logger log = Logger.getLogger(this.getClass().getName());
25:
26:         public JmlUnionTypeTrans(TransAssistantIR transAssistant,
27:                         UnionTypeVarPrefixes unionTypePrefixes, List<INode> cloneFreeNodes,
28:                         StateDesInfo stateDesInfo)
29:         {
30:                 super(transAssistant, unionTypePrefixes, cloneFreeNodes);
31:
32:                 this.stateDesInfo = stateDesInfo;
33:         }
34:
35:         @Override
36:         public void caseAAssignToExpStmIR(AAssignToExpStmIR node)
37:                         throws AnalysisException
38:         {
39:•                if (node.getTarget() instanceof AFieldExpIR)
40:                 {
41:                         AFieldExpIR field = (AFieldExpIR) node.getTarget();
42:
43:•                        if (field.getObject().getType() instanceof AUnionTypeIR)
44:                         {
45:•                                if (p != null)
46:                                 {
47:                                         log.error("Expected no state designator data by now");
48:                                 }
49:
50:                                 p = this.stateDesInfo.remove(node);
51:
52:                                 handAssignRighHandSide(node);
53:                                 handleAssignTarget(node);
54:                         }
55:                 } else
56:                 {
57:                         handAssignRighHandSide(node);
58:                 }
59:
60:                 p = null;
61:         }
62:
63:         Pair<List<AIdentifierVarExpIR>, List<AVarDeclIR>> p = null;
64:
65:         @Override
66:         public AAssignToExpStmIR castFieldObj(AAssignToExpStmIR assign,
67:                         AFieldExpIR target, STypeIR possibleType)
68:         {
69:                 AAssignToExpStmIR ret = super.castFieldObj(assign, target, possibleType);
70:
71:•                if (p != null)
72:                 {
73:                         stateDesInfo.register(ret, p.getFirst(), p.getSecond());
74:                 } else
75:                 {
76:                         log.error("Expected to have state designator data at this point");
77:                 }
78:
79:                 return ret;
80:         }
81: }