aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-24 13:45:02 +0200
committerlemon <lsof@mailbox.org>2022-08-24 13:45:02 +0200
commit53fcd5e1647fb56511bbdd98925dd38a84fd7248 (patch)
tree4710e65d5d2a7a2c701d9c155460478b7c155cbd
parent333728ad37cae80f3ab53aaeb2c98352eb787b5f (diff)
fold fix
-rw-r--r--src/fold.cff16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/fold.cff b/src/fold.cff
index 00e4702..dd16f2a 100644
--- a/src/fold.cff
+++ b/src/fold.cff
@@ -89,10 +89,10 @@ fn funary(ex *Expr) void {
fn fbinary(ex *Expr) void {
let l = ex.u.BinOp.lhs,
r = ex.u.BinOp.rhs;
- let li = l.u.IntLit,
- lf = l.u.FloLit,
- ri = r.u.IntLit,
- rf = r.u.FloLit,
+ let li = &l.u.IntLit,
+ lf = &l.u.FloLit,
+ ri = &r.u.IntLit,
+ rf = &r.u.FloLit,
ei = &ex.u.IntLit,
ef = &ex.u.FloLit,
eb = &ex.u.BoolLit;
@@ -113,15 +113,15 @@ fn fbinary(ex *Expr) void {
}
switch {
case op == '+' and ty->is(:Int); ei.i = li.i + ri.i;
- case op == '+' and ty->is(:Flo); *ef = lf + rf;
+ case op == '+' and ty->is(:Flo); *ef = *lf + *rf;
case op == '-' and ty->is(:Int); ei.i = li.i - ri.i;
- case op == '-' and ty->is(:Flo); *ef = lf - rf;
+ case op == '-' and ty->is(:Flo); *ef = *lf - *rf;
case op == '*' and ty == ty_u64; ei.u = li.u * ri.u;
case op == '*' and ty->is(:Int); ei.i = li.i * ri.i;
- case op == '*' and ty->is(:Flo); *ef = lf * rf;
+ case op == '*' and ty->is(:Flo); *ef = *lf * *rf;
case op == '/' and ty == ty_u64; ei.u = li.u / ri.u;
case op == '/' and ty->is(:Int); ei.i = li.i / ri.i;
- case op == '/' and ty->is(:Flo); *ef = lf / rf;
+ case op == '/' and ty->is(:Flo); *ef = *lf / *rf;
case op == '%' and ty == ty_u64; ei.u = li.u % ri.u;
case op == '&' and ty->is(:Int); ei.i = li.i & ri.i;
case op == '|' and ty->is(:Int); ei.i = li.i | ri.i;