1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:17:35 +00:00

LibJS: Add using declaration support, RAII like operation in js

In this patch only top level and not the more complicated for loop using
statements are supported. Also, as noted in the latest meeting of tc39
async parts of the spec are not stage 3 thus not included.
This commit is contained in:
davidot 2022-12-20 22:09:57 +01:00 committed by Linus Groh
parent 2c87ff2218
commit 541637e15a
15 changed files with 861 additions and 68 deletions

View file

@ -88,7 +88,15 @@ public:
NonnullRefPtr<BlockStatement> parse_block_statement();
NonnullRefPtr<FunctionBody> parse_function_body(Vector<FunctionParameter> const& parameters, FunctionKind function_kind, bool& contains_direct_call_to_eval);
NonnullRefPtr<ReturnStatement> parse_return_statement();
NonnullRefPtr<VariableDeclaration> parse_variable_declaration(bool for_loop_variable_declaration = false);
enum class IsForLoopVariableDeclaration {
No,
Yes
};
NonnullRefPtr<VariableDeclaration> parse_variable_declaration(IsForLoopVariableDeclaration is_for_loop_variable_declaration = IsForLoopVariableDeclaration::No);
RefPtr<Identifier> parse_lexical_binding();
NonnullRefPtr<UsingDeclaration> parse_using_declaration(IsForLoopVariableDeclaration is_for_loop_variable_declaration = IsForLoopVariableDeclaration::No);
NonnullRefPtr<Statement> parse_for_statement();
enum class IsForAwaitLoop {
@ -208,8 +216,15 @@ private:
bool match_statement() const;
bool match_export_or_import() const;
bool match_assert_clause() const;
bool match_declaration() const;
enum class AllowUsingDeclaration {
No,
Yes
};
bool match_declaration(AllowUsingDeclaration allow_using = AllowUsingDeclaration::No) const;
bool try_match_let_declaration() const;
bool try_match_using_declaration() const;
bool match_variable_declaration() const;
bool match_identifier() const;
bool match_identifier_name() const;