فهرست منبع

LibJS: Don't require Interpreter& for constructing an Accessor

Andreas Kling 4 سال پیش
والد
کامیت
a61ede51e2
3فایلهای تغییر یافته به همراه8 افزوده شده و 8 حذف شده
  1. 5 5
      Libraries/LibJS/Runtime/Accessor.h
  2. 1 1
      Libraries/LibJS/Runtime/IndexedProperties.cpp
  3. 2 2
      Libraries/LibJS/Runtime/Object.cpp

+ 5 - 5
Libraries/LibJS/Runtime/Accessor.h

@@ -27,16 +27,16 @@
 
 #pragma once
 
-#include <LibJS/Interpreter.h>
 #include <LibJS/Runtime/Function.h>
+#include <LibJS/Runtime/VM.h>
 
 namespace JS {
 
 class Accessor final : public Cell {
 public:
-    static Accessor* create(Interpreter& interpreter, Function* getter, Function* setter)
+    static Accessor* create(VM& vm, Function* getter, Function* setter)
     {
-        return interpreter.heap().allocate_without_global_object<Accessor>(getter, setter);
+        return vm.heap().allocate_without_global_object<Accessor>(getter, setter);
     }
 
     Accessor(Function* getter, Function* setter)
@@ -55,7 +55,7 @@ public:
     {
         if (!m_getter)
             return js_undefined();
-        return interpreter().call(*m_getter, this_value);
+        return vm().call(*m_getter, this_value);
     }
 
     void call_setter(Value this_value, Value setter_value)
@@ -63,7 +63,7 @@ public:
         if (!m_setter)
             return;
         // FIXME: It might be nice if we had a way to communicate to our caller if an exception happened after this.
-        (void)interpreter().call(*m_setter, this_value, setter_value);
+        (void)vm().call(*m_setter, this_value, setter_value);
     }
 
     void visit_children(Cell::Visitor& visitor) override

+ 1 - 1
Libraries/LibJS/Runtime/IndexedProperties.cpp

@@ -341,7 +341,7 @@ void IndexedProperties::append_all(Object* this_object, const IndexedProperties&
 
     for (auto it = properties.begin(false); it != properties.end(); ++it) {
         const auto& element = it.value_and_attributes(this_object, evaluate_accessors);
-        if (this_object && this_object->interpreter().exception())
+        if (this_object && this_object->vm().exception())
             return;
         m_storage->put(m_storage->array_like_size(), element.value, element.attributes);
     }

+ 2 - 2
Libraries/LibJS/Runtime/Object.cpp

@@ -392,7 +392,7 @@ bool Object::define_property(const StringOrSymbol& property_name, const Object&
               << "setter=" << setter.to_string_without_side_effects() << "}";
 #endif
 
-        return define_property(property_name, Accessor::create(interpreter(), getter_function, setter_function), attributes, throw_exceptions);
+        return define_property(property_name, Accessor::create(vm(), getter_function, setter_function), attributes, throw_exceptions);
     }
 
     auto value = descriptor.get("value");
@@ -438,7 +438,7 @@ bool Object::define_accessor(const PropertyName& property_name, Function& getter
             accessor = &existing_property.as_accessor();
     }
     if (!accessor) {
-        accessor = Accessor::create(interpreter(), nullptr, nullptr);
+        accessor = Accessor::create(vm(), nullptr, nullptr);
         bool definition_success = define_property(property_name, accessor, attributes, throw_exceptions);
         if (vm().exception())
             return {};