feat: 函数名登记为作用域内不可写绑定并按帧槽写入函数对象

This commit is contained in:
2026-10-09 21:32:51 +00:00
parent 71904a644f
commit 4f6bd5d947
16 changed files with 271 additions and 42 deletions
+7 -4
View File
@@ -47,6 +47,7 @@ impl Emitter {
is_expr_body,
true,
arrow.has_use_strict_directive(),
None,
)?
} else {
self.compile_function_body(
@@ -56,6 +57,7 @@ impl Emitter {
is_expr_body,
true,
arrow.has_use_strict_directive(),
None,
)?
};
sub_module.is_arrow = true;
@@ -98,14 +100,15 @@ impl Emitter {
let body_stmts: &[Statement] = if let Some(body) = &fe.body { &body.statements } else { &[] };
let own_strict = fe.has_use_strict_directive();
let fn_name = fe.id.as_ref().map(|id| id.name.as_str());
let mut sub_module = if fe.generator && fe.r#async {
self.compile_async_generator_body(&param_names, body_stmts, ctx, own_strict)?
self.compile_async_generator_body(&param_names, body_stmts, ctx, own_strict, fn_name)?
} else if fe.generator {
self.compile_generator_body(&param_names, body_stmts, ctx, own_strict)?
self.compile_generator_body(&param_names, body_stmts, ctx, own_strict, fn_name)?
} else if fe.r#async {
self.compile_async_body(&param_names, body_stmts, ctx, false, false, own_strict)?
self.compile_async_body(&param_names, body_stmts, ctx, false, false, own_strict, fn_name)?
} else {
self.compile_function_body(&param_names, body_stmts, ctx, false, false, own_strict)?
self.compile_function_body(&param_names, body_stmts, ctx, false, false, own_strict, fn_name)?
};
if let Some(id) = &fe.id {
sub_module.function_name = Some(id.name.to_string());