diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-07-20 14:49:18 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-07-30 00:41:56 +0200 |
commit | 41114a02a38a65956010bab95c4bff19af7ac1ed (patch) | |
tree | d993746857c6a57ff61dfefc315537825c1ee63f /source.c | |
parent | 70ae3040fb384e7a77ef43ca6b426269f9acdcab (diff) |
source: add tracking of exported symbols
Extend abstract source objects to maintain a list of exported symbols and
add functions to append and lookup exported names.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'source.c')
-rw-r--r-- | source.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -196,3 +196,28 @@ uc_source_runpath_set(uc_source_t *source, const char *runpath) source->runpath = xstrdup(runpath); } + +bool +uc_source_export_add(uc_source_t *source, uc_value_t *name) +{ + ssize_t idx = uc_source_export_lookup(source, name); + + if (idx > -1) + return false; + + uc_vector_push(&source->exports, ucv_get(name)); + + return true; +} + +ssize_t +uc_source_export_lookup(uc_source_t *source, uc_value_t *name) +{ + size_t i; + + for (i = 0; i < source->exports.count; i++) + if (ucv_is_equal(source->exports.entries[i], name)) + return i; + + return -1; +} |