Implement template literals. (#2025)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-09-27 11:24:51 +02:00
committed by GitHub
parent fe864bcf53
commit 8a5bfd2279
13 changed files with 441 additions and 88 deletions
+45 -27
View File
@@ -34,36 +34,53 @@
* @{
*/
/* General parser flags. */
#define PARSER_IS_STRICT 0x00000001u
#define PARSER_IS_FUNCTION 0x00000002u
#define PARSER_IS_CLOSURE 0x00000004u
#define PARSER_IS_PROPERTY_GETTER 0x00000008u
#define PARSER_IS_PROPERTY_SETTER 0x00000010u
#define PARSER_IS_FUNC_EXPRESSION 0x00000020u
#define PARSER_NAMED_FUNCTION_EXP 0x00000040u
#define PARSER_HAS_NON_STRICT_ARG 0x00000080u
#define PARSER_ARGUMENTS_NEEDED 0x00000100u
#define PARSER_ARGUMENTS_NOT_NEEDED 0x00000200u
#define PARSER_LEXICAL_ENV_NEEDED 0x00000400u
#define PARSER_INSIDE_WITH 0x00000800u
#define PARSER_RESOLVE_THIS_FOR_CALLS 0x00001000u
#define PARSER_HAS_INITIALIZED_VARS 0x00002000u
#define PARSER_HAS_LATE_LIT_INIT 0x00004000u
#define PARSER_NO_END_LABEL 0x00008000u
#define PARSER_NO_REG_STORE 0x00010000u
#define PARSER_DEBUGGER_BREAKPOINT_APPENDED 0x00020000u
/**
* General parser flags.
*/
typedef enum
{
PARSER_IS_STRICT = (1u << 0), /**< strict mode code */
PARSER_IS_FUNCTION = (1u << 1), /**< function body is parsed */
PARSER_IS_CLOSURE = (1u << 2), /**< function body is encapsulated in {} block */
PARSER_IS_FUNC_EXPRESSION = (1u << 3), /**< a function expression is parsed */
PARSER_IS_PROPERTY_GETTER = (1u << 4), /**< a property getter function is parsed */
PARSER_IS_PROPERTY_SETTER = (1u << 5), /**< a property setter function is parsed */
PARSER_NAMED_FUNCTION_EXP = (1u << 6), /**< a function expression has a name binding */
PARSER_HAS_NON_STRICT_ARG = (1u << 7), /**< the function has arguments which
* are not supported in strict mode */
PARSER_ARGUMENTS_NEEDED = (1u << 8), /**< arguments object must be created */
PARSER_ARGUMENTS_NOT_NEEDED = (1u << 9), /**< arguments object must NOT be created */
PARSER_LEXICAL_ENV_NEEDED = (1u << 10), /**< lexical environment object must be created */
PARSER_NO_REG_STORE = (1u << 11), /**< all local variables must be stored
* in the lexical environment object */
PARSER_INSIDE_WITH = (1u << 12), /**< code block is inside a with statement */
PARSER_RESOLVE_BASE_FOR_CALLS = (1u << 13), /**< the this object must be resolved when
* a function without a base object is called */
PARSER_HAS_INITIALIZED_VARS = (1u << 14), /**< a CBC_INITIALIZE_VARS instruction must be emitted */
PARSER_HAS_LATE_LIT_INIT = (1u << 15), /**< allocate memory for this string after
* the local parser data is freed */
PARSER_NO_END_LABEL = (1u << 16), /**< return instruction must be inserted
* after the last byte code */
PARSER_DEBUGGER_BREAKPOINT_APPENDED = (1u << 17), /**< pending (unsent) breakpoint
* info is available */
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
#define PARSER_IS_ARROW_FUNCTION 0x00040000u
#define PARSER_ARROW_PARSE_ARGS 0x00080000u
PARSER_IS_ARROW_FUNCTION = (1u << 18), /**< an arrow function is parsed */
PARSER_ARROW_PARSE_ARGS = (1u << 19), /**< parse the argument list of an arrow function */
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
} parser_general_flags_t;
/* Expression parsing flags. */
#define PARSE_EXPR 0x00
#define PARSE_EXPR_STATEMENT 0x01
#define PARSE_EXPR_BLOCK 0x02
#define PARSE_EXPR_NO_COMMA 0x04
#define PARSE_EXPR_HAS_LITERAL 0x08
/**
* Expression parsing flags.
*/
typedef enum
{
PARSE_EXPR = 0, /**< parse an expression without any special flags */
PARSE_EXPR_STATEMENT = (1u << 0), /**< discard the result of the expression */
PARSE_EXPR_BLOCK = (1u << 1), /**< copy the expression result into the block result */
PARSE_EXPR_NO_COMMA = (1u << 2), /**< do not parse comma operator */
PARSE_EXPR_HAS_LITERAL = (1u << 3), /**< a primary literal is provided by a
* CBC_PUSH_LITERAL instruction */
} parser_expression_flags_t;
/* The maximum of PARSER_CBC_STREAM_PAGE_SIZE is 127. */
#define PARSER_CBC_STREAM_PAGE_SIZE \
@@ -400,6 +417,7 @@ bool lexer_check_colon (parser_context_t *context_p);
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
lexer_token_type_t lexer_check_arrow (parser_context_t *context_p);
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
void lexer_parse_string (parser_context_t *context_p);
void lexer_expect_identifier (parser_context_t *context_p, uint8_t literal_type);
void lexer_scan_identifier (parser_context_t *context_p, bool propety_name);
ecma_char_t lexer_hex_to_character (parser_context_t *context_p, const uint8_t *source_p, int length);