Refactor RegExp builtin (#3136)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
committed by
Robert Fancsik
parent
c3510fc03d
commit
c3bb516e4a
File diff suppressed because it is too large
Load Diff
@@ -35,34 +35,66 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RE_FLAG_EMPTY = 0u, /* Empty RegExp flags */
|
||||
RE_FLAG_GLOBAL = (1u << 1), /**< ECMA-262 v5, 15.10.7.2 */
|
||||
RE_FLAG_IGNORE_CASE = (1u << 2), /**< ECMA-262 v5, 15.10.7.3 */
|
||||
RE_FLAG_MULTILINE = (1u << 3) /**< ECMA-262 v5, 15.10.7.4 */
|
||||
} re_flags_t;
|
||||
} ecma_regexp_flags_t;
|
||||
|
||||
/**
|
||||
* Structure for storing capturing group results
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const lit_utf8_byte_t *begin_p; /**< substring start pointer */
|
||||
const lit_utf8_byte_t *end_p; /**< substring end pointer */
|
||||
} ecma_regexp_capture_t;
|
||||
|
||||
/**
|
||||
* Structure for storing non-capturing group results
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const lit_utf8_byte_t *str_p; /**< string pointer */
|
||||
} ecma_regexp_non_capture_t;
|
||||
|
||||
#if (JERRY_STACK_LIMIT != 0)
|
||||
/**
|
||||
* Value used ase result when stack limit is reached
|
||||
*/
|
||||
#define ECMA_RE_OUT_OF_STACK ((const lit_utf8_byte_t *) UINTPTR_MAX)
|
||||
|
||||
/**
|
||||
* Checks if the stack limit has been reached during regexp matching
|
||||
*/
|
||||
#define ECMA_RE_STACK_LIMIT_REACHED(p) (JERRY_UNLIKELY (p == ECMA_RE_OUT_OF_STACK))
|
||||
#else /* JERRY_STACK_LIMIT == 0 */
|
||||
#define ECMA_RE_STACK_LIMIT_REACHED(p) (false)
|
||||
#endif /* JERRY_STACK_LIMIT != 0 */
|
||||
|
||||
/**
|
||||
* RegExp executor context
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const lit_utf8_byte_t **saved_p; /**< saved result string pointers, ECMA 262 v5, 15.10.2.1, State */
|
||||
const lit_utf8_byte_t *input_start_p; /**< start of input pattern string */
|
||||
const lit_utf8_byte_t *input_end_p; /**< end of input pattern string */
|
||||
uint32_t num_of_captures; /**< number of capture groups */
|
||||
uint32_t num_of_non_captures; /**< number of non-capture groups */
|
||||
uint32_t *num_of_iterations_p; /**< number of iterations */
|
||||
uint16_t flags; /**< RegExp flags */
|
||||
} re_matcher_ctx_t;
|
||||
const lit_utf8_byte_t *input_end_p; /**< end of input string */
|
||||
const lit_utf8_byte_t *input_start_p; /**< start of input string */
|
||||
uint32_t captures_count; /**< number of capture groups */
|
||||
ecma_regexp_capture_t *captures_p; /**< capturing groups */
|
||||
uint32_t non_captures_count; /**< number of non-capture groups */
|
||||
ecma_regexp_non_capture_t *non_captures_p; /**< non-capturing groups */
|
||||
uint32_t *iterations_p; /**< number of iterations */
|
||||
uint16_t flags; /**< RegExp flags */
|
||||
} ecma_regexp_ctx_t;
|
||||
|
||||
ecma_value_t ecma_op_create_regexp_object_from_bytecode (re_compiled_code_t *bytecode_p);
|
||||
ecma_value_t ecma_op_create_regexp_object (ecma_string_t *pattern_p, uint16_t flags);
|
||||
ecma_value_t ecma_regexp_exec_helper (ecma_value_t regexp_value, ecma_value_t input_string, bool ignore_global);
|
||||
ecma_value_t ecma_regexp_read_pattern_str_helper (ecma_value_t pattern_arg, ecma_string_t **pattern_string_p);
|
||||
ecma_char_t re_canonicalize (ecma_char_t ch, bool is_ignorecase);
|
||||
void re_set_result_array_properties (ecma_object_t *array_obj_p, ecma_string_t *input_str_p, uint32_t num_of_elements,
|
||||
int32_t index);
|
||||
ecma_value_t re_parse_regexp_flags (ecma_string_t *flags_str_p, uint16_t *flags_p);
|
||||
void re_initialize_props (ecma_object_t *re_obj_p, ecma_string_t *source_p, uint16_t flags);
|
||||
ecma_char_t ecma_regexp_canonicalize (ecma_char_t ch, bool is_ignorecase);
|
||||
ecma_char_t ecma_regexp_canonicalize_char (ecma_char_t ch);
|
||||
ecma_value_t ecma_regexp_parse_flags (ecma_string_t *flags_str_p, uint16_t *flags_p);
|
||||
void ecma_regexp_initialize_props (ecma_object_t *re_obj_p, ecma_string_t *source_p, uint16_t flags);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user