Initial draft of interpreter. Lua compiled "chunks" can be unmarshalled. Approximately half of bytecodes implemented in some form or another.

This commit is contained in:
James Roseborough
2007-06-08 05:11:37 +00:00
commit 70dfc20f57
31 changed files with 1368 additions and 0 deletions

7
src/test/res/compile.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
LUA_HOME=/cygdrive/c/programs/lua5.1
for x in test1 test2 test3 test4
do
echo compiling $x
${LUA_HOME}/luac5.1.exe -l -o ${x}.luac ${x}.lua
done

5
src/test/res/test1.lua Normal file
View File

@@ -0,0 +1,5 @@
a = 123 + 456
print( a )

BIN
src/test/res/test1.luac Normal file

Binary file not shown.

10
src/test/res/test2.lua Normal file
View File

@@ -0,0 +1,10 @@
function sum(a,b,c,d) -- "sum" method
return a+b+c+d -- return sum
end
print( sum( 1, 2, 3, 4 ) )
print( sum( 5, 6, 7 ) )
print( sum( 9, 10, 11, 12, 13, 14 ) )
print( sum( sum(1,2,3,4), sum(5,6,7), sum(9,10,11,12,13,14), 15 ) )

BIN
src/test/res/test2.luac Normal file

Binary file not shown.

6
src/test/res/test3.lua Normal file
View File

@@ -0,0 +1,6 @@
a = func(1, 2, 3)
a = func(3, 2, 1)
a = func(func(),func(),func())

BIN
src/test/res/test3.luac Normal file

Binary file not shown.

8
src/test/res/test4.lua Normal file
View File

@@ -0,0 +1,8 @@
function Point(x, y) -- "Point" object constructor
return { x = x, y = y } -- Creates and returns a new object (table)
end
array = { Point(10, 20), Point(30, 40), Point(50, 60) } -- Creates array of points
print(array[2].y) -- Prints 40

BIN
src/test/res/test4.luac Normal file

Binary file not shown.