Add custom dispatcher to builtin_weakref_prototype. (#4686)

JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
This commit is contained in:
Virag Orkenyi 2021-06-24 15:36:47 +02:00 committed by GitHub
parent dddd37d38f
commit d97d407eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

View File

@ -21,6 +21,20 @@
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_BUILTIN_WEAKREF_PROTOTYPE_OBJECT_ROUTINE_START = 0,
ECMA_BUILTIN_WEAKREF_PROTOTYPE_OBJECT_DEREF
};
/**
* This object has a custom dispatch function.
*/
@ -63,6 +77,35 @@ ecma_builtin_weakref_prototype_object_deref (ecma_value_t this_arg) /**< this ar
return ecma_copy_value (this_ext_obj->u.cls.u3.target);
} /* ecma_builtin_weakref_prototype_object_deref */
/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_weakref_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in routine identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**< list of arguments
* passed to routine */
uint32_t arguments_number) /**< length of arguments' list */
{
JERRY_UNUSED (arguments_list_p);
JERRY_UNUSED (arguments_number);
switch (builtin_routine_id)
{
case ECMA_BUILTIN_WEAKREF_PROTOTYPE_OBJECT_DEREF:
{
return ecma_builtin_weakref_prototype_object_deref (this_arg);
}
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_weakref_prototype_dispatch_routine */
/**
* @}
* @}

View File

@ -34,7 +34,7 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_DEREF, ecma_builtin_weakref_prototype_object_deref, 0, 0)
ROUTINE (LIT_MAGIC_STRING_DEREF, ECMA_BUILTIN_WEAKREF_PROTOTYPE_OBJECT_DEREF, 0, 0)
#endif /* JERRY_BUILTIN_WEAKREF */