.
This commit is contained in:
4
TODO.md
4
TODO.md
@@ -15,8 +15,8 @@ Decisions:
|
||||
- [x] Arrays
|
||||
- [x] Tables
|
||||
- [ ] VM
|
||||
- [ ] (Lua interface) call assembler
|
||||
- [ ] (Lua) generate bytecode
|
||||
- [x] (Lua interface) call assembler
|
||||
- [x] (Lua) generate bytecode
|
||||
- [ ] Labels
|
||||
- [ ] Code
|
||||
- [ ] Interpret bytecode (fast)
|
||||
|
||||
@@ -227,6 +227,10 @@ local function assemble(proto)
|
||||
if opcode == nil then error("Unknown instruction " .. inst[1]) end
|
||||
if operand == nil then
|
||||
push8(opcode)
|
||||
elseif type(operand) == 'string' then
|
||||
-- TODO
|
||||
push8(opcode)
|
||||
push16(0)
|
||||
else
|
||||
if opcode >= 0xc0 and opcode < 0xe0 then
|
||||
push8(opcode)
|
||||
|
||||
19
test/tests.c
19
test/tests.c
@@ -269,4 +269,23 @@ int main()
|
||||
code_destroy(code);
|
||||
free(bytecode);
|
||||
}
|
||||
|
||||
{
|
||||
printf("### Bytecode - labels\n");
|
||||
const char* assembly_code =
|
||||
".func 0\n"
|
||||
" jmp @my_label\n"
|
||||
" pushi \n"
|
||||
"@my_label:\n"
|
||||
" ret";
|
||||
|
||||
uint8_t* bytecode; size_t bytecode_sz;
|
||||
assert(code_assemble(assembly_code, &bytecode, &bytecode_sz) == T_OK);
|
||||
|
||||
Code* code = code_new();
|
||||
assert(code_load_bytecode(code, bytecode, bytecode_sz) == T_OK);
|
||||
|
||||
code_destroy(code);
|
||||
free(bytecode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user