fix: 修复数组回调与原始值属性访问

This commit is contained in:
2026-06-17 12:59:11 +08:00
parent 6a99209af8
commit f7834df245
10 changed files with 328 additions and 66 deletions
+10
View File
@@ -57,6 +57,9 @@ pub fn boolean_constructor(vm: &mut Vm, args: &[u8]) -> NativeResult {
pub fn boolean_prototype_value_of(vm: &mut Vm, args: &[u8]) -> NativeResult {
let this_val = vm.reg(if args.is_empty() { 0 } else { args[0] });
if this_val.is_bool() {
return NativeResult::Ok(this_val);
}
if !this_val.is_object() {
return NativeResult::Err(crate::builtins::error::create_type_error(
vm,
@@ -76,6 +79,13 @@ pub fn boolean_prototype_value_of(vm: &mut Vm, args: &[u8]) -> NativeResult {
pub fn boolean_prototype_to_string(vm: &mut Vm, args: &[u8]) -> NativeResult {
let this_val = vm.reg(if args.is_empty() { 0 } else { args[0] });
if this_val.is_bool() {
return if this_val.as_bool() {
NativeResult::Ok(vm.intern("true"))
} else {
NativeResult::Ok(vm.intern("false"))
};
}
if !this_val.is_object() {
return NativeResult::Err(crate::builtins::error::create_type_error(
vm,