diff options
author | Ben Smith <binji@chromium.org> | 2020-02-28 17:08:32 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 17:08:32 -0800 |
commit | 2d5bdb4a3a1bf8541dda300ffc2d35ffd9d4f84b (patch) | |
tree | 37ae07bfac508745bb6d020df8860029300448bc /src/wast-parser.cc | |
parent | 02aa62e015e3eff5a50bad5d94d9a7d98f4e9d89 (diff) | |
download | wabt-2d5bdb4a3a1bf8541dda300ffc2d35ffd9d4f84b.tar.gz wabt-2d5bdb4a3a1bf8541dda300ffc2d35ffd9d4f84b.tar.bz2 wabt-2d5bdb4a3a1bf8541dda300ffc2d35ffd9d4f84b.zip |
Add TypeEntry, base class for type section entries (#1349)
The type section currently only has one form: functions. With the GC
proposal, at least two more forms are added: struct and array. To
facilitate this:
* Rename FuncTypeModuleField -> TypeModuleField
* Rename Module::func_types -> Module::types
* Rename func_type_bindings -> type_bindings
* TypeEntry is added as a base class of FuncType
* TypeModuleField stores a unique_ptr to a TypeEntry
Diffstat (limited to 'src/wast-parser.cc')
-rw-r--r-- | src/wast-parser.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 42286e08..3468e008 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -260,8 +260,8 @@ void ResolveImplicitlyDefinedFunctionType(const Location& loc, if (!decl.has_func_type) { Index func_type_index = module->GetFuncTypeIndex(decl.sig); if (func_type_index == kInvalidIndex) { - auto func_type_field = MakeUnique<FuncTypeModuleField>(loc); - func_type_field->func_type.sig = decl.sig; + auto func_type_field = MakeUnique<TypeModuleField>(loc); + cast<FuncType>(func_type_field->type.get())->sig = decl.sig; module->AppendField(std::move(func_type_field)); } } @@ -1182,13 +1182,14 @@ Result WastParser::ParseFuncModuleField(Module* module) { Result WastParser::ParseTypeModuleField(Module* module) { WABT_TRACE(ParseTypeModuleField); EXPECT(Lpar); - auto field = MakeUnique<FuncTypeModuleField>(GetLocation()); + auto field = MakeUnique<TypeModuleField>(GetLocation()); + FuncType& func_type = *cast<FuncType>(field->type.get()); EXPECT(Type); - ParseBindVarOpt(&field->func_type.name); + ParseBindVarOpt(&func_type.name); EXPECT(Lpar); EXPECT(Func); BindingHash bindings; - CHECK_RESULT(ParseFuncSignature(&field->func_type.sig, &bindings)); + CHECK_RESULT(ParseFuncSignature(&func_type.sig, &bindings)); CHECK_RESULT(ErrorIfLpar({"param", "result"})); EXPECT(Rpar); EXPECT(Rpar); |