@@ -411,6 +411,11 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
411
411
else
412
412
{
413
413
/* b. */
414
+ if (property_desc_p -> flags & ECMA_PROP_IS_DATA_ACCESSOR )
415
+ {
416
+ prop_attributes |= ECMA_PROPERTY_FLAG_DATA_ACCESSOR ;
417
+ }
418
+
414
419
ecma_create_named_accessor_property (object_p ,
415
420
property_name_p ,
416
421
property_desc_p -> get_p ,
@@ -503,15 +508,9 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
503
508
}
504
509
}
505
510
}
506
- else
511
+ else if ( is_current_configurable )
507
512
{
508
513
/* 9. */
509
- if (!is_current_configurable )
510
- {
511
- /* a. */
512
- return ecma_reject (property_desc_p -> flags & ECMA_PROP_IS_THROW );
513
- }
514
-
515
514
ecma_property_value_t * value_p = ext_property_ref .property_ref .value_p ;
516
515
517
516
if (property_desc_type == ECMA_OP_OBJECT_DEFINE_ACCESSOR )
@@ -548,6 +547,81 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
548
547
prop_flags ^= ECMA_PROPERTY_FLAG_DATA ;
549
548
* (ext_property_ref .property_p ) = prop_flags ;
550
549
}
550
+ else
551
+ {
552
+ /* Property is non-configurable. */
553
+ if ((current_prop & ECMA_PROPERTY_FLAG_DATA )
554
+ || !(current_prop & ECMA_PROPERTY_FLAG_DATA_ACCESSOR ))
555
+ {
556
+ /* a. */
557
+ return ecma_reject (property_desc_p -> flags & ECMA_PROP_IS_THROW );
558
+ }
559
+
560
+ /* Non-standard extension. */
561
+ ecma_getter_setter_pointers_t * getter_setter_pair_p ;
562
+ getter_setter_pair_p = ecma_get_named_accessor_property (ext_property_ref .property_ref .value_p );
563
+
564
+ if (getter_setter_pair_p -> setter_cp == JMEM_CP_NULL )
565
+ {
566
+ const uint16_t mask = ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE ;
567
+
568
+ if ((property_desc_p -> flags & mask ) == mask )
569
+ {
570
+ return ecma_reject (property_desc_p -> flags & ECMA_PROP_IS_THROW );
571
+ }
572
+
573
+ if (!(property_desc_p -> flags & ECMA_PROP_IS_VALUE_DEFINED ))
574
+ {
575
+ return ECMA_VALUE_TRUE ;
576
+ }
577
+
578
+ ecma_value_t result = ECMA_VALUE_UNDEFINED ;
579
+
580
+ if (getter_setter_pair_p -> getter_cp != JMEM_CP_NULL )
581
+ {
582
+ ecma_object_t * getter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t , getter_setter_pair_p -> getter_cp );
583
+ result = ecma_op_function_call (getter_p , ecma_make_object_value (object_p ), NULL , 0 );
584
+
585
+ if (ECMA_IS_VALUE_ERROR (result ))
586
+ {
587
+ return result ;
588
+ }
589
+ }
590
+
591
+ bool same_value = ecma_op_same_value (property_desc_p -> value , result );
592
+ ecma_free_value (result );
593
+
594
+ if (!same_value )
595
+ {
596
+ return ecma_reject (property_desc_p -> flags & ECMA_PROP_IS_THROW );
597
+ }
598
+ return ECMA_VALUE_TRUE ;
599
+ }
600
+
601
+ if (property_desc_p -> flags & ECMA_PROP_IS_VALUE_DEFINED )
602
+ {
603
+ ecma_object_t * setter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t , getter_setter_pair_p -> setter_cp );
604
+
605
+ ecma_value_t result ;
606
+ result = ecma_op_function_call (setter_p , ecma_make_object_value (object_p ), & property_desc_p -> value , 1 );
607
+
608
+ if (ECMA_IS_VALUE_ERROR (result ))
609
+ {
610
+ return result ;
611
+ }
612
+
613
+ ecma_free_value (result );
614
+ }
615
+
616
+ /* Because the property is non-configurable, it cannot be modified. */
617
+ if ((property_desc_p -> flags & ECMA_PROP_IS_WRITABLE_DEFINED )
618
+ && !(property_desc_p -> flags & ECMA_PROP_IS_WRITABLE ))
619
+ {
620
+ getter_setter_pair_p -> setter_cp = JMEM_CP_NULL ;
621
+ }
622
+
623
+ return ECMA_VALUE_TRUE ;
624
+ }
551
625
552
626
/* 12. */
553
627
if (property_desc_type == ECMA_OP_OBJECT_DEFINE_DATA )
@@ -583,6 +657,15 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
583
657
ext_property_ref .property_ref .value_p ,
584
658
property_desc_p -> set_p );
585
659
}
660
+
661
+ if (property_desc_p -> flags & ECMA_PROP_IS_DATA_ACCESSOR )
662
+ {
663
+ * ext_property_ref .property_p |= ECMA_PROPERTY_FLAG_DATA_ACCESSOR ;
664
+ }
665
+ else
666
+ {
667
+ * ext_property_ref .property_p &= (uint8_t ) ~ECMA_PROPERTY_FLAG_DATA_ACCESSOR ;
668
+ }
586
669
}
587
670
588
671
if (property_desc_p -> flags & ECMA_PROP_IS_ENUMERABLE_DEFINED )
0 commit comments