Correctly halts
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
|
||||
use futures::FutureExt;
|
||||
@@ -5,7 +6,6 @@ use orchid_base::error::{OrcErr, OrcErrv};
|
||||
use orchid_base::format::{FmtCtx, FmtUnit, Format, Variants};
|
||||
use orchid_base::location::Pos;
|
||||
use orchid_base::name::Sym;
|
||||
use orchid_base::reqnot::ReqHandlish;
|
||||
use orchid_base::{match_mapping, tl_cache};
|
||||
|
||||
use crate::api;
|
||||
@@ -19,17 +19,21 @@ pub struct GExpr {
|
||||
pub pos: Pos,
|
||||
}
|
||||
impl GExpr {
|
||||
pub async fn api_return(self, ctx: SysCtx, hand: &impl ReqHandlish) -> api::Expression {
|
||||
pub async fn api_return(self, ctx: SysCtx) -> api::Expression {
|
||||
if let GExprKind::Slot(ex) = self.kind {
|
||||
hand.defer_drop(ex.handle());
|
||||
let hand = ex.handle();
|
||||
mem::drop(ex);
|
||||
api::Expression {
|
||||
location: api::Location::SlotTarget,
|
||||
kind: api::ExpressionKind::Slot(ex.handle().tk),
|
||||
kind: match Rc::try_unwrap(hand) {
|
||||
Ok(h) => api::ExpressionKind::Slot { tk: h.serialize(), by_value: true },
|
||||
Err(rc) => api::ExpressionKind::Slot { tk: rc.tk, by_value: false },
|
||||
},
|
||||
}
|
||||
} else {
|
||||
api::Expression {
|
||||
location: api::Location::Inherit,
|
||||
kind: self.kind.api_return(ctx, hand).boxed_local().await,
|
||||
kind: self.kind.api_return(ctx).boxed_local().await,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,17 +57,17 @@ pub enum GExprKind {
|
||||
Bottom(OrcErrv),
|
||||
}
|
||||
impl GExprKind {
|
||||
pub async fn api_return(self, ctx: SysCtx, hand: &impl ReqHandlish) -> api::ExpressionKind {
|
||||
pub async fn api_return(self, ctx: SysCtx) -> api::ExpressionKind {
|
||||
match_mapping!(self, Self => api::ExpressionKind {
|
||||
Call(
|
||||
f => Box::new(f.api_return(ctx.clone(), hand).await),
|
||||
x => Box::new(x.api_return(ctx, hand).await)
|
||||
f => Box::new(f.api_return(ctx.clone()).await),
|
||||
x => Box::new(x.api_return(ctx).await)
|
||||
),
|
||||
Seq(
|
||||
a => Box::new(a.api_return(ctx.clone(), hand).await),
|
||||
b => Box::new(b.api_return(ctx, hand).await)
|
||||
a => Box::new(a.api_return(ctx.clone()).await),
|
||||
b => Box::new(b.api_return(ctx).await)
|
||||
),
|
||||
Lambda(arg, body => Box::new(body.api_return(ctx, hand).await)),
|
||||
Lambda(arg, body => Box::new(body.api_return(ctx).await)),
|
||||
Arg(arg),
|
||||
Const(name.to_api()),
|
||||
Bottom(err.to_api()),
|
||||
|
||||
Reference in New Issue
Block a user