summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime/ErrorConstructor.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-27 18:36:49 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-27 20:26:58 +0200
commit340a115dfe9518eae3d76154fba9092c36526430 (patch)
treeced6db98e45ce6ac110db8e6a2a8ba7d95565cea /Libraries/LibJS/Runtime/ErrorConstructor.cpp
parent1ff9d33131921d97b5de99496f933bcebeb4faaa (diff)
downloadserenity-340a115dfe9518eae3d76154fba9092c36526430.zip
LibJS: Make native function/property callbacks take VM, not Interpreter
More work on decoupling the general runtime from Interpreter. The goal is becoming clearer. Interpreter should be one possible way to execute code inside a VM. In the future we might have other ways :^)
Diffstat (limited to 'Libraries/LibJS/Runtime/ErrorConstructor.cpp')
-rw-r--r--Libraries/LibJS/Runtime/ErrorConstructor.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Libraries/LibJS/Runtime/ErrorConstructor.cpp
index 93915f0f58..939e1294e9 100644
--- a/Libraries/LibJS/Runtime/ErrorConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ErrorConstructor.cpp
@@ -56,38 +56,38 @@ Value ErrorConstructor::construct(Interpreter& interpreter, Function&)
{
String message = "";
if (!interpreter.call_frame().arguments.is_empty() && !interpreter.call_frame().arguments[0].is_undefined()) {
- message = interpreter.call_frame().arguments[0].to_string(interpreter);
+ message = interpreter.call_frame().arguments[0].to_string(global_object());
if (interpreter.exception())
return {};
}
return Error::create(global_object(), "Error", message);
}
-#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
- ConstructorName::ConstructorName(GlobalObject& global_object) \
- : NativeFunction(*global_object.function_prototype()) \
- { \
- } \
- void ConstructorName::initialize(GlobalObject& global_object) \
- { \
- NativeFunction::initialize(global_object); \
- define_property("prototype", global_object.snake_name##_prototype(), 0); \
- define_property("length", Value(1), Attribute::Configurable); \
- } \
- ConstructorName::~ConstructorName() { } \
- Value ConstructorName::call() \
- { \
- return construct(interpreter(), *this); \
- } \
- Value ConstructorName::construct(Interpreter& interpreter, Function&) \
- { \
- String message = ""; \
- if (!interpreter.call_frame().arguments.is_empty() && !interpreter.call_frame().arguments[0].is_undefined()) { \
- message = interpreter.call_frame().arguments[0].to_string(interpreter); \
- if (interpreter.exception()) \
- return {}; \
- } \
- return ClassName::create(global_object(), message); \
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ ConstructorName::ConstructorName(GlobalObject& global_object) \
+ : NativeFunction(*global_object.function_prototype()) \
+ { \
+ } \
+ void ConstructorName::initialize(GlobalObject& global_object) \
+ { \
+ NativeFunction::initialize(global_object); \
+ define_property("prototype", global_object.snake_name##_prototype(), 0); \
+ define_property("length", Value(1), Attribute::Configurable); \
+ } \
+ ConstructorName::~ConstructorName() { } \
+ Value ConstructorName::call() \
+ { \
+ return construct(interpreter(), *this); \
+ } \
+ Value ConstructorName::construct(Interpreter&, Function&) \
+ { \
+ String message = ""; \
+ if (!vm().call_frame().arguments.is_empty() && !vm().call_frame().arguments[0].is_undefined()) { \
+ message = vm().call_frame().arguments[0].to_string(global_object()); \
+ if (vm().exception()) \
+ return {}; \
+ } \
+ return ClassName::create(global_object(), message); \
}
JS_ENUMERATE_ERROR_SUBCLASSES