Skip to content

Commit 843c542

Browse files
authored
Rework the Reflect.setPrototypeOf method (#3774)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
1 parent e50e271 commit 843c542

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

jerry-core/ecma/builtin-objects/ecma-builtin-reflect.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ecma-exceptions.h"
2323
#include "ecma-function-object.h"
2424
#include "ecma-gc.h"
25+
#include "ecma-proxy-object.h"
2526
#include "jcontext.h"
2627

2728
#if ENABLED (JERRY_ES2015_BUILTIN_REFLECT)
@@ -227,19 +228,26 @@ ecma_builtin_reflect_dispatch_routine (uint16_t builtin_routine_id, /**< built-i
227228
}
228229
case ECMA_REFLECT_OBJECT_SET_PROTOTYPE_OF:
229230
{
230-
ecma_value_t result = ecma_builtin_object_object_set_prototype_of (arguments_list[0], arguments_list[1]);
231-
bool is_error = ECMA_IS_VALUE_ERROR (result);
231+
if (!ecma_is_value_object (arguments_list[1]) && !ecma_is_value_null (arguments_list[1]))
232+
{
233+
return ecma_raise_type_error (ECMA_ERR_MSG ("proto is neither Object nor Null."));
234+
}
235+
236+
ecma_object_t *obj_p = ecma_get_object_from_value (arguments_list[0]);
237+
ecma_value_t status;
232238

233-
if (is_error)
239+
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
240+
if (ECMA_OBJECT_IS_PROXY (obj_p))
234241
{
235-
jcontext_release_exception ();
242+
status = ecma_proxy_object_set_prototype_of (obj_p, arguments_list[1]);
236243
}
237244
else
245+
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
238246
{
239-
ecma_free_value (result);
247+
status = ecma_op_ordinary_object_set_prototype_of (obj_p, arguments_list[1]);
240248
}
241249

242-
return ecma_make_boolean_value (!is_error);
250+
return status;
243251
}
244252
case ECMA_REFLECT_OBJECT_APPLY:
245253
{

tests/test262-es6-excludelist.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@
190190
<test id="built-ins/Reflect/preventExtensions/return-boolean-from-proxy-object.js"><reason></reason></test>
191191
<test id="built-ins/Reflect/set/name.js"><reason></reason></test>
192192
<test id="built-ins/Reflect/setPrototypeOf/name.js"><reason></reason></test>
193-
<test id="built-ins/Reflect/setPrototypeOf/proto-is-not-object-and-not-null-throws.js"><reason></reason></test>
194-
<test id="built-ins/Reflect/setPrototypeOf/proto-is-symbol-throws.js"><reason></reason></test>
195-
<test id="built-ins/Reflect/setPrototypeOf/return-abrupt-from-result.js"><reason></reason></test>
196193
<test id="built-ins/RegExp/prototype/exec/get-sticky-coerce.js"><reason></reason></test>
197194
<test id="built-ins/RegExp/prototype/exec/get-sticky-err.js"><reason></reason></test>
198195
<test id="built-ins/RegExp/prototype/flags/name.js"><reason></reason></test>

0 commit comments

Comments
 (0)