static bool RenderBlock(WasmRenderContext& c, AstBlock& block, bool isInline = false) { if (!isInline && !RenderIndent(c)) return false; MAP_AST_EXPR(c, block); if (block.op() == Op::Block) { if (!c.buffer.append("block")) return false; } else if (block.op() == Op::Loop) { if (!c.buffer.append("loop")) return false; } else { return Fail(c, "unexpected block kind"); } if (!RenderBlockNameAndSignature(c, block.name(), block.type())) return false; uint32_t startAtSubExpr = 0; // If there is a stack of blocks, print them all inline. if (block.op() == Op::Block && block.exprs().length() && block.exprs()[0]->kind() == AstExprKind::Block && block.exprs()[0]->as<AstBlock>().op() == Op::Block) { if (!c.buffer.append(' ')) return false; // Render the first inner expr (block) at the same indent level, but // next instructions one level further. if (!RenderBlock(c, block.exprs()[0]->as<AstBlock>(), /* isInline */ true)) return false; startAtSubExpr = 1; } if (!c.buffer.append('\n')) return false; c.indent++; if (!RenderExprList(c, block.exprs(), startAtSubExpr)) return false; c.indent--; return RenderIndent(c) && c.buffer.append("end ") && RenderName(c, block.name()); }