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:
committed by
Akos Kiss
parent
e0e6363f85
commit
d1860d0e34
@@ -14,10 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "js-parser-internal.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS
|
||||
#include "lit-char-helpers.h"
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
|
||||
#ifndef JERRY_DISABLE_JS_PARSER
|
||||
|
||||
@@ -75,6 +72,7 @@ typedef enum
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TEMPLATE_STRINGS */
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
SCAN_STACK_CLASS, /**< class language element */
|
||||
SCAN_STACK_CLASS_EXTENDS, /**< class extends expression */
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
} scan_stack_modes_t;
|
||||
|
||||
@@ -335,6 +333,9 @@ parser_scan_primary_expression_end (parser_context_t *context_p, /**< context */
|
||||
|
||||
if ((type == LEXER_RIGHT_SQUARE && stack_top == SCAN_STACK_SQUARE_BRACKETED_EXPRESSION)
|
||||
|| (type == LEXER_RIGHT_PAREN && stack_top == SCAN_STACK_PAREN_EXPRESSION)
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
|| (type == LEXER_LEFT_BRACE && stack_top == SCAN_STACK_CLASS_EXTENDS)
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
|| (type == LEXER_RIGHT_BRACE && stack_top == SCAN_STACK_OBJECT_LITERAL))
|
||||
{
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
@@ -345,6 +346,12 @@ parser_scan_primary_expression_end (parser_context_t *context_p, /**< context */
|
||||
*mode = SCAN_MODE_ARROW_FUNCTION;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
|
||||
#ifndef CONFIG_DISABLE_ES2015_CLASS
|
||||
if (stack_top == SCAN_STACK_CLASS_EXTENDS)
|
||||
{
|
||||
*mode = SCAN_MODE_CLASS_METHOD;
|
||||
}
|
||||
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -699,8 +706,13 @@ parser_scan_until (parser_context_t *context_p, /**< context */
|
||||
lexer_next_token (context_p);
|
||||
}
|
||||
|
||||
/* Currently heritage is not supported so the next token must be left brace. */
|
||||
if (context_p->token.type != LEXER_LEFT_BRACE)
|
||||
if (context_p->token.type == LEXER_KEYW_EXTENDS)
|
||||
{
|
||||
parser_stack_push_uint8 (context_p, SCAN_STACK_CLASS_EXTENDS);
|
||||
mode = SCAN_MODE_PRIMARY_EXPRESSION;
|
||||
break;
|
||||
}
|
||||
else if (context_p->token.type != LEXER_LEFT_BRACE)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_LEFT_BRACE_EXPECTED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user