diff options
author | Ben Smith <binji@chromium.org> | 2020-05-28 11:30:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-28 11:30:38 -0700 |
commit | bf46c08b05fc6fcc457f1657e936fab24b4dceee (patch) | |
tree | f57a19c670a3e222896c252c829d5eb5ec4db6d2 /src/binary-writer-spec.cc | |
parent | 0630dc53755678239d7609b61776b125221eefb8 (diff) | |
download | wabt-bf46c08b05fc6fcc457f1657e936fab24b4dceee.tar.gz wabt-bf46c08b05fc6fcc457f1657e936fab24b4dceee.tar.bz2 wabt-bf46c08b05fc6fcc457f1657e936fab24b4dceee.zip |
Reference types changes to remove subtyping (#1407)
Main changes:
* Rename `anyref` -> `externref`
* Remove `nullref`
* Rename `hostref` -> `externref`
* `ref.null` and `ref.is_null` now have "ref kind" parameter
* Add ref kind keywords: `func`, `extern`, `exn`
Diffstat (limited to 'src/binary-writer-spec.cc')
-rw-r--r-- | src/binary-writer-spec.cc | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/binary-writer-spec.cc b/src/binary-writer-spec.cc index 27c83767..4499e0ff 100644 --- a/src/binary-writer-spec.cc +++ b/src/binary-writer-spec.cc @@ -56,6 +56,7 @@ class BinaryWriterSpec { void WriteTypeObject(Type type); void WriteF32(uint32_t, ExpectedNan); void WriteF64(uint64_t, ExpectedNan); + void WriteRefBits(uintptr_t ref_bits); void WriteConst(const Const& const_); void WriteConstVector(const ConstVector& consts); void WriteAction(const Action& action); @@ -194,6 +195,14 @@ void BinaryWriterSpec::WriteF64(uint64_t f64_bits, ExpectedNan expected) { } } +void BinaryWriterSpec::WriteRefBits(uintptr_t ref_bits) { + if (ref_bits == Const::kRefNullBits) { + json_stream_->Writef("\"null\""); + } else { + json_stream_->Writef("\"%" PRIu64 "\"", ref_bits); + } +} + void BinaryWriterSpec::WriteConst(const Const& const_) { json_stream_->Writef("{"); WriteKey("type"); @@ -229,28 +238,19 @@ void BinaryWriterSpec::WriteConst(const Const& const_) { WriteF64(const_.f64_bits(), const_.expected_nan()); break; - case Type::Nullref: - WriteString("nullref"); - WriteSeparator(); - WriteKey("value"); - json_stream_->Writef("\"0\""); - break; - - case Type::Funcref: { + case Type::FuncRef: { WriteString("funcref"); WriteSeparator(); WriteKey("value"); - int64_t ref_bits = static_cast<int64_t>(const_.ref_bits()); - json_stream_->Writef("\"%" PRIu64 "\"", ref_bits); + WriteRefBits(const_.ref_bits()); break; } - case Type::Hostref: { - WriteString("hostref"); + case Type::ExternRef: { + WriteString("externref"); WriteSeparator(); WriteKey("value"); - int64_t ref_bits = static_cast<int64_t>(const_.ref_bits()); - json_stream_->Writef("\"%" PRIu64 "\"", ref_bits); + WriteRefBits(const_.ref_bits()); break; } |