Package: AssignStmTrans

AssignStmTrans

nameinstructionbranchcomplexitylinemethod
AssignStmTrans(TransAssistantIR)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
caseAAssignmentStmIR(AAssignmentStmIR)
M: 11 C: 86
89%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 23
96%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.trans;
2:
3: import org.apache.log4j.Logger;
4: import org.overture.codegen.ir.SExpIR;
5: import org.overture.codegen.ir.SStmIR;
6: import org.overture.codegen.ir.analysis.AnalysisException;
7: import org.overture.codegen.ir.analysis.DepthFirstAnalysisAdaptor;
8: import org.overture.codegen.ir.statements.AAssignToExpStmIR;
9: import org.overture.codegen.ir.statements.AAssignmentStmIR;
10: import org.overture.codegen.ir.statements.AMapSeqStateDesignatorIR;
11: import org.overture.codegen.ir.statements.AMapSeqUpdateStmIR;
12: import org.overture.codegen.trans.assistants.TransAssistantIR;
13: import org.overture.codegen.trans.conv.StateDesignatorToExpIR;
14:
15: public class AssignStmTrans extends DepthFirstAnalysisAdaptor
16: {
17:         private StateDesignatorToExpIR converter;
18:
19:         private Logger log = Logger.getLogger(this.getClass().getName());
20:
21:         public AssignStmTrans(TransAssistantIR transAssistant)
22:         {
23:                 this.converter = new StateDesignatorToExpIR(transAssistant);
24:         }
25:
26:         @Override
27:         public void caseAAssignmentStmIR(AAssignmentStmIR node)
28:                         throws AnalysisException
29:         {
30:                 SStmIR newNode = null;
31:
32:•                if (node.getTarget() instanceof AMapSeqStateDesignatorIR)
33:                 {
34:                         AMapSeqStateDesignatorIR target = (AMapSeqStateDesignatorIR) node.getTarget();
35:
36:                         SExpIR col = target.getMapseq().apply(converter);
37:                         SExpIR index = target.getExp();
38:                         SExpIR value = node.getExp();
39:
40:                         AMapSeqUpdateStmIR mapSeqUpd = new AMapSeqUpdateStmIR();
41:                         mapSeqUpd.setCol(col);
42:                         mapSeqUpd.setIndex(index.clone());
43:                         mapSeqUpd.setValue(value.clone());
44:                         mapSeqUpd.setSourceNode(node.getSourceNode());
45:                         mapSeqUpd.setTag(node.getTag());
46:
47:                         newNode = mapSeqUpd;
48:
49:                 } else
50:                 {
51:                         AAssignToExpStmIR assign = new AAssignToExpStmIR();
52:                         assign.setTarget(node.getTarget().apply(converter));
53:                         assign.setExp(node.getExp().clone());
54:                         assign.setSourceNode(node.getSourceNode());
55:                         assign.setTag(node.getTag());
56:
57:                         newNode = assign;
58:                 }
59:
60:•                if (node.parent() != null)
61:                 {
62:                         node.parent().replaceChild(node, newNode);
63:                 } else
64:                 {
65:                         log.error("Could not find parent of " + node);
66:                 }
67:         }
68: }