summaryrefslogtreecommitdiff
path: root/deps/v8/src/wasm/wasm-init-expr.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/wasm/wasm-init-expr.cc')
-rw-r--r--deps/v8/src/wasm/wasm-init-expr.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/deps/v8/src/wasm/wasm-init-expr.cc b/deps/v8/src/wasm/wasm-init-expr.cc
new file mode 100644
index 0000000000..6348c58193
--- /dev/null
+++ b/deps/v8/src/wasm/wasm-init-expr.cc
@@ -0,0 +1,57 @@
+// Copyright 2021 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/wasm/wasm-init-expr.h"
+
+namespace v8 {
+namespace internal {
+namespace wasm {
+
+std::ostream& operator<<(std::ostream& os, const WasmInitExpr& expr) {
+ os << "(";
+ switch (expr.kind()) {
+ case WasmInitExpr::kNone:
+ UNREACHABLE();
+ case WasmInitExpr::kGlobalGet:
+ os << "global.get " << expr.immediate().index;
+ break;
+ case WasmInitExpr::kI32Const:
+ os << "i32.const " << expr.immediate().i32_const;
+ break;
+ case WasmInitExpr::kI64Const:
+ os << "i64.const " << expr.immediate().i64_const;
+ break;
+ case WasmInitExpr::kF32Const:
+ os << "f32.const " << expr.immediate().f32_const;
+ break;
+ case WasmInitExpr::kF64Const:
+ os << "f64.const " << expr.immediate().f64_const;
+ break;
+ case WasmInitExpr::kS128Const:
+ os << "s128.const 0x" << std::hex;
+ for (uint8_t b : expr.immediate().s128_const) {
+ os << b;
+ }
+ os << std::dec;
+ break;
+ case WasmInitExpr::kRefNullConst:
+ os << "ref.null " << expr.immediate().heap_type;
+ break;
+ case WasmInitExpr::kRefFuncConst:
+ os << "ref.func " << expr.immediate().index;
+ break;
+ case WasmInitExpr::kRttCanon:
+ os << "rtt.canon " << expr.immediate().heap_type;
+ break;
+ case WasmInitExpr::kRttSub:
+ os << "rtt.sub " << *expr.operand();
+ break;
+ }
+ os << ")";
+ return os;
+}
+
+} // namespace wasm
+} // namespace internal
+} // namespace v8