wip: working on extern in VM
- Feat: add usage of vm reader instead of old way in vm.c - Ref: update debug opcodes printing
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <vm/internals/reader.h>
|
||||
|
||||
// Read opcodes
|
||||
bool vm_rd_ops(fzl_vm_reader_t *reader, FILE *fd)
|
||||
{
|
||||
if (!reader || !fd)
|
||||
return false;
|
||||
|
||||
size_t ops_count = reader->ops_count;
|
||||
if (!ops_count)
|
||||
return false;
|
||||
|
||||
reader->ops = malloc(sizeof(size_t) * ops_count);
|
||||
if (!reader->ops)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < ops_count; i++)
|
||||
{
|
||||
size_t opcode;
|
||||
if (!vm_rd_word(fd, 1, &opcode))
|
||||
return false;
|
||||
|
||||
reader->ops[i] = opcode;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user