diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/emscripten-optimizer/istring.h | 3 | ||||
-rw-r--r-- | src/shell-interface.h | 4 | ||||
-rw-r--r-- | src/tools/wasm-shell.cpp | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/emscripten-optimizer/istring.h b/src/emscripten-optimizer/istring.h index ccb08bf4b..af3386162 100644 --- a/src/emscripten-optimizer/istring.h +++ b/src/emscripten-optimizer/istring.h @@ -151,6 +151,9 @@ struct IString { bool startsWith(const char* prefix) const { return stripPrefix(prefix) != nullptr; } + bool startsWith(const IString& prefix) const { + return startsWith(prefix.str); + } size_t size() const { return str ? strlen(str) : 0; } }; diff --git a/src/shell-interface.h b/src/shell-interface.h index 71e09189d..e73ce4c48 100644 --- a/src/shell-interface.h +++ b/src/shell-interface.h @@ -98,7 +98,7 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { void importGlobals(std::map<Name, Literal>& globals, Module& wasm) override { // add spectest globals ModuleUtils::iterImportedGlobals(wasm, [&](Global* import) { - if (import->module == SPECTEST && import->base == GLOBAL) { + if (import->module == SPECTEST && import->base.startsWith(GLOBAL)) { switch (import->type) { case i32: globals[import->name] = Literal(int32_t(666)); @@ -133,7 +133,7 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface { } Literal callImport(Function* import, LiteralList& arguments) override { - if (import->module == SPECTEST && import->base == PRINT) { + if (import->module == SPECTEST && import->base.startsWith(PRINT)) { for (auto argument : arguments) { std::cout << argument << " : " << argument.type << '\n'; } diff --git a/src/tools/wasm-shell.cpp b/src/tools/wasm-shell.cpp index 4f7624294..b83989a2d 100644 --- a/src/tools/wasm-shell.cpp +++ b/src/tools/wasm-shell.cpp @@ -164,7 +164,7 @@ static void run_asserts(Name moduleName, }; ModuleUtils::iterImportedGlobals(wasm, reportUnknownImport); ModuleUtils::iterImportedFunctions(wasm, [&](Importable* import) { - if (import->module == SPECTEST && import->base == PRINT) { + if (import->module == SPECTEST && import->base.startsWith(PRINT)) { // We can handle it. } else { reportUnknownImport(import); @@ -181,7 +181,7 @@ static void run_asserts(Name moduleName, // spec tests consider it illegal to use spectest.print in a table if (auto* import = wasm.getFunction(name)) { if (import->imported() && import->module == SPECTEST && - import->base == PRINT) { + import->base.startsWith(PRINT)) { std::cerr << "cannot put spectest.print in table\n"; invalid = true; } |