diff options
author | Ben Smith <binjimin@gmail.com> | 2019-04-18 16:37:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-18 16:37:58 -0700 |
commit | e7a3802b6e8bb1ab88d9b0bc97d7f5a20ffe0ab9 (patch) | |
tree | a10f021e6eeefe1fa5cca343156adc328913b115 /src/binary-reader-ir.cc | |
parent | 791896866ee26621ba806d03c69b64ece0992c66 (diff) | |
download | wabt-e7a3802b6e8bb1ab88d9b0bc97d7f5a20ffe0ab9.tar.gz wabt-e7a3802b6e8bb1ab88d9b0bc97d7f5a20ffe0ab9.tar.bz2 wabt-e7a3802b6e8bb1ab88d9b0bc97d7f5a20ffe0ab9.zip |
Proper encoding of passive element segments (#1066)
* Store element segments as a vector of `ElemExpr`, instead of func index
* Read/write binary format for each element expression
* Read/write text format for each element expression
Diffstat (limited to 'src/binary-reader-ir.cc')
-rw-r--r-- | src/binary-reader-ir.cc | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/binary-reader-ir.cc b/src/binary-reader-ir.cc index 9d71f70b..dd7efeee 100644 --- a/src/binary-reader-ir.cc +++ b/src/binary-reader-ir.cc @@ -201,8 +201,10 @@ class BinaryReaderIR : public BinaryReaderNop { Result BeginElemSegment(Index index, Index table_index, bool passive) override; Result BeginElemSegmentInitExpr(Index index) override; Result EndElemSegmentInitExpr(Index index) override; - Result OnElemSegmentFunctionIndexCount(Index index, Index count) override; - Result OnElemSegmentFunctionIndex(Index index, Index func_index) override; + Result OnElemSegmentElemExprCount(Index index, Index count) override; + Result OnElemSegmentElemExpr_RefNull(Index segment_index) override; + Result OnElemSegmentElemExpr_RefFunc(Index segment_index, + Index func_index) override; Result OnDataSegmentCount(Index count) override; Result BeginDataSegment(Index index, Index memory_index, bool passive) override; @@ -1003,23 +1005,27 @@ Result BinaryReaderIR::EndElemSegmentInitExpr(Index index) { return Result::Ok; } -Result BinaryReaderIR::OnElemSegmentFunctionIndexCount(Index index, - Index count) { +Result BinaryReaderIR::OnElemSegmentElemExprCount(Index index, Index count) { assert(index == module_->elem_segments.size() - 1); ElemSegment* segment = module_->elem_segments[index]; WABT_TRY - segment->vars.reserve(count); + segment->elem_exprs.reserve(count); WABT_CATCH_BAD_ALLOC return Result::Ok; } -Result BinaryReaderIR::OnElemSegmentFunctionIndex(Index segment_index, - Index func_index) { +Result BinaryReaderIR::OnElemSegmentElemExpr_RefNull(Index segment_index) { assert(segment_index == module_->elem_segments.size() - 1); ElemSegment* segment = module_->elem_segments[segment_index]; - segment->vars.emplace_back(); - Var* var = &segment->vars.back(); - *var = Var(func_index, GetLocation()); + segment->elem_exprs.emplace_back(); + return Result::Ok; +} + +Result BinaryReaderIR::OnElemSegmentElemExpr_RefFunc(Index segment_index, + Index func_index) { + assert(segment_index == module_->elem_segments.size() - 1); + ElemSegment* segment = module_->elem_segments[segment_index]; + segment->elem_exprs.emplace_back(Var(func_index, GetLocation())); return Result::Ok; } |