summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binary-reader-ir.cc7
-rw-r--r--src/binary-reader-logging.cc2
-rw-r--r--src/binary-reader-logging.h1
-rw-r--r--src/binary-reader-nop.h3
-rw-r--r--src/binary-reader-objdump.cc14
-rw-r--r--src/binary-reader.cc4
-rw-r--r--src/binary-reader.h1
-rw-r--r--src/interp/binary-reader-interp.cc6
-rw-r--r--src/validator.cc4
9 files changed, 42 insertions, 0 deletions
diff --git a/src/binary-reader-ir.cc b/src/binary-reader-ir.cc
index fb7b53ae..0515f660 100644
--- a/src/binary-reader-ir.cc
+++ b/src/binary-reader-ir.cc
@@ -240,6 +240,7 @@ class BinaryReaderIR : public BinaryReaderNop {
Result OnInitExprGlobalGetExpr(Index index, Index global_index) override;
Result OnInitExprI32ConstExpr(Index index, uint32_t value) override;
Result OnInitExprI64ConstExpr(Index index, uint64_t value) override;
+ Result OnInitExprRefNull(Index index) override;
private:
Location GetLocation() const;
@@ -1178,6 +1179,12 @@ Result BinaryReaderIR::OnInitExprI64ConstExpr(Index index, uint64_t value) {
return Result::Ok;
}
+Result BinaryReaderIR::OnInitExprRefNull(Index index) {
+ Location loc = GetLocation();
+ current_init_expr_->push_back(MakeUnique<RefNullExpr>(loc));
+ return Result::Ok;
+}
+
Result BinaryReaderIR::OnLocalName(Index func_index,
Index local_index,
string_view name) {
diff --git a/src/binary-reader-logging.cc b/src/binary-reader-logging.cc
index ca367855..6d73b89b 100644
--- a/src/binary-reader-logging.cc
+++ b/src/binary-reader-logging.cc
@@ -777,7 +777,9 @@ DEFINE_END(EndNamesSection)
DEFINE_BEGIN(BeginRelocSection)
DEFINE_END(EndRelocSection)
+
DEFINE_INDEX_INDEX(OnInitExprGlobalGetExpr, "index", "global_index")
+DEFINE_INDEX(OnInitExprRefNull)
DEFINE_BEGIN(BeginDylinkSection)
DEFINE_INDEX(OnDylinkNeededCount)
diff --git a/src/binary-reader-logging.h b/src/binary-reader-logging.h
index fab7455d..264f39ac 100644
--- a/src/binary-reader-logging.h
+++ b/src/binary-reader-logging.h
@@ -339,6 +339,7 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
Result OnInitExprGlobalGetExpr(Index index, Index global_index) override;
Result OnInitExprI32ConstExpr(Index index, uint32_t value) override;
Result OnInitExprI64ConstExpr(Index index, uint64_t value) override;
+ Result OnInitExprRefNull(Index index) override;
private:
void Indent();
diff --git a/src/binary-reader-nop.h b/src/binary-reader-nop.h
index 169eb4f5..8074e419 100644
--- a/src/binary-reader-nop.h
+++ b/src/binary-reader-nop.h
@@ -486,6 +486,9 @@ class BinaryReaderNop : public BinaryReaderDelegate {
Result OnInitExprI64ConstExpr(Index index, uint64_t value) override {
return Result::Ok;
}
+ Result OnInitExprRefNull(Index index) override {
+ return Result::Ok;
+ }
};
} // namespace wabt
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index c1feb2fe..371b9a82 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -683,6 +683,7 @@ enum class InitExprType {
F64,
V128,
Global,
+ NullRef,
};
struct InitExpr {
@@ -821,6 +822,7 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase {
Result OnInitExprGlobalGetExpr(Index index, Index global_index) override;
Result OnInitExprI32ConstExpr(Index index, uint32_t value) override;
Result OnInitExprI64ConstExpr(Index index, uint64_t value) override;
+ Result OnInitExprRefNull(Index index) override;
Result OnDylinkInfo(uint32_t mem_size,
uint32_t mem_align_log2,
@@ -1303,6 +1305,10 @@ void BinaryReaderObjdump::PrintInitExpr(const InitExpr& expr) {
PrintDetails("\n");
break;
}
+ case InitExprType::NullRef: {
+ PrintDetails(" - init nullref\n");
+ break;
+ }
}
}
@@ -1319,6 +1325,7 @@ static Result InitExprToConstOffset(const InitExpr& expr,
case InitExprType::F32:
case InitExprType::F64:
case InitExprType::V128:
+ case InitExprType::NullRef:
fprintf(stderr, "Segment/Elem offset must be an i32 init expr");
return Result::Error;
break;
@@ -1392,6 +1399,13 @@ Result BinaryReaderObjdump::OnInitExprI64ConstExpr(Index index,
return Result::Ok;
}
+Result BinaryReaderObjdump::OnInitExprRefNull(Index index) {
+ InitExpr expr;
+ expr.type = InitExprType::NullRef;
+ HandleInitExpr(expr);
+ return Result::Ok;
+}
+
Result BinaryReaderObjdump::OnModuleName(string_view name) {
PrintDetails(" - module <" PRIstringview ">\n",
WABT_PRINTF_STRING_VIEW_ARG(name));
diff --git a/src/binary-reader.cc b/src/binary-reader.cc
index 363edf67..b50c449b 100644
--- a/src/binary-reader.cc
+++ b/src/binary-reader.cc
@@ -480,6 +480,10 @@ Result BinaryReader::ReadInitExpr(Index index, bool require_i32) {
break;
}
+ case Opcode::RefNull:
+ CALLBACK(OnInitExprRefNull, index);
+ break;
+
case Opcode::End:
return Result::Ok;
diff --git a/src/binary-reader.h b/src/binary-reader.h
index 87548e82..e89f01b2 100644
--- a/src/binary-reader.h
+++ b/src/binary-reader.h
@@ -410,6 +410,7 @@ class BinaryReaderDelegate {
virtual Result OnInitExprGlobalGetExpr(Index index, Index global_index) = 0;
virtual Result OnInitExprI32ConstExpr(Index index, uint32_t value) = 0;
virtual Result OnInitExprI64ConstExpr(Index index, uint64_t value) = 0;
+ virtual Result OnInitExprRefNull(Index index) = 0;
const State* state = nullptr;
};
diff --git a/src/interp/binary-reader-interp.cc b/src/interp/binary-reader-interp.cc
index ce45dddf..69539da8 100644
--- a/src/interp/binary-reader-interp.cc
+++ b/src/interp/binary-reader-interp.cc
@@ -245,6 +245,7 @@ class BinaryReaderInterp : public BinaryReaderNop {
Index global_index) override;
wabt::Result OnInitExprI32ConstExpr(Index index, uint32_t value) override;
wabt::Result OnInitExprI64ConstExpr(Index index, uint64_t value) override;
+ wabt::Result OnInitExprRefNull(Index index) override;
private:
Label* GetLabel(Index depth);
@@ -1016,6 +1017,11 @@ wabt::Result BinaryReaderInterp::OnInitExprI64ConstExpr(Index index,
return wabt::Result::Ok;
}
+wabt::Result BinaryReaderInterp::OnInitExprRefNull(Index index) {
+ PrintError("ref.null global init expressions unimplemented by interpreter");
+ return wabt::Result::Error;
+}
+
wabt::Result BinaryReaderInterp::OnExport(Index index,
ExternalKind kind,
Index item_index,
diff --git a/src/validator.cc b/src/validator.cc
index 7af62164..e10db823 100644
--- a/src/validator.cc
+++ b/src/validator.cc
@@ -1069,6 +1069,10 @@ void Validator::CheckConstInitExpr(const Location* loc,
break;
}
+ case ExprType::RefNull:
+ type = Type::Anyref;
+ break;
+
default:
PrintConstExprError(loc, desc);
return;