From 6296a8251c6116ad7d4ed0c9d7296093b13dc6c7 Mon Sep 17 00:00:00 2001 From: Virag Orkenyi Date: Tue, 20 Jul 2021 11:29:10 +0200 Subject: [PATCH] Add custom dispatcher to builtin-iterator-prototype (#4716) JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu --- .../ecma-builtin-iterator-prototype.c | 44 +++++++++++++++++++ .../ecma-builtin-iterator-prototype.inc.h | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.c index 59294883e..b09f9a0f3 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.c @@ -22,6 +22,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_ITERATOR_PROTOTYPE_ROUTINE_START = 0, + ECMA_BUILTIN_ITERATOR_PROTOTYPE_OBJECT_ITERATOR, +}; + #define BUILTIN_INC_HEADER_NAME "ecma-builtin-iterator-prototype.inc.h" #define BUILTIN_UNDERSCORED_ID iterator_prototype #include "ecma-builtin-internal-routines-template.inc.h" @@ -54,6 +68,36 @@ ecma_builtin_iterator_prototype_object_iterator (ecma_value_t this_val) /**< thi return ecma_copy_value (this_val); } /* ecma_builtin_iterator_prototype_object_iterator */ +/** + * Dispatcher of the built-in's routines + * + * @return ecma value + * Returned value must be freed with ecma_free_value. + */ +ecma_value_t +ecma_builtin_iterator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide + * 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_ITERATOR_PROTOTYPE_OBJECT_ITERATOR: + { + return ecma_builtin_iterator_prototype_object_iterator (this_arg); + } + default: + { + JERRY_UNREACHABLE (); + } + } +} /* ecma_builtin_iterator_prototype_dispatch_routine */ /** * @} * @} diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.inc.h b/jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.inc.h index 99bb0c31a..4719360a6 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.inc.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-iterator-prototype.inc.h @@ -23,7 +23,7 @@ /* Routine properties: * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ -ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ecma_builtin_iterator_prototype_object_iterator, 0, 0) +ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ECMA_BUILTIN_ITERATOR_PROTOTYPE_OBJECT_ITERATOR, 0, 0) #endif /* JERRY_ESNEXT */