Move helpers from ecma-helpers-char.cpp to lit-char-helpers.cpp, rename them correspondingly.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -315,13 +315,6 @@ extern ecma_number_t ecma_int32_to_number (int32_t value);
|
||||
extern ecma_number_t ecma_uint32_to_number (uint32_t value);
|
||||
extern lit_utf8_size_t ecma_number_to_utf8_string (ecma_number_t, lit_utf8_byte_t *, ssize_t);
|
||||
|
||||
/* ecma-helpers-char.cpp */
|
||||
extern bool ecma_char_is_new_line (ecma_char_t c);
|
||||
extern bool ecma_char_is_carriage_return (ecma_char_t c);
|
||||
extern bool ecma_char_is_line_terminator (ecma_char_t c);
|
||||
extern bool ecma_char_is_word_char (ecma_char_t c);
|
||||
extern uint32_t ecma_char_hex_to_int (ecma_char_t hex);
|
||||
|
||||
#endif /* !JERRY_ECMA_HELPERS_H */
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ecma-regexp-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "re-compiler.h"
|
||||
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN
|
||||
@@ -360,7 +361,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
|
||||
}
|
||||
|
||||
if (ecma_char_is_line_terminator (lookup_prev_char (str_p)))
|
||||
if (lit_char_is_line_terminator (lookup_prev_char (str_p)))
|
||||
{
|
||||
JERRY_DDLOG ("match\n");
|
||||
break;
|
||||
@@ -387,7 +388,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
|
||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
|
||||
}
|
||||
|
||||
if (ecma_char_is_line_terminator (lookup_input_char (str_p)))
|
||||
if (lit_char_is_line_terminator (lookup_input_char (str_p)))
|
||||
{
|
||||
JERRY_DDLOG ("match\n");
|
||||
break; /* tail merge */
|
||||
@@ -408,7 +409,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
|
||||
}
|
||||
else
|
||||
{
|
||||
is_wordchar_left = ecma_char_is_word_char (lookup_prev_char (str_p));
|
||||
is_wordchar_left = lit_char_is_word_char (lookup_prev_char (str_p));
|
||||
}
|
||||
|
||||
if (str_p >= re_ctx_p->input_end_p)
|
||||
@@ -417,7 +418,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
|
||||
}
|
||||
else
|
||||
{
|
||||
is_wordchar_right = ecma_char_is_word_char (lookup_input_char (str_p));
|
||||
is_wordchar_right = lit_char_is_word_char (lookup_input_char (str_p));
|
||||
}
|
||||
|
||||
if (op == RE_OP_ASSERT_WORD_BOUNDARY)
|
||||
|
||||
@@ -13,15 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmahelpers Helpers for operations with ECMA characters
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
/**
|
||||
* Check if specified character is the newline character
|
||||
@@ -30,10 +22,10 @@
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_char_is_new_line (ecma_char_t c) /**< character value */
|
||||
lit_char_is_new_line (ecma_char_t c) /**< code unit */
|
||||
{
|
||||
return (c == '\x0A');
|
||||
} /* ecma_char_is_new_line */
|
||||
} /* lit_char_is_new_line */
|
||||
|
||||
/**
|
||||
* Check if specified character the carriage return character
|
||||
@@ -42,10 +34,10 @@ ecma_char_is_new_line (ecma_char_t c) /**< character value */
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_char_is_carriage_return (ecma_char_t c) /**< character value */
|
||||
lit_char_is_carriage_return (ecma_char_t c) /**< code unit */
|
||||
{
|
||||
return (c == '\x0D');
|
||||
} /* ecma_char_is_carriage_return */
|
||||
} /* lit_char_is_carriage_return */
|
||||
|
||||
/**
|
||||
* Check if specified character is one of LineTerminator (ECMA-262 v5, Table 3) characters
|
||||
@@ -54,13 +46,13 @@ ecma_char_is_carriage_return (ecma_char_t c) /**< character value */
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_char_is_line_terminator (ecma_char_t c) /**< character value */
|
||||
lit_char_is_line_terminator (ecma_char_t c) /**< code unit */
|
||||
{
|
||||
/* FIXME: Handle <LS> and <PS> (ECMA-262 v5, 7.3, Table 3) when Unicode would be supported */
|
||||
|
||||
return (ecma_char_is_carriage_return (c)
|
||||
|| ecma_char_is_new_line (c));
|
||||
} /* ecma_char_is_line_terminator */
|
||||
return (lit_char_is_carriage_return (c)
|
||||
|| lit_char_is_new_line (c));
|
||||
} /* lit_char_is_line_terminator */
|
||||
|
||||
/**
|
||||
* Check if specified character is a word character (part of IsWordChar abstract operation)
|
||||
@@ -71,7 +63,7 @@ ecma_char_is_line_terminator (ecma_char_t c) /**< character value */
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_char_is_word_char (ecma_char_t c) /**< character value */
|
||||
lit_char_is_word_char (ecma_char_t c) /**< code unit */
|
||||
{
|
||||
if ((c >= 'a' && c <= 'z')
|
||||
|| (c >= 'A' && c <= 'Z')
|
||||
@@ -82,7 +74,7 @@ ecma_char_is_word_char (ecma_char_t c) /**< character value */
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* ecma_char_is_word_char */
|
||||
} /* lit_char_is_word_char */
|
||||
|
||||
/**
|
||||
* Convert a hex character to an unsigned integer
|
||||
@@ -90,9 +82,10 @@ ecma_char_is_word_char (ecma_char_t c) /**< character value */
|
||||
* @return digit value, corresponding to the hex char
|
||||
*/
|
||||
uint32_t
|
||||
ecma_char_hex_to_int (ecma_char_t hex) /**< [0-9A-Fa-f] character value */
|
||||
lit_char_hex_to_int (ecma_char_t c) /**< code unit, corresponding to
|
||||
* one of [0-9A-Fa-f] characters */
|
||||
{
|
||||
switch (hex)
|
||||
switch (c)
|
||||
{
|
||||
case '0': return 0x0;
|
||||
case '1': return 0x1;
|
||||
@@ -118,9 +111,4 @@ ecma_char_hex_to_int (ecma_char_t hex) /**< [0-9A-Fa-f] character value */
|
||||
case 'F': return 0xF;
|
||||
default: JERRY_UNREACHABLE ();
|
||||
}
|
||||
} /* ecma_char_hex_to_int */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
} /* lit_char_hex_to_int */
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef LIT_CHAR_HELPERS_H
|
||||
#define LIT_CHAR_HELPERS_H
|
||||
|
||||
#include "lit-globals.h"
|
||||
|
||||
extern bool lit_char_is_new_line (ecma_char_t);
|
||||
extern bool lit_char_is_carriage_return (ecma_char_t);
|
||||
extern bool lit_char_is_line_terminator (ecma_char_t);
|
||||
extern bool lit_char_is_word_char (ecma_char_t);
|
||||
extern uint32_t lit_char_hex_to_int (ecma_char_t);
|
||||
|
||||
#endif /* LIT_CHAR_HELPERS_H */
|
||||
@@ -18,7 +18,9 @@
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jsp-mm.h"
|
||||
#include "lexer.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "lit-strings.h"
|
||||
#include "syntax-errors.h"
|
||||
|
||||
static token saved_token, prev_token, sent_token, empty_token;
|
||||
@@ -512,7 +514,7 @@ convert_string_to_token_transform_escape_seq (token_type tok_type, /**< type of
|
||||
JERRY_ASSERT ((char_code & 0xF000u) == 0);
|
||||
|
||||
char_code = (uint16_t) (char_code << 4u);
|
||||
char_code = (uint16_t) (char_code + ecma_char_hex_to_int (byte));
|
||||
char_code = (uint16_t) (char_code + lit_char_hex_to_int (byte));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,7 +534,7 @@ convert_string_to_token_transform_escape_seq (token_type tok_type, /**< type of
|
||||
*/
|
||||
converted_char = (ecma_char_t) char_code;
|
||||
}
|
||||
else if (ecma_char_is_line_terminator (escape_character))
|
||||
else if (lit_char_is_line_terminator (escape_character))
|
||||
{
|
||||
if (source_str_iter_p + 1 <= source_str_p + source_str_size)
|
||||
{
|
||||
@@ -729,11 +731,11 @@ parse_number (void)
|
||||
{
|
||||
if (!is_overflow)
|
||||
{
|
||||
res = (res << 4) + ecma_char_hex_to_int (token_start[i]);
|
||||
res = (res << 4) + lit_char_hex_to_int (token_start[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fp_res = fp_res * 16 + (ecma_number_t) ecma_char_hex_to_int (token_start[i]);
|
||||
fp_res = fp_res * 16 + (ecma_number_t) lit_char_hex_to_int (token_start[i]);
|
||||
}
|
||||
|
||||
if (res > 255)
|
||||
@@ -843,11 +845,11 @@ parse_number (void)
|
||||
{
|
||||
if (!is_overflow)
|
||||
{
|
||||
res = res * 8 + ecma_char_hex_to_int (token_start[i]);
|
||||
res = res * 8 + lit_char_hex_to_int (token_start[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fp_res = fp_res * 8 + (ecma_number_t) ecma_char_hex_to_int (token_start[i]);
|
||||
fp_res = fp_res * 8 + (ecma_number_t) lit_char_hex_to_int (token_start[i]);
|
||||
}
|
||||
if (res > 255)
|
||||
{
|
||||
@@ -863,11 +865,11 @@ parse_number (void)
|
||||
{
|
||||
if (!is_overflow)
|
||||
{
|
||||
res = res * 10 + ecma_char_hex_to_int (token_start[i]);
|
||||
res = res * 10 + lit_char_hex_to_int (token_start[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
fp_res = fp_res * 10 + (ecma_number_t) ecma_char_hex_to_int (token_start[i]);
|
||||
fp_res = fp_res * 10 + (ecma_number_t) lit_char_hex_to_int (token_start[i]);
|
||||
}
|
||||
if (res > 255)
|
||||
{
|
||||
@@ -916,7 +918,7 @@ parse_string (void)
|
||||
{
|
||||
PARSE_ERROR ("Unclosed string", token_start - buffer_start);
|
||||
}
|
||||
else if (ecma_char_is_line_terminator (c))
|
||||
else if (lit_char_is_line_terminator (c))
|
||||
{
|
||||
PARSE_ERROR ("String literal shall not contain newline character", token_start - buffer_start);
|
||||
}
|
||||
@@ -928,15 +930,15 @@ parse_string (void)
|
||||
{
|
||||
consume_char ();
|
||||
}
|
||||
else if (ecma_char_is_line_terminator (nc))
|
||||
else if (lit_char_is_line_terminator (nc))
|
||||
{
|
||||
consume_char ();
|
||||
|
||||
if (ecma_char_is_carriage_return (nc))
|
||||
if (lit_char_is_carriage_return (nc))
|
||||
{
|
||||
nc = (ecma_char_t) LA (0);
|
||||
|
||||
if (ecma_char_is_new_line (nc))
|
||||
if (lit_char_is_new_line (nc))
|
||||
{
|
||||
consume_char ();
|
||||
}
|
||||
@@ -1009,8 +1011,8 @@ parse_regexp (void)
|
||||
ecma_char_t c = (ecma_char_t) LA (0);
|
||||
|
||||
if (c == '\0'
|
||||
|| !ecma_char_is_word_char (c)
|
||||
|| ecma_char_is_line_terminator (c))
|
||||
|| !lit_char_is_word_char (c)
|
||||
|| lit_char_is_line_terminator (c))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "re-parser.h"
|
||||
#include "syntax-errors.h"
|
||||
|
||||
@@ -126,7 +126,7 @@ parse_re_iterator (lit_utf8_byte_t *pattern_p, /**< RegExp pattern */
|
||||
return ret_value;
|
||||
}
|
||||
digits++;
|
||||
qmin = qmin * 10 + ecma_char_hex_to_int (ch1);
|
||||
qmin = qmin * 10 + lit_char_hex_to_int (ch1);
|
||||
}
|
||||
else if (ch1 == ',')
|
||||
{
|
||||
@@ -677,7 +677,7 @@ re_parse_next_token (re_parser_ctx_t *parser_ctx_p, /**< RegExp parser context *
|
||||
{
|
||||
break;
|
||||
}
|
||||
number = number * 10 + ecma_char_hex_to_int (digit);
|
||||
number = number * 10 + lit_char_hex_to_int (digit);
|
||||
index++;
|
||||
}
|
||||
while (true);
|
||||
|
||||
Reference in New Issue
Block a user