.
This commit is contained in:
@@ -5,9 +5,9 @@ Progress of the Lua port:
|
||||
- [x] Logic/arithmetic expressions
|
||||
- [x] Variables
|
||||
- [x] Local variables
|
||||
- [ ] Functions
|
||||
- [ ] Calling functions
|
||||
- [ ] Calling functions with parameters
|
||||
- [x] Functions
|
||||
- [x] Calling functions
|
||||
- [x] Calling functions with parameters
|
||||
- [ ] Control flow
|
||||
- [ ] Lablels in Assembly
|
||||
- [ ] Recursion
|
||||
|
||||
@@ -198,7 +198,7 @@ do TEST("VM: local variables")
|
||||
end
|
||||
|
||||
do TEST("VM: functions")
|
||||
local vm = VM:new():set_debug(true):load(assemble([[
|
||||
local vm = VM:new():load(assemble([[
|
||||
.func 0
|
||||
pushf 1
|
||||
pushi 2
|
||||
@@ -208,12 +208,12 @@ do TEST("VM: functions")
|
||||
.func 1
|
||||
dupv 0
|
||||
dupv 1
|
||||
sum
|
||||
sub
|
||||
ret
|
||||
]])):call(0)
|
||||
|
||||
assert_eq(vm:stack_sz(), 1)
|
||||
assert_eq(vm:to_integer(-1), 5)
|
||||
assert_eq(vm:to_integer(-1), -1)
|
||||
end
|
||||
|
||||
print('End.')
|
||||
@@ -340,11 +340,11 @@ function VM:_step()
|
||||
elseif op.operator == 'set' then
|
||||
assert(op.operand >= 0)
|
||||
local a = self.stack:pop()
|
||||
self.stack[op.operand + 1] = a
|
||||
self.stack[op.operand] = a
|
||||
|
||||
elseif op.operator == 'dupv' then
|
||||
assert(op.operand >= 0)
|
||||
local a = self.stack[op.operand + 1]
|
||||
local a = self.stack[op.operand]
|
||||
self.stack:push(a)
|
||||
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user