Implement ES2015 class feature (part II.) (#2439)

This patch is the second milestone of the implementation of this new language element.

Supported:
 - Single class inheritance
 - Functionality of 'super' keyword
 - Implicit constructor in class heritage
 - Specific behaviour while extending with the built-in 'Array' or '%TypedArray%' object
 - Abstract subclasses (Mix-ins)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2018-10-25 16:00:48 +02:00
committed by Akos Kiss
parent e0e6363f85
commit d1860d0e34
54 changed files with 2543 additions and 199 deletions
+19 -25
View File
@@ -352,11 +352,23 @@ static const keyword_string_t keyword_length_4[9] =
LEXER_KEYWORD_END ()
};
#ifndef CONFIG_DISABLE_ES2015
/**
* Number of keywords with 5 characters.
*/
#define KEYWORD_LENGTH_COUNT 11
#else /* CONFIG_DISABLE_ES2015 */
#define KEYWORD_LENGTH_COUNT 10
#endif /* !CONFIG_DISABLE_ES2015 */
/**
* Keywords with 5 characters.
*/
static const keyword_string_t keyword_length_5[10] =
static const keyword_string_t keyword_length_5[KEYWORD_LENGTH_COUNT] =
{
#ifndef CONFIG_DISABLE_ES2015
LEXER_KEYWORD ("await", LEXER_KEYW_AWAIT),
#endif /* !CONFIG_DISABLE_ES2015 */
LEXER_KEYWORD ("break", LEXER_KEYW_BREAK),
LEXER_KEYWORD ("catch", LEXER_KEYW_CATCH),
LEXER_KEYWORD ("class", LEXER_KEYW_CLASS),
@@ -1310,40 +1322,22 @@ lexer_next_token (parser_context_t *context_p) /**< context */
#undef LEXER_TYPE_D_TOKEN
/**
* Checks whether the next token is a colon.
* Checks whether the next token is the specified character.
*
* @return true - if the next token is a colon
* @return true - if the next is the specified character
* false - otherwise
*/
bool
lexer_check_colon (parser_context_t *context_p) /**< context */
lexer_check_next_character (parser_context_t *context_p, /**< context */
lit_utf8_byte_t character) /**< specified character */
{
lexer_skip_spaces (context_p);
context_p->token.flags = (uint8_t) (context_p->token.flags | LEXER_NO_SKIP_SPACES);
return (context_p->source_p < context_p->source_end_p
&& context_p->source_p[0] == (uint8_t) LIT_CHAR_COLON);
} /* lexer_check_colon */
#ifndef CONFIG_DISABLE_ES2015_CLASS
/**
* Checks whether the next token is a left parenthesis.
*
* @return true - if the next token is a left parenthesis
* false - otherwise
*/
bool
lexer_check_left_paren (parser_context_t *context_p) /**< context */
{
lexer_skip_spaces (context_p);
context_p->token.flags = (uint8_t) (context_p->token.flags | LEXER_NO_SKIP_SPACES);
return (context_p->source_p < context_p->source_end_p
&& context_p->source_p[0] == (uint8_t) LIT_CHAR_LEFT_PAREN);
} /* lexer_check_left_paren */
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
&& context_p->source_p[0] == (uint8_t) character);
} /* lexer_check_next_character */
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION