runtime, macros: unify NaN-boxed value API under ValueVariant trait

This commit is contained in:
2026-07-15 19:11:03 +08:00
parent 7220b42024
commit 09ee923903
28 changed files with 510 additions and 490 deletions
+9 -9
View File
@@ -57,7 +57,7 @@ pub(crate) fn op_make_attrs<'gc, M: Machine<'gc>>(
kv.sort_by_key(|(k, _)| *k);
let attrs = Gc::new(mc, AttrSet::from_sorted_unchecked(kv));
m.push(Value::new_gc(attrs));
m.push(Value::new(attrs));
Step::Continue(())
}
@@ -195,7 +195,7 @@ pub(crate) fn op_has_attr_path_static<'gc, M: Machine<'gc>>(
let current = m.force_and_retry::<StrictValue>(reader, mc)?;
match current
.as_gc::<AttrSet>()
.downcast::<AttrSet>()
.and_then(|attrs| attrs.lookup(key))
{
Some(v) => {
@@ -223,7 +223,7 @@ pub(crate) fn op_has_attr_path_dynamic<'gc, M: Machine<'gc>>(
};
match current
.as_gc::<AttrSet>()
.downcast::<AttrSet>()
.and_then(|attrs| attrs.lookup(key_sid))
{
Some(v) => {
@@ -263,9 +263,9 @@ pub(crate) fn op_has_attr_static<'gc, M: Machine<'gc>>(
let key = reader.read_string_id();
let current = m.force_and_retry::<StrictValue>(reader, mc)?;
m.push(Value::new_inline(
m.push(Value::new(
current
.as_gc::<AttrSet>()
.downcast::<AttrSet>()
.and_then(|attrs| attrs.lookup(key))
.is_some(),
));
@@ -289,9 +289,9 @@ pub(crate) fn op_has_attr_dynamic<'gc, M: MachineExt<'gc>>(
Err(got) => return m.finish_type_err(NixType::String, got),
};
m.push(Value::new_inline(
m.push(Value::new(
current
.as_gc::<AttrSet>()
.downcast::<AttrSet>()
.and_then(|attrs| attrs.lookup(key_sid))
.is_some(),
));
@@ -304,7 +304,7 @@ pub(crate) fn op_has_attr_dynamic<'gc, M: MachineExt<'gc>>(
#[inline(always)]
pub(crate) fn op_has_attr_resolve<'gc, M: Machine<'gc>>(m: &mut M) -> Step {
// If we reach here, has_attr check has failed, push false (AttrSet is already popped)
m.push(Value::new_inline(false));
m.push(Value::new(false));
Step::Continue(())
}
@@ -326,7 +326,7 @@ pub(crate) fn op_make_list<'gc, M: Machine<'gc>>(
inner: RefLock::new(items),
},
);
m.push(Value::new_gc(list));
m.push(Value::new(list));
Step::Continue(())
}