From f649b7ca9af02ff3213d8c2b135eaef9d87f5e0d Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Mon, 9 Mar 2020 11:45:17 -0700 Subject: 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 --- src/binary-reader-logging.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/binary-reader-logging.h') 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; -- cgit v1.2.3