diff options
author | Ben Smith <binji@chromium.org> | 2020-03-09 11:45:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 11:45:17 -0700 |
commit | f649b7ca9af02ff3213d8c2b135eaef9d87f5e0d (patch) | |
tree | 41ee03ea4b45fcf9ba2e1347c6f41400c89e53dd /src/binary-reader-logging.h | |
parent | bec78eafbc203d81b9a6d1ce81f5a80dd7bf692a (diff) | |
download | wabt-f649b7ca9af02ff3213d8c2b135eaef9d87f5e0d.tar.gz wabt-f649b7ca9af02ff3213d8c2b135eaef9d87f5e0d.tar.bz2 wabt-f649b7ca9af02ff3213d8c2b135eaef9d87f5e0d.zip |
Initial pass parsing/reading struct (#1352)
This parses just the format `(struct)` as a new type. I added a test for
this using `wat2wasm`, but that requires a rudimentary binary format.
The test runner automatically attempts to rountrip all wat2wasm tests,
so this required implementing the wat writing and binary reading too.
Here's a summary of the changes:
* binary-reader:h: Rename `BinaryReader::OnType` callbacks to `OnFuncType`
* binary-reader.h: Add `BinaryReader::OnStructType`
* binary-reader.cc: Use a switch after reading the type form to
determine whether we're reading a function or struct.
* tokens.def: Add new `TokenType::Struct`
* lexer-keywords.txt: Add new `struct` keyword
* type.h: Add `Type::Struct` type form
* wast-parser.cc: Parse `(struct)` in text format
* wat-writer.cc: Write Func or Struct type forms
Diffstat (limited to 'src/binary-reader-logging.h')
-rw-r--r-- | src/binary-reader-logging.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/binary-reader-logging.h b/src/binary-reader-logging.h index facc8d5d..214d8bae 100644 --- a/src/binary-reader-logging.h +++ b/src/binary-reader-logging.h @@ -42,11 +42,12 @@ class BinaryReaderLogging : public BinaryReaderDelegate { Result BeginTypeSection(Offset size) override; Result OnTypeCount(Index count) override; - Result OnType(Index index, - Index param_count, - Type* param_types, - Index result_count, - Type* result_types) override; + Result OnFuncType(Index index, + Index param_count, + Type* param_types, + Index result_count, + Type* result_types) override; + Result OnStructType(Index index) override; Result EndTypeSection() override; Result BeginImportSection(Offset size) override; |