From eb9edfb19c79daba4467c793127f4f7fcf6f51df Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Thu, 17 Sep 2026 16:26:45 +0000 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B8=85=E7=90=86=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E6=8E=A5=E5=8F=A3=E6=B3=A8=E9=87=8A=E7=9A=84=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E4=B8=8E=E5=8E=86=E5=8F=B2=E6=8E=AA=E8=BE=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_runtime_api/src/coercion.rs | 16 ++++++++-------- crates/oxide_runtime_api/src/host.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/oxide_runtime_api/src/coercion.rs b/crates/oxide_runtime_api/src/coercion.rs index 62cf982d..c386a9b0 100644 --- a/crates/oxide_runtime_api/src/coercion.rs +++ b/crates/oxide_runtime_api/src/coercion.rs @@ -35,15 +35,15 @@ pub fn format_error_message(name: &str, msg: &str) -> String { /// [`VmHost::string_units`] / [`to_units_full`]。 #[inline] pub(crate) unsafe fn string_data(val: JsValue) -> std::borrow::Cow<'static, str> { - // Borrowed 臂借用期名义绑定解引用临时;与旧 `&'static str` 版本同款契约 - // (同函数内即时消费),生命周期统一升为 'static。 + // Borrowed 臂借用期名义绑定解引用临时承载(同函数内即时消费), + // 生命周期由该约定统一升为 'static。 std::mem::transmute((*val.as_string_ptr()).as_lossy_str()) } /// 按内容比较两个字符串 `JsValue` 是否相等。 /// -/// 先做指针级短路(同一 interned 字符串必等);双 Flat 比文本(与旧路径逐位 -/// 一致),其余按单元序列比较(对"rope vs 同内容不同指针"也正确)。 +/// 先做指针级短路(同一 interned 字符串必等);两侧均 Flat 时直接按文本逐位比较, +/// 结果与走单元序列比较一致;其余按单元序列比较(对"rope vs 同内容不同指针"也正确)。 #[inline] pub fn string_value_eq(a: JsValue, b: JsValue) -> bool { if a.as_string_ptr() == b.as_string_ptr() { @@ -520,7 +520,7 @@ pub fn relational_compare(lhs: JsValue, rhs: JsValue) -> Option { let l = unsafe { &*lhs.as_string_ptr() }; let r = unsafe { &*rhs.as_string_ptr() }; if l.is_flat() && r.is_flat() { - // 双 Flat:文本比较与旧路径逐位一致。 + // 双 Flat:直接按文本字典序比较(与 rope 的码元字典序结果一致)。 return Some(l.as_str() < r.as_str()); } // 单元口径:码元字典序即规范序,Flat 编码与 rope 扁平化统一走单元通道。 @@ -912,8 +912,8 @@ pub fn to_string_for_string_constructor(val: JsValue, host: &mut H) - Ok(to_string(primitive)) } -/// Well-known symbols are stored as empty objects in the builtin world; map an object -/// pointer back to its well-known symbol id (0..WELL_KNOWN_SYMBOL_COUNT) if it is one. +/// well-known symbol 以空对象存于 builtin world;把一个对象指针反查回它的 +/// well-known symbol id(0..WELL_KNOWN_SYMBOL_COUNT),非 well-known symbol 返回 None。 pub fn well_known_symbol_id(host: &H, ptr: *mut JsObject) -> Option { if ptr.is_null() { return None; @@ -950,7 +950,7 @@ pub fn well_known_symbol_id(host: &H, ptr: *mut JsObject) -> } } -/// Descriptive name of a well-known symbol id, e.g. `Symbol.toStringTag` for id 9. +/// well-known symbol id 的描述名(如 id 9 对应 `Symbol.toStringTag`)。 pub fn well_known_symbol_name(id: u32) -> Option<&'static str> { Some(match id { 0 => "Symbol.iterator", diff --git a/crates/oxide_runtime_api/src/host.rs b/crates/oxide_runtime_api/src/host.rs index 5d9cfb20..2d5878a8 100644 --- a/crates/oxide_runtime_api/src/host.rs +++ b/crates/oxide_runtime_api/src/host.rs @@ -29,7 +29,7 @@ pub trait VmHost { /// 当前 native 调用的完整实参个数(寄存器窗口 + spill 溢出区,不含 receiver)。 /// /// 供支持大实参集的 builtin(如 `String.fromCodePoint`)遍历全部实参; - /// 未迁移的 builtin 仍按 `args` 索引读寄存器,行为不变。 + /// 尚未改用本接口的 builtin 仍按 `args` 索引读寄存器。 fn native_arg_count(&self, args: &[u8]) -> usize { args.len().saturating_sub(1) + self.native_overflow_count() }