Package: OpBodyEndContext

OpBodyEndContext

nameinstructionbranchcomplexitylinemethod
OpBodyEndContext(List, IPogAssistantFactory)
M: 0 C: 73
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
getContext()
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%
getContextNode(PExp)
M: 3 C: 24
89%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 2 C: 5
71%
M: 0 C: 1
100%

Coverage

1: package org.overture.pog.contexts;
2:
3: import java.util.LinkedList;
4: import java.util.List;
5:
6: import org.overture.ast.analysis.AnalysisException;
7: import org.overture.ast.definitions.AInstanceVariableDefinition;
8: import org.overture.ast.expressions.AVariableExp;
9: import org.overture.ast.expressions.PExp;
10: import org.overture.ast.intf.lex.ILexNameToken;
11: import org.overture.ast.lex.LexNameToken;
12: import org.overture.pog.pub.IPogAssistantFactory;
13: import org.overture.pog.utility.Substitution;
14:
15: public class OpBodyEndContext extends StatefulContext
16: {
17:         List<Substitution> subs;
18:         IPogAssistantFactory af;
19:
20:         public OpBodyEndContext(List<AInstanceVariableDefinition> state,
21:                         IPogAssistantFactory af)
22:         {
23:                 this.af = af;
24:                 subs = new LinkedList<Substitution>();
25:•                for (AInstanceVariableDefinition i : state)
26:                 {
27:                         AVariableExp var_exp = new AVariableExp();
28:                         ILexNameToken it = i.getName();
29:                         String safename = it.getName() + "$";
30:                         ILexNameToken safeToken = new LexNameToken(it.getModule(), safename, it.getLocation().clone());
31:                         var_exp.setName(safeToken);
32:                         var_exp.setType(i.getType().clone());
33:                         var_exp.setOriginal(i.getName().getName().toString());
34:                         subs.add(new Substitution(i.getOldname(), var_exp));
35:                 }
36:
37:         }
38:
39:         @Override
40:         public String getContext()
41:         {
42:                 // not used anymore. Will go out soon
43:                 return null;
44:         }
45:
46:         @Override
47:         public PExp getContextNode(PExp stitch)
48:         {
49:•                for (Substitution sub : subs)
50:                 {
51:                         try
52:                         {
53:                                 stitch = stitch.clone().apply(af.getVarSubVisitor(), sub);
54:                         } catch (AnalysisException e)
55:                         {
56:                                 e.printStackTrace();
57:                         }
58:                 }
59:                 return stitch;
60:         }
61:
62: }