mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
feat: ShadowRealm evaluate 与 importValue 真实现落地
This commit is contained in:
@@ -3,6 +3,14 @@
|
||||
|
||||
use oxide_bytecode::module::CompiledModule;
|
||||
|
||||
/// 模块源码加载器:按 `base_dir` 与 `specifier` 定位依赖模块源码。
|
||||
///
|
||||
/// 供 `compile_module` 解析 ES module 依赖。返回 (源码, 规范路径)。
|
||||
pub trait ModuleSourceLoader {
|
||||
/// 解析依赖模块:返回 (源码, 规范路径)。
|
||||
fn resolve(&mut self, base_dir: &str, specifier: &str) -> Result<(String, String), String>;
|
||||
}
|
||||
|
||||
/// 动态编译服务:`Vm` 经它把源码编译为 `CompiledModule`。
|
||||
///
|
||||
/// 无状态实现 `Send + Sync`,`Arc<dyn CompilerService>` 可跨线程共享
|
||||
@@ -19,4 +27,12 @@ pub trait CompilerService: Send + Sync {
|
||||
///
|
||||
/// 顶层 var/function 声明落全局属性 configurable:true。
|
||||
fn compile_eval_script(&self, source: &str) -> Result<CompiledModule, String>;
|
||||
|
||||
/// 编译 ES module(含依赖加载),返回完整模块树。
|
||||
///
|
||||
/// `module_path` 为模块文件的规范路径(依赖解析基准 = 其父目录),
|
||||
/// 依赖经 `loader` 解析。
|
||||
fn compile_module(
|
||||
&self, source: &str, module_path: &str, loader: &mut dyn ModuleSourceLoader,
|
||||
) -> Result<CompiledModule, String>;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub use coercion::{
|
||||
to_string_for_string_constructor, to_string_full, to_string_value_full, to_uint32, to_units_full,
|
||||
well_known_symbol_name, write_number_into, ToPrimitiveHint,
|
||||
};
|
||||
pub use compiler_service::CompilerService;
|
||||
pub use compiler_service::{CompilerService, ModuleSourceLoader};
|
||||
pub use event_target::{EventTargetState, ListenerEntry};
|
||||
pub use host::{ModuleEvalState, ProtoKind, ShapeNode, VmHost};
|
||||
pub use native_result::NativeResult;
|
||||
|
||||
Reference in New Issue
Block a user