diff options
author | Ben Smith <binjimin@gmail.com> | 2019-02-12 14:41:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-12 14:41:34 -0800 |
commit | e448ac7cbd74f7a048b1de15ce1a2716340a57c8 (patch) | |
tree | 2cdbf9372eabfb2584d26279beee84062036c348 /src/wast-parser.cc | |
parent | 35ee613d4f8e65e730aaa6d519ee39ce581d4f24 (diff) | |
download | wabt-e448ac7cbd74f7a048b1de15ce1a2716340a57c8.tar.gz wabt-e448ac7cbd74f7a048b1de15ce1a2716340a57c8.tar.bz2 wabt-e448ac7cbd74f7a048b1de15ce1a2716340a57c8.zip |
Parse updated event text and binary format (#1014)
An event has a type-section index, like a function definition. The
current proposal doesn't specify the text format, so I assumed that it
would match the format of the other sections that reference function
types. This means that the following declaration styles are allowed:
```
(type $t (func (param i32)))
(event $e1 (type $t))
(event $e2 (param f32))
```
Diffstat (limited to 'src/wast-parser.cc')
-rw-r--r-- | src/wast-parser.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc index 66898a2f..64071faf 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -316,12 +316,17 @@ void ResolveFuncTypes(Module* module) { if (auto* func_field = dyn_cast<FuncModuleField>(&field)) { func = &func_field->func; decl = &func->decl; + } else if (auto* event_field = dyn_cast<EventModuleField>(&field)) { + decl = &event_field->event.decl; } else if (auto* import_field = dyn_cast<ImportModuleField>(&field)) { if (auto* func_import = dyn_cast<FuncImport>(import_field->import.get())) { // Only check the declaration, not the function itself, since it is an // import. decl = &func_import->func.decl; + } else if (auto* event_import = + dyn_cast<EventImport>(import_field->import.get())) { + decl = &event_import->event.decl; } else { continue; } @@ -846,7 +851,8 @@ Result WastParser::ParseEventModuleField(Module* module) { auto field = MakeUnique<EventModuleField>(GetLocation()); EXPECT(Event); ParseBindVarOpt(&field->event.name); - CHECK_RESULT(ParseValueTypeList(&field->event.sig)); + CHECK_RESULT(ParseTypeUseOpt(&field->event.decl)); + CHECK_RESULT(ParseUnboundFuncSignature(&field->event.decl.sig)); EXPECT(Rpar); module->AppendField(std::move(field)); return Result::Ok; @@ -1023,7 +1029,8 @@ Result WastParser::ParseImportModuleField(Module* module) { Consume(); ParseBindVarOpt(&name); auto import = MakeUnique<EventImport>(name); - CHECK_RESULT(ParseValueTypeList(&import->event.sig)); + CHECK_RESULT(ParseTypeUseOpt(&import->event.decl)); + CHECK_RESULT(ParseUnboundFuncSignature(&import->event.decl.sig)); EXPECT(Rpar); field = MakeUnique<ImportModuleField>(std::move(import), loc); break; |