MCPcopy Create free account
hub / github.com/WebAssembly/wabt / CheckModule

Method CheckModule

src/validator.cc:763–1006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

761 current_module_(module) {}
762
763Result Validator::CheckModule() {
764 const Module* module = current_module_;
765
766 // Type section.
767 for (const ModuleField& field : module->fields) {
768 if (auto* f = dyn_cast<TypeModuleField>(&field)) {
769 switch (f->type->kind()) {
770 case TypeEntryKind::Func: {
771 FuncType* func_type = cast<FuncType>(f->type.get());
772 result_ |= validator_.OnFuncType(
773 field.loc, func_type->sig.param_types.size(),
774 func_type->sig.param_types.data(),
775 func_type->sig.result_types.size(),
776 func_type->sig.result_types.data(),
777 module->GetFuncTypeIndex(func_type->sig));
778 break;
779 }
780
781 case TypeEntryKind::Struct: {
782 StructType* struct_type = cast<StructType>(f->type.get());
783 TypeMutVector type_muts;
784 for (auto&& field : struct_type->fields) {
785 type_muts.push_back(TypeMut{field.type, field.mutable_});
786 }
787 result_ |= validator_.OnStructType(field.loc, type_muts.size(),
788 type_muts.data());
789 break;
790 }
791
792 case TypeEntryKind::Array: {
793 ArrayType* array_type = cast<ArrayType>(f->type.get());
794 result_ |= validator_.OnArrayType(
795 field.loc,
796 TypeMut{array_type->field.type, array_type->field.mutable_});
797 break;
798 }
799 }
800 }
801 }
802
803 // Import section.
804 for (const ModuleField& field : module->fields) {
805 if (auto* f = dyn_cast<ImportModuleField>(&field)) {
806 switch (f->import->kind()) {
807 case ExternalKind::Func: {
808 auto&& func = cast<FuncImport>(f->import.get())->func;
809 result_ |= validator_.OnFunction(
810 field.loc, GetFuncTypeIndex(field.loc, func.decl));
811 break;
812 }
813
814 case ExternalKind::Table: {
815 auto&& table = cast<TableImport>(f->import.get())->table;
816 result_ |= validator_.OnTable(
817 field.loc, table.elem_type, table.elem_limits,
818 TableImportStatus::TableIsImported,
819 TableInitExprStatus::TableWithoutInitExpression);
820 break;

Callers 2

CheckCommandMethod · 0.80
ValidateModuleFunction · 0.80

Calls 15

dataMethod · 0.80
OnTableMethod · 0.80
OnGlobalImportMethod · 0.80
OnTagMethod · 0.80
VisitExprListMethod · 0.80
OnGlobalMethod · 0.80
OnStartMethod · 0.80
OnElemSegmentMethod · 0.80
GetTableIndexMethod · 0.80
frontMethod · 0.80
backMethod · 0.80
OnDataSegmentMethod · 0.80

Tested by

no test coverage detected