summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Smith <binji@chromium.org>2020-02-21 09:50:32 -0800
committerGitHub <noreply@github.com>2020-02-21 09:50:32 -0800
commitbb4b65186668ff3ebd2f088778337608969a9567 (patch)
tree29960172f4f925e4fd1d21959746e3228dacf6f4 /src
parent94ad3e84817c546b1313e161da565d181b1a470c (diff)
downloadwabt-bb4b65186668ff3ebd2f088778337608969a9567.tar.gz
wabt-bb4b65186668ff3ebd2f088778337608969a9567.tar.bz2
wabt-bb4b65186668ff3ebd2f088778337608969a9567.zip
Move ValidateFuncSignatures after ParseModuleWat (#1338)
Validating function signatures (i.e. making sure a named function type matches its explicit signature) really should be parse of text parsing. Example: (type $F (func (param i32) (result i32))) ... (call_indirect (type $F) (param f32) (result i32) ;; ERROR! This change doesn't quite get us there, but it's closer. The next step will be to remove `ValidateFuncSignatures` entirely and perform those checks in the parser itself.
Diffstat (limited to 'src')
-rw-r--r--src/tools/spectest-interp.cc10
-rw-r--r--src/wast-parser.cc3
2 files changed, 5 insertions, 8 deletions
diff --git a/src/tools/spectest-interp.cc b/src/tools/spectest-interp.cc
index f29bb0ab..047a3dc1 100644
--- a/src/tools/spectest-interp.cc
+++ b/src/tools/spectest-interp.cc
@@ -1067,15 +1067,9 @@ wabt::Result CommandRunner::ReadInvalidTextModule(string_view module_filename,
module_filename, file_data.data(), file_data.size());
Errors errors;
if (Succeeded(result)) {
- std::unique_ptr<::Script> script;
+ std::unique_ptr<wabt::Module> module;
WastParseOptions options(s_features);
- result = ParseWastScript(lexer.get(), &script, &errors, &options);
- if (Succeeded(result)) {
- wabt::Module* module = script->GetFirstModule();
- ValidateOptions options(s_features);
- // Don't do a full validation, just validate the function signatures.
- result = ValidateFuncSignatures(module, &errors, options);
- }
+ result = ParseWatModule(lexer.get(), &module, &errors, &options);
}
auto line_finder = lexer->MakeLineFinder();
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index c8e3e871..025b7e97 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -24,6 +24,7 @@
#include "src/resolve-names.h"
#include "src/stream.h"
#include "src/utf8.h"
+#include "src/validator.h"
#define WABT_TRACING 0
#include "src/tracing.h"
@@ -2808,6 +2809,8 @@ Result ParseWatModule(WastLexer* lexer,
WastParser parser(lexer, errors, options);
CHECK_RESULT(parser.ParseModule(out_module));
CHECK_RESULT(ResolveNamesModule(out_module->get(), errors));
+ CHECK_RESULT(ValidateFuncSignatures(out_module->get(), errors,
+ ValidateOptions(options->features)));
return Result::Ok;
}