1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:28:11 +00:00

LibJS: Start adding a JS::Script class (spec's "Script Record")

This commit is contained in:
Andreas Kling 2021-09-09 18:02:31 +02:00
parent 619ee99c34
commit 612a23d6fc
3 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <LibJS/AST.h>
#include <LibJS/Heap/Handle.h>
#include <LibJS/Runtime/GlobalObject.h>
namespace JS {
// 16.1.4 Script Records, https://tc39.es/ecma262/#sec-script-records
class Script : public RefCounted<Script> {
public:
~Script();
static NonnullRefPtr<Script> create(GlobalObject&, NonnullRefPtr<ASTNode> parse_node);
GlobalObject& global_object() { return *m_global_object.cell(); }
ASTNode const& parse_node() const { return *m_parse_node; }
private:
Script(GlobalObject&, NonnullRefPtr<ASTNode>);
Handle<GlobalObject> m_global_object;
NonnullRefPtr<ASTNode> m_parse_node;
};
}