mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibJS: Moved SharedFunctionInstanceData into separate files
This will allow it to be reused by NativeJavaScriptBackedFunction.
This commit is contained in:
committed by
Andreas Kling
parent
166c8b116f
commit
2d15326f5d
Notes:
github-actions[bot]
2025-11-30 10:56:34 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/2d15326f5d7 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6728 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/awesomekling
@@ -14,6 +14,7 @@
|
||||
#include <LibJS/Runtime/ClassFieldDefinition.h>
|
||||
#include <LibJS/Runtime/ExecutionContext.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/SharedFunctionInstanceData.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
@@ -23,91 +24,6 @@ void async_block_start(VM&, T const& async_body, PromiseCapability const&, Execu
|
||||
template<typename T>
|
||||
void async_function_start(VM&, PromiseCapability const&, T const& async_function_body);
|
||||
|
||||
enum class ThisMode : u8 {
|
||||
Lexical,
|
||||
Strict,
|
||||
Global,
|
||||
};
|
||||
|
||||
enum class ConstructorKind : u8 {
|
||||
Base,
|
||||
Derived,
|
||||
};
|
||||
|
||||
class SharedFunctionInstanceData final : public GC::Cell {
|
||||
GC_CELL(SharedFunctionInstanceData, GC::Cell);
|
||||
GC_DECLARE_ALLOCATOR(SharedFunctionInstanceData);
|
||||
|
||||
public:
|
||||
virtual ~SharedFunctionInstanceData() override;
|
||||
|
||||
SharedFunctionInstanceData(
|
||||
VM& vm,
|
||||
FunctionKind,
|
||||
Utf16FlyString name,
|
||||
i32 function_length,
|
||||
NonnullRefPtr<FunctionParameters const>,
|
||||
NonnullRefPtr<Statement const> ecmascript_code,
|
||||
ByteString source_text,
|
||||
bool strict,
|
||||
bool is_arrow_function,
|
||||
FunctionParsingInsights const&,
|
||||
Vector<LocalVariable> local_variables_names);
|
||||
|
||||
mutable GC::Ptr<Bytecode::Executable> m_executable;
|
||||
|
||||
RefPtr<FunctionParameters const> m_formal_parameters; // [[FormalParameters]]
|
||||
RefPtr<Statement const> m_ecmascript_code; // [[ECMAScriptCode]]
|
||||
|
||||
Utf16FlyString m_name;
|
||||
ByteString m_source_text; // [[SourceText]]
|
||||
|
||||
Vector<LocalVariable> m_local_variables_names;
|
||||
|
||||
i32 m_function_length { 0 };
|
||||
|
||||
ThisMode m_this_mode : 2 { ThisMode::Global }; // [[ThisMode]]
|
||||
FunctionKind m_kind : 3 { FunctionKind::Normal };
|
||||
|
||||
bool m_strict { false };
|
||||
bool m_might_need_arguments_object { true };
|
||||
bool m_contains_direct_call_to_eval { true };
|
||||
bool m_is_arrow_function { false };
|
||||
bool m_has_simple_parameter_list { false };
|
||||
bool m_is_module_wrapper { false };
|
||||
|
||||
struct VariableNameToInitialize {
|
||||
Identifier const& identifier;
|
||||
bool parameter_binding { false };
|
||||
bool function_name { false };
|
||||
};
|
||||
|
||||
bool m_has_parameter_expressions { false };
|
||||
bool m_has_duplicates { false };
|
||||
enum class ParameterIsLocal {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
HashMap<Utf16FlyString, ParameterIsLocal> m_parameter_names;
|
||||
Vector<FunctionDeclaration const&> m_functions_to_initialize;
|
||||
bool m_arguments_object_needed { false };
|
||||
bool m_function_environment_needed { false };
|
||||
bool m_uses_this { false };
|
||||
Vector<VariableNameToInitialize> m_var_names_to_initialize_binding;
|
||||
Vector<Utf16FlyString> m_function_names_to_initialize_binding;
|
||||
|
||||
size_t m_function_environment_bindings_count { 0 };
|
||||
size_t m_var_environment_bindings_count { 0 };
|
||||
size_t m_lex_environment_bindings_count { 0 };
|
||||
|
||||
Variant<PropertyKey, PrivateName, Empty> m_class_field_initializer_name; // [[ClassFieldInitializerName]]
|
||||
ConstructorKind m_constructor_kind : 1 { ConstructorKind::Base }; // [[ConstructorKind]]
|
||||
bool m_is_class_constructor : 1 { false }; // [[IsClassConstructor]]
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
};
|
||||
|
||||
// 10.2 ECMAScript Function Objects, https://tc39.es/ecma262/#sec-ecmascript-function-objects
|
||||
class JS_API ECMAScriptFunctionObject final : public FunctionObject {
|
||||
JS_OBJECT(ECMAScriptFunctionObject, FunctionObject);
|
||||
|
||||
Reference in New Issue
Block a user