feat: 模块命名空间枚举读活值并支持写穿

This commit is contained in:
2026-09-18 00:02:21 +00:00
parent cafac572fa
commit ed65b5282f
11 changed files with 263 additions and 22 deletions
+5
View File
@@ -137,6 +137,10 @@ pub struct CompileCtx {
pub(crate) for_head_store_registers: HashSet<String>,
/// 模块编译上下文:当前模块命名空间对象寄存器(`__moduleObject` 返回值)。
pub(crate) module_ns_reg: Option<u32>,
/// 写穿反演表:本模块源绑定名 → 引用它的导出名集合。仅自导入 ns 的 live 模块
/// 填充;顶层对该源绑定的赋值据此同步命名空间条目。嵌套函数 ctx 为新建,
/// 不继承本字段,写穿天然只作用于模块顶层。
pub(crate) module_local_exports: HashMap<String, Vec<String>>,
/// 已求值依赖模块的命名空间对象寄存器(按 import/export source 字符串索引)。
pub(crate) module_dep_ns_regs: HashMap<String, u32>,
/// 自导入(import from 自身)的 source 字符串集合:绑定走别名语义,不能链接期快照。
@@ -226,6 +230,7 @@ impl CompileCtx {
register_update_names: Vec::new(),
for_head_store_registers: HashSet::new(),
module_ns_reg: None,
module_local_exports: HashMap::new(),
module_dep_ns_regs: HashMap::new(),
module_self_import_specs: HashSet::new(),
module_self_aliases: HashMap::new(),