Support indirect calls with omitted arguments

This commit is contained in:
dcodeIO
2018-03-24 09:46:22 +01:00
parent 664f2a1c0d
commit 19a616dd96
18 changed files with 1084 additions and 531 deletions

View File

@ -1,6 +1,11 @@
function opt(a: i32, b: i32 = -1, c: i32 = -2): i32 {
return a + b + c;
}
assert(opt(3) == 0); // calls the trampoline with N=0
assert(opt(3, 4) == 5); // calls the trampoline with N=1
assert(opt(3) == 0); // calls the trampoline with 0of2
assert(opt(3, 4) == 5); // calls the trampoline with 1of2
assert(opt(3, 4, 5) == 12); // calls the function directly
var optIndirect = opt;
assert(optIndirect(3) == 0); // calls the trampoline indirectly with 0of2
assert(optIndirect(3, 4) == 5); // calls the trampoline indirectly with 1of2
assert(optIndirect(3, 4, 5) == 12); // calls the trampoline indirectly with 2of2