refactor: 移除代码注释中的文档内部编号引用

This commit is contained in:
爱特每羊队
2026-06-24 16:03:53 +08:00
parent 41c2b9cba9
commit 38657d2171
8 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -22,13 +22,13 @@ pub struct CompiledModule {
pub param_base: u8, pub param_base: u8,
pub builtin_reg_map: Vec<(String, u8)>, pub builtin_reg_map: Vec<(String, u8)>,
pub sub_modules: Vec<CompiledModule>, pub sub_modules: Vec<CompiledModule>,
/// True when this module is an arrow function body (D-01). /// True when this module is an arrow function body.
/// Arrow functions capture lexical `this` from the enclosing scope. /// Arrow functions capture lexical `this` from the enclosing scope.
pub is_arrow: bool, pub is_arrow: bool,
/// Index into `constants` holding the captured `this` JsValue. /// Index into `constants` holding the captured `this` JsValue.
/// 0 means "not captured - use standard this binding". /// 0 means "not captured - use standard this binding".
pub captured_this_const_idx: u16, pub captured_this_const_idx: u16,
/// Function name inferred from assignment context (D-04). /// Function name inferred from assignment context.
/// Set at the VariableDeclaration / ObjectProperty assignment site. /// Set at the VariableDeclaration / ObjectProperty assignment site.
pub function_name: Option<String>, pub function_name: Option<String>,
/// True when this bytecode function is a class constructor. /// True when this bytecode function is a class constructor.
+1 -1
View File
@@ -159,7 +159,7 @@ pub(crate) struct CompileCtx {
pub(crate) builtin_reg_map: Vec<(String, u8)>, pub(crate) builtin_reg_map: Vec<(String, u8)>,
pub(crate) sub_modules: Vec<CompiledModule>, pub(crate) sub_modules: Vec<CompiledModule>,
/// Register holding `this` in the enclosing function context. /// Register holding `this` in the enclosing function context.
/// Used by arrow functions to capture lexical `this` (D-01). /// Used by arrow functions to capture lexical `this`.
/// Initialized to 254 (conventional this register) at the top level. /// Initialized to 254 (conventional this register) at the top level.
pub(crate) enclosing_this_reg: u8, pub(crate) enclosing_this_reg: u8,
pub(crate) in_derived_constructor: bool, pub(crate) in_derived_constructor: bool,
@@ -4,7 +4,7 @@ impl Compiler {
pub(in crate::emitter) fn emit_arrow_function_expression( pub(in crate::emitter) fn emit_arrow_function_expression(
&self, arrow: &oxide_parser::ArrowFunctionExpression, ctx: &mut CompileCtx, &self, arrow: &oxide_parser::ArrowFunctionExpression, ctx: &mut CompileCtx,
) -> Result<u8, String> { ) -> Result<u8, String> {
// Rest params not yet supported (D-06 placeholder) // Rest params not yet supported
if let Some(_rest) = &arrow.params.rest { if let Some(_rest) = &arrow.params.rest {
return Err("rest params in arrow functions not yet supported".into()); return Err("rest params in arrow functions not yet supported".into());
} }
@@ -38,7 +38,7 @@ impl Compiler {
let key_reg = ctx.alloc_reg(); let key_reg = ctx.alloc_reg();
ctx.emit_load_const(key_reg, idx); ctx.emit_load_const(key_reg, idx);
let val_reg = self.emit_expression(&p.value, ctx)?; let val_reg = self.emit_expression(&p.value, ctx)?;
// Name inference (D-04): if property value is an arrow function, // Name inference: if property value is an arrow function,
// set the compiled sub_module's function_name to the property key. // set the compiled sub_module's function_name to the property key.
if matches!(&p.value, Expression::ArrowFunctionExpression(_)) { if matches!(&p.value, Expression::ArrowFunctionExpression(_)) {
if let Some(sub_mod) = ctx.sub_modules.last_mut() { if let Some(sub_mod) = ctx.sub_modules.last_mut() {
@@ -76,7 +76,7 @@ fn compile_arrow_name_inference() {
.sub_modules .sub_modules
.iter() .iter()
.any(|m| m.is_arrow && m.function_name.as_deref() == Some("myArrow")); .any(|m| m.is_arrow && m.function_name.as_deref() == Some("myArrow"));
assert!(named, "arrow function should have function_name='myArrow' from D-04 inference"); assert!(named, "arrow function should have function_name='myArrow' from name inference");
} }
#[test] #[test]
+3 -3
View File
@@ -53,9 +53,9 @@ impl<T: fmt::Display> fmt::Display for P<T> {
/// Persistent heap for cross-epoch object storage. /// Persistent heap for cross-epoch object storage.
/// ///
/// Phase 3 provides a minimal API: `promote(value)` moves `value` to the /// Provides a minimal API: `promote(value)` moves `value` to the
/// global heap under `Arc` and returns `P<T>`. Phase 7 (OxideKernel) expands /// global heap under `Arc` and returns `P<T>`. Typed storage for shapes,
/// with typed storage for shapes, code, IC templates, and strings. /// code, IC templates, and strings lives in the OxideKernel.
pub struct PersistentHeap; pub struct PersistentHeap;
impl PersistentHeap { impl PersistentHeap {
+1 -1
View File
@@ -5,7 +5,7 @@ fn stub_error(vm: &mut Vm, name: &str) -> NativeResult {
NativeResult::Err(crate::builtins::error::create_type_error(vm, &format!("{name} is not implemented"))) NativeResult::Err(crate::builtins::error::create_type_error(vm, &format!("{name} is not implemented")))
} }
// Architecturally deferred — see 13.5-CONTEXT.md for rationale // Architecturally deferred — these features are excluded from the supported language subset by design.
pub fn proxy_stub(vm: &mut Vm, _args: &[u8]) -> NativeResult { pub fn proxy_stub(vm: &mut Vm, _args: &[u8]) -> NativeResult {
stub_error(vm, "Proxy") stub_error(vm, "Proxy")
} }
+1 -1
View File
@@ -202,7 +202,7 @@ impl Vm {
/// Create a function JsObject for a BytecodeFunc constant. /// Create a function JsObject for a BytecodeFunc constant.
/// When `is_arrow` is true, captures the current `this` (regs[254]) /// When `is_arrow` is true, captures the current `this` (regs[254])
/// for lexical this binding at call time (D-01). /// for lexical this binding at call time.
fn create_function_object( fn create_function_object(
&mut self, sub_idx: u32, is_arrow: bool, is_class_constructor: bool, is_derived_constructor: bool, &mut self, sub_idx: u32, is_arrow: bool, is_class_constructor: bool, is_derived_constructor: bool,
needs_home_object: bool, needs_home_object: bool,