Package: RenamedTrans

RenamedTrans

nameinstructionbranchcomplexitylinemethod
RenamedTrans(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%
caseAIdentifierVarExpIR(AIdentifierVarExpIR)
M: 0 C: 74
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 19
100%
M: 0 C: 1
100%
caseAPlainCallStmIR(APlainCallStmIR)
M: 11 C: 86
89%
M: 2 C: 4
67%
M: 2 C: 2
50%
M: 2 C: 23
92%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.trans;
2:
3: import org.overture.ast.definitions.ARenamedDefinition;
4: import org.overture.ast.definitions.PDefinition;
5: import org.overture.ast.expressions.AVariableExp;
6: import org.overture.ast.node.INode;
7: import org.overture.ast.statements.ACallStm;
8: import org.overture.codegen.assistant.AssistantBase;
9: import org.overture.codegen.ir.SExpIR;
10: import org.overture.codegen.ir.analysis.AnalysisException;
11: import org.overture.codegen.ir.analysis.DepthFirstAnalysisAdaptor;
12: import org.overture.codegen.ir.expressions.AExplicitVarExpIR;
13: import org.overture.codegen.ir.expressions.AIdentifierVarExpIR;
14: import org.overture.codegen.ir.statements.APlainCallStmIR;
15: import org.overture.codegen.ir.types.AClassTypeIR;
16: import org.overture.codegen.trans.assistants.TransAssistantIR;
17:
18: public class RenamedTrans extends DepthFirstAnalysisAdaptor {
19:
20: private TransAssistantIR assist;
21:
22: public RenamedTrans(TransAssistantIR assist)
23: {
24: this.assist = assist;
25: }
26:
27: @Override
28: public void caseAIdentifierVarExpIR(AIdentifierVarExpIR node) throws AnalysisException {
29:
30: INode var = AssistantBase.getVdmNode(node);
31:
32:• if(var instanceof AVariableExp)
33: {
34: PDefinition def = ((AVariableExp) var).getVardef();
35:
36:• if(def instanceof ARenamedDefinition)
37: {
38: ARenamedDefinition renamedDef = (ARenamedDefinition) def;
39:
40: AClassTypeIR definingClass = new AClassTypeIR();
41: definingClass.setName(renamedDef.getDef().getName().getModule());
42: definingClass.setSourceNode(node.getSourceNode());
43:
44: AExplicitVarExpIR expVar = new AExplicitVarExpIR();
45: expVar.setName(renamedDef.getDef().getName().getName());
46: expVar.setType(node.getType().clone());
47: expVar.setIsLambda(node.getIsLambda());
48: expVar.setIsLocal(node.getIsLocal());
49: expVar.setMetaData(node.getMetaData());
50: expVar.setTag(node.getTag());
51: expVar.setSourceNode(node.getSourceNode());
52: expVar.setClassType(definingClass);
53:
54: assist.replaceNodeWith(node, expVar);
55: }
56: }
57: }
58:
59: @Override
60: public void caseAPlainCallStmIR(APlainCallStmIR node) throws AnalysisException {
61:
62: super.caseAPlainCallStmIR(node);
63:
64: INode vdmNode = AssistantBase.getVdmNode(node);
65:
66:• if(vdmNode instanceof ACallStm)
67: {
68: ACallStm cs = (ACallStm) vdmNode;
69: PDefinition def = cs.getRootdef();
70:
71:• if(def instanceof ARenamedDefinition)
72: {
73: ARenamedDefinition rd = (ARenamedDefinition) def;
74:
75: String opName = rd.getDef().getName().getName();
76: String moduleName = rd.getDef().getName().getModule();
77:
78: AClassTypeIR definingClass = new AClassTypeIR();
79: definingClass.setName(moduleName);
80: definingClass.setSourceNode(node.getSourceNode());
81:
82: APlainCallStmIR call = new APlainCallStmIR();
83: call.setClassType(definingClass);
84: call.setName(opName);
85: call.setIsStatic(false);
86: call.setMetaData(node.getMetaData());
87: call.setSourceNode(node.getSourceNode());
88: call.setTag(node.getTag());
89: call.setType(node.getType().clone());
90:• for(SExpIR a : node.getArgs())
91: {
92: call.getArgs().add(a.clone());
93: }
94:
95: assist.replaceNodeWith(node, call);
96: }
97: }
98: }
99: }