Skip to content

Commit

Permalink
Add custom dispatcher to every builtin object for consistency
Browse files Browse the repository at this point in the history
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag [email protected]
  • Loading branch information
orkvi committed Dec 3, 2021
1 parent 3737a28 commit 5a4bf13
Show file tree
Hide file tree
Showing 112 changed files with 1,537 additions and 400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,27 @@
#define BUILTIN_UNDERSCORED_ID aggregate_error_prototype
#include "ecma-builtin-internal-routines-template.inc.h"

/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_aggregate_error_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 (this_arg);
JERRY_UNUSED (arguments_number);
JERRY_UNUSED (arguments_list_p);
JERRY_UNUSED (builtin_routine_id);

JERRY_UNREACHABLE ();
} /* ecma_builtin_aggregate_error_prototype_dispatch_routine */

#endif /* JERRY_ESNEXT */
21 changes: 21 additions & 0 deletions jerry-core/ecma/builtin-objects/ecma-builtin-aggregateerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ ecma_builtin_aggregate_error_dispatch_construct (const ecma_value_t *arguments_l
return result;
} /* ecma_builtin_aggregate_error_dispatch_construct */

/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_aggregate_error_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 (this_arg);
JERRY_UNUSED (arguments_number);
JERRY_UNUSED (arguments_list_p);
JERRY_UNUSED (builtin_routine_id);

JERRY_UNREACHABLE ();
} /* ecma_builtin_aggregate_error_dispatch_routine */

/**
* @}
* @}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
#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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,27 @@
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
#include "ecma-builtin-internal-routines-template.inc.h"

/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_array_prototype_unscopables_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 (this_arg);
JERRY_UNUSED (arguments_number);
JERRY_UNUSED (arguments_list_p);
JERRY_UNUSED (builtin_routine_id);

JERRY_UNREACHABLE ();
} /* ecma_builtin_array_prototype_unscopables_dispatch_routine */

#endif /* JERRY_ESNEXT */
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
#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.
*/
Expand Down
5 changes: 0 additions & 5 deletions jerry-core/ecma/builtin-objects/ecma-builtin-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
#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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"

/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_ARRAYBUFFER_PROTOTYPE_ROUTINE_START = 0,
ECMA_ARRAYBUFFER_PROTOTYPE_SLICE,
ECMA_ARRAYBUFFER_PROTOTYPE_BYTELENGTH_GETTER,
};

#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
Expand Down Expand Up @@ -107,6 +117,38 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
return ecma_builtin_arraybuffer_slice (this_arg, argument_list_p, arguments_number);
} /* ecma_builtin_arraybuffer_prototype_object_slice */

/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_arraybuffer_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 */
{
switch (builtin_routine_id)
{
case ECMA_ARRAYBUFFER_PROTOTYPE_SLICE:
{
return ecma_builtin_arraybuffer_prototype_object_slice (this_arg, arguments_list_p, arguments_number);
}
case ECMA_ARRAYBUFFER_PROTOTYPE_BYTELENGTH_GETTER:
{
return ecma_builtin_arraybuffer_prototype_bytelength_getter (this_arg);
}
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_arraybuffer_prototype_dispatch_routine */

/**
* @}
* @}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAYBUFFER, ECMA_PR

/* Readonly accessor properties */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
ecma_builtin_arraybuffer_prototype_bytelength_getter,
ECMA_ARRAYBUFFER_PROTOTYPE_BYTELENGTH_GETTER,
ECMA_PROPERTY_FLAG_CONFIGURABLE)

/* ECMA-262 v6, 24.1.4.4 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)

/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_SLICE, ecma_builtin_arraybuffer_prototype_object_slice, NON_FIXED, 2)
ROUTINE (LIT_MAGIC_STRING_SLICE, ECMA_ARRAYBUFFER_PROTOTYPE_SLICE, NON_FIXED, 2)

#endif /* JERRY_BUILTIN_TYPEDARRAY */

Expand Down
42 changes: 36 additions & 6 deletions jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"

/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_ARRAYBUFFER_ROUTINE_START = 0,
ECMA_ARRAYBUFFER_OBJECT_IS_VIEW,
ECMA_ARRAYBUFFER_SPECIES_GET,
};

#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer.inc.h"
#define BUILTIN_UNDERSCORED_ID arraybuffer
#include "ecma-builtin-internal-routines-template.inc.h"
Expand Down Expand Up @@ -94,16 +104,36 @@ ecma_builtin_arraybuffer_dispatch_construct (const ecma_value_t *arguments_list_
} /* ecma_builtin_arraybuffer_dispatch_construct */

/**
* 24.1.3.3 get ArrayBuffer [ @@species ] accessor
* Dispatcher of the built-in's routines
*
* @return ecma_value
* returned value must be freed with ecma_free_value
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_arraybuffer_species_get (ecma_value_t this_value) /**< This Value */
ecma_builtin_arraybuffer_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 */
{
return ecma_copy_value (this_value);
} /* ecma_builtin_arraybuffer_species_get */
JERRY_UNUSED (arguments_number);

switch (builtin_routine_id)
{
case ECMA_ARRAYBUFFER_OBJECT_IS_VIEW:
{
return ecma_builtin_arraybuffer_object_is_view (this_arg, arguments_list_p[0]);
}
case ECMA_ARRAYBUFFER_SPECIES_GET:
{
return ecma_copy_value (this_arg);
}
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_arraybuffer_dispatch_routine */

/**
* @}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROP
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */

/* ES2015 24.1.3.1 */
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ECMA_ARRAYBUFFER_OBJECT_IS_VIEW, 1, 1)

/* ES2015 24.1.3.3 */
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ecma_builtin_arraybuffer_species_get, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ECMA_ARRAYBUFFER_SPECIES_GET, ECMA_PROPERTY_FLAG_CONFIGURABLE)

#endif /* JERRY_BUILTIN_TYPEDARRAY */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@
* @{
*/

/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_async_function_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 (this_arg);
JERRY_UNUSED (arguments_number);
JERRY_UNUSED (arguments_list_p);
JERRY_UNUSED (builtin_routine_id);

JERRY_UNREACHABLE ();
} /* ecma_builtin_async_function_prototype_dispatch_routine */

/**
* @}
* @}
Expand Down
21 changes: 21 additions & 0 deletions jerry-core/ecma/builtin-objects/ecma-builtin-async-function.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ ecma_builtin_async_function_dispatch_construct (const ecma_value_t *arguments_li
return ecma_builtin_async_function_dispatch_call (arguments_list_p, arguments_list_len);
} /* ecma_builtin_async_function_dispatch_construct */

/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_async_function_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 (this_arg);
JERRY_UNUSED (arguments_number);
JERRY_UNUSED (arguments_list_p);
JERRY_UNUSED (builtin_routine_id);

JERRY_UNREACHABLE ();
} /* ecma_builtin_async_function_dispatch_routine */

/**
* @}
* @}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ ecma_builtin_async_generator_function_dispatch_construct (const ecma_value_t *ar
return ecma_builtin_async_generator_function_dispatch_call (arguments_list_p, arguments_list_len);
} /* ecma_builtin_async_generator_function_dispatch_construct */

/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_async_generator_function_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 (this_arg);
JERRY_UNUSED (arguments_number);
JERRY_UNUSED (arguments_list_p);
JERRY_UNUSED (builtin_routine_id);

JERRY_UNREACHABLE ();
} /* ecma_builtin_async_generator_function_dispatch_routine */

/**
* @}
* @}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
#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.
*/
Expand Down
21 changes: 21 additions & 0 deletions jerry-core/ecma/builtin-objects/ecma-builtin-async-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@
* @{
*/

/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_async_generator_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 (this_arg);
JERRY_UNUSED (arguments_number);
JERRY_UNUSED (arguments_list_p);
JERRY_UNUSED (builtin_routine_id);

JERRY_UNREACHABLE ();
} /* ecma_builtin_async_generator_dispatch_routine */

/**
* @}
* @}
Expand Down
Loading

0 comments on commit 5a4bf13

Please sign in to comment.