EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.stoex.analyser.visitors]

COVERAGE SUMMARY FOR SOURCE FILE [NonProbabilisticExpressionInferTypeVisitor.java]

nameclass, %method, %block, %line, %
NonProbabilisticExpressionInferTypeVisitor.java0%   (0/1)0%   (0/3)0%   (0/93)0%   (0/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NonProbabilisticExpressionInferTypeVisitor0%   (0/1)0%   (0/3)0%   (0/93)0%   (0/24)
NonProbabilisticExpressionInferTypeVisitor (): void 0%   (0/1)0%   (0/3)0%   (0/2)
casePowerExpression (PowerExpression): Object 0%   (0/1)0%   (0/56)0%   (0/10)
getType (Expression): TypeEnum 0%   (0/1)0%   (0/34)0%   (0/12)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.stoex.analyser.visitors;
5 
6import de.uka.ipd.sdq.stoex.Expression;
7import de.uka.ipd.sdq.stoex.PowerExpression;
8 
9/**
10 * @author Steffen
11 *
12 */
13public class NonProbabilisticExpressionInferTypeVisitor extends
14                ExpressionInferTypeVisitor {
15 
16        /**
17         * 
18         */
19        public NonProbabilisticExpressionInferTypeVisitor() {
20                super();
21        }
22 
23        @Override
24        public TypeEnum getType(Expression e) {
25                TypeEnum result = super.getType(e);
26                if (result == TypeEnum.INT_PMF)
27                        result = TypeEnum.INT;
28                if (result == TypeEnum.DOUBLE_PMF || result == TypeEnum.DOUBLE_PDF)
29                        result = TypeEnum.DOUBLE;
30                if (result == TypeEnum.ENUM_PMF)
31                        result = TypeEnum.ENUM;
32                if (result == TypeEnum.BOOL_PMF)
33                        result = TypeEnum.BOOL;
34                if (result == TypeEnum.ANY_PMF)
35                        result = TypeEnum.ANY;
36                return result;
37        }
38        
39        /**
40         * Result of a power expression so far only be of type DOUBLE,
41         * as the power operation is only allowed on NUMBERs, not PMFs.
42         */
43        @Override
44        public Object casePowerExpression(PowerExpression expr) {
45                doSwitch(expr.getBase());
46                doSwitch(expr.getExponent());
47                
48                TypeEnum baseType = getType(expr.getBase());
49                TypeEnum exponentType = getType(expr.getExponent());
50                
51                if (baseType == TypeEnum.INT && exponentType == TypeEnum.INT)
52                        getTypeAnnotation().put(expr, TypeEnum.INT);
53                else if (isNumeric(baseType) && isNumeric(exponentType)){
54                        getTypeAnnotation().put(expr, TypeEnum.DOUBLE);
55                } else 
56                        getTypeAnnotation().put(expr, TypeEnum.ANY);
57                return expr;
58        }
59}

[all classes][de.uka.ipd.sdq.stoex.analyser.visitors]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov