Package: DivideTrans

DivideTrans

nameinstructionbranchcomplexitylinemethod
DivideTrans(IRInfo)
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%
caseADivideNumericBinaryExpIR(ADivideNumericBinaryExpIR)
M: 0 C: 69
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 17
100%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.trans;
2:
3: import org.overture.ast.types.ARealNumericBasicType;
4: import org.overture.codegen.ir.IRInfo;
5: import org.overture.codegen.ir.SExpIR;
6: import org.overture.codegen.ir.SourceNode;
7: import org.overture.codegen.ir.analysis.AnalysisException;
8: import org.overture.codegen.ir.analysis.DepthFirstAnalysisAdaptor;
9: import org.overture.codegen.ir.expressions.ADivideNumericBinaryExpIR;
10: import org.overture.codegen.ir.expressions.ARealLiteralExpIR;
11: import org.overture.codegen.ir.expressions.ATimesNumericBinaryExpIR;
12: import org.overture.codegen.ir.types.ARealNumericBasicTypeIR;
13:
14: public class DivideTrans extends DepthFirstAnalysisAdaptor
15: {
16:         private IRInfo info;
17:
18:         public DivideTrans(IRInfo info)
19:         {
20:                 this.info = info;
21:         }
22:
23:         @Override
24:         public void caseADivideNumericBinaryExpIR(ADivideNumericBinaryExpIR node)
25:                         throws AnalysisException
26:         {
27:                 SExpIR leftExp = node.getLeft();
28:                 leftExp.apply(this);
29:
30:                 SExpIR rightExp = node.getRight();
31:                 rightExp.apply(this);
32:
33:•                if (info.getExpAssistant().isIntegerType(leftExp)
34:•                                && info.getExpAssistant().isIntegerType(rightExp))
35:                 {
36:                         ARealLiteralExpIR one = new ARealLiteralExpIR();
37:                         ARealNumericBasicTypeIR realTypeCg = new ARealNumericBasicTypeIR();
38:                         realTypeCg.setSourceNode(new SourceNode(new ARealNumericBasicType()));
39:                         one.setType(realTypeCg);
40:                         one.setValue(1.0);
41:
42:                         ATimesNumericBinaryExpIR neutralMul = new ATimesNumericBinaryExpIR();
43:                         neutralMul.setType(realTypeCg.clone());
44:                         neutralMul.setLeft(one);
45:                         neutralMul.setRight(leftExp);
46:
47:                         node.setLeft(info.getExpAssistant().isolateExpression(neutralMul));
48:                 }
49:         }
50: }