MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / compareTo

Method compareTo

src/main/java/wycc/util/AbstractItem.java:207–237  ·  view source on GitHub ↗
(Item other)

Source from the content-addressed store, hash-verified

205 }
206
207 @Override
208 public int compareTo(Item other) {
209 int diff = opcode - other.getOpcode();
210 if (diff != 0) {
211 return diff;
212 }
213 // We have two items with the same opcode. Need to investigate their
214 // structure.
215 diff = size() - other.size();
216 if (diff != 0) {
217 return diff;
218 }
219 for (int i = 0; i != size(); ++i) {
220 Item my_ith = get(i);
221 Item other_ith = other.get(i);
222 if (my_ith == null && other_ith == null) {
223 // skip
224 } else if(my_ith == null) {
225 // null is below everything
226 return -1;
227 } else if(other_ith == null) {
228 return 1;
229 } else {
230 diff = my_ith.compareTo(other_ith);
231 if (diff != 0) {
232 return diff;
233 }
234 }
235 }
236 return compareData(data, other.getData());
237 }
238
239 /**
240 * Compare the data object associated with a given syntactic item. An

Callers 1

compareDataMethod · 0.45

Calls 7

sizeMethod · 0.95
getMethod · 0.95
compareDataMethod · 0.95
getOpcodeMethod · 0.65
sizeMethod · 0.65
getMethod · 0.65
getDataMethod · 0.65

Tested by

no test coverage detected