Skip over empty branch destinations

This commit is contained in:
James Roseborough
2010-05-06 04:34:30 +00:00
parent 40672336bf
commit 482b6056a1

View File

@@ -696,9 +696,12 @@ public class JavaBuilder {
int nc = p.code.length; int nc = p.code.length;
for (int pc = 0; pc < nc; pc++) { for (int pc = 0; pc < nc; pc++) {
if (branches[pc] != null) { if (branches[pc] != null) {
if ( branchDestHandles[targets[pc]] == null ) int t=targets[pc];
throw new IllegalArgumentException("no target at "+targets[pc]+" op="+Lua.GET_OPCODE(p.code[targets[pc]])); while ( t<branchDestHandles.length && branchDestHandles[t] == null )
branches[pc].setTarget(branchDestHandles[targets[pc]]); t++;
if ( t>= branchDestHandles.length )
throw new IllegalArgumentException("no target at or after "+targets[pc]+" op="+Lua.GET_OPCODE(p.code[targets[pc]]));
branches[pc].setTarget(branchDestHandles[t]);
} }
} }
} }