Package: CallSequence

CallSequence

nameinstructionbranchcomplexitylinemethod
CallSequence()
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%
compareItem(CallSequence, int)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
compareStem(CallSequence, int)
M: 30 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
getFilter()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setFilter(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
toShape(TraceReductionType)
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%
toString()
M: 34 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (C) 2008, 2009 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.LinkedList;
27:
28: @SuppressWarnings("serial")
29: public class CallSequence extends LinkedList<Statement>
30: {
31:         private int filtered = 0;
32:
33:         @Override
34:         public String toString()
35:         {
36:                 StringBuilder sb = new StringBuilder();
37:                 String sep = "";
38:
39:•                for (Statement stmt : this)
40:                 {
41:•                        if (!(stmt instanceof TraceVariable))
42:                         {
43:                                 sb.append(sep);
44:                                 sb.append(stmt.toString());
45:                                 sep = "; ";
46:                         }
47:                 }
48:
49:                 return sb.toString();
50:         }
51:
52:         public String toShape(TraceReductionType type)
53:         {
54:                 throw new UnsupportedOperationException("Support for shaping has not yet been implemented");
55:
56:                 // StringBuilder sb = new StringBuilder();
57:                 // String sep = "";
58:                 //
59:                 // for (PStm stmt : this)
60:                 // {
61:                 // if (stmt instanceof TraceVariableStatement)
62:                 // {
63:                 // TraceVariableStatement tvs = (TraceVariableStatement) stmt;
64:                 //
65:                 // switch (type)
66:                 // {
67:                 // case SHAPES_NOVARS:
68:                 // break;
69:                 //
70:                 // case SHAPES_VARNAMES:
71:                 // sb.append(sep);
72:                 // sb.append(tvs.var.name);
73:                 // sep = "; ";
74:                 // break;
75:                 //
76:                 // case SHAPES_VARVALUES:
77:                 // sb.append(sep);
78:                 // sb.append(tvs.toString());
79:                 // sep = "; ";
80:                 // break;
81:                 //
82:                 // default:
83:                 // break;
84:                 // }
85:                 // } else if (stmt instanceof ACallStm)
86:                 // {
87:                 // ACallStm cs = (ACallStm) stmt;
88:                 // sb.append(sep);
89:                 // sb.append(cs.getName().getName());
90:                 // sep = "; ";
91:                 // } else if (stmt instanceof ACallObjectStm)
92:                 // {
93:                 // ACallObjectStm cs = (ACallObjectStm) stmt;
94:                 // sb.append(sep);
95:                 // sb.append(cs.getFieldname());
96:                 // sep = "; ";
97:                 // }
98:                 // }
99:                 //
100:                 // return sb.toString();
101:         }
102:
103:         public boolean compareStem(CallSequence other, int upto)
104:         {
105:                 // Note that the upto count does not include the variable statements
106:                 // that may be in the sequences, but those variables do need to be
107:                 // included in the stem match. "count" is the position ignoring any
108:                 // variable statements.
109:
110:                 int i = 0;
111:
112:•                for (int count = 0; count < upto;)
113:                 {
114:•                        if (i >= size())
115:                         {
116:                                 return false;
117:                         }
118:
119:•                        if (!compareItem(other, i))
120:                         {
121:                                 return false;
122:                         }
123:
124:•                        if (!(get(i) instanceof TraceVariable))
125:                         {
126:                                 count++; // Only increment for non-variable statements
127:                         }
128:
129:                         i++;
130:                 }
131:
132:                 return true;
133:         }
134:
135:         private boolean compareItem(CallSequence other, int i)
136:         {
137:                 return get(i).toString().equals(other.get(i).toString());
138:         }
139:
140:         public void setFilter(int n)
141:         {
142:                 filtered = n;
143:         }
144:
145:         public int getFilter()
146:         {
147:                 return filtered;
148:         }
149: }