diff options
-rw-r--r-- | include/ucode/program.h | 1 | ||||
-rw-r--r-- | program.c | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/include/ucode/program.h b/include/ucode/program.h index e540807..4fb4a9b 100644 --- a/include/ucode/program.h +++ b/include/ucode/program.h @@ -53,6 +53,7 @@ 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 *); +ssize_t uc_program_export_lookup(uc_program_t *, uc_source_t *, uc_value_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 *); @@ -846,3 +846,24 @@ uc_program_entry(uc_program_t *program) return (uc_function_t *)program->functions.prev; } + +ssize_t +uc_program_export_lookup(uc_program_t *program, uc_source_t *source, uc_value_t *name) +{ + size_t i, off; + ssize_t slot; + + for (i = 0, off = 0; i < program->sources.count; i++) { + if (program->sources.entries[i] != source) { + off += program->sources.entries[i]->exports.count; + continue; + } + + slot = uc_source_export_lookup(source, name); + + if (slot > -1) + return off + slot; + } + + return -1; +} |