mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
631bbcd00a
This also refactors interpreter creation to follow InitializeHostDefinedRealm, but I couldn't fit it in the title :^) This allows us to follow the spec much more closely rather than being completely ad-hoc with just the parse node instead of having all the surrounding data such as the realm of the parse node. The interpreter creation refactor creates the global execution context once and doesn't take it off the stack. This allows LibWeb to take the global execution context and manually handle it, following the HTML spec. The HTML spec calls this the "realm execution context" of the environment settings object. It also allows us to specify the globalThis type, as it can be different from the global object type. For example, on the web, Window global objects use a WindowProxy global this value to enforce the same origin policy on operations like [[GetOwnProperty]]. Finally, it allows us to directly call Program::execute in perform_eval and perform_shadow_realm_eval as this moves global_declaration_instantiation into Interpreter::run (ScriptEvaluation) as per the spec. Note that this doesn't evalulate Source Text Modules yet or refactor the bytecode interpreter, that's work for future us :^) This patch was originally build by Luke for the environment settings object change but was also needed for modules. So I (davidot) have modified it with the new completion changes and setup for that. Co-authored-by: davidot <davidot@serenityos.org>
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "Forward.h"
|
|
#include <LibJS/Forward.h>
|
|
#include <LibJS/Runtime/Completion.h>
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
namespace Spreadsheet {
|
|
|
|
struct FunctionAndArgumentIndex {
|
|
String function_name;
|
|
size_t argument_index { 0 };
|
|
};
|
|
Optional<FunctionAndArgumentIndex> get_function_and_argument_index(StringView source);
|
|
|
|
class SheetGlobalObject final : public JS::GlobalObject {
|
|
JS_OBJECT(SheetGlobalObject, JS::GlobalObject);
|
|
|
|
public:
|
|
SheetGlobalObject(Sheet&);
|
|
|
|
virtual ~SheetGlobalObject() override;
|
|
|
|
virtual JS::ThrowCompletionOr<bool> internal_has_property(JS::PropertyKey const& name) const override;
|
|
virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyKey const&, JS::Value receiver) const override;
|
|
virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override;
|
|
virtual void initialize_global_object() override;
|
|
|
|
JS_DECLARE_NATIVE_FUNCTION(get_real_cell_contents);
|
|
JS_DECLARE_NATIVE_FUNCTION(set_real_cell_contents);
|
|
JS_DECLARE_NATIVE_FUNCTION(parse_cell_name);
|
|
JS_DECLARE_NATIVE_FUNCTION(current_cell_position);
|
|
JS_DECLARE_NATIVE_FUNCTION(column_index);
|
|
JS_DECLARE_NATIVE_FUNCTION(column_arithmetic);
|
|
JS_DECLARE_NATIVE_FUNCTION(get_column_bound);
|
|
|
|
private:
|
|
virtual void visit_edges(Visitor&) override;
|
|
Sheet& m_sheet;
|
|
};
|
|
|
|
class WorkbookObject final : public JS::Object {
|
|
JS_OBJECT(WorkbookObject, JS::Object);
|
|
|
|
public:
|
|
WorkbookObject(Workbook&, JS::GlobalObject&);
|
|
|
|
virtual ~WorkbookObject() override;
|
|
|
|
virtual void initialize(JS::GlobalObject&) override;
|
|
|
|
JS_DECLARE_NATIVE_FUNCTION(sheet);
|
|
|
|
private:
|
|
virtual void visit_edges(Visitor&) override;
|
|
Workbook& m_workbook;
|
|
};
|
|
|
|
}
|