diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-02-06 00:12:48 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-02-07 00:04:35 +0100 |
commit | 3a49192f3a1e8a5d348cdbfccd0a16d74ba61e3d (patch) | |
tree | 6d8a4b620b362ab4f707678a5b626a85e1531c0b /main.c | |
parent | 5bd764a35aeaf50b54957bfa94ba94198514baf0 (diff) |
treewide: rework function memory model
- Instead of treating individual program functions as managed ucode types,
demote uc_function_t values to pointers into a uc_program_t entity
- Promote uc_program_t to a managed type
- Let uc_closure_t claim references to the owning program of the enclosed
uc_function_t
- Redefine public APIs uc_compile() and uc_vm_execute() APIs to return and
expect an uc_program_t object respectively
- Remove vallist indirection for function loading and let the compiler
emit the function id directly when producing function construction code
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -81,13 +81,13 @@ static int compile(uc_vm_t *vm, uc_source_t *src, FILE *precompile, bool strip) { uc_value_t *res = NULL; - uc_function_t *entry; + uc_program_t *program; int rc = 0; char *err; - entry = uc_compile(vm->config, src, &err); + program = uc_compile(vm->config, src, &err); - if (!entry) { + if (!program) { fprintf(stderr, "%s", err); free(err); rc = -1; @@ -95,13 +95,12 @@ compile(uc_vm_t *vm, uc_source_t *src, FILE *precompile, bool strip) } if (precompile) { - uc_program_write(entry->program, precompile, !strip); - uc_program_free(entry->program); + uc_program_write(program, precompile, !strip); fclose(precompile); goto out; } - rc = uc_vm_execute(vm, entry, &res); + rc = uc_vm_execute(vm, program, &res); switch (rc) { case STATUS_OK: @@ -122,6 +121,7 @@ compile(uc_vm_t *vm, uc_source_t *src, FILE *precompile, bool strip) } out: + uc_program_put(program); ucv_put(res); return rc; |