static bool RenderLoad(WasmRenderContext& c, AstLoad& load) { uint32_t defaultAlignLog2; switch (load.expr()) { case Expr::I32Load8S: if (!c.buffer.append("(i32.load8_s")) return false; defaultAlignLog2 = 0; break; case Expr::I64Load8S: if (!c.buffer.append("(i64.load8_s")) return false; defaultAlignLog2 = 0; break; case Expr::I32Load8U: if (!c.buffer.append("(i32.load8_u")) return false; defaultAlignLog2 = 0; break; case Expr::I64Load8U: if (!c.buffer.append("(i64.load8_u")) return false; defaultAlignLog2 = 0; break; case Expr::I32Load16S: if (!c.buffer.append("(i32.load16_s")) return false; defaultAlignLog2 = 1; break; case Expr::I64Load16S: if (!c.buffer.append("(i64.load16_s")) return false; defaultAlignLog2 = 1; break; case Expr::I32Load16U: if (!c.buffer.append("(i32.load16_u")) return false; defaultAlignLog2 = 1; break; case Expr::I64Load16U: if (!c.buffer.append("(i64.load16_u")) return false; defaultAlignLog2 = 1; break; case Expr::I64Load32S: if (!c.buffer.append("(i64.load32_s")) return false; defaultAlignLog2 = 2; break; case Expr::I64Load32U: if (!c.buffer.append("(i64.load32_u")) return false; defaultAlignLog2 = 2; break; case Expr::I32Load: if (!c.buffer.append("(i32.load")) return false; defaultAlignLog2 = 2; break; case Expr::I64Load: if (!c.buffer.append("(i64.load")) return false; defaultAlignLog2 = 3; break; case Expr::F32Load: if (!c.buffer.append("(f32.load")) return false; defaultAlignLog2 = 2; break; case Expr::F64Load: if (!c.buffer.append("(f64.load")) return false; defaultAlignLog2 = 3; break; default: return false; } if (!RenderLoadStoreAddress(c, load.address(), defaultAlignLog2)) return false; return c.buffer.append(")"); }
static bool RenderLoad(WasmRenderContext& c, AstLoad& load) { if (!RenderLoadStoreBase(c, load.address())) return false; if (!RenderIndent(c)) return false; MAP_AST_EXPR(c, load); uint32_t defaultAlignLog2; switch (load.op()) { case Op::I32Load8S: if (!c.buffer.append("i32.load8_s")) return false; defaultAlignLog2 = 0; break; case Op::I64Load8S: if (!c.buffer.append("i64.load8_s")) return false; defaultAlignLog2 = 0; break; case Op::I32Load8U: if (!c.buffer.append("i32.load8_u")) return false; defaultAlignLog2 = 0; break; case Op::I64Load8U: if (!c.buffer.append("i64.load8_u")) return false; defaultAlignLog2 = 0; break; case Op::I32Load16S: if (!c.buffer.append("i32.load16_s")) return false; defaultAlignLog2 = 1; break; case Op::I64Load16S: if (!c.buffer.append("i64.load16_s")) return false; defaultAlignLog2 = 1; break; case Op::I32Load16U: if (!c.buffer.append("i32.load16_u")) return false; defaultAlignLog2 = 1; break; case Op::I64Load16U: if (!c.buffer.append("i64.load16_u")) return false; defaultAlignLog2 = 1; break; case Op::I64Load32S: if (!c.buffer.append("i64.load32_s")) return false; defaultAlignLog2 = 2; break; case Op::I64Load32U: if (!c.buffer.append("i64.load32_u")) return false; defaultAlignLog2 = 2; break; case Op::I32Load: if (!c.buffer.append("i32.load")) return false; defaultAlignLog2 = 2; break; case Op::I64Load: if (!c.buffer.append("i64.load")) return false; defaultAlignLog2 = 3; break; case Op::F32Load: if (!c.buffer.append("f32.load")) return false; defaultAlignLog2 = 2; break; case Op::F64Load: if (!c.buffer.append("f64.load")) return false; defaultAlignLog2 = 3; break; default: return Fail(c, "unexpected load operator"); } return RenderLoadStoreAddress(c, load.address(), defaultAlignLog2); }