summaryrefslogtreecommitdiff
path: root/src/wast-parser.cc
diff options
context:
space:
mode:
authorBen Smith <binji@chromium.org>2020-03-23 18:54:14 -0700
committerGitHub <noreply@github.com>2020-03-23 18:54:14 -0700
commit7898e57f28c89565b99e894e764e058346e28fbe (patch)
tree91d72a1bcef76ecb83f3f550710bee8f9152b8ce /src/wast-parser.cc
parentdc396c9d57d59c33c99f5f6c6c1b8f67de086dc8 (diff)
downloadwabt-7898e57f28c89565b99e894e764e058346e28fbe.tar.gz
wabt-7898e57f28c89565b99e894e764e058346e28fbe.tar.bz2
wabt-7898e57f28c89565b99e894e764e058346e28fbe.zip
Parse ArrayTypes (#1364)
The following formats are supported: * (type (array i32)) * (type (array (field i32))) * (type (array (field (mut i32)))) This PR adds support for reading/writing binary and text, but no interpreter support yet.
Diffstat (limited to 'src/wast-parser.cc')
-rw-r--r--src/wast-parser.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index be9ea512..408dfd93 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -1196,8 +1196,6 @@ Result WastParser::ParseTypeModuleField(Module* module) {
BindingHash bindings;
CHECK_RESULT(ParseFuncSignature(&func_type->sig, &bindings));
CHECK_RESULT(ErrorIfLpar({"param", "result"}));
- EXPECT(Rpar);
- EXPECT(Rpar);
field->type = std::move(func_type);
} else if (Match(TokenType::Struct)) {
if (!options_->features.gc_enabled()) {
@@ -1206,13 +1204,20 @@ Result WastParser::ParseTypeModuleField(Module* module) {
}
auto struct_type = MakeUnique<StructType>(name);
CHECK_RESULT(ParseFieldList(&struct_type->fields));
- EXPECT(Rpar);
- EXPECT(Rpar);
field->type = std::move(struct_type);
+ } else if (Match(TokenType::Array)) {
+ if (!options_->features.gc_enabled()) {
+ Error(loc, "array type not allowed");
+ }
+ auto array_type = MakeUnique<ArrayType>(name);
+ CHECK_RESULT(ParseField(&array_type->field));
+ field->type = std::move(array_type);
} else {
- return ErrorExpected({"func", "struct"});
+ return ErrorExpected({"func", "struct", "array"});
}
+ EXPECT(Rpar);
+ EXPECT(Rpar);
module->AppendField(std::move(field));
return Result::Ok;
}