/** * Throws an exception when an invalid state is hit in a tableswitch */ private static void stateNotFound(final CodeAttribute c, final TableSwitchBuilder builder) { c.branchEnd(builder.getDefaultBranchEnd().get()); c.newInstruction(RuntimeException.class); c.dup(); c.ldc("Invalid character"); c.invokespecial(RuntimeException.class.getName(), "<init>", "(Ljava/lang/String;)V"); c.athrow(); }
TableSwitchBuilder builder = new TableSwitchBuilder(-2, noStates); final IdentityHashMap<State, AtomicReference<BranchEnd>> ends = new IdentityHashMap<State, AtomicReference<BranchEnd>>(); final AtomicReference<BranchEnd> prefixMatch = builder.add(); final AtomicReference<BranchEnd> noState = builder.add(); ends.put(initial, builder.add()); for (final State s : states) { if (s.stateno > 0) { ends.put(s, builder.add());
if (builder.getHigh() - builder.getLow() + 1 != builder.getValues().size()) { throw new RuntimeException("high - low + 1 != the number of values in the table"); if (builder.getDefaultLocation() != null) { writeInt(builder.getDefaultLocation().getLocation() - currentOffset); } else { writeInt(0); final BranchEnd ret = new BranchEnd(currentOffset, frame, true, startOffset); builder.getDefaultBranchEnd().set(ret); writeInt(builder.getLow()); writeInt(builder.getHigh()); currentOffset += 12; for (final TableSwitchBuilder.ValuePair value : builder.getValues()) { if (value.getLocation() != null) { writeInt(value.getLocation().getLocation());
if (builder.getHigh() - builder.getLow() + 1 != builder.getValues().size()) { throw new RuntimeException("high - low + 1 != the number of values in the table"); if (builder.getDefaultLocation() != null) { writeInt(builder.getDefaultLocation().getLocation() - currentOffset); } else { writeInt(0); final BranchEnd ret = new BranchEnd(currentOffset, frame, true, startOffset); builder.getDefaultBranchEnd().set(ret); writeInt(builder.getLow()); writeInt(builder.getHigh()); currentOffset += 12; for (final TableSwitchBuilder.ValuePair value : builder.getValues()) { if (value.getLocation() != null) { writeInt(value.getLocation().getLocation());
if (builder.getHigh() - builder.getLow() + 1 != builder.getValues().size()) { throw new RuntimeException("high - low + 1 != the number of values in the table"); if (builder.getDefaultLocation() != null) { writeInt(builder.getDefaultLocation().getLocation() - currentOffset); } else { writeInt(0); final BranchEnd ret = new BranchEnd(currentOffset, frame, true, startOffset); builder.getDefaultBranchEnd().set(ret); writeInt(builder.getLow()); writeInt(builder.getHigh()); currentOffset += 12; for (final TableSwitchBuilder.ValuePair value : builder.getValues()) { if (value.getLocation() != null) { writeInt(value.getLocation().getLocation());
if(builder.getHigh() - builder.getLow() + 1 != builder.getValues().size()) { throw new RuntimeException("high - low + 1 != the number of values in the table"); if (builder.getDefaultLocation() != null) { writeInt(builder.getDefaultLocation().getLocation() - currentOffset); } else { writeInt(0); final BranchEnd ret = new BranchEnd(currentOffset, frame, true, startOffset); builder.getDefaultBranchEnd().set(ret); writeInt(builder.getLow()); writeInt(builder.getHigh()); currentOffset += 12; for (final TableSwitchBuilder.ValuePair value : builder.getValues()) { if (value.getLocation() != null) { writeInt(value.getLocation().getLocation());
if (builder.getHigh() - builder.getLow() + 1 != builder.getValues().size()) { throw new RuntimeException("high - low + 1 != the number of values in the table"); if (builder.getDefaultLocation() != null) { writeInt(builder.getDefaultLocation().getLocation() - currentOffset); } else { writeInt(0); final BranchEnd ret = new BranchEnd(currentOffset, frame, true, startOffset); builder.getDefaultBranchEnd().set(ret); writeInt(builder.getLow()); writeInt(builder.getHigh()); currentOffset += 12; for (final TableSwitchBuilder.ValuePair value : builder.getValues()) { if (value.getLocation() != null) { writeInt(value.getLocation().getLocation());