Mercurial > p > unluac > hgcode
changeset 507:d91af66f8b46
Support for excess function calls
author | tehtmi |
---|---|
date | Tue, 24 Oct 2023 20:41:15 -0700 |
parents | ee9d34f1f5ce |
children | ced414e6cb21 |
files | src/unluac/decompile/Decompiler.java src/unluac/decompile/Op.java src/unluac/test/TestFiles.java test/src/excess04.lua |
diffstat | 4 files changed, 32 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/unluac/decompile/Decompiler.java Sun Sep 24 10:24:18 2023 -0700 +++ b/src/unluac/decompile/Decompiler.java Tue Oct 24 20:41:15 2023 -0700 @@ -633,9 +633,10 @@ arguments[register - A - 1] = r.getExpression(register, line); } FunctionCall value = new FunctionCall(function, arguments, multiple); - if(C == 1) { + if(C == 1 && !(A > 0 && (!r.isLocal(A - 1, line) || r.isNewLocal(A - 1, line)))) { operations.add(new CallOperation(line, value)); } else { + if(C == 1) C = 2; if(C == 2 && !multiple) { operations.add(new RegisterSet(line, A, value)); } else {
--- a/src/unluac/decompile/Op.java Sun Sep 24 10:24:18 2023 -0700 +++ b/src/unluac/decompile/Op.java Tue Oct 24 20:41:15 2023 -0700 @@ -281,7 +281,7 @@ case CALL: { int a = ex.A.extract(codepoint); int c = ex.C.extract(codepoint); - if(c == 2) { + if(c == 1 || c == 2) { return a; } else { return -1;
--- a/src/unluac/test/TestFiles.java Sun Sep 24 10:24:18 2023 -0700 +++ b/src/unluac/test/TestFiles.java Tue Oct 24 20:41:15 2023 -0700 @@ -24,6 +24,7 @@ new TestFile("excess01"), new TestFile("excess02", 0x51), new TestFile("excess03"), + new TestFile("excess04"), new TestFile("expression"), new TestFile("expression02"), new TestFile("functioncall"),
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/src/excess04.lua Tue Oct 24 20:41:15 2023 -0700 @@ -0,0 +1,28 @@ +local x, y + +x = 1, f() +print(x) + +x = 1, f(), 3 +print(x) + +x = 1, 2, 3, 4, 5, 6, f() +print(x) + +x, y = 1, 2, f() +print(x, y) + +local a = 1, f() +print(a) + +local b = 1, f(), 3 +print(b) + +local c = 1, 2, 3, f() +print(c) + +local d = f(), 2 +print(d) + +local d, e = 1, 2, f() +print(d, e)