summaryrefslogtreecommitdiff
path: root/src/validator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/validator.cc')
-rw-r--r--src/validator.cc38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/validator.cc b/src/validator.cc
index ba2cfb79..0373ac1c 100644
--- a/src/validator.cc
+++ b/src/validator.cc
@@ -753,8 +753,8 @@ void Validator::CheckTable(const Location* loc, const Table* table) {
}
void Validator::CheckElemSegments(const Module* module) {
- for (ModuleField* field = module->first_field; field; field = field->next) {
- if (auto elem_segment_field = dyn_cast<ElemSegmentModuleField>(field)) {
+ for (const ModuleField& field : module->fields) {
+ if (auto elem_segment_field = dyn_cast<ElemSegmentModuleField>(&field)) {
ElemSegment* elem_segment = elem_segment_field->elem_segment;
const Table* table;
if (!Succeeded(CheckTableVar(&elem_segment->table_var, &table)))
@@ -765,7 +765,7 @@ void Validator::CheckElemSegments(const Module* module) {
continue;
}
- CheckConstInitExpr(&field->loc, elem_segment->offset, Type::I32,
+ CheckConstInitExpr(&field.loc, elem_segment->offset, Type::I32,
"elem segment offset");
}
}
@@ -778,14 +778,14 @@ void Validator::CheckMemory(const Location* loc, const Memory* memory) {
}
void Validator::CheckDataSegments(const Module* module) {
- for (ModuleField* field = module->first_field; field; field = field->next) {
- if (auto data_segment_field = dyn_cast<DataSegmentModuleField>(field)) {
+ for (const ModuleField& field : module->fields) {
+ if (auto data_segment_field = dyn_cast<DataSegmentModuleField>(&field)) {
DataSegment* data_segment = data_segment_field->data_segment;
const Memory* memory;
if (!Succeeded(CheckMemoryVar(&data_segment->memory_var, &memory)))
continue;
- CheckConstInitExpr(&field->loc, data_segment->offset, Type::I32,
+ CheckConstInitExpr(&field.loc, data_segment->offset, Type::I32,
"data segment offset");
}
}
@@ -866,32 +866,32 @@ Result Validator::CheckModule(const Module* module) {
num_imported_globals_ = 0;
current_except_index_ = 0;
- for (ModuleField* field = module->first_field; field; field = field->next) {
- switch (field->type) {
+ for (const ModuleField& field : module->fields) {
+ switch (field.type) {
case ModuleFieldType::Except:
++current_except_index_;
- CheckExcept(&field->loc, cast<ExceptionModuleField>(field)->except);
+ CheckExcept(&field.loc, cast<ExceptionModuleField>(&field)->except);
break;
case ModuleFieldType::Func:
- CheckFunc(&field->loc, cast<FuncModuleField>(field)->func);
+ CheckFunc(&field.loc, cast<FuncModuleField>(&field)->func);
break;
case ModuleFieldType::Global:
- CheckGlobal(&field->loc, cast<GlobalModuleField>(field)->global);
+ CheckGlobal(&field.loc, cast<GlobalModuleField>(&field)->global);
current_global_index_++;
break;
case ModuleFieldType::Import:
- CheckImport(&field->loc, cast<ImportModuleField>(field)->import);
+ CheckImport(&field.loc, cast<ImportModuleField>(&field)->import);
break;
case ModuleFieldType::Export:
- CheckExport(&field->loc, cast<ExportModuleField>(field)->export_);
+ CheckExport(&field.loc, cast<ExportModuleField>(&field)->export_);
break;
case ModuleFieldType::Table:
- CheckTable(&field->loc, cast<TableModuleField>(field)->table);
+ CheckTable(&field.loc, cast<TableModuleField>(&field)->table);
current_table_index_++;
break;
@@ -900,7 +900,7 @@ Result Validator::CheckModule(const Module* module) {
break;
case ModuleFieldType::Memory:
- CheckMemory(&field->loc, cast<MemoryModuleField>(field)->memory);
+ CheckMemory(&field.loc, cast<MemoryModuleField>(&field)->memory);
current_memory_index_++;
break;
@@ -913,18 +913,18 @@ Result Validator::CheckModule(const Module* module) {
case ModuleFieldType::Start: {
if (seen_start) {
- PrintError(&field->loc, "only one start function allowed");
+ PrintError(&field.loc, "only one start function allowed");
}
const Func* start_func = nullptr;
- CheckFuncVar(&cast<StartModuleField>(field)->start, &start_func);
+ CheckFuncVar(&cast<StartModuleField>(&field)->start, &start_func);
if (start_func) {
if (start_func->GetNumParams() != 0) {
- PrintError(&field->loc, "start function must be nullary");
+ PrintError(&field.loc, "start function must be nullary");
}
if (start_func->GetNumResults() != 0) {
- PrintError(&field->loc, "start function must not return anything");
+ PrintError(&field.loc, "start function must not return anything");
}
}
seen_start = true;