void PrintVisitor::visit(const AstReturn &ref) { if (ref.HasExpression()) { cout << "AstReturn<Expr="; ref.GetExpression()->accept(*this); cout << ">\n"; } else { cout << "AstReturn<>\n"; } }
static bool RenderReturn(WasmRenderContext& c, AstReturn& ret) { if (ret.maybeExpr()) { if (!RenderExpr(c, *(ret.maybeExpr()))) return false; } if (!RenderIndent(c)) return false; MAP_AST_EXPR(c, ret); return c.buffer.append("return"); }
static bool RenderReturn(WasmRenderContext& c, AstReturn& ret) { if (!c.buffer.append("(return")) return false; if (ret.maybeExpr()) { if (!c.buffer.append(" ")) return false; if (!RenderExpr(c, *(ret.maybeExpr()))) return false; } return c.buffer.append(")"); }
void IrGen::visit(AstReturn& return_) { auto&& ctorArgs = return_.ctorArgs().childs(); assert(ctorArgs.size() == 1U); Value* retVal = callAcceptOn(*ctorArgs.front()); assert(retVal); if (ctorArgs.front()->objType().isVoid()) { m_builder.CreateRetVoid(); } else { m_builder.CreateRet(retVal); } allocateAndInitLocalIrObjectFor(return_, m_abstractObject); }