feat: 支持 JSON 成员方法

This commit is contained in:
爱特每羊队
2026-06-07 23:41:52 +08:00
parent 4777783f92
commit 69945b9610
8 changed files with 572 additions and 1 deletions
+4
View File
@@ -112,6 +112,7 @@ pub struct BuiltinWorld {
pub uri_error_proto: P<JsObject>,
pub eval_error_proto: P<JsObject>,
pub math_object: P<JsObject>,
pub json_object: P<JsObject>,
}
fn intern_label(string_forge: &StringForge, label: &str) -> u32 {
@@ -242,6 +243,8 @@ impl BuiltinWorld {
let math_object = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
let json_object = P::new(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::null()));
/// Overwrite placeholder slots (set up by make_pair) with real values.
/// ctor.vec[0] = constructor.prototype -> proto
/// proto.vec[0] = proto.constructor -> ctor
@@ -293,6 +296,7 @@ impl BuiltinWorld {
uri_error_proto,
eval_error_proto,
math_object,
json_object,
}
}