feat: 实现最小 BigInt 子集(字面量/算术/比较/构造器,Temporal 前置)
This commit is contained in:
@@ -251,6 +251,8 @@ pub struct BuiltinWorld {
|
||||
pub plain_date_proto: P<JsObject>,
|
||||
pub plain_time_constructor: P<JsObject>,
|
||||
pub plain_time_proto: P<JsObject>,
|
||||
pub bigint_constructor: P<JsObject>,
|
||||
pub bigint_proto: P<JsObject>,
|
||||
pub stub_objects: Vec<P<JsObject>>,
|
||||
}
|
||||
|
||||
@@ -502,9 +504,10 @@ fn wire_builtin_world_links(world: &BuiltinWorld) {
|
||||
wire_ctor_proto(&world.instant_constructor, &world.instant_proto);
|
||||
wire_ctor_proto(&world.plain_date_constructor, &world.plain_date_proto);
|
||||
wire_ctor_proto(&world.plain_time_constructor, &world.plain_time_proto);
|
||||
wire_ctor_proto(&world.bigint_constructor, &world.bigint_proto);
|
||||
|
||||
let obj_proto_val = JsValue::from_js_object(world.object_proto.as_ptr() as *mut JsObject);
|
||||
let non_object_protos: [&P<JsObject>; 17] = [
|
||||
let non_object_protos: [&P<JsObject>; 18] = [
|
||||
&world.array_proto,
|
||||
&world.function_proto,
|
||||
&world.string_proto,
|
||||
@@ -522,6 +525,7 @@ fn wire_builtin_world_links(world: &BuiltinWorld) {
|
||||
&world.instant_proto,
|
||||
&world.plain_date_proto,
|
||||
&world.plain_time_proto,
|
||||
&world.bigint_proto,
|
||||
];
|
||||
for proto in &non_object_protos {
|
||||
set_proto_if_changed(proto, obj_proto_val);
|
||||
@@ -656,6 +660,8 @@ impl BuiltinWorld {
|
||||
BuiltinId::PlainDateProto => &self.plain_date_proto,
|
||||
BuiltinId::PlainTimeConstructor => &self.plain_time_constructor,
|
||||
BuiltinId::PlainTimeProto => &self.plain_time_proto,
|
||||
BuiltinId::BigIntConstructor => &self.bigint_constructor,
|
||||
BuiltinId::BigIntProto => &self.bigint_proto,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,6 +710,7 @@ impl BuiltinWorld {
|
||||
make_named_pair(string_forge, shape_forge, labels, "PlainDate");
|
||||
let (plain_time_proto, plain_time_constructor) =
|
||||
make_named_pair(string_forge, shape_forge, labels, "PlainTime");
|
||||
let (bigint_proto, bigint_constructor) = make_named_pair(string_forge, shape_forge, labels, "BigInt");
|
||||
let stub_objects = Vec::new();
|
||||
|
||||
let world = Self {
|
||||
@@ -784,6 +791,8 @@ impl BuiltinWorld {
|
||||
plain_date_proto,
|
||||
plain_time_constructor,
|
||||
plain_time_proto,
|
||||
bigint_constructor,
|
||||
bigint_proto,
|
||||
stub_objects,
|
||||
};
|
||||
wire_builtin_world_links(&world);
|
||||
@@ -987,6 +996,11 @@ impl BuiltinWorld {
|
||||
current.plain_time_constructor.clone(),
|
||||
)
|
||||
};
|
||||
let (bigint_proto, bigint_constructor) = if dirty.stubs {
|
||||
make_named_pair(string_forge, shape_forge, labels, "BigInt")
|
||||
} else {
|
||||
(current.bigint_proto.clone(), current.bigint_constructor.clone())
|
||||
};
|
||||
let stub_objects = if dirty.stubs { Vec::new() } else { current.stub_objects.clone() };
|
||||
|
||||
let world = BuiltinWorld {
|
||||
@@ -1067,6 +1081,8 @@ impl BuiltinWorld {
|
||||
plain_date_proto,
|
||||
plain_time_constructor,
|
||||
plain_time_proto,
|
||||
bigint_constructor,
|
||||
bigint_proto,
|
||||
stub_objects,
|
||||
};
|
||||
wire_builtin_world_links(&world);
|
||||
|
||||
@@ -225,7 +225,7 @@ pub struct KernelSession {
|
||||
/// 维护注意:每个新增的 `BuiltinWorld` 对象字段都必须加到这里以及
|
||||
/// `KernelSession::dirty_since_snapshot()`,以便选择性重置重建正确的
|
||||
/// builtin 家族。
|
||||
pub const NUM_BUILTINS: usize = 76;
|
||||
pub const NUM_BUILTINS: usize = 78;
|
||||
|
||||
/// 内置对象枚举 id,与 `BuiltinWorld` 中的存储槽一一对应。
|
||||
///
|
||||
@@ -310,6 +310,8 @@ pub enum BuiltinId {
|
||||
PlainDateProto = 73,
|
||||
PlainTimeConstructor = 74,
|
||||
PlainTimeProto = 75,
|
||||
BigIntConstructor = 76,
|
||||
BigIntProto = 77,
|
||||
}
|
||||
|
||||
impl BuiltinId {
|
||||
@@ -391,6 +393,8 @@ impl BuiltinId {
|
||||
BuiltinId::PlainDateProto,
|
||||
BuiltinId::PlainTimeConstructor,
|
||||
BuiltinId::PlainTimeProto,
|
||||
BuiltinId::BigIntConstructor,
|
||||
BuiltinId::BigIntProto,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -624,7 +628,10 @@ impl KernelSession {
|
||||
|| gen(BuiltinId::PlainDateProto) != snap(BuiltinId::PlainDateProto)
|
||||
|| gen(BuiltinId::PlainTimeConstructor) != snap(BuiltinId::PlainTimeConstructor)
|
||||
|| gen(BuiltinId::PlainTimeProto) != snap(BuiltinId::PlainTimeProto),
|
||||
stubs: world.stub_objects.len() != snapshot.stub_objects_len || stub_generations_dirty,
|
||||
stubs: world.stub_objects.len() != snapshot.stub_objects_len
|
||||
|| stub_generations_dirty
|
||||
|| gen(BuiltinId::BigIntConstructor) != snap(BuiltinId::BigIntConstructor)
|
||||
|| gen(BuiltinId::BigIntProto) != snap(BuiltinId::BigIntProto),
|
||||
global: BuiltinSnapshot::gen(&self.global_object) != snapshot.global_object_generation,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user