summaryrefslogtreecommitdiff
path: root/src/shared-validator.cc
diff options
context:
space:
mode:
authorBen Smith <binji@chromium.org>2020-03-11 09:54:35 -0700
committerGitHub <noreply@github.com>2020-03-11 09:54:35 -0700
commitcbe3f1291df14685bf44a61692ebef8934d17c4f (patch)
treee4e17e8612e29599a12900d92d95f697095dfabe /src/shared-validator.cc
parentf649b7ca9af02ff3213d8c2b135eaef9d87f5e0d (diff)
downloadwabt-cbe3f1291df14685bf44a61692ebef8934d17c4f.tar.gz
wabt-cbe3f1291df14685bf44a61692ebef8934d17c4f.tar.bz2
wabt-cbe3f1291df14685bf44a61692ebef8934d17c4f.zip
Remove validation from the BinaryReader (#1354)
Validation should only happen in ValidateModule, BinaryReader should only check whether the binary is malformed. This change also fixes a few places in BinaryReaderIR where an index is assumed to be valid.
Diffstat (limited to 'src/shared-validator.cc')
-rw-r--r--src/shared-validator.cc18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/shared-validator.cc b/src/shared-validator.cc
index 1d251e2e..5af98356 100644
--- a/src/shared-validator.cc
+++ b/src/shared-validator.cc
@@ -49,19 +49,20 @@ Result SharedValidator::OnFuncType(const Location& loc,
const Type* param_types,
Index result_count,
const Type* result_types) {
+ Result result = Result::Ok;
+ if (!options_.features.multi_value_enabled() && result_count > 1) {
+ result |=
+ PrintError(loc, "multiple result values not currently supported.");
+ }
types_.push_back(FuncType{ToTypeVector(param_count, param_types),
ToTypeVector(result_count, result_types)});
- return Result::Ok;
+ return result;
}
Result SharedValidator::OnFunction(const Location& loc, Var sig_var) {
Result result = Result::Ok;
FuncType type;
result |= CheckTypeIndex(sig_var, &type);
- if (!options_.features.multi_value_enabled() && type.results.size() > 1) {
- result |=
- PrintError(loc, "multiple result values not currently supported.");
- }
funcs_.push_back(type);
return result;
}
@@ -481,11 +482,8 @@ Result SharedValidator::CheckBlockSignature(const Location& loc,
result |= PrintError(loc, "%s params not currently supported.",
opcode.GetName());
}
- if (func_type.results.size() > 1 &&
- !options_.features.multi_value_enabled()) {
- result |= PrintError(loc, "multiple %s results not currently supported.",
- opcode.GetName());
- }
+ // Multiple results without --enable-multi-value is checked above in
+ // OnType.
*out_param_types = func_type.params;
*out_result_types = func_type.results;