mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibJS: Implement 'new.target'
This adds a new MetaProperty AST node which will be used for 'new.target' and 'import.meta' meta properties. The parser now distinguishes between "in function context" and "in arrow function context" (which is required for this). When encountering TokenType::New we will attempt to parse it as meta property and resort to regular new expression parsing if that fails, much like the parsing of labelled statements.
This commit is contained in:
parent
e07a39c816
commit
39a1c9d827
6 changed files with 109 additions and 10 deletions
|
@ -81,7 +81,6 @@ public:
|
|||
NonnullRefPtr<WhileStatement> parse_while_statement();
|
||||
NonnullRefPtr<DebuggerStatement> parse_debugger_statement();
|
||||
NonnullRefPtr<ConditionalExpression> parse_conditional_expression(NonnullRefPtr<Expression> test);
|
||||
|
||||
NonnullRefPtr<Expression> parse_expression(int min_precedence, Associativity associate = Associativity::Right, Vector<TokenType> forbidden = {});
|
||||
NonnullRefPtr<Expression> parse_primary_expression();
|
||||
NonnullRefPtr<Expression> parse_unary_prefixed_expression();
|
||||
|
@ -93,13 +92,15 @@ public:
|
|||
NonnullRefPtr<Expression> parse_secondary_expression(NonnullRefPtr<Expression>, int min_precedence, Associativity associate = Associativity::Right);
|
||||
NonnullRefPtr<CallExpression> parse_call_expression(NonnullRefPtr<Expression>);
|
||||
NonnullRefPtr<NewExpression> parse_new_expression();
|
||||
RefPtr<FunctionExpression> try_parse_arrow_function_expression(bool expect_parens);
|
||||
RefPtr<Statement> try_parse_labelled_statement();
|
||||
NonnullRefPtr<ClassDeclaration> parse_class_declaration();
|
||||
NonnullRefPtr<ClassExpression> parse_class_expression(bool expect_class_name);
|
||||
NonnullRefPtr<Expression> parse_property_key();
|
||||
NonnullRefPtr<AssignmentExpression> parse_assignment_expression(AssignmentOp, NonnullRefPtr<Expression> lhs, int min_precedence, Associativity);
|
||||
|
||||
RefPtr<FunctionExpression> try_parse_arrow_function_expression(bool expect_parens);
|
||||
RefPtr<Statement> try_parse_labelled_statement();
|
||||
RefPtr<MetaProperty> try_parse_new_target_expression();
|
||||
|
||||
struct Position {
|
||||
size_t line;
|
||||
size_t column;
|
||||
|
@ -181,6 +182,7 @@ private:
|
|||
bool m_allow_super_property_lookup { false };
|
||||
bool m_allow_super_constructor_call { false };
|
||||
bool m_in_function_context { false };
|
||||
bool m_in_arrow_function_context { false };
|
||||
bool m_in_break_context { false };
|
||||
bool m_in_continue_context { false };
|
||||
bool m_string_legacy_octal_escape_sequence_in_scope { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue