public static TypePathEntry fromBinary(int tag, int arg) { if (arg != 0 && tag != TypePathEntryKind.TYPE_ARGUMENT.tag) { throw new AssertionError("Invalid TypePathEntry tag/arg: " + tag + "/" + arg); } switch (tag) { case 0: return ARRAY; case 1: return INNER_TYPE; case 2: return WILDCARD; case 3: return new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg); default: throw new AssertionError("Invalid TypePathEntryKind tag: " + tag); } }
private TypePathEntry(TypePathEntryKind tag) { if (!(tag == TypePathEntryKind.ARRAY || tag == TypePathEntryKind.INNER_TYPE || tag == TypePathEntryKind.WILDCARD)) { throw new AssertionError("Invalid TypePathEntryKind: " + tag); } this.tag = tag; this.arg = 0; }
public TypePathEntry(TypePathEntryKind tag, int arg) { if (tag != TypePathEntryKind.TYPE_ARGUMENT) { throw new AssertionError("Invalid TypePathEntryKind: " + tag); } this.tag = tag; this.arg = arg; }
@Override public boolean equals(Object other) { if (! (other instanceof TypePathEntry)) { return false; } TypePathEntry tpe = (TypePathEntry) other; return this.tag == tpe.tag && this.arg == tpe.arg; }
/** * Decode the binary representation for a type path and set * the {@code location} field. * * @param list The bytecode representation of the type path. */ public static List<TypePathEntry> getTypePathFromBinary(List<Integer> list) { List<TypePathEntry> loc = new ArrayList<TypePathEntry>(list.size() / TypePathEntry.bytesPerEntry); int idx = 0; while (idx < list.size()) { if (idx + 1 == list.size()) { throw new AssertionError("Could not decode type path: " + list); } loc.add(TypePathEntry.fromBinary(list.get(idx), list.get(idx + 1))); idx += 2; } return loc; }
public static List<Integer> getBinaryFromTypePath(List<TypePathEntry> locs) { List<Integer> loc = new ArrayList<Integer>(locs.size() * TypePathEntry.bytesPerEntry); for (TypePathEntry tpe : locs) { loc.add(tpe.tag.tag); loc.add(tpe.arg); } return loc; }
/** * Decode the binary representation for a type path and set * the {@code location} field. * * @param list The bytecode representation of the type path. */ public static List<TypePathEntry> getTypePathFromBinary(List<Integer> list) { List<TypePathEntry> loc = new ArrayList<>(list.size() / TypePathEntry.bytesPerEntry); int idx = 0; while (idx < list.size()) { if (idx + 1 == list.size()) { throw new AssertionError("Could not decode type path: " + list); } loc.add(TypePathEntry.fromBinary(list.get(idx), list.get(idx + 1))); idx += 2; } return loc; }
public static List<Integer> getBinaryFromTypePath(List<TypePathEntry> locs) { List<Integer> loc = new ArrayList<>(locs.size() * TypePathEntry.bytesPerEntry); for (TypePathEntry tpe : locs) { loc.add(tpe.tag.tag); loc.add(tpe.arg); } return loc; }