Package: SubExpressionsLocator

SubExpressionsLocator

nameinstructionbranchcomplexitylinemethod
SubExpressionsLocator(IInterpreterAssistantFactory)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
caseAApplyExp(AApplyExp)
M: 19 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseACaseAlternative(ACaseAlternative)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
caseACasesExp(ACasesExp)
M: 45 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
caseAElseIfExp(AElseIfExp)
M: 22 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
caseAIfExp(AIfExp)
M: 54 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
createNewReturnValue(INode)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createNewReturnValue(Object)
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
defaultPExp(PExp)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
defaultSBinaryExp(SBinaryExp)
M: 22 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package org.overture.interpreter.utilities.expression;
2:
3: import java.util.List;
4: import java.util.Vector;
5:
6: import org.overture.ast.analysis.AnalysisException;
7: import org.overture.ast.analysis.AnswerAdaptor;
8: import org.overture.ast.expressions.AApplyExp;
9: import org.overture.ast.expressions.ACaseAlternative;
10: import org.overture.ast.expressions.ACasesExp;
11: import org.overture.ast.expressions.AElseIfExp;
12: import org.overture.ast.expressions.AIfExp;
13: import org.overture.ast.expressions.PExp;
14: import org.overture.ast.expressions.SBinaryExp;
15: import org.overture.ast.node.INode;
16: import org.overture.interpreter.assistant.IInterpreterAssistantFactory;
17:
18: /***************************************
19: * This method collects and returns the subexpressions in a expression.
20: *
21: * @author gkanos
22: ****************************************/
23: public class SubExpressionsLocator extends AnswerAdaptor<List<PExp>>
24: {
25:         protected IInterpreterAssistantFactory af;
26:
27:         public SubExpressionsLocator(IInterpreterAssistantFactory af)
28:         {
29:                 this.af = af;
30:         }
31:
32:         @Override
33:         public List<PExp> caseAApplyExp(AApplyExp exp) throws AnalysisException
34:         {
35:                 List<PExp> subs = new Vector<PExp>();
36:                 subs.addAll(exp.getRoot().apply(THIS));
37:                 subs.add(exp);
38:                 return subs;
39:         }
40:
41:         @Override
42:         public List<PExp> defaultSBinaryExp(SBinaryExp exp)
43:                         throws AnalysisException
44:         {
45:                 List<PExp> subs = exp.getLeft().apply(THIS);
46:                 subs.addAll(exp.getRight().apply(THIS));
47:                 subs.add(exp);
48:                 return subs;
49:         }
50:
51:         @Override
52:         public List<PExp> caseACaseAlternative(ACaseAlternative exp)
53:                         throws AnalysisException
54:         {
55:                 return exp.getResult().apply(THIS);
56:         }
57:
58:         @Override
59:         public List<PExp> caseACasesExp(ACasesExp exp) throws AnalysisException
60:         {
61:                 List<PExp> subs = exp.getExpression().apply(THIS);
62:
63:•                for (ACaseAlternative c : exp.getCases())
64:                 {
65:                         subs.addAll(c.apply(THIS));
66:                 }
67:
68:•                if (exp.getOthers() != null)
69:                 {
70:                         subs.addAll(exp.getOthers().apply(THIS));
71:                 }
72:
73:                 subs.add(exp);
74:                 return subs;
75:         }
76:
77:         @Override
78:         public List<PExp> caseAElseIfExp(AElseIfExp exp) throws AnalysisException
79:         {
80:                 List<PExp> subs = exp.getElseIf().apply(THIS);
81:                 subs.addAll(exp.getThen().apply(THIS));
82:                 subs.add(exp);
83:                 return subs;
84:         }
85:
86:         @Override
87:         public List<PExp> caseAIfExp(AIfExp exp) throws AnalysisException
88:         {
89:                 List<PExp> subs = exp.getTest().apply(THIS);
90:                 subs.addAll(exp.getThen().apply(THIS));
91:
92:•                for (AElseIfExp elif : exp.getElseList())
93:                 {
94:                         subs.addAll(elif.apply(THIS));
95:                 }
96:
97:•                if (exp.getElse() != null)
98:                 {
99:                         subs.addAll(exp.getElse().apply(THIS));
100:                 }
101:
102:                 subs.add(exp);
103:                 return subs;
104:         }
105:
106:         @Override
107:         public List<PExp> defaultPExp(PExp exp) throws AnalysisException
108:         {
109:                 List<PExp> subs = new Vector<PExp>();
110:                 subs.add(exp);
111:                 return subs;
112:         }
113:
114:         @Override
115:         public List<PExp> createNewReturnValue(INode node) throws AnalysisException
116:         {
117:                 // TODO Auto-generated method stub
118:                 return null;
119:         }
120:
121:         @Override
122:         public List<PExp> createNewReturnValue(Object node)
123:                         throws AnalysisException
124:         {
125:                 // TODO Auto-generated method stub
126:                 return null;
127:         }
128: }