summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp57
1 files changed, 30 insertions, 27 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index 4921dafdd..1ff04906e 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -641,20 +641,21 @@ void FunctionValidator::visitCall(Call* curr) {
if (!shouldBeTrue(!!target, curr, "call target must exist")) {
return;
}
- const std::vector<Type> params = target->sig.params.expand();
- if (!shouldBeTrue(curr->operands.size() == params.size(),
+ if (!shouldBeTrue(curr->operands.size() == target->sig.params.size(),
curr,
"call param number must match")) {
return;
}
- for (size_t i = 0; i < curr->operands.size(); i++) {
+ size_t i = 0;
+ for (auto& param : target->sig.params) {
if (!shouldBeSubTypeOrFirstIsUnreachable(curr->operands[i]->type,
- params[i],
+ param,
curr,
"call param types must match") &&
!info.quiet) {
getStream() << "(on argument " << i << ")\n";
}
+ ++i;
}
if (curr->isReturn) {
shouldBeEqual(curr->type,
@@ -692,24 +693,25 @@ void FunctionValidator::visitCallIndirect(CallIndirect* curr) {
if (!info.validateGlobally) {
return;
}
- const std::vector<Type>& params = curr->sig.params.expand();
shouldBeEqualOrFirstIsUnreachable(curr->target->type,
Type(Type::i32),
curr,
"indirect call target must be an i32");
- if (!shouldBeTrue(curr->operands.size() == params.size(),
+ if (!shouldBeTrue(curr->operands.size() == curr->sig.params.size(),
curr,
"call param number must match")) {
return;
}
- for (size_t i = 0; i < curr->operands.size(); i++) {
+ size_t i = 0;
+ for (auto& param : curr->sig.params) {
if (!shouldBeSubTypeOrFirstIsUnreachable(curr->operands[i]->type,
- params[i],
+ param,
curr,
"call param types must match") &&
!info.quiet) {
getStream() << "(on argument " << i << ")\n";
}
+ ++i;
}
if (curr->isReturn) {
shouldBeEqual(curr->type,
@@ -1871,15 +1873,16 @@ void FunctionValidator::visitThrow(Throw* curr) {
"event's param numbers must match")) {
return;
}
- const std::vector<Type>& paramTypes = event->sig.params.expand();
- for (size_t i = 0; i < curr->operands.size(); i++) {
+ size_t i = 0;
+ for (auto& param : event->sig.params) {
if (!shouldBeSubTypeOrFirstIsUnreachable(curr->operands[i]->type,
- paramTypes[i],
+ param,
curr->operands[i],
"event param types must match") &&
!info.quiet) {
getStream() << "(on argument " << i << ")\n";
}
+ ++i;
}
}
@@ -1957,7 +1960,7 @@ void FunctionValidator::visitTupleExtract(TupleExtract* curr) {
shouldBeTrue(inBounds, curr, "tuple.extract index out of bounds");
if (inBounds) {
shouldBeSubType(
- curr->tuple->type.expand()[curr->index],
+ curr->tuple->type[curr->index],
curr->type,
curr,
"tuple.extract type does not match the type of the extracted element");
@@ -1972,17 +1975,17 @@ void FunctionValidator::visitFunction(Function* curr) {
"Multivalue function results (multivalue is not enabled)");
}
FeatureSet features;
- for (auto type : curr->sig.params.expand()) {
- features |= type.getFeatures();
- shouldBeTrue(type.isConcrete(), curr, "params must be concretely typed");
+ for (auto& param : curr->sig.params) {
+ features |= param.getFeatures();
+ shouldBeTrue(param.isConcrete(), curr, "params must be concretely typed");
}
- for (auto type : curr->sig.results.expand()) {
- features |= type.getFeatures();
- shouldBeTrue(type.isConcrete(), curr, "results must be concretely typed");
+ for (auto& result : curr->sig.results) {
+ features |= result.getFeatures();
+ shouldBeTrue(result.isConcrete(), curr, "results must be concretely typed");
}
- for (auto type : curr->vars) {
- features |= type.getFeatures();
- shouldBeTrue(type.isConcrete(), curr, "vars must be concretely typed");
+ for (auto& var : curr->vars) {
+ features |= var.getFeatures();
+ shouldBeTrue(var.isConcrete(), curr, "vars must be concretely typed");
}
shouldBeTrue(features <= getModule()->features,
curr,
@@ -2141,13 +2144,13 @@ static void validateImports(Module& module, ValidationInfo& info) {
"(multivalue is not enabled)");
}
if (info.validateWeb) {
- for (Type param : curr->sig.params.expand()) {
+ for (auto& param : curr->sig.params) {
info.shouldBeUnequal(param,
Type(Type::i64),
curr->name,
"Imported function must not have i64 parameters");
}
- for (Type result : curr->sig.results.expand()) {
+ for (auto& result : curr->sig.results) {
info.shouldBeUnequal(result,
Type(Type::i64),
curr->name,
@@ -2170,14 +2173,14 @@ static void validateExports(Module& module, ValidationInfo& info) {
if (curr->kind == ExternalKind::Function) {
if (info.validateWeb) {
Function* f = module.getFunction(curr->value);
- for (auto param : f->sig.params.expand()) {
+ for (auto& param : f->sig.params) {
info.shouldBeUnequal(
param,
Type(Type::i64),
f->name,
"Exported function must not have i64 parameters");
}
- for (auto result : f->sig.results.expand()) {
+ for (auto& result : f->sig.results) {
info.shouldBeUnequal(result,
Type(Type::i64),
f->name,
@@ -2349,8 +2352,8 @@ static void validateEvents(Module& module, ValidationInfo& info) {
curr->name,
"Multivalue event type (multivalue is not enabled)");
}
- for (auto type : curr->sig.params.expand()) {
- info.shouldBeTrue(type.isConcrete(),
+ for (auto& param : curr->sig.params) {
+ info.shouldBeTrue(param.isConcrete(),
curr->name,
"Values in an event should have concrete types");
}