implement |> and <|
This commit is contained in:
@@ -795,18 +795,6 @@ impl<'a, Ctx: BytecodeContext> BytecodeEmitter<'a, Ctx> {
|
|||||||
let end_offset = (self.ctx.get_code_mut().len() as i32) - (after_jump as i32);
|
let end_offset = (self.ctx.get_code_mut().len() as i32) - (after_jump as i32);
|
||||||
self.patch_i32(end_placeholder, end_offset);
|
self.patch_i32(end_placeholder, end_offset);
|
||||||
}
|
}
|
||||||
PipeL => {
|
|
||||||
todo!("new call");
|
|
||||||
// self.emit_expr(rhs);
|
|
||||||
// self.emit_expr(lhs);
|
|
||||||
// self.emit_op(Op::Call);
|
|
||||||
}
|
|
||||||
PipeR => {
|
|
||||||
todo!("new call");
|
|
||||||
// self.emit_expr(lhs);
|
|
||||||
// self.emit_expr(rhs);
|
|
||||||
// self.emit_op(Op::Call);
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
self.emit_expr(lhs);
|
self.emit_expr(lhs);
|
||||||
self.emit_expr(rhs);
|
self.emit_expr(rhs);
|
||||||
|
|||||||
+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 {
|
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>> {
|
fn downgrade(self, ctx: &mut Ctx) -> Result<GhostRoIrRef<'id, 'ir>> {
|
||||||
|
use ast::BinOpKind as Kind;
|
||||||
|
use BinOpKind::*;
|
||||||
|
|
||||||
let span = self.syntax().text_range();
|
let span = self.syntax().text_range();
|
||||||
let lhs = self.lhs().require(ctx, span)?.downgrade(ctx)?;
|
let lhs = self.lhs().require(ctx, span)?.downgrade(ctx)?;
|
||||||
let rhs = self.rhs().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 }))
|
Ok(ctx.new_expr(Ir::BinOp { lhs, rhs, kind }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,36 +265,6 @@ pub enum BinOpKind {
|
|||||||
// Set/String/Path operations
|
// Set/String/Path operations
|
||||||
Con, // List concatenation (`++`)
|
Con, // List concatenation (`++`)
|
||||||
Upd, // AttrSet update (`//`)
|
Upd, // AttrSet update (`//`)
|
||||||
|
|
||||||
// Not standard, but part of rnix AST
|
|
||||||
PipeL,
|
|
||||||
PipeR,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ast::BinOpKind> for BinOpKind {
|
|
||||||
fn from(op: ast::BinOpKind) -> Self {
|
|
||||||
use BinOpKind::*;
|
|
||||||
use ast::BinOpKind as kind;
|
|
||||||
match op {
|
|
||||||
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 => PipeL,
|
|
||||||
kind::PipeRight => PipeR,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The kinds of unary operations.
|
/// The kinds of unary operations.
|
||||||
|
|||||||
Reference in New Issue
Block a user