mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibJS: Start adding a JS::Script class (spec's "Script Record")
This commit is contained in:
parent
619ee99c34
commit
612a23d6fc
Notes:
sideshowbarker
2024-07-18 04:22:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/612a23d6fc1
@ -184,6 +184,7 @@ set(SOURCES
|
|||||||
Runtime/WeakSet.cpp
|
Runtime/WeakSet.cpp
|
||||||
Runtime/WeakSetConstructor.cpp
|
Runtime/WeakSetConstructor.cpp
|
||||||
Runtime/WeakSetPrototype.cpp
|
Runtime/WeakSetPrototype.cpp
|
||||||
|
Script.cpp
|
||||||
SyntaxHighlighter.cpp
|
SyntaxHighlighter.cpp
|
||||||
Token.cpp
|
Token.cpp
|
||||||
)
|
)
|
||||||
|
26
Userland/Libraries/LibJS/Script.cpp
Normal file
26
Userland/Libraries/LibJS/Script.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Script.h>
|
||||||
|
|
||||||
|
namespace JS {
|
||||||
|
|
||||||
|
NonnullRefPtr<Script> Script::create(GlobalObject& global_object, NonnullRefPtr<ASTNode> parse_node)
|
||||||
|
{
|
||||||
|
return adopt_ref(*new Script(global_object, move(parse_node)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Script::Script(GlobalObject& global_object, NonnullRefPtr<ASTNode> parse_node)
|
||||||
|
: m_global_object(make_handle(&global_object))
|
||||||
|
, m_parse_node(move(parse_node))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Script::~Script()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
33
Userland/Libraries/LibJS/Script.h
Normal file
33
Userland/Libraries/LibJS/Script.h
Normal 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user