Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing MIR_get_global_item #141

Open
wants to merge 1 commit into
base: v0_master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,16 @@ void MIR_finish_module (MIR_context_t ctx) {
curr_module = NULL;
}

MIR_item_t MIR_get_global_item (MIR_context_t ctx, const char *name) {
for (MIR_item_t item = DLIST_HEAD (MIR_item_t, environment_module.items); item != NULL;
item = DLIST_NEXT (MIR_item_t, item)) {
if (item->item_type == MIR_import_item && strcmp (item->u.import_id, name) == 0) {
return item->ref_def;
}
}
return NULL;
}

static void setup_global (MIR_context_t ctx, const char *name, void *addr, MIR_item_t def) {
MIR_item_t item, tab_item;
MIR_module_t saved = curr_module;
Expand Down
1 change: 1 addition & 0 deletions mir.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ extern void MIR_read_with_func (MIR_context_t ctx, int (*const reader_func) (MIR
extern void MIR_scan_string (MIR_context_t ctx, const char *str);
#endif

/* Get an exported item or an external function by its name */
extern MIR_item_t MIR_get_global_item (MIR_context_t ctx, const char *name);
extern void MIR_load_module (MIR_context_t ctx, MIR_module_t m);
extern void MIR_load_external (MIR_context_t ctx, const char *name, void *addr);
Expand Down