Package: RecModHandler

RecModHandler

nameinstructionbranchcomplexitylinemethod
RecModHandler(TypePredDecorator)
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%
consAssert(AIdentifierVarExpIR)
M: 22 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getInvTrans()
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%
handleCallObj(ACallObjectExpStmIR)
M: 29 C: 65
69%
M: 4 C: 8
67%
M: 4 C: 3
43%
M: 7 C: 14
67%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.vdm2jml.predgen;
2:
3: import org.apache.log4j.Logger;
4: import org.overture.codegen.ir.expressions.ACastUnaryExpIR;
5: import org.overture.codegen.ir.expressions.AIdentifierVarExpIR;
6: import org.overture.codegen.ir.expressions.SVarExpIR;
7: import org.overture.codegen.ir.statements.ACallObjectExpStmIR;
8: import org.overture.codegen.ir.statements.AMetaStmIR;
9: import org.overture.codegen.ir.types.ARecordTypeIR;
10:
11: public class RecModHandler
12: {
13:         private TypePredDecorator invTrans;
14:         private RecModUtil util;
15:
16:         private Logger log = Logger.getLogger(this.getClass().getName());
17:
18:         public RecModHandler(TypePredDecorator invTrans)
19:         {
20:                 this.invTrans = invTrans;
21:                 this.util = new RecModUtil(this);
22:         }
23:
24:         public AMetaStmIR handleCallObj(ACallObjectExpStmIR node)
25:         {
26:•                if (util.simpleRecSetCallOutsideAtomic(node))
27:                 {
28:                         // E.g. rec.set_x(3). Setter call to record outside atomic statement block
29:                         // or ((R) rec).set_x(3);
30:                         return null;
31:                 }
32:
33:•                if (node.getObj() instanceof SVarExpIR)
34:                 {
35:                         SVarExpIR subject = (SVarExpIR) node.getObj();
36:
37:•                        if (util.assertRec(subject))
38:                         {
39:                                 ARecordTypeIR recType = (ARecordTypeIR) subject.getType();
40:
41:                                 return util.handleRecAssert(subject, subject.getName(), recType);
42:                         }
43:•                } else if (node.getObj() instanceof ACastUnaryExpIR)
44:                 {
45:                         ACastUnaryExpIR subject = (ACastUnaryExpIR) node.getObj();
46:
47:•                        if (subject.getExp() instanceof SVarExpIR)
48:                         {
49:                                 SVarExpIR var = (SVarExpIR) subject.getExp();
50:
51:•                                if (util.assertRec(subject))
52:                                 {
53:                                         ARecordTypeIR recType = (ARecordTypeIR) subject.getType();
54:
55:                                         return util.handleRecAssert(subject, var.getName(), recType);
56:                                 }
57:                         } else
58:                         {
59:                                 log.error("Expected subject of cast expression to be a variable. Got: "
60:                                                 + subject.getExp());
61:                         }
62:                 } else
63:                 {
64:                         log.error("Expected target to be a variable or cast expression at this point. Got "
65:                                         + node.getObj());
66:                 }
67:                 return null;
68:         }
69:
70:         public TypePredDecorator getInvTrans()
71:         {
72:                 return invTrans;
73:         }
74:
75:         public AMetaStmIR consAssert(AIdentifierVarExpIR var)
76:         {
77:•                if (util.assertRec(var))
78:                 {
79:                         ARecordTypeIR recType = (ARecordTypeIR) var.getType();
80:
81:                         return invTrans.consMetaStm(util.consValidRecCheck(var, var.getName(), recType));
82:                 } else
83:                 {
84:                         return null;
85:                 }
86:         }
87: }