Rework external function handlers (#4599)
Instead of a fixed number of arguments, a call info structure is passed to the handlers, which can be extended in the future without breaknig the API. This structure holds new.target value, so its getter function is removed. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -4835,34 +4835,6 @@ jerry_get_resource_name (const jerry_value_t value) /**< jerry api value */
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
|
||||
} /* jerry_get_resource_name */
|
||||
|
||||
/**
|
||||
* Access the "new.target" value.
|
||||
*
|
||||
* The "new.target" value depends on the current call site. That is
|
||||
* this method will only have a function object result if, at the call site
|
||||
* it was called inside a constructor method invoked with "new".
|
||||
*
|
||||
* @return "undefined" - if at the call site it was not a constructor call.
|
||||
* function object - if the current call site is in a constructor call.
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_get_new_target (void)
|
||||
{
|
||||
#if JERRY_ESNEXT
|
||||
ecma_object_t *current_new_target_p = JERRY_CONTEXT (current_new_target_p);
|
||||
|
||||
if (current_new_target_p == NULL)
|
||||
{
|
||||
return jerry_create_undefined ();
|
||||
}
|
||||
|
||||
ecma_ref_object (current_new_target_p);
|
||||
return ecma_make_object_value (current_new_target_p);
|
||||
#else /* !JERRY_ESNEXT */
|
||||
return jerry_create_undefined ();
|
||||
#endif /* JERRY_ESNEXT */
|
||||
} /* jerry_get_new_target */
|
||||
|
||||
/**
|
||||
* Replaces the currently active realm with another realm.
|
||||
*
|
||||
|
||||
@@ -296,11 +296,15 @@ enum
|
||||
*/
|
||||
typedef ecma_value_t (*ecma_vm_exec_stop_callback_t) (void *user_p);
|
||||
|
||||
/**
|
||||
* Forward definition of jerry_call_info_t.
|
||||
*/
|
||||
struct jerry_call_info_t;
|
||||
|
||||
/**
|
||||
* Type of an external function handler.
|
||||
*/
|
||||
typedef ecma_value_t (*ecma_native_handler_t) (const ecma_value_t function_obj,
|
||||
const ecma_value_t this_val,
|
||||
typedef ecma_value_t (*ecma_native_handler_t) (const struct jerry_call_info_t *call_info_p,
|
||||
const ecma_value_t args_p[],
|
||||
const uint32_t args_count);
|
||||
|
||||
@@ -881,6 +885,13 @@ typedef struct
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
} ecma_built_in_props_t;
|
||||
|
||||
/**
|
||||
* Type of a built-in function handler.
|
||||
*/
|
||||
typedef ecma_value_t (*ecma_builtin_handler_t) (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t args_p[],
|
||||
const uint32_t args_count);
|
||||
|
||||
#if JERRY_BUILTIN_REALMS
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
#include "ecma-builtin-handlers.h"
|
||||
#include "ecma-promise-object.h"
|
||||
|
||||
static const ecma_native_handler_t ecma_native_handlers[] =
|
||||
static const ecma_builtin_handler_t ecma_native_handlers[] =
|
||||
{
|
||||
#define ECMA_NATIVE_HANDLER(id, handler, length) handler,
|
||||
#include "ecma-builtin-handlers.inc.h"
|
||||
#undef ECMA_NATIVE_HANDLER
|
||||
};
|
||||
|
||||
static const uint8_t ecma_native_handler_lengths[] =
|
||||
static const uint8_t ecma_native_handler_lengths[] =
|
||||
{
|
||||
#define ECMA_NATIVE_HANDLER(id, handler, length) length,
|
||||
#include "ecma-builtin-handlers.inc.h"
|
||||
@@ -39,7 +39,7 @@ static const uint8_t ecma_native_handler_lengths[] =
|
||||
*
|
||||
* return Function pointer of the handler
|
||||
*/
|
||||
ecma_native_handler_t
|
||||
ecma_builtin_handler_t
|
||||
ecma_builtin_handler_get (ecma_native_handler_id_t id) /**< handler id */
|
||||
{
|
||||
JERRY_ASSERT (id != ECMA_NATIVE_HANDLER_START && id < ECMA_NATIVE_HANDLER__COUNT);
|
||||
|
||||
@@ -42,7 +42,7 @@ typedef enum
|
||||
ECMA_NATIVE_HANDLER_FLAGS_PROMISE_ALREADY_RESOLVED = (1 << 2),
|
||||
} ecma_native_handler_flags_t;
|
||||
|
||||
ecma_native_handler_t
|
||||
ecma_builtin_handler_t
|
||||
ecma_builtin_handler_get (ecma_native_handler_id_t id);
|
||||
uint8_t
|
||||
ecma_builtin_handler_get_length (ecma_native_handler_id_t id);
|
||||
|
||||
@@ -1481,8 +1481,8 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
|
||||
#if JERRY_ESNEXT
|
||||
if (JERRY_UNLIKELY (ext_obj_p->u.built_in.id == ECMA_BUILTIN_ID_HANDLER))
|
||||
{
|
||||
ecma_native_handler_t handler = ecma_builtin_handler_get (ext_obj_p->u.built_in.routine_id);
|
||||
return handler (ecma_make_object_value (obj_p), this_arg_value, arguments_list_p, arguments_list_len);
|
||||
ecma_builtin_handler_t handler = ecma_builtin_handler_get (ext_obj_p->u.built_in.routine_id);
|
||||
return handler (obj_p, arguments_list_p, arguments_list_len);
|
||||
}
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -1227,9 +1227,19 @@ ecma_op_function_call_native (ecma_object_t *func_obj_p, /**< Function object */
|
||||
native_function_p->realm_value);
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
|
||||
jerry_call_info_t call_info;
|
||||
call_info.function = ecma_make_object_value (func_obj_p);
|
||||
call_info.this_value = this_arg_value;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
ecma_object_t *new_target_p = JERRY_CONTEXT (current_new_target_p);
|
||||
call_info.new_target = (new_target_p == NULL) ? ECMA_VALUE_UNDEFINED : ecma_make_object_value (new_target_p);
|
||||
#else /* JERRY_ESNEXT */
|
||||
call_info.new_target = ECMA_VALUE_UNDEFINED;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
JERRY_ASSERT (native_function_p->native_handler_cb != NULL);
|
||||
ecma_value_t ret_value = native_function_p->native_handler_cb (ecma_make_object_value (func_obj_p),
|
||||
this_arg_value,
|
||||
ecma_value_t ret_value = native_function_p->native_handler_cb (&call_info,
|
||||
arguments_list_p,
|
||||
arguments_list_len);
|
||||
#if JERRY_BUILTIN_REALMS
|
||||
|
||||
@@ -296,13 +296,11 @@ ecma_fulfill_promise (ecma_value_t promise, /**< promise */
|
||||
* @return ecma value of undefined.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_promise_reject_handler (const ecma_value_t function, /**< the function itself */
|
||||
const ecma_value_t this_arg, /**< this_arg of the function */
|
||||
const ecma_value_t argv[], /**< argument list */
|
||||
const uint32_t argc) /**< argument number */
|
||||
ecma_promise_reject_handler (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
ecma_promise_resolver_t *function_p = (ecma_promise_resolver_t *) ecma_get_object_from_value (function);
|
||||
ecma_promise_resolver_t *function_p = (ecma_promise_resolver_t *) function_obj_p;
|
||||
|
||||
/* 1. */
|
||||
ecma_object_t *promise_obj_p = ecma_get_object_from_value (function_p->promise);
|
||||
@@ -315,7 +313,7 @@ ecma_promise_reject_handler (const ecma_value_t function, /**< the function itse
|
||||
((ecma_extended_object_t *) promise_obj_p)->u.class_prop.extra_info |= ECMA_PROMISE_ALREADY_RESOLVED;
|
||||
|
||||
/* 6. */
|
||||
ecma_value_t reject_value = (argc == 0) ? ECMA_VALUE_UNDEFINED : argv[0];
|
||||
ecma_value_t reject_value = (args_count == 0) ? ECMA_VALUE_UNDEFINED : args_p[0];
|
||||
ecma_reject_promise (function_p->promise, reject_value);
|
||||
}
|
||||
|
||||
@@ -330,13 +328,11 @@ ecma_promise_reject_handler (const ecma_value_t function, /**< the function itse
|
||||
* @return ecma value of undefined.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_promise_resolve_handler (const ecma_value_t function, /**< the function itself */
|
||||
const ecma_value_t this_arg, /**< this_arg of the function */
|
||||
const ecma_value_t argv[], /**< argument list */
|
||||
const uint32_t argc) /**< argument number */
|
||||
ecma_promise_resolve_handler (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
ecma_promise_resolver_t *function_p = (ecma_promise_resolver_t *) ecma_get_object_from_value (function);
|
||||
ecma_promise_resolver_t *function_p = (ecma_promise_resolver_t *) function_obj_p;
|
||||
|
||||
/* 1. */
|
||||
ecma_object_t *promise_obj_p = ecma_get_object_from_value (function_p->promise);
|
||||
@@ -348,7 +344,7 @@ ecma_promise_resolve_handler (const ecma_value_t function, /**< the function its
|
||||
/* 5. */
|
||||
((ecma_extended_object_t *) promise_obj_p)->u.class_prop.extra_info |= ECMA_PROMISE_ALREADY_RESOLVED;
|
||||
|
||||
ecma_fulfill_promise (function_p->promise, (argc == 0) ? ECMA_VALUE_UNDEFINED : argv[0]);
|
||||
ecma_fulfill_promise (function_p->promise, (args_count == 0) ? ECMA_VALUE_UNDEFINED : args_p[0]);
|
||||
}
|
||||
|
||||
return ECMA_VALUE_UNDEFINED;
|
||||
@@ -529,14 +525,12 @@ ecma_promise_remaining_inc_or_dec (ecma_value_t remaining, /**< the remaining co
|
||||
* @return ecma value of undefined.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_promise_all_handler_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_promise_all_handler_cb (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED (this_val);
|
||||
JERRY_UNUSED (args_count);
|
||||
ecma_promise_all_executor_t *executor_p = (ecma_promise_all_executor_t *) ecma_get_object_from_value (function_obj);
|
||||
ecma_promise_all_executor_t *executor_p = (ecma_promise_all_executor_t *) function_obj_p;
|
||||
|
||||
/* 1 - 2. */
|
||||
if (executor_p->index == 0)
|
||||
@@ -578,16 +572,12 @@ ecma_promise_all_handler_cb (const ecma_value_t function_obj, /**< the function
|
||||
* returned value must be freed with ecma_free_value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_get_capabilities_executor_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_op_get_capabilities_executor_cb (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED (this_val);
|
||||
|
||||
/* 1. */
|
||||
ecma_promise_capability_executor_t *executor_p;
|
||||
executor_p = (ecma_promise_capability_executor_t *) ecma_get_object_from_value (function_obj);
|
||||
ecma_promise_capability_executor_t *executor_p = (ecma_promise_capability_executor_t *) function_obj_p;
|
||||
|
||||
/* 2-3. */
|
||||
ecma_object_t *capability_obj_p = ecma_get_object_from_value (executor_p->capability);
|
||||
@@ -607,9 +597,9 @@ ecma_op_get_capabilities_executor_cb (const ecma_value_t function_obj, /**< the
|
||||
}
|
||||
|
||||
/* 6. */
|
||||
capability_p->resolve = args_count > 0 ? args_p[0] : ECMA_VALUE_UNDEFINED;
|
||||
capability_p->resolve = (args_count > 0) ? args_p[0] : ECMA_VALUE_UNDEFINED;
|
||||
/* 7. */
|
||||
capability_p->reject = args_count > 1 ? args_p[1] : ECMA_VALUE_UNDEFINED;
|
||||
capability_p->reject = (args_count > 1) ? args_p[1] : ECMA_VALUE_UNDEFINED;
|
||||
|
||||
/* 8. */
|
||||
return ECMA_VALUE_UNDEFINED;
|
||||
@@ -901,15 +891,13 @@ ecma_promise_then (ecma_value_t promise, /**< the promise which call 'then' */
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_value_thunk_helper_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_value_thunk_helper_cb (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED_3 (this_val, args_p, args_count);
|
||||
JERRY_UNUSED_2 (args_p, args_count);
|
||||
|
||||
ecma_object_t *func_obj_p = ecma_get_object_from_value (function_obj);
|
||||
ecma_promise_value_thunk_t *value_thunk_obj_p = (ecma_promise_value_thunk_t *) func_obj_p;
|
||||
ecma_promise_value_thunk_t *value_thunk_obj_p = (ecma_promise_value_thunk_t *) function_obj_p;
|
||||
|
||||
return ecma_copy_value (value_thunk_obj_p->value);
|
||||
} /* ecma_value_thunk_helper_cb */
|
||||
@@ -923,15 +911,13 @@ ecma_value_thunk_helper_cb (const ecma_value_t function_obj, /**< the function i
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_value_thunk_thrower_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_value_thunk_thrower_cb (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED_3 (this_val, args_p, args_count);
|
||||
JERRY_UNUSED_2 (args_p, args_count);
|
||||
|
||||
ecma_object_t *func_obj_p = ecma_get_object_from_value (function_obj);
|
||||
ecma_promise_value_thunk_t *value_thunk_obj_p = (ecma_promise_value_thunk_t *) func_obj_p;
|
||||
ecma_promise_value_thunk_t *value_thunk_obj_p = (ecma_promise_value_thunk_t *) function_obj_p;
|
||||
|
||||
jcontext_raise_exception (ecma_copy_value (value_thunk_obj_p->value));
|
||||
|
||||
@@ -948,13 +934,12 @@ ecma_value_thunk_thrower_cb (const ecma_value_t function_obj, /**< the function
|
||||
* @return ecma value
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_promise_then_catch_finally_helper (ecma_value_t function_obj, /**< the function itself */
|
||||
ecma_promise_then_catch_finally_helper (ecma_object_t *function_obj_p, /**< function object */
|
||||
ecma_native_handler_id_t id, /**< handler id */
|
||||
ecma_value_t arg) /**< callback function argument */
|
||||
{
|
||||
/* 2. */
|
||||
ecma_object_t *func_obj_p = ecma_get_object_from_value (function_obj);
|
||||
ecma_promise_finally_function_t *finally_func_obj = (ecma_promise_finally_function_t *) func_obj_p;
|
||||
ecma_promise_finally_function_t *finally_func_obj = (ecma_promise_finally_function_t *) function_obj_p;
|
||||
|
||||
/* 3. */
|
||||
JERRY_ASSERT (ecma_op_is_callable (finally_func_obj->on_finally));
|
||||
@@ -1009,15 +994,14 @@ ecma_promise_then_catch_finally_helper (ecma_value_t function_obj, /**< the fun
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_promise_then_finally_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_promise_then_finally_cb (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED_2 (this_val, args_count);
|
||||
JERRY_UNUSED (args_count);
|
||||
JERRY_ASSERT (args_count > 0);
|
||||
|
||||
return ecma_promise_then_catch_finally_helper (function_obj, ECMA_NATIVE_HANDLER_VALUE_THUNK, args_p[0]);
|
||||
return ecma_promise_then_catch_finally_helper (function_obj_p, ECMA_NATIVE_HANDLER_VALUE_THUNK, args_p[0]);
|
||||
} /* ecma_promise_then_finally_cb */
|
||||
|
||||
/**
|
||||
@@ -1029,15 +1013,14 @@ ecma_promise_then_finally_cb (const ecma_value_t function_obj, /**< the function
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_promise_catch_finally_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_promise_catch_finally_cb (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED_2 (this_val, args_count);
|
||||
JERRY_UNUSED (args_count);
|
||||
JERRY_ASSERT (args_count > 0);
|
||||
|
||||
return ecma_promise_then_catch_finally_helper (function_obj, ECMA_NATIVE_HANDLER_VALUE_THROWER, args_p[0]);
|
||||
return ecma_promise_then_catch_finally_helper (function_obj_p, ECMA_NATIVE_HANDLER_VALUE_THROWER, args_p[0]);
|
||||
} /* ecma_promise_catch_finally_cb */
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,32 +112,23 @@ void ecma_fulfill_promise (ecma_value_t promise, ecma_value_t value);
|
||||
ecma_object_t *ecma_promise_new_capability (ecma_value_t constructor);
|
||||
ecma_value_t ecma_promise_reject_or_resolve (ecma_value_t this_arg, ecma_value_t value, bool is_resolve);
|
||||
ecma_value_t ecma_promise_then (ecma_value_t promise, ecma_value_t on_fulfilled, ecma_value_t on_rejected);
|
||||
ecma_value_t ecma_value_thunk_helper_cb (const ecma_value_t function_obj,
|
||||
const ecma_value_t this_val,
|
||||
const ecma_value_t args_p[],
|
||||
const uint32_t args_count);
|
||||
ecma_value_t ecma_value_thunk_thrower_cb (const ecma_value_t function_obj,
|
||||
const ecma_value_t this_val,
|
||||
const ecma_value_t args_p[],
|
||||
const uint32_t args_count);
|
||||
ecma_value_t ecma_promise_then_finally_cb (const ecma_value_t function_obj,
|
||||
const ecma_value_t this_val,
|
||||
const ecma_value_t args_p[],
|
||||
const uint32_t args_count);
|
||||
ecma_value_t ecma_promise_catch_finally_cb (const ecma_value_t function_obj,
|
||||
const ecma_value_t this_val,
|
||||
const ecma_value_t args_p[],
|
||||
const uint32_t args_count);
|
||||
ecma_value_t
|
||||
ecma_promise_reject_handler (const ecma_value_t function,
|
||||
const ecma_value_t this_arg,
|
||||
const ecma_value_t argv[],
|
||||
const uint32_t argc);
|
||||
ecma_value_t
|
||||
ecma_promise_resolve_handler (const ecma_value_t function,
|
||||
const ecma_value_t this_arg,
|
||||
const ecma_value_t argv[],
|
||||
const uint32_t argc);
|
||||
|
||||
ecma_value_t ecma_value_thunk_helper_cb (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t args_p[], const uint32_t args_count);
|
||||
ecma_value_t ecma_value_thunk_thrower_cb (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t args_p[], const uint32_t args_count);
|
||||
ecma_value_t ecma_promise_then_finally_cb (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t args_p[], const uint32_t args_count);
|
||||
ecma_value_t ecma_promise_catch_finally_cb (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t args_p[], const uint32_t args_count);
|
||||
ecma_value_t ecma_promise_reject_handler (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t argv[], const uint32_t args_count);
|
||||
ecma_value_t ecma_promise_resolve_handler (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t argv[], const uint32_t args_count);
|
||||
ecma_value_t ecma_promise_all_handler_cb (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t args_p[], const uint32_t args_count);
|
||||
ecma_value_t ecma_op_get_capabilities_executor_cb (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t args_p[], const uint32_t args_count);
|
||||
|
||||
ecma_value_t ecma_promise_finally (ecma_value_t promise, ecma_value_t on_finally);
|
||||
void ecma_promise_async_then (ecma_value_t promise, ecma_value_t executable_object);
|
||||
@@ -145,11 +136,6 @@ ecma_value_t ecma_promise_async_await (ecma_extended_object_t *async_generator_o
|
||||
void ecma_promise_create_resolving_functions (ecma_promise_object_t *object_p);
|
||||
|
||||
uint32_t ecma_promise_remaining_inc_or_dec (ecma_value_t remaining, bool is_inc);
|
||||
ecma_value_t ecma_promise_all_handler_cb (const ecma_value_t function_obj, const ecma_value_t this_val,
|
||||
const ecma_value_t args_p[], const uint32_t args_count);
|
||||
|
||||
ecma_value_t ecma_op_get_capabilities_executor_cb (const ecma_value_t function_obj, const ecma_value_t this_val,
|
||||
const ecma_value_t args_p[], const uint32_t args_count);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -104,17 +104,14 @@ ecma_proxy_create (ecma_value_t target, /**< proxy target */
|
||||
* @return ECMA_VALUE_UNDEFINED
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_proxy_revoke_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_proxy_revoke_cb (ecma_object_t *function_obj_p, /**< function object */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED_3 (this_val, args_p, args_count);
|
||||
|
||||
ecma_object_t *func_obj_p = ecma_get_object_from_value (function_obj);
|
||||
JERRY_UNUSED_2 (args_p, args_count);
|
||||
|
||||
/* 1. */
|
||||
ecma_revocable_proxy_object_t *rev_proxy_p = (ecma_revocable_proxy_object_t *) func_obj_p;
|
||||
ecma_revocable_proxy_object_t *rev_proxy_p = (ecma_revocable_proxy_object_t *) function_obj_p;
|
||||
|
||||
/* 2. */
|
||||
if (ecma_is_value_null (rev_proxy_p->proxy))
|
||||
|
||||
@@ -37,8 +37,7 @@ ecma_proxy_create_revocable (ecma_value_t target,
|
||||
ecma_value_t handler);
|
||||
|
||||
ecma_value_t
|
||||
ecma_proxy_revoke_cb (const ecma_value_t function_obj,
|
||||
const ecma_value_t this_val,
|
||||
ecma_proxy_revoke_cb (ecma_object_t *function_obj_p,
|
||||
const ecma_value_t args_p[],
|
||||
const uint32_t args_count);
|
||||
|
||||
|
||||
@@ -34,12 +34,12 @@ extern "C"
|
||||
/**
|
||||
* Major version of JerryScript API.
|
||||
*/
|
||||
#define JERRY_API_MAJOR_VERSION 2
|
||||
#define JERRY_API_MAJOR_VERSION 3
|
||||
|
||||
/**
|
||||
* Minor version of JerryScript API.
|
||||
*/
|
||||
#define JERRY_API_MINOR_VERSION 4
|
||||
#define JERRY_API_MINOR_VERSION 0
|
||||
|
||||
/**
|
||||
* Patch version of JerryScript API.
|
||||
@@ -247,11 +247,20 @@ typedef struct
|
||||
size_t reserved[4]; /**< padding for future extensions */
|
||||
} jerry_heap_stats_t;
|
||||
|
||||
/**
|
||||
* Call related information passed to jerry_external_handler_t.
|
||||
*/
|
||||
typedef struct jerry_call_info_t
|
||||
{
|
||||
jerry_value_t function; /**< invoked function object */
|
||||
jerry_value_t this_value; /**< this value passed to the function */
|
||||
jerry_value_t new_target; /**< current new target value, undefined for non-constructor calls */
|
||||
} jerry_call_info_t;
|
||||
|
||||
/**
|
||||
* Type of an external function handler.
|
||||
*/
|
||||
typedef jerry_value_t (*jerry_external_handler_t) (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_val,
|
||||
typedef jerry_value_t (*jerry_external_handler_t) (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_count);
|
||||
|
||||
@@ -814,7 +823,6 @@ bool jerry_backtrace_is_strict (jerry_backtrace_frame_t *frame_p);
|
||||
*/
|
||||
void jerry_set_vm_exec_stop_callback (jerry_vm_exec_stop_callback_t stop_cb, void *user_p, uint32_t frequency);
|
||||
jerry_value_t jerry_get_resource_name (const jerry_value_t value);
|
||||
jerry_value_t jerry_get_new_target (void);
|
||||
|
||||
/**
|
||||
* Array buffer components.
|
||||
|
||||
@@ -1059,8 +1059,7 @@ opfunc_add_computed_field (ecma_value_t class_object, /**< class object */
|
||||
* ECMA_VALUE_UNDEFINED - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_op_implicit_constructor_handler_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_op_implicit_constructor_handler_cb (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
@@ -1071,7 +1070,7 @@ ecma_op_implicit_constructor_handler_cb (const ecma_value_t function_obj, /**< t
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Class constructor cannot be invoked without 'new'"));
|
||||
}
|
||||
|
||||
return opfunc_init_class_fields (function_obj, this_val);
|
||||
return opfunc_init_class_fields (call_info_p->function, call_info_p->this_value);
|
||||
} /* ecma_op_implicit_constructor_handler_cb */
|
||||
|
||||
/**
|
||||
@@ -1083,19 +1082,16 @@ ecma_op_implicit_constructor_handler_cb (const ecma_value_t function_obj, /**< t
|
||||
* result of the super call - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_op_implicit_constructor_handler_heritage_cb (const ecma_value_t function_obj, /**< the function itself */
|
||||
const ecma_value_t this_val, /**< this_arg of the function */
|
||||
ecma_op_implicit_constructor_handler_heritage_cb (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const ecma_value_t args_p[], /**< argument list */
|
||||
const uint32_t args_count) /**< argument number */
|
||||
{
|
||||
JERRY_UNUSED (this_val);
|
||||
|
||||
if (JERRY_CONTEXT (current_new_target_p) == NULL)
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Class constructor cannot be invoked without 'new'"));
|
||||
}
|
||||
|
||||
ecma_object_t *func_obj_p = ecma_get_object_from_value (function_obj);
|
||||
ecma_object_t *func_obj_p = ecma_get_object_from_value (call_info_p->function);
|
||||
ecma_value_t super_ctor = ecma_op_function_get_super_constructor (func_obj_p);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (super_ctor))
|
||||
@@ -1112,7 +1108,7 @@ ecma_op_implicit_constructor_handler_heritage_cb (const ecma_value_t function_ob
|
||||
|
||||
if (ecma_is_value_object (result))
|
||||
{
|
||||
ecma_value_t fields_value = opfunc_init_class_fields (function_obj, result);
|
||||
ecma_value_t fields_value = opfunc_init_class_fields (call_info_p->function, result);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (fields_value))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user