Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Wabt has been compiled to JavaScript via emscripten. Some of the functionality i
| [multi-value][] | `--enable-multi-value` | ✓ | ✓ | ✓ | ✓ |
| [tail-call][] | `--enable-tail-call` | ✓ | ✓ | ✓ | ✓ |
| [bulk memory][] | `--enable-bulk-memory` | ✓ | ✓ | ✓ | ✓ |
| [reference types][] | `--enable-reference-types` | ✓ | ✓ | ✓ | |
| [reference types][] | `--enable-reference-types` | ✓ | ✓ | ✓ | |
| [annotations][] | `--enable-annotations` | | ✓ | | |

[exception handling]: https://github.com/WebAssembly/exception-handling
Expand Down
8 changes: 8 additions & 0 deletions src/binary-reader-ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class BinaryReaderIR : public BinaryReaderNop {
Result OnInitExprI32ConstExpr(Index index, uint32_t value) override;
Result OnInitExprI64ConstExpr(Index index, uint64_t value) override;
Result OnInitExprRefNull(Index index) override;
Result OnInitExprRefFunc(Index index, Index func_index) override;

private:
Location GetLocation() const;
Expand Down Expand Up @@ -1197,6 +1198,13 @@ Result BinaryReaderIR::OnInitExprRefNull(Index index) {
return Result::Ok;
}

Result BinaryReaderIR::OnInitExprRefFunc(Index index, Index func_index) {
Location loc = GetLocation();
current_init_expr_->push_back(
MakeUnique<RefFuncExpr>(Var(func_index, loc), loc));
return Result::Ok;
}

Result BinaryReaderIR::OnLocalName(Index func_index,
Index local_index,
string_view name) {
Expand Down
22 changes: 10 additions & 12 deletions src/binary-reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,14 @@ bool BinaryReader::IsConcreteType(Type type) {
case Type::V128:
return options_.features.simd_enabled();

case Type::Exnref:
return options_.features.exceptions_enabled();

case Type::Funcref:
case Type::Anyref:
case Type::Nullref:
return options_.features.reference_types_enabled();

case Type::Funcref:
return options_.features.reference_types_enabled();
case Type::Exnref:
return options_.features.reference_types_enabled() &&
options_.features.exceptions_enabled();

default:
return false;
Expand Down Expand Up @@ -525,9 +525,8 @@ Result BinaryReader::ReadInitExpr(Index index, bool require_i32) {

Result BinaryReader::ReadTable(Type* out_elem_type, Limits* out_elem_limits) {
CHECK_RESULT(ReadType(out_elem_type, "table elem type"));
ERROR_UNLESS(
*out_elem_type == Type::Funcref || *out_elem_type == Type::Anyref,
"table elem type must by funcref or anyref");
ERROR_UNLESS(IsRefType(*out_elem_type),
"table elem type must be a reference type");

uint32_t flags;
uint32_t initial;
Expand Down Expand Up @@ -2190,10 +2189,9 @@ Result BinaryReader::ReadElemSection(Offset section_size) {
if (!legacy) {
if (flags & SegUseElemExprs) {
CHECK_RESULT(ReadType(&elem_type, "table elem type"));
ERROR_UNLESS(
elem_type == Type::Funcref || elem_type == Type::Anyref,
"segment elem expr type must be funcref or anyref (got %s)",
GetTypeName(elem_type));
ERROR_UNLESS(IsRefType(elem_type),
"segment elem expr type must be a reference type (got %s)",
GetTypeName(elem_type));
} else {
ExternalKind kind;
CHECK_RESULT(ReadExternalKind(&kind, "export kind"));
Expand Down
5 changes: 3 additions & 2 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ enum class Type : int32_t {
V128 = -0x05, // 0x7b
Funcref = -0x10, // 0x70
Anyref = -0x11, // 0x6f
Nullref = -0x12, // 0x6e
Exnref = -0x18, // 0x68
Func = -0x20, // 0x60
Void = -0x40, // 0x40
___ = Void, // Convenient for the opcode table in opcode.h
Any = 0, // Not actually specified, but useful for type-checking
Nullref = 1, // Not actually specified, but used in testing and type-checking
Hostref = 2, // Not actually specified, but used in testing and type-checking
I8 = 3, // Not actually specified, but used internally with load/store
I8U = 4, // Not actually specified, but used internally with load/store
Expand Down Expand Up @@ -383,7 +383,7 @@ static WABT_INLINE const char* GetSymbolTypeName(SymbolType type) {

static WABT_INLINE bool IsRefType(Type t) {
return t == Type::Anyref || t == Type::Funcref || t == Type::Nullref ||
t == Type::Hostref;
t == Type::Exnref || t == Type::Hostref;
}

static WABT_INLINE bool IsNullableRefType(Type t) {
Expand Down Expand Up @@ -444,6 +444,7 @@ static WABT_INLINE TypeVector GetInlineTypeVector(Type type) {
case Type::V128:
case Type::Funcref:
case Type::Anyref:
case Type::Nullref:
case Type::Exnref:
return TypeVector(&type, &type + 1);

Expand Down
5 changes: 3 additions & 2 deletions src/decompiler-ls.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ inline const char *GetDecompTypeName(Type t) {
case Type::F32: return "float";
case Type::F64: return "double";
case Type::V128: return "simd";
case Type::Anyref: return "anyref";
case Type::Func: return "func";
case Type::Funcref: return "funcref";
case Type::Exnref: return "exceptionref";
case Type::Anyref: return "anyref";
case Type::Nullref: return "nullref";
case Type::Exnref: return "exnref";
case Type::Void: return "void";
default: return "ILLEGAL";
}
Expand Down
1 change: 1 addition & 0 deletions src/lexer-keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ memory, TokenType::Memory
module, TokenType::Module
mut, TokenType::Mut
nop, TokenType::Nop, Opcode::Nop
nullref, Type::Nullref
offset, TokenType::Offset
param, TokenType::Param
quote, TokenType::Quote
Expand Down
Loading