summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-07-20 00:12:08 +0200
committerJo-Philipp Wich <jo@mein.io>2022-07-30 00:41:56 +0200
commitc441f65c19e62eefaa8af37ae74ae47c4d4eaa4e (patch)
treececea2c2870311d7abc4c741bb1b38a5dc1ca454 /include
parent23224687205076604c1e0e5829690a5b6e150c06 (diff)
program: add infrastructure to handle multiple sources per program
The upcoming module support requires maintaining multiple source objects within the same program, so add the necessary infrastructure for it. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'include')
-rw-r--r--include/ucode/program.h5
-rw-r--r--include/ucode/types.h5
2 files changed, 7 insertions, 3 deletions
diff --git a/include/ucode/program.h b/include/ucode/program.h
index e8b96ed..e540807 100644
--- a/include/ucode/program.h
+++ b/include/ucode/program.h
@@ -20,7 +20,7 @@
#include "types.h"
-uc_program_t *uc_program_new(uc_source_t *);
+uc_program_t *uc_program_new(void);
static inline uc_program_t *
uc_program_get(uc_program_t *prog) {
@@ -46,9 +46,10 @@ uc_program_put(uc_program_t *prog) {
fn = fn##_tmp, \
fn##_tmp = (uc_function_t *)fn##_tmp->progref.prev)
-uc_function_t *uc_program_function_new(uc_program_t *, const char *, size_t);
+uc_function_t *uc_program_function_new(uc_program_t *, const char *, uc_source_t *, size_t);
size_t uc_program_function_id(uc_program_t *, uc_function_t *);
uc_function_t *uc_program_function_load(uc_program_t *, size_t);
+uc_source_t *uc_program_function_source(uc_function_t *);
size_t uc_program_function_srcpos(uc_function_t *, size_t);
void uc_program_function_free(uc_function_t *);
diff --git a/include/ucode/types.h b/include/ucode/types.h
index cde84f6..14f2a43 100644
--- a/include/ucode/types.h
+++ b/include/ucode/types.h
@@ -115,6 +115,7 @@ typedef struct uc_function {
bool arrow, vararg, strict;
size_t nargs;
size_t nupvals;
+ size_t srcidx;
size_t srcpos;
uc_chunk_t chunk;
struct uc_program *program;
@@ -204,11 +205,13 @@ uc_declare_vector(uc_resource_types_t, uc_resource_type_t *);
/* Program structure definitions */
+uc_declare_vector(uc_sources_t, uc_source_t *);
+
typedef struct uc_program {
uc_value_t header;
uc_value_list_t constants;
uc_weakref_t functions;
- uc_source_t *source;
+ uc_sources_t sources;
} uc_program_t;