From 8e6b4cb0e29f894dbca9fe7a90df8e493765b99e Mon Sep 17 00:00:00 2001 From: min Date: Thu, 9 Oct 2025 20:24:51 -0400 Subject: [PATCH] sub / block output --- src/compiler.rs | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 7a7189f..b6f1710 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -394,11 +394,11 @@ impl<'a> FuncBuild<'a> { for e in b.exprs { self.translate(e, false, false); } - // yield last expr - last.map_or(Val::Nil, |e| self.translate(e, false, do_yield)) + // compute/yield last expr if requested + last.map_or(Val::Nil, |e| self.translate(e, do_compute, do_yield)) } Expr::Func(args, exprs, fs) => { - //1 + // neww function!!!! Val::Nil } @@ -539,28 +539,11 @@ impl<'a> FuncBuild<'a> { } } Expr::Negate(_) => Val::Nil, - Expr::Subtract(l, r) => { - // negate - let nv2 = match *r { - // statically - Expr::Literal(Literal::Integer(i)) => Val::Int64(-i), - Expr::Literal(Literal::Float(f)) => Val::Float64(-f), - // at runtime - e => { - let v2 = self.translate(e, do_compute, do_yield); - let a2 = self.check_drop(&v2); - self.insts.push(Inst::Mul(a2, false, v2, Val::Int64(-1))); - Val::Stack(self.pop_top(), true) - } - }; - - // add - let v1 = self.translate(*l, do_compute, do_yield); - let a1 = self.check_drop(&v1); - - self.insts.push(Inst::Add(a1, true, v1, nv2)); - Val::Stack(self.push_any(), true) - } + Expr::Subtract(l, r) => self.translate( + Expr::Add(l, Box::new(Expr::Negate(r))), + do_compute, + do_yield, + ), /* logic */ Expr::And(l, r) => self.gen_binop(*l, *r, Inst::And, do_compute),