This commit is contained in:
2025-08-05 21:51:03 +08:00
parent 7afb2a7b1c
commit 64f650b695
12 changed files with 288 additions and 86 deletions

View File

@@ -12,24 +12,61 @@
use rnix::ast;
use derive_more::TryUnwrap;
use hashbrown::HashMap;
use hashbrown::{HashMap, HashSet};
use nixjit_value::Const as PubConst;
/// A type-safe wrapper for an index into an expression table.
#[repr(transparent)]
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ExprId(usize);
impl From<usize> for ExprId {
fn from(id: usize) -> Self {
ExprId(id)
}
}
impl From<ExprId> for usize {
fn from(id: ExprId) -> Self {
id.0
}
}
/// A type-safe wrapper for an index into a function table.
#[repr(transparent)]
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FuncId(usize);
impl From<usize> for FuncId {
fn from(id: usize) -> Self {
FuncId(id)
}
}
impl From<FuncId> for usize {
fn from(id: FuncId) -> Self {
id.0
}
}
/// A type-safe wrapper for an index into a function's argument list.
#[repr(transparent)]
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ArgIdx(usize);
impl From<usize> for ArgIdx {
fn from(id: usize) -> Self {
ArgIdx(id)
}
}
impl From<ArgIdx> for usize {
fn from(id: ArgIdx) -> Self {
id.0
}
}
/// Represents a Nix attribute set.
#[derive(Debug, Default)]
pub struct AttrSet {
@@ -185,7 +222,7 @@ pub struct Func {
pub struct Param {
pub ident: Option<String>,
pub required: Option<Vec<String>>,
pub allowed: Option<Vec<String>>,
pub allowed: Option<HashSet<String>>,
}
/// Represents a function call.