feat: a lot

This commit is contained in:
2025-08-06 18:30:19 +08:00
parent 32c602f21c
commit f946cb2fd1
22 changed files with 735 additions and 591 deletions

View File

@@ -1,10 +1,9 @@
use nixjit_macros::builtins;
use nixjit_eval::EvalContext;
pub trait BuiltinsContext: EvalContext {}
pub trait BuiltinsContext {}
#[builtins]
mod builtins {
pub mod builtins {
use nixjit_error::{Error, Result};
use nixjit_eval::Value;
use nixjit_value::Const;
@@ -15,7 +14,7 @@ mod builtins {
const FALSE: Const = Const::Bool(false);
const NULL: Const = Const::Null;
fn add<Ctx: BuiltinsContext>(a: Value<Ctx>, b: Value<Ctx>) -> Result<Value<Ctx>> {
fn add(a: Value, b: Value) -> Result<Value> {
use Value::*;
Ok(match (a, b) {
(Int(a), Int(b)) => Int(a + b),
@@ -28,11 +27,11 @@ mod builtins {
})
}
pub fn import<Ctx: BuiltinsContext>(ctx: &mut Ctx, path: Value<Ctx>) -> Result<Value<Ctx>> {
pub fn import<Ctx: BuiltinsContext>(ctx: &mut Ctx, path: Value) -> Result<Value> {
todo!()
}
fn elem_at<Ctx: BuiltinsContext>(list: Value<Ctx>, idx: Value<Ctx>) -> Result<Value<Ctx>> {
fn elem_at(list: Value, idx: Value) -> Result<Value> {
todo!()
}
}