-
Notifications
You must be signed in to change notification settings - Fork 39
api: resolving imported globals #637
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
Changes from 1 commit
c32cb3d
a7812d2
9321b18
570e8ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,22 @@ struct ImportedFunction | |
std::vector<ExternalFunction> resolve_imported_functions( | ||
const Module& module, const std::vector<ImportedFunction>& imported_functions); | ||
|
||
// Global that should be used by instantiate as import, identified by module and global name. | ||
struct ImportedGlobal | ||
{ | ||
std::string module; | ||
std::string name; | ||
Value* value = nullptr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes I missed the return value. |
||
ValType type = ValType::i32; | ||
bool is_mutable = false; | ||
}; | ||
|
||
// Create vector of ExternalGlobals ready to be passed to instantiate. | ||
// imported_globals may be in any order, but must contain globals for all of the imported global | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just realised these comments are no doxygen, neither for |
||
// names defined in the module. | ||
std::vector<ExternalGlobal> resolve_imported_globals( | ||
const Module& module, const std::vector<ImportedGlobal>& imported_globals); | ||
|
||
/// Find exported function index by name. | ||
std::optional<FuncIdx> find_exported_function(const Module& module, std::string_view name); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check here also that
it->value != nullptr
?(note that it's checked in
instantiate
anyway)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is fine as is. Perhaps a comment here could be useful to say that
instantiate
will validate the presence of a value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment.