Package: CallSequence

CallSequence

nameinstructionbranchcomplexitylinemethod
CallSequence()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
compareItem(CallSequence, int)
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%
compareStem(CallSequence, int)
M: 2 C: 28
93%
M: 1 C: 7
88%
M: 1 C: 4
80%
M: 1 C: 9
90%
M: 0 C: 1
100%
getFilter()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setFilter(int)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
toShape(TraceReductionType)
M: 17 C: 77
82%
M: 4 C: 8
67%
M: 3 C: 5
63%
M: 4 C: 23
85%
M: 0 C: 1
100%
toString()
M: 0 C: 34
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 9
100%
M: 0 C: 1
100%

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