implement |> and <|
This commit is contained in:
+28
-1
@@ -266,10 +266,37 @@ impl<'id: 'ir, 'ir, Ctx: DowngradeContext<'id, 'ir>> Downgrade<'id, 'ir, Ctx> fo
|
||||
|
||||
impl<'id: 'ir, 'ir, Ctx: DowngradeContext<'id, 'ir>> Downgrade<'id, 'ir, Ctx> for ast::BinOp {
|
||||
fn downgrade(self, ctx: &mut Ctx) -> Result<GhostRoIrRef<'id, 'ir>> {
|
||||
use ast::BinOpKind as Kind;
|
||||
use BinOpKind::*;
|
||||
|
||||
let span = self.syntax().text_range();
|
||||
let lhs = self.lhs().require(ctx, span)?.downgrade(ctx)?;
|
||||
let rhs = self.rhs().require(ctx, span)?.downgrade(ctx)?;
|
||||
let kind = self.operator().require(ctx, span)?.into();
|
||||
let kind = match self.operator().require(ctx, span)? {
|
||||
Kind::Concat => Con,
|
||||
Kind::Update => Upd,
|
||||
Kind::Add => Add,
|
||||
Kind::Sub => Sub,
|
||||
Kind::Mul => Mul,
|
||||
Kind::Div => Div,
|
||||
Kind::And => And,
|
||||
Kind::Equal => Eq,
|
||||
Kind::Implication => Impl,
|
||||
Kind::Less => Lt,
|
||||
Kind::LessOrEq => Leq,
|
||||
Kind::More => Gt,
|
||||
Kind::MoreOrEq => Geq,
|
||||
Kind::NotEqual => Neq,
|
||||
Kind::Or => Or,
|
||||
Kind::PipeLeft => {
|
||||
let arg = ctx.maybe_thunk(rhs);
|
||||
return Ok(ctx.new_expr(Ir::Call { func: lhs, arg, span }))
|
||||
},
|
||||
Kind::PipeRight => {
|
||||
let arg = ctx.maybe_thunk(lhs);
|
||||
return Ok(ctx.new_expr(Ir::Call { func: rhs, arg, span }))
|
||||
},
|
||||
};
|
||||
Ok(ctx.new_expr(Ir::BinOp { lhs, rhs, kind }))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user