Compare commits
4 Commits
7eb3acf26f
...
45096f5254
| Author | SHA1 | Date | |
|---|---|---|---|
| 45096f5254 | |||
| b57fea3104 | |||
| 4380fa85c4 | |||
| 99045aa76c |
@@ -185,7 +185,7 @@ export const fetchGit = (args: NixValue): NixAttrs => {
|
||||
]);
|
||||
}
|
||||
const attrs = forceAttrs(args);
|
||||
const url = forceStringValue(select("attrs", ["url"]));
|
||||
const url = forceStringValue(select(attrs, ["url"]));
|
||||
const gitRef = attrs.has("ref") ? forceStringValue(attrs.get("ref") as NixValue) : null;
|
||||
const rev = attrs.has("rev") ? forceStringValue(attrs.get("rev") as NixValue) : null;
|
||||
const shallow = attrs.has("shallow") ? forceBool(attrs.get("shallow") as NixValue) : false;
|
||||
|
||||
@@ -270,6 +270,12 @@ export const op = {
|
||||
update: (a: NixValue, b: NixValue): NixAttrs => {
|
||||
const mapA = forceAttrs(a);
|
||||
const mapB = forceAttrs(b);
|
||||
if (mapA.size === 0) {
|
||||
return mapB;
|
||||
}
|
||||
if (mapB.size === 0) {
|
||||
return mapA;
|
||||
}
|
||||
const result: NixAttrs = new Map(mapA);
|
||||
for (const [k, v] of mapB) {
|
||||
result.set(k, v);
|
||||
|
||||
@@ -238,12 +238,12 @@ impl<Ctx: CodegenContext> Compile<Ctx> 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<Ctx: CodegenContext> Compile<Ctx> 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<Ctx: CodegenContext> Compile<Ctx> 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<Ctx: CodegenContext> Compile<Ctx> 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 "')");
|
||||
})
|
||||
";"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ enum Command {
|
||||
#[clap(flatten)]
|
||||
source: ExprSource,
|
||||
#[arg(long)]
|
||||
silent: bool
|
||||
silent: bool,
|
||||
},
|
||||
Eval {
|
||||
#[clap(flatten)]
|
||||
@@ -180,7 +180,7 @@ fn main() -> Result<()> {
|
||||
)?;
|
||||
|
||||
match cli.command {
|
||||
Command::Compile { source , silent } => run_compile(&mut context, source, silent),
|
||||
Command::Compile { source, silent } => run_compile(&mut context, source, silent),
|
||||
Command::Eval { source } => run_eval(&mut context, source),
|
||||
Command::Repl => run_repl(&mut context),
|
||||
}
|
||||
|
||||
@@ -192,14 +192,11 @@ eval_okay_test!(
|
||||
eval_okay_test!(partition);
|
||||
eval_okay_test!(path);
|
||||
eval_okay_test!(pathexists);
|
||||
eval_okay_test!(
|
||||
path_string_interpolation,
|
||||
|| {
|
||||
unsafe {
|
||||
std::env::set_var("HOME", "/fake-home");
|
||||
}
|
||||
eval_okay_test!(path_string_interpolation, || {
|
||||
unsafe {
|
||||
std::env::set_var("HOME", "/fake-home");
|
||||
}
|
||||
);
|
||||
});
|
||||
eval_okay_test!(patterns);
|
||||
eval_okay_test!(print);
|
||||
eval_okay_test!(readDir);
|
||||
|
||||
@@ -6,6 +6,7 @@ mod findfile;
|
||||
mod free_globals;
|
||||
mod functions;
|
||||
mod io_operations;
|
||||
mod lang;
|
||||
mod numeric_types;
|
||||
mod operators;
|
||||
mod path_operations;
|
||||
@@ -13,5 +14,4 @@ mod regex;
|
||||
mod string_context;
|
||||
mod thunk_scope;
|
||||
mod to_string;
|
||||
mod lang;
|
||||
mod utils;
|
||||
|
||||
Reference in New Issue
Block a user