refactor: 闭包捕获分析拆目录并自由函数化去除接收者

This commit is contained in:
2026-09-15 23:02:03 +00:00
parent 985c27e5bb
commit fa4c9edb81
12 changed files with 1453 additions and 1408 deletions
+3 -2
View File
@@ -7,6 +7,7 @@
use std::collections::HashSet;
use std::path::Path;
use crate::capture::{collect_captured_bindings, collect_own_binding_names};
use crate::expr::call::pack_arg_regs;
use crate::{CompileCtx, Emitter};
use oxc_allocator::Box;
@@ -171,8 +172,8 @@ impl Emitter {
let _ = self.predeclare_lexical_declarations(body, ctx, false);
// 闭包捕获分析(import 绑定名纳入 own_bindings,供嵌套函数 cell 捕获)。
ctx.own_bindings = self.collect_own_binding_names(&[], body);
ctx.captured_bindings = self.collect_captured_bindings(body, &[], &ctx.own_bindings);
ctx.own_bindings = collect_own_binding_names(&[], body);
ctx.captured_bindings = collect_captured_bindings(body, &[], &ctx.own_bindings);
// —— 模块命名空间对象 ——
let ns_reg = self.emit_module_call(ctx, "__moduleObject", &[])?;