1120 break;
1121 default:
1122 assert(false);
1123 }
1124 if (getIndexByTag(tag).size() > 0) return true;
1125 }
1126 return false;
1127 }
1128
1129 }
1130
1131 /** Close the set cpRefs under the getRef(*) relation.
1132 * Also, if flattenSigs, replace all signatures in cpRefs
1133 * by their equivalent Utf8s.
1134 * Also, discard null from cpRefs.
1135 */
1136 public static
1137 void completeReferencesIn(Set<Entry> cpRefs, boolean flattenSigs) {
1138 cpRefs.remove(null);
1139 for (ListIterator<Entry> work =
1140 new ArrayList<Entry>(cpRefs).listIterator(cpRefs.size());
1141 work.hasPrevious(); ) {
1142 Entry e = work.previous();
1143 work.remove(); // pop stack
1144 assert(e != null);
1145 if (flattenSigs && e.tag == CONSTANT_Signature) {
1146 SignatureEntry se = (SignatureEntry) e;
1147 Utf8Entry ue = se.asUtf8Entry();
1148 // Totally replace e by se.
1149 cpRefs.remove(se);
1150 cpRefs.add(ue);
1151 e = ue; // do not descend into the sig
1152 }
1153 // Recursively add the refs of e to cpRefs:
1154 for (int i = 0; ; i++) {
1155 Entry re = e.getRef(i);
1156 if (re == null)
1157 break; // no more refs in e
1158 if (cpRefs.add(re)) // output the ref
1159 work.add(re); // push stack, if a new ref
1160 }
|
1120 break;
1121 default:
1122 assert(false);
1123 }
1124 if (getIndexByTag(tag).size() > 0) return true;
1125 }
1126 return false;
1127 }
1128
1129 }
1130
1131 /** Close the set cpRefs under the getRef(*) relation.
1132 * Also, if flattenSigs, replace all signatures in cpRefs
1133 * by their equivalent Utf8s.
1134 * Also, discard null from cpRefs.
1135 */
1136 public static
1137 void completeReferencesIn(Set<Entry> cpRefs, boolean flattenSigs) {
1138 cpRefs.remove(null);
1139 for (ListIterator<Entry> work =
1140 new ArrayList<>(cpRefs).listIterator(cpRefs.size());
1141 work.hasPrevious(); ) {
1142 Entry e = work.previous();
1143 work.remove(); // pop stack
1144 assert(e != null);
1145 if (flattenSigs && e.tag == CONSTANT_Signature) {
1146 SignatureEntry se = (SignatureEntry) e;
1147 Utf8Entry ue = se.asUtf8Entry();
1148 // Totally replace e by se.
1149 cpRefs.remove(se);
1150 cpRefs.add(ue);
1151 e = ue; // do not descend into the sig
1152 }
1153 // Recursively add the refs of e to cpRefs:
1154 for (int i = 0; ; i++) {
1155 Entry re = e.getRef(i);
1156 if (re == null)
1157 break; // no more refs in e
1158 if (cpRefs.add(re)) // output the ref
1159 work.add(re); // push stack, if a new ref
1160 }
|