Package: StateDesignatorToExpIR

StateDesignatorToExpIR

nameinstructionbranchcomplexitylinemethod
StateDesignatorToExpIR(TransAssistantIR)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
caseAFieldStateDesignatorIR(AFieldStateDesignatorIR)
M: 0 C: 32
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
caseAIdentifierStateDesignatorIR(AIdentifierStateDesignatorIR)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
caseAMapSeqStateDesignatorIR(AMapSeqStateDesignatorIR)
M: 0 C: 35
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
createNewReturnValue(INode)
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%
createNewReturnValue(Object)
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%
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.trans.conv;
2:
3: import org.overture.codegen.ir.INode;
4: import org.overture.codegen.ir.SExpIR;
5: import org.overture.codegen.ir.analysis.AnalysisException;
6: import org.overture.codegen.ir.analysis.AnswerAdaptor;
7: import org.overture.codegen.ir.expressions.AFieldExpIR;
8: import org.overture.codegen.ir.expressions.AMapSeqGetExpIR;
9: import org.overture.codegen.ir.statements.AFieldStateDesignatorIR;
10: import org.overture.codegen.ir.statements.AIdentifierStateDesignatorIR;
11: import org.overture.codegen.ir.statements.AMapSeqStateDesignatorIR;
12: import org.overture.codegen.trans.assistants.TransAssistantIR;
13:
14: /**
15: * Converts a state designator into an equivalent expression. Please note that this converter assumes map sequence state
16: * designators to be "map readings" and not "map modifications". More explicitly, this means that the parent of a map
17: * sequence state designator is assumed to be a state designator and not an assignment statement.
18: *
19: * @author pvj
20: */
21:•public class StateDesignatorToExpIR extends AnswerAdaptor<SExpIR>
22: {
23:         private TransAssistantIR transAssistant;
24:
25:         public StateDesignatorToExpIR(TransAssistantIR transAssistant)
26:         {
27:                 this.transAssistant = transAssistant;
28:         }
29:
30:         @Override
31:         public SExpIR caseAIdentifierStateDesignatorIR(
32:                         AIdentifierStateDesignatorIR node) throws AnalysisException
33:         {
34:                 return transAssistant.getInfo().getExpAssistant().idStateDesignatorToExp(node);
35:         }
36:
37:         @Override
38:         public SExpIR caseAFieldStateDesignatorIR(AFieldStateDesignatorIR node)
39:                         throws AnalysisException
40:         {
41:                 SExpIR objExp = node.getObject().apply(this);
42:
43:                 AFieldExpIR fieldExp = new AFieldExpIR();
44:                 fieldExp.setMemberName(node.getField());
45:                 fieldExp.setObject(objExp);
46:                 fieldExp.setType(node.getType().clone());
47:                 fieldExp.setTag(node.getTag());
48:                 fieldExp.setSourceNode(node.getSourceNode());
49:
50:                 return fieldExp;
51:         }
52:
53:         @Override
54:         public SExpIR caseAMapSeqStateDesignatorIR(AMapSeqStateDesignatorIR node)
55:                         throws AnalysisException
56:         {
57:                 // Reading a map or a sequence on the left hand
58:                 // side of an assignment, e.g. m(1).field := 5;
59:
60:                 SExpIR index = node.getExp();
61:                 SExpIR col = node.getMapseq().apply(this);
62:
63:                 AMapSeqGetExpIR mapSeqGet = new AMapSeqGetExpIR();
64:                 mapSeqGet.setType(node.getType().clone());
65:                 mapSeqGet.setIndex(index.clone());
66:                 mapSeqGet.setCol(col);
67:                 mapSeqGet.setSourceNode(node.getSourceNode());
68:                 mapSeqGet.setTag(node.getTag());
69:
70:                 return mapSeqGet;
71:         }
72:
73:         @Override
74:         public SExpIR createNewReturnValue(INode node) throws AnalysisException
75:         {
76:•                assert false : "This should never happen";
77:                 return null;
78:         }
79:
80:         @Override
81:         public SExpIR createNewReturnValue(Object node) throws AnalysisException
82:         {
83:•                assert false : "This should never happen";
84:                 return null;
85:         }
86: }