Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions jerry-core/parser/js/js-lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ static const keyword_string_t keywords_with_length_2[] =
{
LEXER_KEYWORD ("do", LEXER_KEYW_DO),
LEXER_KEYWORD ("if", LEXER_KEYW_IF),
LEXER_KEYWORD ("in", LEXER_KEYW_IN),
LEXER_KEYWORD ("in", LEXER_KEYW_IN)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add these back. It helps in various cases to have comma-terminated arrays (and enums). If an array (or an enum) has to me changed (new element gets added, an old one gets removed) then only that line needs to be changed that contains the affected element. One doesn't have to check whether it is/was/becomes before/after/the last element in the array (or enum) and doesn't have to add/remove another comma. It also helps if content is ifdef-guarded: again, one doesn't have to care about which element is the last. So, please keep also the last entry comma-terminated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think such change is rare because the items are in alphabetic order. And we usually don't put a comma after the last item in other enums as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the arrays and enums where the use-trailing-comma-everywhere principle is used:

  • arrays:
    jerry_typedarray_mappings, ecma_builtin_routines, ecma_builtin_call_functions, ecma_builtin_construct_functions, ecma_builtin_property_list_references, ecma_error_mappings, cbc_flags, cbc_ext_flags, cbc_names, cbc_ext_names, statement_lengths
  • enums:
    jerry_debugger_flags_t, jerry_debugger_header_type_t, jerry_debugger_configuration_flags_t, jerry_debugger_eval_type_t, jerry_debugger_eval_result_type_t, jerry_debugger_output_subtype_t, ecma_init_flag_t, ecma_status_flag_t, ecma_parse_opts_t, ecma_property_types_t, ecma_list_properties_options_t, ecma_property_flags_t, ecma_collection_flag_t, ecma_direct_string_type_t, ecma_arraybuffer_extra_flag_t, ecma_property_hashmap_delete_status, ecma_builtin_property_type_t, ecma_builtin_number_type_t, ecma_array_object_set_length_flags_t, jerry_init_flag_t, jerry_type_t, jerry_typedarray_type_t, jerry_debugger_wait_for_source_status_t, jerry_generate_snapshot_opts_t, jerry_exec_snapshot_opts_t, jmem_free_unused_memory_severity_t, cbc_code_flags, cbc_opcode_t, cbc_ext_opcode_t, lexer_literal_type_t, lexer_literal_status_flags_t, skip_mode_t, lexer_token_type_t, lexer_obj_ident_opts_t, lexer_literal_object_type_t, lexer_number_type_t, parser_object_literal_item_types_t, parser_general_flags_t, parser_expression_flags_t, scan_modes_t, scan_stack_modes_t, parser_statement_type_t, parser_try_block_type_t, re_token_type_t, number_arithmetic_op, number_bitwise_logic_op, vm_stack_context_type_t, vm_oc_get_types, vm_oc_types, vm_oc_put_types, vm_call_operation

That's quite some, I think. But not universal, for sure. The style is mixed in the code base. But if I had to choose between future proof and not future proof, I'd go for the first option. And definitely would not change back from the first style to the latter one.

};

/**
Expand All @@ -331,7 +331,7 @@ static const keyword_string_t keywords_with_length_3[] =
LEXER_KEYWORD ("let", LEXER_KEYW_LET),
LEXER_KEYWORD ("new", LEXER_KEYW_NEW),
LEXER_KEYWORD ("try", LEXER_KEYW_TRY),
LEXER_KEYWORD ("var", LEXER_KEYW_VAR),
LEXER_KEYWORD ("var", LEXER_KEYW_VAR)
};

/**
Expand All @@ -346,7 +346,7 @@ static const keyword_string_t keywords_with_length_4[] =
LEXER_KEYWORD ("this", LEXER_KEYW_THIS),
LEXER_KEYWORD ("true", LEXER_LIT_TRUE),
LEXER_KEYWORD ("void", LEXER_KEYW_VOID),
LEXER_KEYWORD ("with", LEXER_KEYW_WITH),
LEXER_KEYWORD ("with", LEXER_KEYW_WITH)
};

/**
Expand All @@ -365,7 +365,7 @@ static const keyword_string_t keywords_with_length_5[] =
LEXER_KEYWORD ("super", LEXER_KEYW_SUPER),
LEXER_KEYWORD ("throw", LEXER_KEYW_THROW),
LEXER_KEYWORD ("while", LEXER_KEYW_WHILE),
LEXER_KEYWORD ("yield", LEXER_KEYW_YIELD),
LEXER_KEYWORD ("yield", LEXER_KEYW_YIELD)
};

/**
Expand All @@ -380,7 +380,7 @@ static const keyword_string_t keywords_with_length_6[] =
LEXER_KEYWORD ("return", LEXER_KEYW_RETURN),
LEXER_KEYWORD ("static", LEXER_KEYW_STATIC),
LEXER_KEYWORD ("switch", LEXER_KEYW_SWITCH),
LEXER_KEYWORD ("typeof", LEXER_KEYW_TYPEOF),
LEXER_KEYWORD ("typeof", LEXER_KEYW_TYPEOF)
};

/**
Expand All @@ -392,7 +392,7 @@ static const keyword_string_t keywords_with_length_7[] =
LEXER_KEYWORD ("extends", LEXER_KEYW_EXTENDS),
LEXER_KEYWORD ("finally", LEXER_KEYW_FINALLY),
LEXER_KEYWORD ("package", LEXER_KEYW_PACKAGE),
LEXER_KEYWORD ("private", LEXER_KEYW_PRIVATE),
LEXER_KEYWORD ("private", LEXER_KEYW_PRIVATE)
};

/**
Expand All @@ -402,7 +402,7 @@ static const keyword_string_t keywords_with_length_8[] =
{
LEXER_KEYWORD ("continue", LEXER_KEYW_CONTINUE),
LEXER_KEYWORD ("debugger", LEXER_KEYW_DEBUGGER),
LEXER_KEYWORD ("function", LEXER_KEYW_FUNCTION),
LEXER_KEYWORD ("function", LEXER_KEYW_FUNCTION)
};

/**
Expand All @@ -411,7 +411,7 @@ static const keyword_string_t keywords_with_length_8[] =
static const keyword_string_t keywords_with_length_9[] =
{
LEXER_KEYWORD ("interface", LEXER_KEYW_INTERFACE),
LEXER_KEYWORD ("protected", LEXER_KEYW_PROTECTED),
LEXER_KEYWORD ("protected", LEXER_KEYW_PROTECTED)
};

/**
Expand All @@ -420,7 +420,7 @@ static const keyword_string_t keywords_with_length_9[] =
static const keyword_string_t keywords_with_length_10[] =
{
LEXER_KEYWORD ("implements", LEXER_KEYW_IMPLEMENTS),
LEXER_KEYWORD ("instanceof", LEXER_KEYW_INSTANCEOF),
LEXER_KEYWORD ("instanceof", LEXER_KEYW_INSTANCEOF)
};

/**
Expand Down
37 changes: 4 additions & 33 deletions jerry-core/parser/js/js-lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,14 @@ typedef enum
LEXER_SCAN_SWITCH, /**< special value for switch pre-scan */
LEXER_CLASS_CONSTRUCTOR, /**< special value for class constructor method */

#ifdef CONFIG_DISABLE_ES2015
/* Future reserved words: these keywords
* must form a group after all other keywords. */
#define LEXER_FIRST_FUTURE_RESERVED_WORD LEXER_KEYW_CLASS
#endif /* CONFIG_DISABLE_ES2015 */
/* Keywords which may be reserved. */
LEXER_KEYW_CLASS, /**< class */
LEXER_KEYW_ENUM, /**< enum */
LEXER_KEYW_EXTENDS, /**< extends */
LEXER_KEYW_SUPER, /**< super */
LEXER_KEYW_CONST, /**< const */
LEXER_KEYW_EXPORT, /**< export */
LEXER_KEYW_IMPORT, /**< import */
#ifndef CONFIG_DISABLE_ES2015
/* Future reserved words: these keywords
* must form a group after all other keywords.
* Note:
* Tokens from LEXER_KEYW_CLASS to LEXER_KEYW_IMPORT
* are no longer future reserved words in ES2015. */
#define LEXER_FIRST_FUTURE_RESERVED_WORD LEXER_KEYW_ENUM
#endif /* !CONFIG_DISABLE_ES2015 */
LEXER_KEYW_ENUM, /**< enum */
#ifndef CONFIG_DISABLE_ES2015
LEXER_KEYW_AWAIT, /**< await */
#endif /* !CONFIG_DISABLE_ES2015 */
Expand All @@ -179,31 +167,14 @@ typedef enum
* must form a group after future reserved words. */
#define LEXER_FIRST_FUTURE_STRICT_RESERVED_WORD LEXER_KEYW_IMPLEMENTS
LEXER_KEYW_IMPLEMENTS, /**< implements */
LEXER_KEYW_LET, /**< let */
LEXER_KEYW_PRIVATE, /**< private */
LEXER_KEYW_PUBLIC, /**< public */
LEXER_KEYW_YIELD, /**< yield */
LEXER_KEYW_INTERFACE, /**< interface */
LEXER_KEYW_PACKAGE, /**< package */
LEXER_KEYW_PROTECTED, /**< protected */

#ifndef CONFIG_DISABLE_ES2015
/* Context dependent strict reserved words:
* See also: ECMA-262 v6, 11.6.2.1 */
#define LEXER_FIRST_CONTEXT_DEPENDENT_RESERVED_WORD LEXER_KEYW_STATIC
LEXER_KEYW_STATIC, /**< static */
#else /* CONFIG_DISABLE_ES2015 */
/* Context dependent strict reserved words:
* See also: ECMA-262 v6, 11.6.2.1 */
#define LEXER_FIRST_CONTEXT_DEPENDENT_RESERVED_WORD
#endif /* !CONFIG_DISABLE_ES2015 */

/* Context dependent future strict reserved words:
* See also: ECMA-262 v6, 11.6.2.1 */
#define LEXER_FIRST_CONTEXT_DEPENDENT_FUTURE_RESERVED_WORD LEXER_KEYW_LET
LEXER_KEYW_LET, /**< let */
LEXER_KEYW_YIELD, /**< yield */
#ifdef CONFIG_DISABLE_ES2015
LEXER_KEYW_STATIC, /**< static */
#endif /* CONFIG_DISABLE_ES2015 */
} lexer_token_type_t;

#define LEXER_NEWLINE_LS_PS_BYTE_1 0xe2
Expand Down
46 changes: 24 additions & 22 deletions jerry-core/parser/js/js-parser-expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,14 +1286,10 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
if (PARSER_IS_CLASS_CONSTRUCTOR_SUPER (context_p->status_flags))
{
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_CONSTRUCTOR_THIS);
}
else
{
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
parser_emit_cbc (context_p, CBC_PUSH_THIS);
#ifndef CONFIG_DISABLE_ES2015_CLASS
break;
}
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
parser_emit_cbc (context_p, CBC_PUSH_THIS);
break;
}
case LEXER_LIT_TRUE:
Expand All @@ -1320,7 +1316,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
case LEXER_KEYW_SUPER:
{
if ((lexer_check_next_character (context_p, LIT_CHAR_DOT)
|| lexer_check_next_character (context_p, LIT_CHAR_LEFT_SQUARE))
|| lexer_check_next_character (context_p, LIT_CHAR_LEFT_SQUARE))
&& context_p->status_flags & (PARSER_CLASS_HAS_SUPER | PARSER_IS_ARROW_FUNCTION))
{
if (!LEXER_IS_BINARY_OP_TOKEN (context_p->stack_top_uint8))
Expand Down Expand Up @@ -1375,6 +1371,24 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
lexer_next_token (context_p);
} /* parser_parse_unary_expression */

/**
* Push an eval opcode.
*/
static inline void
parser_emit_eval (parser_context_t *context_p) /**< context */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function OK here? parser_emit_s used to be at the beginning of the source, just like parser_emit_unary_lvalue_opcode is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is such rule. This is a static inline helper, usually defined before use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I was not referring to rules as such but to coding patterns, especially related to parser_emit_ helper functions. Such functions appear in two files: js-parser-expr.c and js-parser-util.c. In js-parser-util.c, all parser_emit_ functions are grouped to the beginning of the file, just like the single parser_emit_unary_lvalue_opcode helper in js-parser-expr.c (this file). Moreover parser_emit_unary_lvalue_opcode is first used at line 1693 but already defined at line 86 (i.e., not before the use).

{
#ifndef CONFIG_DISABLE_ES2015_CLASS
if (context_p->status_flags & PARSER_CLASS_HAS_SUPER)
{
uint8_t data_byte = (uint8_t) PARSER_GET_CLASS_ECMA_PARSE_OPTS (context_p->status_flags);
parser_emit_cbc_ext_byte (context_p, CBC_EXT_CLASS_EVAL, data_byte);
return;
}
#endif /* !CONFIG_DISABLE_ES2015_CLASS */

parser_emit_cbc (context_p, CBC_EVAL);
} /* parser_emit_eval */

/**
* Parse the postfix part of unary operators, and
* generate byte code for the whole expression.
Expand Down Expand Up @@ -1557,20 +1571,7 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */

if (is_eval)
{
#ifndef CONFIG_DISABLE_ES2015_CLASS
if (context_p->status_flags & PARSER_CLASS_HAS_SUPER)
{
parser_flush_cbc (context_p);
context_p->last_cbc_opcode = PARSER_TO_EXT_OPCODE (CBC_EXT_CLASS_EVAL);
context_p->last_cbc.value = PARSER_GET_CLASS_ECMA_PARSE_OPTS (context_p->status_flags);
}
else
{
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
parser_emit_cbc (context_p, CBC_EVAL);
#ifndef CONFIG_DISABLE_ES2015_CLASS
}
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
parser_emit_eval (context_p);
}

#ifndef CONFIG_DISABLE_ES2015_CLASS
Expand Down Expand Up @@ -1813,13 +1814,14 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */
parser_stack_push_uint16 (context_p, context_p->last_cbc.literal_index);
parser_stack_push_uint8 (context_p, CBC_ASSIGN_PROP_LITERAL);
context_p->last_cbc_opcode = PARSER_CBC_UNAVAILABLE;

#ifndef CONFIG_DISABLE_ES2015_CLASS
if (context_p->status_flags & PARSER_CLASS_SUPER_PROP_REFERENCE)
{
context_p->status_flags &= (uint32_t) ~PARSER_CLASS_SUPER_PROP_REFERENCE;
parser_emit_cbc_ext (context_p, CBC_EXT_SUPER_PROP_ASSIGN);
parser_flush_cbc (context_p);
}
context_p->status_flags &= (uint32_t) ~PARSER_CLASS_SUPER_PROP_REFERENCE;
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
}
else
Expand Down
65 changes: 34 additions & 31 deletions jerry-core/parser/js/js-parser-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,41 @@
*/
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 */
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
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 */
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 */
#ifndef CONFIG_DISABLE_ES2015_CLASS
/* These three status flags must be in this order. See PARSER_CLASS_PARSE_OPTS_OFFSET. */
PARSER_CLASS_CONSTRUCTOR = (1u << 20), /**< a class constructor is parsed (this value must be kept in
* in sync with ECMA_PARSE_CLASS_CONSTRUCTOR) */
PARSER_CLASS_HAS_SUPER = (1u << 21), /**< class has super reference */
PARSER_CLASS_STATIC_FUNCTION = (1u << 22), /**< this function is a static class method */
PARSER_CLASS_SUPER_PROP_REFERENCE = (1u << 23), /**< super property call or assignment */
PARSER_CLASS_CONSTRUCTOR = (1u << 20), /**< a class constructor is parsed (this value must be
* kept in in sync with ECMA_PARSE_CLASS_CONSTRUCTOR) */
PARSER_CLASS_HAS_SUPER = (1u << 21), /**< class has super reference */
PARSER_CLASS_STATIC_FUNCTION = (1u << 22), /**< this function is a static class method */
PARSER_CLASS_SUPER_PROP_REFERENCE = (1u << 23), /**< super property call or assignment */
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
} parser_general_flags_t;

Expand Down Expand Up @@ -455,6 +455,7 @@ void parser_flush_cbc (parser_context_t *context_p);
void parser_emit_cbc (parser_context_t *context_p, uint16_t opcode);
void parser_emit_cbc_literal (parser_context_t *context_p, uint16_t opcode, uint16_t literal_index);
void parser_emit_cbc_literal_from_token (parser_context_t *context_p, uint16_t opcode);
void parser_emit_cbc_byte (parser_context_t *context_p, uint16_t opcode, uint8_t data_byte);
void parser_emit_cbc_call (parser_context_t *context_p, uint16_t opcode, size_t call_arguments);
void parser_emit_cbc_push_number (parser_context_t *context_p, bool is_negative_number);
void parser_emit_cbc_forward_branch (parser_context_t *context_p, uint16_t opcode, parser_branch_t *branch_p);
Expand All @@ -470,6 +471,8 @@ void parser_set_continues_to_current_position (parser_context_t *context_p, pars
parser_emit_cbc ((context_p), PARSER_TO_EXT_OPCODE (opcode))
#define parser_emit_cbc_ext_literal(context_p, opcode, literal_index) \
parser_emit_cbc_literal ((context_p), PARSER_TO_EXT_OPCODE (opcode), (literal_index))
#define parser_emit_cbc_ext_byte(context_p, opcode, data) \
parser_emit_cbc_byte ((context_p), PARSER_TO_EXT_OPCODE (opcode), (data))
#define parser_emit_cbc_ext_call(context_p, opcode, call_arguments) \
parser_emit_cbc_call ((context_p), PARSER_TO_EXT_OPCODE (opcode), (call_arguments))
#define parser_emit_cbc_ext_forward_branch(context_p, opcode, branch_p) \
Expand Down
8 changes: 2 additions & 6 deletions jerry-core/parser/js/js-parser-statm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2024,14 +2024,10 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
{
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_CONSTRUCTOR_THIS);
parser_emit_cbc (context_p, CBC_RETURN);
}
else
{
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
parser_emit_cbc (context_p, CBC_RETURN_WITH_BLOCK);
#ifndef CONFIG_DISABLE_ES2015_CLASS
break;
}
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
parser_emit_cbc (context_p, CBC_RETURN_WITH_BLOCK);
break;
}

Expand Down
22 changes: 17 additions & 5 deletions jerry-core/parser/js/js-parser-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,23 +297,35 @@ parser_emit_cbc_literal_from_token (parser_context_t *context_p, /**< context */
} /* parser_emit_cbc_literal_from_token */

/**
* Append a byte code with a call argument
* Append a byte code with a byte argument
*/
void
parser_emit_cbc_call (parser_context_t *context_p, /**< context */
parser_emit_cbc_byte (parser_context_t *context_p, /**< context */
uint16_t opcode, /**< opcode */
size_t call_arguments) /**< number of arguments */
uint8_t data_byte) /**< data byte */
{
JERRY_ASSERT (PARSER_ARGS_EQ (opcode, CBC_HAS_BYTE_ARG));
JERRY_ASSERT (call_arguments <= CBC_MAXIMUM_BYTE_VALUE);

if (context_p->last_cbc_opcode != PARSER_CBC_UNAVAILABLE)
{
parser_flush_cbc (context_p);
}

context_p->last_cbc_opcode = opcode;
context_p->last_cbc.value = (uint16_t) call_arguments;
context_p->last_cbc.value = data_byte;
} /* parser_emit_cbc_byte */

/**
* Append a byte code with a call argument
*/
void
parser_emit_cbc_call (parser_context_t *context_p, /**< context */
uint16_t opcode, /**< opcode */
size_t call_arguments) /**< number of arguments */
{
JERRY_ASSERT (call_arguments <= CBC_MAXIMUM_BYTE_VALUE);

parser_emit_cbc_byte (context_p, opcode, (uint8_t) call_arguments);
} /* parser_emit_cbc_call */

/**
Expand Down