Ejemplo n.º 1
0
static bool
RenderBlock(WasmRenderContext& c, AstBlock& block)
{
    if (block.expr() == Expr::Block) {
        if (!c.buffer.append("(block "))
            return false;
        if (!RenderName(c, block.breakName()))
            return false;
    } else if (block.expr() == Expr::Loop) {
        if (!c.buffer.append("(loop "))
            return false;
        if (block.breakName().empty() && !block.continueName().empty()) {
            // Giving auto label if continue label is present.
            if (!c.buffer.append("$exit$"))
                return false;
        } else {
            if (!RenderName(c, block.breakName()))
                return false;
        }
        if (!block.continueName().empty()) {
          if (!c.buffer.append(" "))
              return false;
          if (!RenderName(c, block.continueName()))
              return false;
        }
    } else
        return false;

    c.indent++;
    if (!RenderExprList(c, block.exprs()))
        return false;
    c.indent--;

    return c.buffer.append(")");
}