Package: ConcurrentTraceNode

ConcurrentTraceNode

nameinstructionbranchcomplexitylinemethod
ConcurrentTraceNode()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
add(TraceNode)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
get(int)
M: 136 C: 0
0%
M: 18 C: 0
0%
M: 10 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
getTests()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
size()
M: 105 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 26 C: 0
0%
M: 1 C: 0
0%
toString()
M: 40 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (c) 2010 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.codegen.runtime.traces;
25:
26: import java.util.HashMap;
27: import java.util.List;
28: import java.util.Map;
29: import java.util.Vector;
30:
31: public class ConcurrentTraceNode extends TraceNode implements IIterableTraceNode
32: {
33:         private Map<Integer, Pair<Integer, Integer>> indics;
34:         public List<TraceNode> nodes;
35:
36:         public void add(TraceNode node)
37:         {
38:                 nodes.add(node);
39:         }
40:
41:         public ConcurrentTraceNode()
42:         {
43:                 nodes = new Vector<TraceNode>();
44:         }
45:
46:         @Override
47:         public CallSequence get(int index)
48:         {
49:•                if (indics == null)
50:                 {
51:                         size();
52:                 }
53:                 Pair<Integer, Integer> v = indics.get(index);
54:
55:                 List<TestSequence> nodetests = new Vector<TestSequence>();
56:                 int count = nodes.size();
57:
58:•                for (TraceNode node : nodes)
59:                 {
60:                         nodetests.add(node.getTests());
61:                 }
62:
63:                 PermuteArray pa = new PermuteArray(count);
64:
65:                 int r = 0;
66:
67:•                while (pa.hasNext())
68:                 {
69:                         int[] perm = pa.next();
70:                         r++;
71:•                        if (r < v.getFirst())
72:                         {
73:                                 continue;
74:                         }
75:
76:                         int[] sizes = new int[count];
77:
78:•                        for (int i = 0; i < count; i++)
79:                         {
80:                                 sizes[i] = nodetests.get(perm[i]).size();
81:                         }
82:
83:                         Permutor p = new Permutor(sizes);
84:
85:                         int j = 0;
86:•                        while (p.hasNext())
87:                         {
88:                                 int[] select = p.next();
89:                                 j++;
90:•                                if (j < v.getSecond())
91:                                 {
92:                                         continue;
93:                                 }
94:                                 CallSequence seq = getVars();
95:
96:•                                for (int i = 0; i < count; i++)
97:                                 {
98:                                         TestSequence ith = nodetests.get(perm[i]);
99:
100:•                                        if (!ith.isEmpty())
101:                                         {
102:                                                 CallSequence subseq = ith.get(select[i]);
103:                                                 seq.addAll(subseq);
104:                                         }
105:                                 }
106:
107:                                 return seq;
108:                         }
109:                 }
110:
111:                 return null;
112:         }
113:
114:         @Override
115:         public TestSequence getTests()
116:         {
117:                 return new LazyTestSequence(this);
118:         }
119:
120:         @Override
121:         public int size()
122:         {
123:•                if (indics != null)
124:                 {
125:                         return indics.size();
126:                 }
127:
128:                 indics = new HashMap<Integer, Pair<Integer, Integer>>();
129:
130:                 int size = 0;
131:
132:                 List<TestSequence> nodetests = new Vector<TestSequence>();
133:                 int count = nodes.size();
134:
135:•                for (TraceNode node : nodes)
136:                 {
137:                         nodetests.add(node.getTests());
138:                 }
139:
140:                 PermuteArray pa = new PermuteArray(count);
141:
142:                 int r = 0;
143:•                while (pa.hasNext())
144:                 {
145:                         r++;
146:                         int[] sizes = new int[count];
147:                         int[] perm = pa.next();
148:
149:•                        for (int i = 0; i < count; i++)
150:                         {
151:                                 sizes[i] = nodetests.get(perm[i]).size();
152:                         }
153:
154:                         Permutor p = new Permutor(sizes);
155:
156:                         int j = 0;
157:•                        while (p.hasNext())
158:                         {
159:                                 j++;
160:                                 p.next();
161:                                 indics.put(size, new Pair<Integer, Integer>(r, j));
162:                                 size++;
163:                         }
164:                 }
165:
166:                 return size;
167:         }
168:
169:         @Override
170:         public String toString()
171:         {
172:                 StringBuilder sb = new StringBuilder();
173:                 sb.append("|| (");
174:                 String sep = "";
175:
176:•                for (TraceNode node : nodes)
177:                 {
178:                         sb.append(sep);
179:                         sb.append(node.toString());
180:                         sep = ", ";
181:                 }
182:
183:                 sb.append(")");
184:                 return sb.toString();
185:         }
186: }