summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-03-16 09:09:56 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-16 10:08:07 +0100
commitdadf2e8251389f048b246fd23d5557308d16fedb (patch)
treefc3486ee6c17107e296263f82b02517e94ecefb4 /Userland
parentef3679f9c391b088598279fd0c77e1abcddfc15f (diff)
downloadserenity-dadf2e8251389f048b246fd23d5557308d16fedb.zip
LibJS: Make Interpreter::run() a void function
With one small exception, this is how we've been using this API already, and it makes sense: a Program is just a ScopeNode with any number of statements, which are executed one by one. There's no explicit return value at the end, only a completion value of the last value-producing statement, which we then access using VM::last_value() if needed (e.g. in the REPL).
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Interpreter.cpp5
-rw-r--r--Userland/Libraries/LibJS/Interpreter.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp9
3 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/Interpreter.cpp b/Userland/Libraries/LibJS/Interpreter.cpp
index 3fcdc00852..132bfa32f5 100644
--- a/Userland/Libraries/LibJS/Interpreter.cpp
+++ b/Userland/Libraries/LibJS/Interpreter.cpp
@@ -54,7 +54,7 @@ Interpreter::~Interpreter()
{
}
-Value Interpreter::run(GlobalObject& global_object, const Program& program)
+void Interpreter::run(GlobalObject& global_object, const Program& program)
{
auto& vm = this->vm();
VERIFY(!vm.exception());
@@ -71,9 +71,8 @@ Value Interpreter::run(GlobalObject& global_object, const Program& program)
global_call_frame.is_strict_mode = program.is_strict_mode();
vm.push_call_frame(global_call_frame, global_object);
VERIFY(!vm.exception());
- auto result = program.execute(*this, global_object);
+ program.execute(*this, global_object);
vm.pop_call_frame();
- return result;
}
GlobalObject& Interpreter::global_object()
diff --git a/Userland/Libraries/LibJS/Interpreter.h b/Userland/Libraries/LibJS/Interpreter.h
index f32e4e1ccb..b84b980662 100644
--- a/Userland/Libraries/LibJS/Interpreter.h
+++ b/Userland/Libraries/LibJS/Interpreter.h
@@ -61,7 +61,7 @@ public:
~Interpreter();
- Value run(GlobalObject&, const Program&);
+ void run(GlobalObject&, const Program&);
GlobalObject& global_object();
const GlobalObject& global_object() const;
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index ca319f175e..2bb381b152 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -555,10 +555,11 @@ JS::Value Document::run_javascript(const StringView& source, const StringView& f
return JS::js_undefined();
}
auto& interpreter = document().interpreter();
- auto result = interpreter.run(interpreter.global_object(), *program);
- if (interpreter.exception())
- interpreter.vm().clear_exception();
- return result;
+ auto& vm = interpreter.vm();
+ interpreter.run(interpreter.global_object(), *program);
+ if (vm.exception())
+ vm.clear_exception();
+ return vm.last_value();
}
// https://dom.spec.whatwg.org/#dom-document-createelement