@@ -1083,8 +1083,7 @@ ecma_op_to_index (ecma_value_t value, /**< ecma value */
1083
1083
*/
1084
1084
ecma_collection_t *
1085
1085
ecma_op_create_list_from_array_like (ecma_value_t arr , /**< array value */
1086
- bool prop_names_only ) /**< true - accept only property names
1087
- false - otherwise */
1086
+ uint32_t options ) /**< from array like and property name filter flags */
1088
1087
{
1089
1088
/* 1. */
1090
1089
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (arr ));
@@ -1095,10 +1094,12 @@ ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */
1095
1094
ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object ));
1096
1095
return NULL ;
1097
1096
}
1097
+
1098
1098
ecma_object_t * obj_p = ecma_get_object_from_value (arr );
1099
1099
1100
1100
/* 4. 5. */
1101
1101
ecma_length_t len ;
1102
+
1102
1103
if (ECMA_IS_VALUE_ERROR (ecma_op_object_get_length (obj_p , & len )))
1103
1104
{
1104
1105
return NULL ;
@@ -1107,18 +1108,69 @@ ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */
1107
1108
/* 6. */
1108
1109
ecma_collection_t * list_ptr = ecma_new_collection ();
1109
1110
1111
+ if (!(options & ECMA_FROM_ARRAY_LIKE_ONLY_PROP_NAMES ))
1112
+ {
1113
+ /* 7. 8. */
1114
+ for (ecma_length_t idx = 0 ; idx < len ; idx ++ )
1115
+ {
1116
+ ecma_value_t next = ecma_op_object_get_by_index (obj_p , idx );
1117
+
1118
+ if (ECMA_IS_VALUE_ERROR (next ))
1119
+ {
1120
+ ecma_collection_free (list_ptr );
1121
+ return NULL ;
1122
+ }
1123
+
1124
+ ecma_collection_push_back (list_ptr , next );
1125
+ }
1126
+
1127
+ /* 9. */
1128
+ return list_ptr ;
1129
+ }
1130
+
1110
1131
/* 7. 8. */
1111
1132
for (ecma_length_t idx = 0 ; idx < len ; idx ++ )
1112
1133
{
1113
1134
ecma_value_t next = ecma_op_object_get_by_index (obj_p , idx );
1135
+
1114
1136
if (ECMA_IS_VALUE_ERROR (next ))
1115
1137
{
1116
1138
ecma_collection_free (list_ptr );
1117
1139
return NULL ;
1118
1140
}
1119
1141
1120
- if (prop_names_only
1121
- && !ecma_is_value_prop_name (next ))
1142
+ if (ecma_is_value_string (next ))
1143
+ {
1144
+ jerry_property_filter_t non_symbol_mask = (JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS
1145
+ | JERRY_PROPERTY_FILTER_EXLCUDE_INTEGER_INDICES );
1146
+
1147
+ if (options & non_symbol_mask )
1148
+ {
1149
+ if ((options & non_symbol_mask ) == non_symbol_mask )
1150
+ {
1151
+ ecma_free_value (next );
1152
+ continue ;
1153
+ }
1154
+
1155
+ uint32_t index = ecma_string_get_array_index (ecma_get_string_from_value (next ));
1156
+
1157
+ if ((index != ECMA_STRING_NOT_ARRAY_INDEX && (options & JERRY_PROPERTY_FILTER_EXLCUDE_INTEGER_INDICES ))
1158
+ || (index == ECMA_STRING_NOT_ARRAY_INDEX && (options & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS )))
1159
+ {
1160
+ ecma_free_value (next );
1161
+ continue ;
1162
+ }
1163
+ }
1164
+ }
1165
+ else if (ecma_is_value_symbol (next ))
1166
+ {
1167
+ if (options & JERRY_PROPERTY_FILTER_EXLCUDE_SYMBOLS )
1168
+ {
1169
+ ecma_free_value (next );
1170
+ continue ;
1171
+ }
1172
+ }
1173
+ else
1122
1174
{
1123
1175
ecma_free_value (next );
1124
1176
ecma_collection_free (list_ptr );
@@ -1132,6 +1184,7 @@ ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */
1132
1184
/* 9. */
1133
1185
return list_ptr ;
1134
1186
} /* ecma_op_create_list_from_array_like */
1187
+
1135
1188
#endif /* JERRY_ESNEXT */
1136
1189
1137
1190
/**
0 commit comments