1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:07:46 +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

@ -1719,6 +1719,27 @@ private:
NonnullRefPtrVector<VariableDeclarator> m_declarations;
};
class UsingDeclaration final : public Declaration {
public:
UsingDeclaration(SourceRange source_range, NonnullRefPtrVector<VariableDeclarator> declarations)
: Declaration(move(source_range))
, m_declarations(move(declarations))
{
}
virtual Completion execute(Interpreter&) const override;
virtual void dump(int indent) const override;
virtual ThrowCompletionOr<void> for_each_bound_name(ThrowCompletionOrVoidCallback<DeprecatedFlyString const&>&& callback) const override;
virtual bool is_constant_declaration() const override { return true; };
virtual bool is_lexical_declaration() const override { return true; }
private:
NonnullRefPtrVector<VariableDeclarator> m_declarations;
};
class ObjectProperty final : public ASTNode {
public:
enum class Type : u8 {