Package: StateDesInfo

StateDesInfo

nameinstructionbranchcomplexitylinemethod
StateDesInfo()
M: 0 C: 19
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
addStateDesDecl(SStmIR, List)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addStateDesVars(SStmIR, List)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getEnclosingClass(AIdentifierVarExpIR)
M: 13 C: 40
75%
M: 2 C: 6
75%
M: 2 C: 3
60%
M: 2 C: 8
80%
M: 0 C: 1
100%
getStateDesVars(SStmIR)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isStateDesDecl(AVarDeclIR)
M: 0 C: 39
100%
M: 1 C: 7
88%
M: 1 C: 4
80%
M: 0 C: 9
100%
M: 0 C: 1
100%
register(SStmIR, List, List)
M: 0 C: 17
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
remove(SStmIR)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
replaceStateDesOwner(SStmIR, SStmIR)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: package org.overture.codegen.vdm2jml.data;
2:
3: import java.util.HashMap;
4: import java.util.List;
5: import java.util.Map;
6:
7: import org.apache.log4j.Logger;
8: import org.overture.codegen.ir.SStmIR;
9: import org.overture.codegen.ir.declarations.ADefaultClassDeclIR;
10: import org.overture.codegen.ir.declarations.AVarDeclIR;
11: import org.overture.codegen.ir.expressions.AIdentifierVarExpIR;
12: import org.overture.codegen.runtime.traces.Pair;
13:
14: public class StateDesInfo
15: {
16:         private Map<SStmIR, List<AIdentifierVarExpIR>> stateDesVars;
17:         private Map<SStmIR, List<AVarDeclIR>> stateDesDecls;
18:
19:         private Logger log = Logger.getLogger(this.getClass().getName());
20:
21:         public StateDesInfo()
22:         {
23:                 this.stateDesVars = new HashMap<>();
24:                 this.stateDesDecls = new HashMap<>();
25:         }
26:
27:         public void addStateDesVars(SStmIR stm,
28:                         List<AIdentifierVarExpIR> stateDesVars)
29:         {
30:                 this.stateDesVars.put(stm, stateDesVars);
31:         }
32:
33:         public void addStateDesDecl(SStmIR stm, List<AVarDeclIR> stateDesDecls)
34:         {
35:                 this.stateDesDecls.put(stm, stateDesDecls);
36:         }
37:
38:         public void replaceStateDesOwner(SStmIR oldKey, SStmIR newKey)
39:         {
40:                 register(newKey, stateDesVars.remove(oldKey), stateDesDecls.remove(oldKey));
41:         }
42:
43:         public Pair<List<AIdentifierVarExpIR>, List<AVarDeclIR>> remove(SStmIR key)
44:         {
45:                 return new Pair<List<AIdentifierVarExpIR>, List<AVarDeclIR>>(stateDesVars.remove(key), stateDesDecls.remove(key));
46:         }
47:
48:         public void register(SStmIR key, List<AIdentifierVarExpIR> vars,
49:                         List<AVarDeclIR> decls)
50:         {
51:•                if (vars != null)
52:                 {
53:                         stateDesVars.put(key, vars);
54:                 }
55:
56:•                if (decls != null)
57:                 {
58:                         stateDesDecls.put(key, decls);
59:                 }
60:         }
61:
62:         public boolean isStateDesDecl(AVarDeclIR decl)
63:         {
64:•                for (SStmIR stm : stateDesDecls.keySet())
65:                 {
66:                         List<AVarDeclIR> decls = stateDesDecls.get(stm);
67:
68:•                        if (decls != null)
69:                         {
70:•                                for (AVarDeclIR d : decls)
71:                                 {
72:•                                        if (d == decl)
73:                                         {
74:                                                 return true;
75:                                         }
76:                                 }
77:                         }
78:
79:                 }
80:
81:                 return false;
82:         }
83:
84:         public List<AIdentifierVarExpIR> getStateDesVars(SStmIR stm)
85:         {
86:                 return stateDesVars.get(stm);
87:         }
88:
89:         public ADefaultClassDeclIR getEnclosingClass(
90:                         AIdentifierVarExpIR stateDesVar)
91:         {
92:•                for (SStmIR k : stateDesVars.keySet())
93:                 {
94:•                        for (AIdentifierVarExpIR v : stateDesVars.get(k))
95:                         {
96:•                                if (v == stateDesVar)
97:                                 {
98:                                         ADefaultClassDeclIR encClass = k.getAncestor(ADefaultClassDeclIR.class);
99:
100:•                                        if (encClass == null)
101:                                         {
102:                                                 log.error("Could not find enclosing class of "
103:                                                                 + stateDesVar);
104:                                         }
105:
106:                                         return encClass;
107:                                 }
108:                         }
109:                 }
110:
111:                 return null;
112:         }
113: }