mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Replace JERRY_JS_PARSER feature guard with JERRY_DISABLE_JS_PARSER (#2036)
* Replace JERRY_JS_PARSER feature guard with JERRY_DISABLE_JS_PARSER All feature guards of jerry-core are deciding about the inclusion or exclusion of a feature based on the state (defined or undefined) of a macro -- except for the JS parser guard, which requires `JERRY_JS_PARSER` to be defined with a value of either 0 or 1. This has some issues: - The engine cannot be built with a "clean" compiler invocation, i.e., without any `-D` command line macro definitions. This is painful for targets that must use a different build system from the project's own python/cmake-based one. - Some build systems in targets and even some code in jerry-code are already confused about the different semantics of `JERRY_JS_PARSER`, and simply define it without a value and make decisions based on the macro being simply defined or not. This patch renames the guard to `JERRY_DISABLE_JS_PARSER` and makes use of it in jerry-core based on its state, not based on its value. As obvious from the guard name, the default for the JS parser is that it is included in the build. The patch also touches those targets in the repository that explicitly defined the original macro (correctly or incorrectly). * Make cppcheck verbose Cppcheck can be quite slow sometimes, especially on Travis CI, which has a "10 mins without output means failure" rule. As the code base of the project grows, we start to undeterministically fall over that limit. Thus, this PR makes cppcheck verbose to ensure that it keeps Travis CI continuously fed with output. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
parent
fe26674752
commit
d0143adc82
@ -168,10 +168,8 @@ if(FEATURE_EXTERNAL_CONTEXT)
|
||||
endif()
|
||||
|
||||
# JS-Parser
|
||||
if(FEATURE_JS_PARSER)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_JS_PARSER=1)
|
||||
else()
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_JS_PARSER=0)
|
||||
if(NOT FEATURE_JS_PARSER)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_DISABLE_JS_PARSER)
|
||||
endif()
|
||||
|
||||
# Memory statistics
|
||||
|
||||
@ -55,11 +55,9 @@ JERRY_STATIC_ASSERT ((int) ECMA_INIT_EMPTY == (int) JERRY_INIT_EMPTY
|
||||
&& (int) ECMA_INIT_MEM_STATS == (int) JERRY_INIT_MEM_STATS,
|
||||
ecma_init_flag_t_must_be_equal_to_jerry_init_flag_t);
|
||||
|
||||
#ifndef JERRY_JS_PARSER
|
||||
#error JERRY_JS_PARSER must be defined with 0 (disabled) or 1 (enabled)
|
||||
#elif !JERRY_JS_PARSER && !defined (JERRY_ENABLE_SNAPSHOT_EXEC)
|
||||
#error JERRY_JS_PARSER or JERRY_ENABLE_SNAPSHOT_EXEC must be defined!
|
||||
#endif /* !JERRY_JS_PARSER */
|
||||
#if defined JERRY_DISABLE_JS_PARSER && !defined JERRY_ENABLE_SNAPSHOT_EXEC
|
||||
#error JERRY_ENABLE_SNAPSHOT_EXEC must be defined if JERRY_DISABLE_JS_PARSER is defined!
|
||||
#endif /* JERRY_DISABLE_JS_PARSER && !JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
|
||||
#ifdef JERRY_ENABLE_ERROR_MESSAGES
|
||||
|
||||
@ -342,7 +340,7 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
size_t source_size, /**< script source size */
|
||||
bool is_strict) /**< strict mode */
|
||||
{
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
jerry_assert_api_available ();
|
||||
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
@ -368,13 +366,13 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
ecma_bytecode_deref (bytecode_data_p);
|
||||
|
||||
return ecma_make_object_value (func_obj_p);
|
||||
#else /* !JERRY_JS_PARSER */
|
||||
#else /* JERRY_DISABLE_JS_PARSER */
|
||||
JERRY_UNUSED (source_p);
|
||||
JERRY_UNUSED (source_size);
|
||||
JERRY_UNUSED (is_strict);
|
||||
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("The parser has been disabled."));
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
} /* jerry_parse */
|
||||
|
||||
/**
|
||||
@ -393,7 +391,7 @@ jerry_parse_named_resource (const jerry_char_t *resource_name_p, /**< resource n
|
||||
size_t source_size, /**< script source size */
|
||||
bool is_strict) /**< strict mode */
|
||||
{
|
||||
#if defined JERRY_DEBUGGER && defined JERRY_JS_PARSER
|
||||
#if defined JERRY_DEBUGGER && !defined JERRY_DISABLE_JS_PARSER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_SOURCE_CODE_NAME,
|
||||
@ -401,10 +399,10 @@ jerry_parse_named_resource (const jerry_char_t *resource_name_p, /**< resource n
|
||||
resource_name_p,
|
||||
resource_name_length);
|
||||
}
|
||||
#else /* !(JERRY_DEBUGGER && JERRY_JS_PARSER) */
|
||||
#else /* !(JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER) */
|
||||
JERRY_UNUSED (resource_name_p);
|
||||
JERRY_UNUSED (resource_name_length);
|
||||
#endif /* JERRY_DEBUGGER && JERRY_JS_PARSER */
|
||||
#endif /* JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
return jerry_parse (source_p, source_size, is_strict);
|
||||
} /* jerry_parse_named_resource */
|
||||
@ -425,7 +423,7 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u
|
||||
size_t source_size, /**< script source size */
|
||||
bool is_strict) /**< strict mode */
|
||||
{
|
||||
#if defined JERRY_DEBUGGER && defined JERRY_JS_PARSER
|
||||
#if defined JERRY_DEBUGGER && !defined JERRY_DISABLE_JS_PARSER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_SOURCE_CODE_NAME,
|
||||
@ -433,12 +431,12 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u
|
||||
resource_name_p,
|
||||
resource_name_length);
|
||||
}
|
||||
#else /* !(JERRY_DEBUGGER && JERRY_JS_PARSER) */
|
||||
#else /* !(JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER) */
|
||||
JERRY_UNUSED (resource_name_p);
|
||||
JERRY_UNUSED (resource_name_length);
|
||||
#endif /* JERRY_DEBUGGER && JERRY_JS_PARSER */
|
||||
#endif /* JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
jerry_assert_api_available ();
|
||||
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
@ -470,7 +468,7 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u
|
||||
ecma_bytecode_deref (bytecode_data_p);
|
||||
|
||||
return ecma_make_object_value (func_obj_p);
|
||||
#else /* !JERRY_JS_PARSER */
|
||||
#else /* JERRY_DISABLE_JS_PARSER */
|
||||
JERRY_UNUSED (arg_list_p);
|
||||
JERRY_UNUSED (arg_list_size);
|
||||
JERRY_UNUSED (source_p);
|
||||
@ -478,7 +476,7 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u
|
||||
JERRY_UNUSED (is_strict);
|
||||
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("The parser has been disabled."));
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
} /* jerry_parse_function */
|
||||
|
||||
/**
|
||||
@ -745,9 +743,9 @@ bool jerry_is_feature_enabled (const jerry_feature_t feature)
|
||||
#ifdef JERRY_ENABLE_ERROR_MESSAGES
|
||||
|| feature == JERRY_FEATURE_ERROR_MESSAGES
|
||||
#endif /* JERRY_ENABLE_ERROR_MESSAGES */
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|| feature == JERRY_FEATURE_JS_PARSER
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
#ifdef JMEM_STATS
|
||||
|| feature == JERRY_FEATURE_MEM_STATS
|
||||
#endif /* JMEM_STATS */
|
||||
|
||||
@ -81,7 +81,7 @@ ecma_op_eval_chars_buffer (const lit_utf8_byte_t *code_p, /**< code characters b
|
||||
bool is_direct, /**< is eval called directly (ECMA-262 v5, 15.1.2.1.1) */
|
||||
bool is_called_from_strict_mode_code) /**< is eval is called from strict mode code */
|
||||
{
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
JERRY_ASSERT (code_p != NULL);
|
||||
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
@ -101,14 +101,14 @@ ecma_op_eval_chars_buffer (const lit_utf8_byte_t *code_p, /**< code characters b
|
||||
}
|
||||
|
||||
return vm_run_eval (bytecode_data_p, is_direct);
|
||||
#else /* !JERRY_JS_PARSER */
|
||||
#else /* JERRY_DISABLE_JS_PARSER */
|
||||
JERRY_UNUSED (code_p);
|
||||
JERRY_UNUSED (code_buffer_size);
|
||||
JERRY_UNUSED (is_direct);
|
||||
JERRY_UNUSED (is_called_from_strict_mode_code);
|
||||
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("The parser has been disabled."));
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
} /* ecma_op_eval_chars_buffer */
|
||||
|
||||
/**
|
||||
|
||||
@ -21,7 +21,7 @@ JERRY_STATIC_ASSERT ((sizeof (cbc_uint8_arguments_t) % sizeof (jmem_cpointer_t))
|
||||
JERRY_STATIC_ASSERT ((sizeof (cbc_uint16_arguments_t) % sizeof (jmem_cpointer_t)) == 0,
|
||||
sizeof_cbc_uint16_arguments_t_must_be_divisible_by_sizeof_jmem_cpointer_t);
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@ -84,4 +84,4 @@ const char * const cbc_ext_names[] =
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include "common.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@ -136,4 +136,4 @@ util_print_literal (lexer_literal_t *literal_p) /**< literal */
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "js-parser-internal.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@ -2355,4 +2355,4 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< co
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "lit-char-helpers.h"
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@ -1774,4 +1774,4 @@ parser_parse_expression (parser_context_t *context_p, /**< context */
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
#include "js-parser-internal.h"
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
/** \addtogroup mem Memory allocation
|
||||
* @{
|
||||
@ -678,4 +678,4 @@ parser_stack_iterator_write (parser_stack_iterator_t *iterator, /**< iterator */
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "lit-char-helpers.h"
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@ -771,4 +771,4 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
#include "js-parser-internal.h"
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
#ifdef JERRY_DEBUGGER
|
||||
#include "jcontext.h"
|
||||
@ -2245,4 +2245,4 @@ parser_free_jumps (parser_stack_iterator_t iterator) /**< iterator position */
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
#include "js-parser-internal.h"
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@ -953,4 +953,4 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#include "jcontext.h"
|
||||
#include "js-parser-internal.h"
|
||||
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
/** \addtogroup parser Parser
|
||||
* @{
|
||||
@ -2668,7 +2668,7 @@ parser_send_breakpoints (parser_context_t *context_p, /**< context */
|
||||
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
|
||||
/**
|
||||
* Parse EcamScript source code
|
||||
@ -2688,7 +2688,7 @@ parser_parse_script (const uint8_t *arg_list_p, /**< function argument list */
|
||||
bool is_strict, /**< strict mode */
|
||||
ecma_compiled_code_t **bytecode_data_p) /**< [out] JS bytecode */
|
||||
{
|
||||
#if JERRY_JS_PARSER
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
parser_error_location_t parser_error;
|
||||
|
||||
#ifdef JERRY_DEBUGGER
|
||||
@ -2748,7 +2748,7 @@ parser_parse_script (const uint8_t *arg_list_p, /**< function argument list */
|
||||
#endif /* JERRY_ENABLE_ERROR_MESSAGES */
|
||||
}
|
||||
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||
#else /* !JERRY_JS_PARSER */
|
||||
#else /* JERRY_DISABLE_JS_PARSER */
|
||||
JERRY_UNUSED (arg_list_p);
|
||||
JERRY_UNUSED (arg_list_size);
|
||||
JERRY_UNUSED (source_p);
|
||||
@ -2757,7 +2757,7 @@ parser_parse_script (const uint8_t *arg_list_p, /**< function argument list */
|
||||
JERRY_UNUSED (bytecode_data_p);
|
||||
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("The parser has been disabled."));
|
||||
#endif /* JERRY_JS_PARSER */
|
||||
#endif /* !JERRY_DISABLE_JS_PARSER */
|
||||
} /* parser_parse_script */
|
||||
|
||||
/**
|
||||
|
||||
@ -85,7 +85,6 @@ def build_jerry_data(jerry_path):
|
||||
jerry_cflags = [
|
||||
'-DCONFIG_MEM_HEAP_AREA_SIZE=10*1024',
|
||||
'-DJERRY_NDEBUG',
|
||||
'-DJERRY_JS_PARSER',
|
||||
'-DJERRY_DISABLE_HEAVY_DEBUG',
|
||||
'-DCONFIG_DISABLE_NUMBER_BUILTIN',
|
||||
'-DCONFIG_DISABLE_STRING_BUILTIN',
|
||||
|
||||
@ -3,6 +3,5 @@
|
||||
"NRF52_DK": {
|
||||
"target.uart_hwfc": 0
|
||||
}
|
||||
},
|
||||
"macros": ["JERRY_JS_PARSER 1"]
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ APPNAME = jerry
|
||||
ROOT_DIR = ../../..
|
||||
PRIORITY = $(CONFIG_JERRYSCRIPT_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_JERRYSCRIPT_STACKSIZE)
|
||||
CFLAGS += -std=c99 -DJERRY_NDEBUG -DJERRY_JS_PARSER '-DCONFIG_MEM_HEAP_AREA_SIZE=$(CONFIG_JERRYSCRIPT_HEAPSIZE)'
|
||||
CFLAGS += -std=c99 -DJERRY_NDEBUG '-DCONFIG_MEM_HEAP_AREA_SIZE=$(CONFIG_JERRYSCRIPT_HEAPSIZE)'
|
||||
CFLAGS += -I$(ROOT_DIR)/ $(shell find $(ROOT_DIR)/jerryscript/jerry-core -type d | sed -r -e 's/^/-I/g')
|
||||
CFLAGS += -I$(ROOT_DIR)/jerryscript/jerry-libm/include
|
||||
CFLAGS += -I$(ROOT_DIR)/jerryscript/jerry-ext/include
|
||||
|
||||
@ -78,7 +78,7 @@ APPNAME = jerry
|
||||
ROOT_DIR = ../../../..
|
||||
PRIORITY = $(CONFIG_JERRYSCRIPT_PRIORITY)
|
||||
STACKSIZE = $(CONFIG_JERRYSCRIPT_STACKSIZE)
|
||||
CFLAGS += -std=c99 -DJERRY_NDEBUG -DJERRY_JS_PARSER '-DCONFIG_MEM_HEAP_AREA_SIZE=$(CONFIG_JERRYSCRIPT_HEAPSIZE)'
|
||||
CFLAGS += -std=c99 -DJERRY_NDEBUG '-DCONFIG_MEM_HEAP_AREA_SIZE=$(CONFIG_JERRYSCRIPT_HEAPSIZE)'
|
||||
CFLAGS += -I$(ROOT_DIR)/ $(shell find $(ROOT_DIR)/jerryscript/jerry-core -type d | sed -r -e 's/^/-I/g')
|
||||
CFLAGS += -I$(ROOT_DIR)/jerryscript/jerry-ext/include
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ done
|
||||
cppcheck -j$CPPCHECK_JOBS --force \
|
||||
--language=c --std=c99 \
|
||||
--enable=warning,style,performance,portability,information \
|
||||
--quiet --template="{file}:{line}: {severity}({id}): {message}" \
|
||||
--template="{file}:{line}: {severity}({id}): {message}" \
|
||||
--error-exitcode=1 \
|
||||
--exitcode-suppressions=tools/cppcheck/suppressions-list \
|
||||
--suppressions-list=tools/cppcheck/suppressions-list \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user