runtime, macros: unify NaN-boxed value API under ValueVariant trait
This commit is contained in:
@@ -40,7 +40,7 @@ pub fn import<'gc, M: Machine<'gc>>(
|
||||
// finalizer can use it as the cache key. The slot we pop here was
|
||||
// freed by `force_and_retry`, so we simply push.
|
||||
let path_sid = ctx.intern_string(abs.to_string_lossy());
|
||||
m.push(Value::new_inline(path_sid));
|
||||
m.push(Value::new(path_sid));
|
||||
let env = m.env();
|
||||
m.push_call_frame(CallFrame {
|
||||
pc: Continuation::PImportFinalize.ip() as usize,
|
||||
@@ -63,7 +63,7 @@ pub fn import_finalize<'gc, M: Machine<'gc>>(
|
||||
// stack: [path_sid, return_value]
|
||||
let val = m.pop();
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let path_sid = m.pop().as_inline::<StringId>().unwrap();
|
||||
let path_sid = m.pop().downcast::<StringId>().unwrap();
|
||||
// The cache key is keyed by the absolute path string we interned in
|
||||
// `import`. Resolve it back to the host PathBuf.
|
||||
let path_str = ctx.resolve_string(path_sid).to_owned();
|
||||
@@ -107,7 +107,7 @@ pub fn scoped_import<'gc, M: Machine<'gc>>(
|
||||
};
|
||||
|
||||
let keys: HashSet<StringId> = scope_attrs.entries.iter().map(|&(k, _)| k).collect();
|
||||
let slot_id = m.scope_slots_push(Value::new_gc(scope_attrs));
|
||||
let slot_id = m.scope_slots_push(Value::new(scope_attrs));
|
||||
|
||||
let env = m.env();
|
||||
m.push_call_frame(CallFrame {
|
||||
@@ -146,7 +146,7 @@ pub fn path_exists<'gc, M: Machine<'gc>>(
|
||||
let path_val = m.force_and_retry::<StrictValue>(reader, mc)?;
|
||||
// pathExists requires an absolute path. A `Path` value is
|
||||
// always absolute; a string is accepted only if it starts with `/`.
|
||||
let (path, is_path_value) = if let Some(p) = path_val.as_inline::<Path>() {
|
||||
let (path, is_path_value) = if let Some(p) = path_val.downcast::<Path>() {
|
||||
(ctx.resolve_string(p.0).to_owned(), true)
|
||||
} else if let Some(s) = ctx.get_string(path_val) {
|
||||
(s.to_owned(), false)
|
||||
@@ -171,7 +171,7 @@ pub fn path_exists<'gc, M: Machine<'gc>>(
|
||||
} else {
|
||||
std::fs::symlink_metadata(p).is_ok()
|
||||
};
|
||||
m.return_from_primop(Value::new_inline(exists), reader)
|
||||
m.return_from_primop(Value::new(exists), reader)
|
||||
}
|
||||
|
||||
/// Convert the user-supplied path string into an absolute, dotted-segment
|
||||
|
||||
Reference in New Issue
Block a user