Fix bugs in emit API

This commit is contained in:
Alexey Andreev 2015-07-30 23:09:07 +03:00
parent 0be4ca336d
commit e95b537687
4 changed files with 8 additions and 3 deletions

View File

@ -119,7 +119,7 @@ public interface ClassReaderSource {
return Optional.of(true); return Optional.of(true);
} }
ClassReader cls = get(subType); ClassReader cls = get(subType);
if (subType == null) { if (cls == null) {
return Optional.empty(); return Optional.empty();
} }
if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) {

View File

@ -345,6 +345,9 @@ public final class ProgramEmitter {
} }
public void addInstruction(Instruction insn) { public void addInstruction(Instruction insn) {
if (escapes()) {
throw new EmitException("This block has already escaped");
}
if (currentLocation != null) { if (currentLocation != null) {
insn.setLocation(currentLocation); insn.setLocation(currentLocation);
} }

View File

@ -39,8 +39,10 @@ public class StringChooseEmitter {
this.insn = insn; this.insn = insn;
this.joinBlock = joinBlock; this.joinBlock = joinBlock;
this.otherwiseBlock = pe.prepareBlock(); this.otherwiseBlock = pe.prepareBlock();
this.testValue = testValue;
insn.setCondition(testValue.invokeVirtual("hashCode", int.class).getVariable()); insn.setCondition(testValue.invokeVirtual("hashCode", int.class).getVariable());
insn.setDefaultTarget(otherwiseBlock); insn.setDefaultTarget(otherwiseBlock);
pe.addInstruction(insn);
pe.enter(otherwiseBlock); pe.enter(otherwiseBlock);
pe.jump(joinBlock); pe.jump(joinBlock);
pe.enter(joinBlock); pe.enter(joinBlock);
@ -62,7 +64,7 @@ public class StringChooseEmitter {
} }
pe.enter(block); pe.enter(block);
fork = testValue.invokeVirtual("equals", boolean.class, testValue.cast(Object.class)) fork = testValue.invokeVirtual("equals", boolean.class, pe.constant(value).cast(Object.class))
.fork(BranchingCondition.NOT_EQUAL); .fork(BranchingCondition.NOT_EQUAL);
hashForks.put(hash, fork); hashForks.put(hash, fork);

View File

@ -229,7 +229,7 @@ public class InstructionStringifier implements InstructionReader {
sb.append("; "); sb.append("; ");
} }
SwitchTableEntryReader entry = table.get(i); SwitchTableEntryReader entry = table.get(i);
sb.append("case ").append(entry.getCondition()).append(": goto $").append(entry.getTarget()); sb.append("case ").append(entry.getCondition()).append(": goto $").append(entry.getTarget().getIndex());
} }
sb.append(", default: goto $").append(defaultTarget.getIndex()); sb.append(", default: goto $").append(defaultTarget.getIndex());
} }