optimize: compact
This commit is contained in:
@@ -238,12 +238,12 @@ impl<Ctx: CodegenContext> Compile<Ctx> for Ir {
|
|||||||
Ir::List(x) => x.compile(ctx, buf),
|
Ir::List(x) => x.compile(ctx, buf),
|
||||||
Ir::Call(x) => x.compile(ctx, buf),
|
Ir::Call(x) => x.compile(ctx, buf),
|
||||||
Ir::Arg(x) => {
|
Ir::Arg(x) => {
|
||||||
code!(buf, "arg{}", x.inner.0);
|
code!(buf, "a{}", x.inner.0);
|
||||||
}
|
}
|
||||||
Ir::TopLevel(x) => x.compile(ctx, buf),
|
Ir::TopLevel(x) => x.compile(ctx, buf),
|
||||||
Ir::Select(x) => x.compile(ctx, buf),
|
Ir::Select(x) => x.compile(ctx, buf),
|
||||||
&Ir::Thunk(Thunk { inner: expr_id, .. }) => {
|
&Ir::Thunk(Thunk { inner: expr_id, .. }) => {
|
||||||
code!(buf, "expr{}", expr_id.0);
|
code!(buf, "e{}", expr_id.0);
|
||||||
}
|
}
|
||||||
Ir::Builtins(_) => {
|
Ir::Builtins(_) => {
|
||||||
// Nix.builtins
|
// Nix.builtins
|
||||||
@@ -416,7 +416,7 @@ impl<Ctx: CodegenContext> Compile<Ctx> for Func {
|
|||||||
ellipsis,
|
ellipsis,
|
||||||
}) = &self.param
|
}) = &self.param
|
||||||
{
|
{
|
||||||
code!(buf, "$mf(arg{}=>", id);
|
code!(buf, "$mf(a{}=>", id);
|
||||||
if has_thunks {
|
if has_thunks {
|
||||||
code!(buf, ctx; "{" self.thunks "return " self.body "}");
|
code!(buf, ctx; "{" self.thunks "return " self.body "}");
|
||||||
} else {
|
} else {
|
||||||
@@ -440,7 +440,7 @@ impl<Ctx: CodegenContext> Compile<Ctx> for Func {
|
|||||||
")"
|
")"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
code!(buf, "arg{}=>", id);
|
code!(buf, "a{}=>", id);
|
||||||
if has_thunks {
|
if has_thunks {
|
||||||
code!(buf, ctx; "{" self.thunks "return " self.body "}");
|
code!(buf, ctx; "{" self.thunks "return " self.body "}");
|
||||||
} else {
|
} else {
|
||||||
@@ -470,16 +470,16 @@ impl<Ctx: CodegenContext> Compile<Ctx> for [(ExprId, ExprId)] {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for &(slot, inner) in self {
|
|
||||||
let inner_ir = ctx.get_ir(inner);
|
|
||||||
code!(
|
code!(
|
||||||
buf, ctx;
|
buf, ctx;
|
||||||
"let expr" slot.0 "=$t(()=>(" inner_ir "),"
|
"const "
|
||||||
"\"expr" slot.0 "\");"
|
joined(self.iter(), ",", |ctx: &Ctx, buf, &(slot, inner)| {
|
||||||
|
code!(buf, ctx; "e" slot.0 "=$t(()=>(" ctx.get_ir(inner) ")," "'e" slot.0 "')");
|
||||||
|
})
|
||||||
|
";"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<Ctx: CodegenContext> Compile<Ctx> for TopLevel {
|
impl<Ctx: CodegenContext> Compile<Ctx> for TopLevel {
|
||||||
fn compile(&self, ctx: &Ctx, buf: &mut CodeBuffer) {
|
fn compile(&self, ctx: &Ctx, buf: &mut CodeBuffer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user