mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 19:21:11 +08:00
style: 自动格式化
This commit is contained in:
@@ -2,9 +2,7 @@
|
|||||||
//!
|
//!
|
||||||
//! 函数:`emit_class`。
|
//! 函数:`emit_class`。
|
||||||
|
|
||||||
use crate::{
|
use crate::{symbol_table::ScopeKind, ClassElementHooks, CompileCtx, Emitter, FunctionBodyContext, FunctionFlags};
|
||||||
symbol_table::ScopeKind, ClassElementHooks, CompileCtx, Emitter, FunctionBodyContext, FunctionFlags,
|
|
||||||
};
|
|
||||||
use oxide_bytecode::module::Constant;
|
use oxide_bytecode::module::Constant;
|
||||||
use oxide_bytecode::opcode::OpCode;
|
use oxide_bytecode::opcode::OpCode;
|
||||||
use oxide_ir::inst::Inst;
|
use oxide_ir::inst::Inst;
|
||||||
@@ -299,14 +297,8 @@ impl Emitter {
|
|||||||
ctor_hooks,
|
ctor_hooks,
|
||||||
)?
|
)?
|
||||||
} else {
|
} else {
|
||||||
let mut module = self.compile_function_body(
|
let mut module =
|
||||||
&[],
|
self.compile_function_body(&[], &[], ctx, FunctionBodyContext::ClassElement, ctor_flags, ctor_hooks)?;
|
||||||
&[],
|
|
||||||
ctx,
|
|
||||||
FunctionBodyContext::ClassElement,
|
|
||||||
ctor_flags,
|
|
||||||
ctor_hooks,
|
|
||||||
)?;
|
|
||||||
if is_derived {
|
if is_derived {
|
||||||
module.insts.clear();
|
module.insts.clear();
|
||||||
module.constants.clear();
|
module.constants.clear();
|
||||||
|
|||||||
@@ -202,13 +202,8 @@ impl Emitter {
|
|||||||
/// vreg 化后临时值不复用(独立 vreg),但 builtin 槽预注册仍保证分配序稳定:
|
/// vreg 化后临时值不复用(独立 vreg),但 builtin 槽预注册仍保证分配序稳定:
|
||||||
/// builtin 槽先于临时值池,嵌套函数继承边界不受扰。
|
/// builtin 槽先于临时值池,嵌套函数继承边界不受扰。
|
||||||
pub(crate) fn compile_function_body<'a, E>(
|
pub(crate) fn compile_function_body<'a, E>(
|
||||||
&self,
|
&self, param_specs: &[ParamSpec<'a>], body_stmts: &[Statement<'a>], parent_ctx: &CompileCtx,
|
||||||
param_specs: &[ParamSpec<'a>],
|
body_context: FunctionBodyContext, flags: FunctionFlags<'a>, hooks: ClassElementHooks<'a, E>,
|
||||||
body_stmts: &[Statement<'a>],
|
|
||||||
parent_ctx: &CompileCtx,
|
|
||||||
body_context: FunctionBodyContext,
|
|
||||||
flags: FunctionFlags<'a>,
|
|
||||||
hooks: ClassElementHooks<'a, E>,
|
|
||||||
) -> Result<IRFunction, String>
|
) -> Result<IRFunction, String>
|
||||||
where
|
where
|
||||||
E: FnMut(&Emitter, &mut CompileCtx) -> Result<(), String>,
|
E: FnMut(&Emitter, &mut CompileCtx) -> Result<(), String>,
|
||||||
@@ -218,9 +213,8 @@ impl Emitter {
|
|||||||
ctx.is_async = flags.is_async;
|
ctx.is_async = flags.is_async;
|
||||||
// 函数 strict = 自身 directive ‖ 外层严格(规范不可解除);
|
// 函数 strict = 自身 directive ‖ 外层严格(规范不可解除);
|
||||||
// 类元素方法/构造器恒 strict(ClassBody 是严格模式代码)。
|
// 类元素方法/构造器恒 strict(ClassBody 是严格模式代码)。
|
||||||
ctx.is_strict = flags.own_strict
|
ctx.is_strict =
|
||||||
|| matches!(body_context, FunctionBodyContext::ClassElement)
|
flags.own_strict || matches!(body_context, FunctionBodyContext::ClassElement) || parent_ctx.is_strict;
|
||||||
|| parent_ctx.is_strict;
|
|
||||||
|
|
||||||
// 形参名集(含解构叶子与 rest):块级函数名同名的 web-compat 守卫查此集。
|
// 形参名集(含解构叶子与 rest):块级函数名同名的 web-compat 守卫查此集。
|
||||||
let mut param_names = HashSet::new();
|
let mut param_names = HashSet::new();
|
||||||
@@ -504,21 +498,10 @@ impl Emitter {
|
|||||||
|
|
||||||
/// 非类元素函数体便捷入口:空钩子,等价于核心入口传 `ClassElementHooks::none()`。
|
/// 非类元素函数体便捷入口:空钩子,等价于核心入口传 `ClassElementHooks::none()`。
|
||||||
pub(crate) fn compile_simple_function_body<'a>(
|
pub(crate) fn compile_simple_function_body<'a>(
|
||||||
&self,
|
&self, param_specs: &[ParamSpec<'a>], body_stmts: &[Statement<'a>], parent_ctx: &CompileCtx,
|
||||||
param_specs: &[ParamSpec<'a>],
|
body_context: FunctionBodyContext, flags: FunctionFlags<'a>,
|
||||||
body_stmts: &[Statement<'a>],
|
|
||||||
parent_ctx: &CompileCtx,
|
|
||||||
body_context: FunctionBodyContext,
|
|
||||||
flags: FunctionFlags<'a>,
|
|
||||||
) -> Result<IRFunction, String> {
|
) -> Result<IRFunction, String> {
|
||||||
self.compile_function_body(
|
self.compile_function_body(param_specs, body_stmts, parent_ctx, body_context, flags, ClassElementHooks::none())
|
||||||
param_specs,
|
|
||||||
body_stmts,
|
|
||||||
parent_ctx,
|
|
||||||
body_context,
|
|
||||||
flags,
|
|
||||||
ClassElementHooks::none(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 规范 `argumentsObjNeeded` 的引擎判据:函数作用域是否声明 `arguments`
|
/// 规范 `argumentsObjNeeded` 的引擎判据:函数作用域是否声明 `arguments`
|
||||||
|
|||||||
Reference in New Issue
Block a user