wip: begin dynamic library loading dev

This commit is contained in:
samsonium
2026-10-28 15:20:58 +03:00
parent 70bf63e2ea
commit ea28c470d2
7 changed files with 45 additions and 9 deletions
+6
View File
@@ -0,0 +1,6 @@
/// Converts integer [value] to string
extern fn itos(int value) str;
/// Converts string [value] to integer
extern fn stoi(str value) int;
+6
View File
@@ -0,0 +1,6 @@
/// Get the minimum of specified values
extern fn min([]int ...values) int;
/// Get the maximum of specified values
extern fn max([]int ...values) int;
+13 -8
View File
@@ -28,14 +28,16 @@ fzl_vm_t *fzl_mkvm(const char *filepath)
return NULL;
}
vm->consts = NULL;
vm->consts_count = 0;
vm->ops = NULL;
vm->ops_count = 0;
vm->ip = 0;
vm->dtop = 0;
vm->ctop = 0;
vm->etop = 0;
vm->consts = NULL;
vm->consts_count = 0;
vm->ops = NULL;
vm->ops_count = 0;
vm->externs = NULL;
vm->externs_count = 0;
vm->ip = 0;
vm->dtop = 0;
vm->ctop = 0;
vm->etop = 0;
memset(vm->dstack, 0, sizeof(vm->dstack));
memset(vm->cstack, 0, sizeof(vm->cstack));
@@ -63,6 +65,7 @@ fzl_vm_t *fzl_mkvm(const char *filepath)
size_t consts_count, ops_count;
fread(&consts_count, sizeof(size_t), 1, fd);
fread(&ops_count, sizeof(size_t), 1, fd);
// TODO: read externs count
if (ops_count < 1)
{
@@ -116,6 +119,8 @@ fzl_vm_t *fzl_mkvm(const char *filepath)
fread(&op, sizeof(uint64_t), 1, fd);
vm->ops[i] = op;
}
// TODO: read externs
fclose(fd);
return vm;