feat: WIP

This commit is contained in:
2025-08-22 21:40:52 +08:00
parent 3c7722a3d2
commit 65bcfcb47b
9 changed files with 312 additions and 154 deletions

View File

@@ -330,13 +330,7 @@ impl<Ctx: EvalContext> Evaluate<Ctx> for ir::Str {
impl<Ctx: EvalContext> Evaluate<Ctx> for ir::Const {
/// Evaluates a `Const` literal into its corresponding `Value` variant.
fn eval(&self, _: &mut Ctx) -> Result<Value> {
let result = match self.val {
Const::Null => Value::Null,
Const::Int(x) => Value::Int(x),
Const::Float(x) => Value::Float(x),
Const::Bool(x) => Value::Bool(x),
};
Ok(result)
Ok(self.val.into())
}
}

View File

@@ -76,6 +76,17 @@ impl Debug for Value {
}
}
impl From<Const> for Value {
fn from(value: nixjit_value::Const) -> Self {
match value {
Const::Null => Value::Null,
Const::Int(x) => Value::Int(x),
Const::Float(x) => Value::Float(x),
Const::Bool(x) => Value::Bool(x),
}
}
}
impl Value {
pub const INT: u64 = 0;
pub const FLOAT: u64 = 1;