diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/wabt/binary-reader-logging.h | 6 | ||||
-rw-r--r-- | include/wabt/binary-reader-nop.h | 9 | ||||
-rw-r--r-- | include/wabt/binary-reader.h | 7 | ||||
-rw-r--r-- | include/wabt/ir.h | 12 | ||||
-rw-r--r-- | include/wabt/token.def | 4 | ||||
-rw-r--r-- | include/wabt/wast-parser.h | 3 |
6 files changed, 41 insertions, 0 deletions
diff --git a/include/wabt/binary-reader-logging.h b/include/wabt/binary-reader-logging.h index ba205a10..4bb16deb 100644 --- a/include/wabt/binary-reader-logging.h +++ b/include/wabt/binary-reader-logging.h @@ -346,6 +346,12 @@ class BinaryReaderLogging : public BinaryReaderDelegate { Result OnDylinkExport(std::string_view name, uint32_t flags) override; Result EndDylinkSection() override; + Result BeginGenericCustomSection(Offset size) override; + Result OnGenericCustomSection(std::string_view name, + const void* data, + Offset size) override; + Result EndGenericCustomSection() override; + Result BeginTargetFeaturesSection(Offset size) override; Result OnFeatureCount(Index count) override; Result OnFeature(uint8_t prefix, std::string_view name) override; diff --git a/include/wabt/binary-reader-nop.h b/include/wabt/binary-reader-nop.h index 75e28d4a..ffa3a4b7 100644 --- a/include/wabt/binary-reader-nop.h +++ b/include/wabt/binary-reader-nop.h @@ -519,6 +519,15 @@ class BinaryReaderNop : public BinaryReaderDelegate { } Result EndTargetFeaturesSection() override { return Result::Ok; } + /* Generic custom section */ + Result BeginGenericCustomSection(Offset size) override { return Result::Ok; } + Result OnGenericCustomSection(std::string_view name, + const void* data, + Offset size) override { + return Result::Ok; + }; + Result EndGenericCustomSection() override { return Result::Ok; } + /* Linking section */ Result BeginLinkingSection(Offset size) override { return Result::Ok; } Result OnSymbolCount(Index count) override { return Result::Ok; } diff --git a/include/wabt/binary-reader.h b/include/wabt/binary-reader.h index 1099e217..de7c4e8f 100644 --- a/include/wabt/binary-reader.h +++ b/include/wabt/binary-reader.h @@ -424,6 +424,13 @@ class BinaryReaderDelegate { virtual Result OnFeature(uint8_t prefix, std::string_view name) = 0; virtual Result EndTargetFeaturesSection() = 0; + /* Generic custom section */ + virtual Result BeginGenericCustomSection(Offset size) = 0; + virtual Result OnGenericCustomSection(std::string_view name, + const void* data, + Offset size) = 0; + virtual Result EndGenericCustomSection() = 0; + /* Linking section */ virtual Result BeginLinkingSection(Offset size) = 0; virtual Result OnSymbolCount(Index count) = 0; diff --git a/include/wabt/ir.h b/include/wabt/ir.h index 78f3f6f9..2bc5d9bd 100644 --- a/include/wabt/ir.h +++ b/include/wabt/ir.h @@ -1164,6 +1164,17 @@ class StartModuleField : public ModuleFieldMixin<ModuleFieldType::Start> { Var start; }; +struct Custom { + explicit Custom(const Location& loc = Location(), + std::string_view name = std::string_view(), + std::vector<uint8_t> data = std::vector<uint8_t>()) + : name(name), data(data), loc(loc) {} + + std::string name; + std::vector<uint8_t> data; + Location loc; +}; + struct Module { Index GetFuncTypeIndex(const Var&) const; Index GetFuncTypeIndex(const FuncDeclaration&) const; @@ -1235,6 +1246,7 @@ struct Module { std::vector<Memory*> memories; std::vector<DataSegment*> data_segments; std::vector<Var*> starts; + std::vector<Custom> customs; BindingHash tag_bindings; BindingHash func_bindings; diff --git a/include/wabt/token.def b/include/wabt/token.def index 1e95da62..2c9ff2b8 100644 --- a/include/wabt/token.def +++ b/include/wabt/token.def @@ -20,6 +20,7 @@ /* Tokens with no additional data (i.e. bare). */ WABT_TOKEN(Invalid, "Invalid") +WABT_TOKEN(After, "after") WABT_TOKEN(Array, "array") WABT_TOKEN(AssertException, "assert_exception") WABT_TOKEN(AssertExhaustion, "assert_exhaustion") @@ -28,6 +29,7 @@ WABT_TOKEN(AssertMalformed, "assert_malformed") WABT_TOKEN(AssertReturn, "assert_return") WABT_TOKEN(AssertTrap, "assert_trap") WABT_TOKEN(AssertUnlinkable, "assert_unlinkable") +WABT_TOKEN(Before, "before") WABT_TOKEN(Bin, "bin") WABT_TOKEN(Item, "item") WABT_TOKEN(Data, "data") @@ -40,6 +42,7 @@ WABT_TOKEN(Eof, "EOF") WABT_TOKEN(Tag, "tag") WABT_TOKEN(Export, "export") WABT_TOKEN(Field, "field") +WABT_TOKEN(Function, "function") WABT_TOKEN(Get, "get") WABT_TOKEN(Global, "global") WABT_TOKEN(Import, "import") @@ -95,6 +98,7 @@ WABT_TOKEN(Block, "block") WABT_TOKEN(Br, "br") WABT_TOKEN(BrIf, "br_if") WABT_TOKEN(BrTable, "br_table") +WABT_TOKEN(Code, "code") WABT_TOKEN(Call, "call") WABT_TOKEN(CallIndirect, "call_indirect") WABT_TOKEN(CallRef, "call_ref") diff --git a/include/wabt/wast-parser.h b/include/wabt/wast-parser.h index b80a8e5d..9464147d 100644 --- a/include/wabt/wast-parser.h +++ b/include/wabt/wast-parser.h @@ -163,6 +163,9 @@ class WastParser { Result ParseStartModuleField(Module*); Result ParseTableModuleField(Module*); + Result ParseCustomSectionAnnotation(Module*); + bool PeekIsCustom(); + Result ParseExportDesc(Export*); Result ParseInlineExports(ModuleFieldList*, ExternalKind); Result ParseInlineImport(Import*); |