Added new target support to Promise (#3707)

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
kisbg
2020-05-04 15:03:12 +02:00
committed by GitHub
parent 132a2008c9
commit 8ccb95c31c
3 changed files with 48 additions and 3 deletions
+11 -1
View File
@@ -1616,7 +1616,17 @@ jerry_create_promise (void)
jerry_assert_api_available ();
#if ENABLED (JERRY_ES2015_BUILTIN_PROMISE)
return ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_PROMISE_EXECUTOR_EMPTY);
ecma_object_t * old_new_target_p = JERRY_CONTEXT (current_new_target);
if (old_new_target_p == NULL)
{
JERRY_CONTEXT (current_new_target) = ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE);
}
ecma_value_t promise_value = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_PROMISE_EXECUTOR_EMPTY);
JERRY_CONTEXT (current_new_target) = old_new_target_p;
return promise_value;
#else /* !ENABLED (JERRY_ES2015_BUILTIN_PROMISE) */
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Promise not supported.")));
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROMISE) */