Rework usages/naming of configuration macros [part 1] (#2793)

There are quite a few configuration macros in the project.
As discussed in the #2520 issue there are a few awkward constructs.

Main changes:

* Renamed all CONFIG_DISABLE_<name>_BUILTIN macro to JERRY_BUILTIN_<name> format.
* The special JERRY_BUILTINS macro specifies the basic config for all es5.1 builtins.
* Renamed all CONFIG_DISABLE_ES2015_<name> to JERRY_ES2015_<name> format.
* The special JERRY_ES2015 macro specifies the basic config for all es2015 builtins.
* Renamed UNICODE_CASE_CONVERSION to JERRY_UNICODE_CASE_CONVERSION.
* Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE.
* All options (in this change) can have a value of 0 or 1.
* Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE.
  JERRY_REGEXP_STRICT_MODE is set to 0 by default.
* Reworked CONFIG_ECMA_NUMBER_TYPE macro to JERRY_NUMBER_TYPE_FLOAT64 name and now
  it uses the value 1 for 64 bit floating point numbers and 0 for 32 bit floating point
  number.
  By default the 64-bit floating point number mode is enabled.
* All new JERRY_ defines can be used wit the `#if ENABLED (JERRY_...)` construct to
  test if the feature is enabled or not.
* Added/replaced a few config.h includes to correctly propagate the macro values.
* Added sanity checks for each macro to avoid incorrectly set values.
* Updated profile documentation.
* The CMake feature names are not updated at this point.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
Péter Gál
2019-04-09 10:14:46 +02:00
committed by Robert Fancsik
parent 722d092528
commit 40f7b1c27f
213 changed files with 1902 additions and 1649 deletions
+56 -56
View File
@@ -26,10 +26,10 @@
JERRY_STATIC_ASSERT ((int) ECMA_PARSE_STRICT_MODE == (int) PARSER_IS_STRICT,
ecma_parse_strict_mode_must_be_equal_to_parser_is_strict);
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
JERRY_STATIC_ASSERT ((ECMA_PARSE_CLASS_CONSTRUCTOR << PARSER_CLASS_PARSE_OPTS_OFFSET) == PARSER_CLASS_CONSTRUCTOR,
ecma_class_parse_options_must_be_able_to_be_shifted_to_ecma_general_flags);
#endif /* !CONFIG_DISABLE_ES2015 */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
/** \addtogroup parser Parser
* @{
@@ -602,18 +602,18 @@ parser_generate_initializers (parser_context_t *context_p, /**< context */
}
}
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
JERRY_ASSERT ((argument_count - 1) == context_p->argument_count);
}
else
{
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
JERRY_ASSERT (argument_count == context_p->argument_count);
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
}
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
}
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
@@ -712,13 +712,13 @@ parser_generate_initializers (parser_context_t *context_p, /**< context */
}
}
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
JERRY_ASSERT ((argument_count - 1) == context_p->argument_count);
return dst_p;
}
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
JERRY_ASSERT (argument_count == context_p->argument_count);
return dst_p;
@@ -994,12 +994,12 @@ parse_print_literal (ecma_compiled_code_t *compiled_code_p, /**< compiled code *
const_literal_end = args_p->const_literal_end;
}
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_REST_PARAMETER)
{
argument_end++;
}
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
parser_list_iterator_init (literal_pool_p, &literal_iterator);
@@ -1214,19 +1214,19 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
JERRY_DEBUG_MSG (",no_lexical_env");
}
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION)
{
JERRY_DEBUG_MSG (",arrow");
}
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_CONSTRUCTOR)
{
JERRY_DEBUG_MSG (",constructor");
}
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
JERRY_DEBUG_MSG ("]\n");
@@ -1564,12 +1564,12 @@ parser_post_processing (parser_context_t *context_p) /**< context */
PARSER_NEXT_BYTE (page_p, offset);
length++;
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
if (ext_opcode == CBC_EXT_CONSTRUCTOR_RETURN)
{
last_opcode = CBC_RETURN;
}
#endif /* !CONFIG_DISABLE_ES2015 */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
#ifdef JERRY_ENABLE_LINE_INFO
if (ext_opcode == CBC_EXT_LINE)
@@ -1769,13 +1769,13 @@ parser_post_processing (parser_context_t *context_p) /**< context */
compiled_code_p->refs = 1;
compiled_code_p->status_flags = CBC_CODE_FLAGS_FUNCTION;
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
JERRY_ASSERT (context_p->argument_count > 0);
context_p->argument_count--;
}
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
if (needs_uint16_arguments)
{
@@ -1828,26 +1828,26 @@ parser_post_processing (parser_context_t *context_p) /**< context */
compiled_code_p->status_flags |= CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED;
}
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
if (context_p->status_flags & PARSER_IS_ARROW_FUNCTION)
{
compiled_code_p->status_flags |= CBC_CODE_FLAGS_ARROW_FUNCTION;
}
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
if (context_p->status_flags & PARSER_CLASS_CONSTRUCTOR)
{
compiled_code_p->status_flags |= CBC_CODE_FLAGS_CONSTRUCTOR;
}
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
compiled_code_p->status_flags |= CBC_CODE_FLAGS_REST_PARAMETER;
}
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
literal_pool_p = (ecma_value_t *) byte_code_p;
literal_pool_p -= context_p->register_count;
@@ -2188,10 +2188,10 @@ static void
parser_parse_function_arguments (parser_context_t *context_p, /**< context */
lexer_token_type_t end_type) /**< expected end type */
{
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
bool duplicated_argument_names = false;
bool initializer_found = false;
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
if (context_p->token.type == end_type)
{
@@ -2202,7 +2202,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
{
uint16_t literal_count = context_p->literal_count;
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
parser_raise_error (context_p, PARSER_ERR_FORMAL_PARAM_AFTER_REST_PARAMETER);
@@ -2218,7 +2218,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
context_p->status_flags |= PARSER_FUNCTION_HAS_REST_PARAM;
}
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
if (context_p->token.type != LEXER_LITERAL
|| context_p->token.lit_location.type != LEXER_IDENT_LITERAL)
@@ -2252,13 +2252,13 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
{
lexer_literal_t *literal_p;
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
if (initializer_found)
{
parser_raise_error (context_p, PARSER_ERR_DUPLICATED_ARGUMENT_NAMES);
}
duplicated_argument_names = true;
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
if (context_p->literal_count >= PARSER_MAXIMUM_NUMBER_OF_LITERALS)
{
@@ -2296,15 +2296,15 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
lexer_next_token (context_p);
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER
#if ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER)
if (context_p->token.type == LEXER_ASSIGN)
{
#ifndef CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
{
parser_raise_error (context_p, PARSER_ERR_REST_PARAMETER_DEFAULT_INITIALIZER);
}
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_REST_PARAMETER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
parser_branch_t skip_init;
@@ -2324,7 +2324,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
parser_set_branch_to_current_position (context_p, &skip_init);
}
#endif /* !CONFIG_DISABLE_ES2015_FUNCTION_PARAMETER_INITIALIZER */
#endif /* ENABLED (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
if (context_p->token.type != LEXER_COMMA)
{
@@ -2398,13 +2398,13 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
context.last_statement.current_p = NULL;
context.status_flags |= parse_opts & PARSER_STRICT_MODE_MASK;
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
context.module_context_p = NULL;
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
context.status_flags |= PARSER_GET_CLASS_PARSER_OPTS (parse_opts);
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
context.token.flags = 0;
context.line = 1;
@@ -2479,13 +2479,13 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
JERRY_ASSERT (context.last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
JERRY_ASSERT (context.allocated_buffer_p == NULL);
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
if (context.module_context_p != NULL)
{
parser_module_handle_requests (&context);
ecma_module_load_modules (&context);
}
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
compiled_code_p = parser_post_processing (&context);
parser_list_free (&context.literal_pool);
@@ -2535,9 +2535,9 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
}
#endif /* PARSER_DUMP_BYTE_CODE */
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
parser_module_context_cleanup (&context);
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
parser_stack_free (&context);
return compiled_code_p;
@@ -2653,13 +2653,13 @@ parser_parse_function (parser_context_t *context_p, /**< context */
#ifdef PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes)
{
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
JERRY_DEBUG_MSG ("\n--- %s parsing start ---\n\n",
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor"
: "Function");
#else /* CONFIG_DISABLE_ES2015_CLASS */
#else /* !ENABLED (JERRY_ES2015_CLASS) */
JERRY_DEBUG_MSG ("\n--- Function parsing start ---\n\n");
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
}
#endif /* PARSER_DUMP_BYTE_CODE */
@@ -2712,25 +2712,25 @@ parser_parse_function (parser_context_t *context_p, /**< context */
lexer_next_token (context_p);
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
if ((context_p->status_flags & PARSER_CLASS_CONSTRUCTOR_SUPER) == PARSER_CLASS_CONSTRUCTOR_SUPER)
{
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
}
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
parser_parse_statements (context_p);
compiled_code_p = parser_post_processing (context_p);
#ifdef PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes)
{
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
JERRY_DEBUG_MSG ("\n--- %s parsing end ---\n\n",
(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR) ? "Class constructor"
: "Function");
#else /* CONFIG_DISABLE_ES2015_CLASS */
#else /* !ENABLED (JERRY_ES2015_CLASS) */
JERRY_DEBUG_MSG ("\n--- Function parsing end ---\n\n");
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
}
#endif /* PARSER_DUMP_BYTE_CODE */
@@ -2739,7 +2739,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
return compiled_code_p;
} /* parser_parse_function */
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
/**
* Parse arrow function code
@@ -2757,9 +2757,9 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
&& (status_flags & PARSER_IS_ARROW_FUNCTION));
parser_save_context (context_p, &saved_context);
context_p->status_flags |= status_flags | PARSER_ARGUMENTS_NOT_NEEDED;
#ifndef CONFIG_DISABLE_ES2015_CLASS
#if ENABLED (JERRY_ES2015_CLASS)
context_p->status_flags |= saved_context.status_flags & PARSER_CLASS_HAS_SUPER;
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
#endif /* ENABLED (JERRY_ES2015_CLASS) */
#ifdef PARSER_DUMP_BYTE_CODE
if (context_p->is_show_opcodes)
@@ -2857,7 +2857,7 @@ parser_parse_arrow_function (parser_context_t *context_p, /**< context */
return compiled_code_p;
} /* parser_parse_arrow_function */
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
/**
* Raise a parse error
@@ -2866,12 +2866,12 @@ void
parser_raise_error (parser_context_t *context_p, /**< context */
parser_error_t error) /**< error code */
{
#ifndef CONFIG_DISABLE_ES2015_MODULE_SYSTEM
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
if (context_p->module_context_p != NULL)
{
parser_module_free_saved_names (context_p->module_current_node_p);
}
#endif /* !CONFIG_DISABLE_ES2015_MODULE_SYSTEM */
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
parser_saved_context_t *saved_context_p = context_p->last_context_p;