mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Remove Interpreter::call()
Just use VM::call() directly everywhere.
This commit is contained in:
parent
ec55490198
commit
94b95a4924
Notes:
sideshowbarker
2024-07-19 02:03:25 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/94b95a49244
4 changed files with 6 additions and 36 deletions
|
@ -249,7 +249,7 @@ RefPtr<Sheet> Sheet::from_json(const JsonObject& object, Workbook& workbook)
|
|||
break;
|
||||
case Cell::Formula: {
|
||||
auto& interpreter = sheet->interpreter();
|
||||
auto value = interpreter.call(parse_function, json, JS::js_string(interpreter.heap(), obj.get("value").as_string()));
|
||||
auto value = interpreter.vm().call(parse_function, json, JS::js_string(interpreter.heap(), obj.get("value").as_string()));
|
||||
cell = make<Cell>(obj.get("source").to_string(), move(value), position, sheet->make_weak_ptr());
|
||||
break;
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ JsonObject Sheet::to_json() const
|
|||
if (it.value->kind == Cell::Formula) {
|
||||
data.set("source", it.value->data);
|
||||
auto json = interpreter().global_object().get("JSON");
|
||||
auto stringified = interpreter().call(json.as_object().get("stringify").as_function(), json, it.value->evaluated_data);
|
||||
auto stringified = interpreter().vm().call(json.as_object().get("stringify").as_function(), json, it.value->evaluated_data);
|
||||
data.set("value", stringified.to_string_without_side_effects());
|
||||
} else {
|
||||
data.set("value", it.value->data);
|
||||
|
|
|
@ -215,7 +215,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj
|
|||
|
||||
interpreter.current_environment()->bind_this_value(global_object, result);
|
||||
} else {
|
||||
result = interpreter.call(function, this_value, move(arguments));
|
||||
result = interpreter.vm().call(function, this_value, move(arguments));
|
||||
}
|
||||
|
||||
if (interpreter.exception())
|
||||
|
@ -1760,7 +1760,7 @@ Value TaggedTemplateLiteral::execute(Interpreter& interpreter, GlobalObject& glo
|
|||
raw_strings->indexed_properties().append(value);
|
||||
}
|
||||
strings->define_property("raw", raw_strings, 0);
|
||||
return interpreter.call(tag_function, js_undefined(), move(arguments));
|
||||
return interpreter.vm().call(tag_function, js_undefined(), move(arguments));
|
||||
}
|
||||
|
||||
void TryStatement::dump(int indent) const
|
||||
|
|
|
@ -59,21 +59,6 @@ public:
|
|||
|
||||
static NonnullOwnPtr<Interpreter> create_with_existing_global_object(GlobalObject&);
|
||||
|
||||
template<typename... Args>
|
||||
[[nodiscard]] ALWAYS_INLINE Value call(Function& function, Value this_value, Args... args)
|
||||
{
|
||||
// Are there any values in this argpack?
|
||||
// args = [] -> if constexpr (false)
|
||||
// args = [x, y, z] -> if constexpr ((void)x, true || ...)
|
||||
if constexpr ((((void)args, true) || ...)) {
|
||||
MarkedValueList arglist { heap() };
|
||||
(..., arglist.append(move(args)));
|
||||
return call(function, this_value, move(arglist));
|
||||
}
|
||||
|
||||
return call(function, this_value);
|
||||
}
|
||||
|
||||
~Interpreter();
|
||||
|
||||
Value run(GlobalObject&, const Program&);
|
||||
|
@ -90,7 +75,6 @@ public:
|
|||
Value argument(size_t index) const { return vm().argument(index); }
|
||||
Value this_value(Object& global_object) const { return vm().this_value(global_object); }
|
||||
LexicalEnvironment* current_environment() { return vm().current_environment(); }
|
||||
const CallFrame& call_frame() { return vm().call_frame(); }
|
||||
|
||||
void enter_scope(const ScopeNode&, ArgumentVector, ScopeType, GlobalObject&);
|
||||
void exit_scope(const ScopeNode&);
|
||||
|
@ -100,11 +84,6 @@ public:
|
|||
private:
|
||||
explicit Interpreter(VM&);
|
||||
|
||||
[[nodiscard]] Value call_internal(Function& function, Value this_value, Optional<MarkedValueList> arguments)
|
||||
{
|
||||
return vm().call(function, this_value, move(arguments));
|
||||
}
|
||||
|
||||
void push_scope(ScopeFrame frame);
|
||||
|
||||
Vector<ScopeFrame> m_scope_stack;
|
||||
|
@ -114,13 +93,4 @@ private:
|
|||
Handle<Object> m_global_object;
|
||||
};
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Interpreter::call(Function& function, Value this_value, MarkedValueList arguments) { return call_internal(function, this_value, move(arguments)); }
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Interpreter::call(Function& function, Value this_value, Optional<MarkedValueList> arguments) { return call_internal(function, this_value, move(arguments)); }
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Interpreter::call(Function& function, Value this_value) { return call(function, this_value, Optional<MarkedValueList> {}); }
|
||||
|
||||
}
|
||||
|
|
|
@ -363,7 +363,7 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
new_interpreter.run(new_interpreter.global_object(), *file_program.value());
|
||||
|
||||
auto& before_initial_page_load = new_interpreter.vm().get_variable("__BeforeInitialPageLoad__", new_interpreter.global_object()).as_function();
|
||||
(void)new_interpreter.call(before_initial_page_load, JS::js_undefined());
|
||||
(void)new_interpreter.vm().call(before_initial_page_load, JS::js_undefined());
|
||||
if (new_interpreter.exception())
|
||||
new_interpreter.vm().clear_exception();
|
||||
|
||||
|
@ -373,7 +373,7 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
|
||||
// Finally run the test by calling "__AfterInitialPageLoad__"
|
||||
auto& after_initial_page_load = new_interpreter.vm().get_variable("__AfterInitialPageLoad__", new_interpreter.global_object()).as_function();
|
||||
(void)new_interpreter.call(after_initial_page_load, JS::js_undefined());
|
||||
(void)new_interpreter.vm().call(after_initial_page_load, JS::js_undefined());
|
||||
if (new_interpreter.exception())
|
||||
new_interpreter.vm().clear_exception();
|
||||
|
||||
|
|
Loading…
Reference in a new issue