diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-01-07 20:03:17 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-01-18 10:58:11 +0100 |
commit | 725bb75b7b66dd1e0a381908e831cede0402cb6e (patch) | |
tree | b8ee8c737198e5b5bad6b809457c59be2a7f8bb5 /include | |
parent | 6b2e79af9fe6e7d05d31245fc9049540a96d5d31 (diff) |
compiler, vm: use a program wide constant list
Instead of storing constant values per function, maintain a global program
wide list for all constant values within the current compilation unit.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'include')
-rw-r--r-- | include/ucode/chunk.h | 2 | ||||
-rw-r--r-- | include/ucode/program.h | 3 | ||||
-rw-r--r-- | include/ucode/types.h | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/include/ucode/chunk.h b/include/ucode/chunk.h index 0005e3c..6804eeb 100644 --- a/include/ucode/chunk.h +++ b/include/ucode/chunk.h @@ -28,8 +28,6 @@ void uc_chunk_init(uc_chunk_t *chunk); void uc_chunk_free(uc_chunk_t *chunk); size_t uc_chunk_add(uc_chunk_t *chunk, uint8_t byte, size_t line); -ssize_t uc_chunk_add_constant(uc_chunk_t *chunk, uc_value_t *value); -uc_value_t *uc_chunk_get_constant(uc_chunk_t *chunk, size_t idx); void uc_chunk_pop(uc_chunk_t *chunk); size_t uc_chunk_debug_get_srcpos(uc_chunk_t *chunk, size_t off); diff --git a/include/ucode/program.h b/include/ucode/program.h index 19b3c9f..9bbc67e 100644 --- a/include/ucode/program.h +++ b/include/ucode/program.h @@ -28,4 +28,7 @@ uc_value_t *uc_program_function_new(uc_program_t *, const char *, size_t, uc_sou size_t uc_program_function_id(uc_program_t *, uc_value_t *); uc_value_t *uc_program_function_load(uc_program_t *, size_t); +uc_value_t *uc_program_get_constant(uc_program_t *, size_t); +ssize_t uc_program_add_constant(uc_program_t *, uc_value_t *); + #endif /* __PROGRAM_H_ */ diff --git a/include/ucode/types.h b/include/ucode/types.h index 7bd0ea9..be10ac5 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -90,7 +90,6 @@ uc_declare_vector(uc_offsetinfo_t, uint8_t); typedef struct { size_t count; uint8_t *entries; - uc_value_list_t constants; uc_ehranges_t ehranges; struct { uc_variables_t variables; @@ -204,6 +203,7 @@ uc_declare_vector(uc_resource_types_t, uc_resource_type_t *); /* Program structure definitions */ typedef struct uc_program { + uc_value_list_t constants; uc_weakref_t functions; } uc_program_t; |