test-wasm: Make more use of Value::as_if
This commit is contained in:
parent
0334a6b341
commit
2d6aba424d
1 changed files with 5 additions and 7 deletions
|
|
@ -173,14 +173,12 @@ TESTJS_GLOBAL_FUNCTION(parse_webassembly_module, parseWebAssemblyModule)
|
|||
|
||||
HashMap<Wasm::Linker::Name, Wasm::ExternValue> imports;
|
||||
auto import_value = vm.argument(1);
|
||||
if (import_value.is_object()) {
|
||||
auto& import_object = import_value.as_object();
|
||||
for (auto& property : import_object.shape().property_table()) {
|
||||
auto value = import_object.get_without_side_effects(property.key);
|
||||
if (!value.is_object() || !is<WebAssemblyModule>(value.as_object()))
|
||||
if (auto import_object = import_value.template as_if<JS::Object>()) {
|
||||
for (auto const& property : import_object->shape().property_table()) {
|
||||
auto module_object = import_object->get_without_side_effects(property.key).as_if<WebAssemblyModule>();
|
||||
if (!module_object)
|
||||
continue;
|
||||
auto& module_object = static_cast<WebAssemblyModule&>(value.as_object());
|
||||
for (auto& entry : module_object.module_instance().exports()) {
|
||||
for (auto& entry : module_object->module_instance().exports()) {
|
||||
// FIXME: Don't pretend that everything is a function
|
||||
imports.set({ property.key.as_string().to_utf16_string().to_byte_string(), entry.name(), Wasm::TypeIndex(0) }, entry.value());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue