implement import & scopedImport (WIP, ResolvePath resolves to string)

This commit is contained in:
2026-05-05 15:18:31 +08:00
parent 49392f66f8
commit cfd2df5d0e
11 changed files with 453 additions and 102 deletions
+4 -2
View File
@@ -7,6 +7,7 @@ use crate::{Break, BytecodeReader, Step, Vm, VmRuntimeCtx};
pub(crate) enum TailResult {
YieldFuel(u32),
Done,
LoadFile,
}
pub(crate) type OpFn<'gc, C> = extern "rust-preserve-none" fn(
@@ -37,6 +38,7 @@ macro_rules! tail_dispatch_after {
($result:expr, $new_pc:expr, $vm:ident, $mc:ident, $ctx:ident, $bc:ident, $table:ident, $fuel:ident) => {{
match $result {
Step::Continue(()) | Step::Break(Break::Force) => {}
Step::Break(Break::LoadFile) => return TailResult::LoadFile,
Step::Break(Break::Done) => return TailResult::Done,
}
let new_pc: u32 = $new_pc;
@@ -183,7 +185,7 @@ tail_fn!(op_jump, (reader));
tail_fn!(op_coerce_to_string, (reader, mc));
tail_fn!(op_concat_strings, (ctx, reader, mc));
tail_fn!(op_resolve_path, (ctx));
tail_fn!(op_resolve_path, (ctx, reader, mc));
tail_fn!(op_assert, (ctx, reader, mc));
@@ -193,7 +195,7 @@ tail_fn!(op_load_builtins, ());
tail_fn!(op_load_builtin, (reader));
tail_fn!(op_load_repl_binding, (reader));
tail_fn!(op_load_scoped_binding, (reader));
tail_fn!(op_load_scoped_binding, (ctx, reader, mc));
macro_rules! table {
($($variant:ident => $fn:ident),* $(,)?) => {