Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -130888
at unluac.decompile.Code.op(Code.java:42)
at unluac.decompile.Decompiler._helper_popSetCondition(Decompiler.java:1092)
at unluac.decompile.Decompiler.popSetCondition(Decompiler.java:1063)
at unluac.decompile.Decompiler.handleBranches(Decompiler.java:829)
at unluac.decompile.Decompiler.decompile(Decompiler.java:107)
at unluac.decompile.expression.ClosureExpression.printMain(ClosureExpression.java:95)
at unluac.decompile.expression.ClosureExpression.printClosure(ClosureExpression.java:68)
at unluac.decompile.statement.Assignment.print(Assignment.java:119)
at unluac.decompile.statement.Statement.printSequence(Statement.java:23)
at unluac.decompile.block.OuterBlock.print(OuterBlock.java:58)
at unluac.decompile.Decompiler.print(Decompiler.java:122)
at unluac.decompile.Decompiler.print(Decompiler.java:113)
at unluac.Main.main(Main.java:43)
Last edit: gir489 2014-05-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
case TESTNIL:
testset = true;
testsetend = line + 2 + code.sBx(line);
stack.push(new TestSetNode(code.A(line), code.A(line) + 1, false, line, line + 2, testsetend));
skip[line + 1] = true;
continue;
Also, I've noticed there's a lot of @Override tags that are used without actually override any functions. Probably doesn't mean shit for 1.5, but in 1.7 that causes an exception.
Last edit: gir489 2014-05-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Also, I've noticed there's a lot of @Override tags that are used without actually override any functions."
I'm not sure what you are talking about. Maybe using @Override when implementing interface methods (http://stackoverflow.com/questions/1678122)? Can you give me a specific example?
As for TESTNIL, this is the reference I'm using.
// OP_TESTNIL: A sBx; if R(A+1) ~= nil then R(A)=R(A+1); pc+=sBx
case OP_TESTNIL: {
if (!ttisnil(ra+1)) {
setobjs2s(L, ra, ra+1);
dojump(L, pc, GETARG_sBx(i));
}
continue;
}
This makes me a little nervous because it is the only jumping instruction that doesn't go through OP_JMP, but it could still work.
I think the correct implementation would be:
case TESTNIL:
testset = true;
testsetend = line + 1 + code.sBx(line); // + 1 here, not 2 because no OP_JMP
stack.push(new TestSetNode(code.A(line), code.A(line) + 1, false, line, line + 1, testsetend)); // line + 1 because no OP_JMP
// don't skip the next line
continue;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually, looking more carefully at the patch that uses OP_TESTNIL, it appears that this op is only emitted for TFOR loops. To handle this correctly, you don't need to push any nodes onto the branch stack, you just need to create a TForBlock. The current code that does this is in case JMP. It seems like it would be pretty similar in the OP_TESTNIL case.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to add support for OP_TESTNIL, but I am having 0 success.
Here's what I've come up with so far:
case TESTNIL:
testset = true;
testsetend = line + 2 + code.sBx(line + 1);
stack.push(new TestSetNode(code.A(line), code.A(line) + 1, false, line, line + 2, line + 2 + code.sBx(line + 1)));
skip[line + 1] = true;
continue;
TESTNIL(OpcodeFormat.A_sBx),
Here's the file I'm using: https://www.mediafire.com/?mak67ppdp4lcjv4
Stack trace:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -130888
at unluac.decompile.Code.op(Code.java:42)
at unluac.decompile.Decompiler._helper_popSetCondition(Decompiler.java:1092)
at unluac.decompile.Decompiler.popSetCondition(Decompiler.java:1063)
at unluac.decompile.Decompiler.handleBranches(Decompiler.java:829)
at unluac.decompile.Decompiler.decompile(Decompiler.java:107)
at unluac.decompile.expression.ClosureExpression.printMain(ClosureExpression.java:95)
at unluac.decompile.expression.ClosureExpression.printClosure(ClosureExpression.java:68)
at unluac.decompile.statement.Assignment.print(Assignment.java:119)
at unluac.decompile.statement.Statement.printSequence(Statement.java:23)
at unluac.decompile.block.OuterBlock.print(OuterBlock.java:58)
at unluac.decompile.Decompiler.print(Decompiler.java:122)
at unluac.decompile.Decompiler.print(Decompiler.java:113)
at unluac.Main.main(Main.java:43)
Last edit: gir489 2014-05-14
Fixed it.
case TESTNIL:
testset = true;
testsetend = line + 2 + code.sBx(line);
stack.push(new TestSetNode(code.A(line), code.A(line) + 1, false, line, line + 2, testsetend));
skip[line + 1] = true;
continue;
Also, I've noticed there's a lot of @Override tags that are used without actually override any functions. Probably doesn't mean shit for 1.5, but in 1.7 that causes an exception.
Last edit: gir489 2014-05-14
"Also, I've noticed there's a lot of @Override tags that are used without actually override any functions."
I'm not sure what you are talking about. Maybe using @Override when implementing interface methods (http://stackoverflow.com/questions/1678122)? Can you give me a specific example?
As for TESTNIL, this is the reference I'm using.
// OP_TESTNIL: A sBx; if R(A+1) ~= nil then R(A)=R(A+1); pc+=sBx
case OP_TESTNIL: {
if (!ttisnil(ra+1)) {
setobjs2s(L, ra, ra+1);
dojump(L, pc, GETARG_sBx(i));
}
continue;
}
This makes me a little nervous because it is the only jumping instruction that doesn't go through OP_JMP, but it could still work.
I think the correct implementation would be:
case TESTNIL:
testset = true;
testsetend = line + 1 + code.sBx(line); // + 1 here, not 2 because no OP_JMP
stack.push(new TestSetNode(code.A(line), code.A(line) + 1, false, line, line + 1, testsetend)); // line + 1 because no OP_JMP
// don't skip the next line
continue;
Actually, looking more carefully at the patch that uses OP_TESTNIL, it appears that this op is only emitted for TFOR loops. To handle this correctly, you don't need to push any nodes onto the branch stack, you just need to create a TForBlock. The current code that does this is in case JMP. It seems like it would be pretty similar in the OP_TESTNIL case.