Fix a few VM issues which were causing subtle failures in the test cases.

Includes a new VM method, newCall, which must be called before pushing
a call onto the stack to make sure that base is set correctly.
A couple of weird issues remain with autoload.lua.
This commit is contained in:
Ian Farmer
2007-09-04 01:52:33 +00:00
parent 0f81c4deaf
commit 75fb975410
8 changed files with 45 additions and 6 deletions

24
src/test/res/calls.lua Normal file
View File

@@ -0,0 +1,24 @@
local function f(x)
-- tailcall to a builtin
return math.sin(x)
end
local function factorial(i)
local function helper(sum, n)
if n <= 0 then
return sum
else
-- tail call to a nested Lua function
return helper(n + sum, n - 1)
end
end
return helper(0, i)
end
local result1 = factorial(5)
print(result1)
print(factorial(5))
local result2 = f(math.pi)
print(result2)
print(f(math.pi))