diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-07-20 14:52:19 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-07-30 00:41:56 +0200 |
commit | 50cf5723f9d41a5a65a6f5d38f8dfff4ff9422a5 (patch) | |
tree | 44211f7efe3e6f35f10b0949ac844a1aa31a683f /program.c | |
parent | c441f65c19e62eefaa8af37ae74ae47c4d4eaa4e (diff) |
program: add function to globally lookup exported name
Add a helper function to query the global index of a named export within
a specific source which is a prerequisite for compiling import statements.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'program.c')
-rw-r--r-- | program.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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; +} |