diff --git a/nix-js/src/codegen.rs b/nix-js/src/codegen.rs index 4c8f617..9ce14a3 100644 --- a/nix-js/src/codegen.rs +++ b/nix-js/src/codegen.rs @@ -238,12 +238,12 @@ impl Compile for Ir { Ir::List(x) => x.compile(ctx, buf), Ir::Call(x) => x.compile(ctx, buf), Ir::Arg(x) => { - code!(buf, "arg{}", x.inner.0); + code!(buf, "a{}", x.inner.0); } Ir::TopLevel(x) => x.compile(ctx, buf), Ir::Select(x) => x.compile(ctx, buf), &Ir::Thunk(Thunk { inner: expr_id, .. }) => { - code!(buf, "expr{}", expr_id.0); + code!(buf, "e{}", expr_id.0); } Ir::Builtins(_) => { // Nix.builtins @@ -416,7 +416,7 @@ impl Compile for Func { ellipsis, }) = &self.param { - code!(buf, "$mf(arg{}=>", id); + code!(buf, "$mf(a{}=>", id); if has_thunks { code!(buf, ctx; "{" self.thunks "return " self.body "}"); } else { @@ -440,7 +440,7 @@ impl Compile for Func { ")" ); } else { - code!(buf, "arg{}=>", id); + code!(buf, "a{}=>", id); if has_thunks { code!(buf, ctx; "{" self.thunks "return " self.body "}"); } else { @@ -470,14 +470,14 @@ impl Compile for [(ExprId, ExprId)] { return; } - for &(slot, inner) in self { - let inner_ir = ctx.get_ir(inner); - code!( - buf, ctx; - "let expr" slot.0 "=$t(()=>(" inner_ir ")," - "\"expr" slot.0 "\");" - ); - } + code!( + buf, ctx; + "const " + joined(self.iter(), ",", |ctx: &Ctx, buf, &(slot, inner)| { + code!(buf, ctx; "e" slot.0 "=$t(()=>(" ctx.get_ir(inner) ")," "'e" slot.0 "')"); + }) + ";" + ); } }