diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-21 23:41:38 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-21 23:49:50 +0200 |
commit | d407f247b7cf7cf5137db82b492917ad6417ab15 (patch) | |
tree | 528e40989dd8b8aa94ca675bd7500c3056204d6b | |
parent | 5edd259b0a0cea1fae994173fcfbb393f5ee9563 (diff) | |
download | serenity-d407f247b7cf7cf5137db82b492917ad6417ab15.zip |
LibJS: Rename virtuals in EnvironmentRecord
This patch makes the following renames:
- get_from_scope() => get_from_environment_record()
- put_to_scope() => put_into_environment_record()
- delete_from_scope() => delete_from_environment_record()
10 files changed, 32 insertions, 31 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 29c7accf1b..e6d02bde7c 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -853,7 +853,7 @@ Value ClassDeclaration::execute(Interpreter& interpreter, GlobalObject& global_o if (interpreter.exception()) return {}; - interpreter.current_scope()->put_to_scope(m_class_expression->name(), { class_constructor, DeclarationKind::Let }); + interpreter.current_scope()->put_into_environment_record(m_class_expression->name(), { class_constructor, DeclarationKind::Let }); return {}; } diff --git a/Userland/Libraries/LibJS/Interpreter.cpp b/Userland/Libraries/LibJS/Interpreter.cpp index 150daefb44..0e44d25ae7 100644 --- a/Userland/Libraries/LibJS/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Interpreter.cpp @@ -91,7 +91,7 @@ void Interpreter::enter_scope(const ScopeNode& scope_node, ScopeType scope_type, if (scope_type == ScopeType::Function) { push_scope({ scope_type, scope_node, false }); for (auto& declaration : scope_node.functions()) - current_scope()->put_to_scope(declaration.name(), { js_undefined(), DeclarationKind::Var }); + current_scope()->put_into_environment_record(declaration.name(), { js_undefined(), DeclarationKind::Var }); return; } diff --git a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp index 064bddf189..a35e50e7a6 100644 --- a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp +++ b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp @@ -52,17 +52,17 @@ void DeclarativeEnvironmentRecord::visit_edges(Visitor& visitor) visitor.visit(it.value.value); } -Optional<Variable> DeclarativeEnvironmentRecord::get_from_scope(FlyString const& name) const +Optional<Variable> DeclarativeEnvironmentRecord::get_from_environment_record(FlyString const& name) const { return m_variables.get(name); } -void DeclarativeEnvironmentRecord::put_to_scope(FlyString const& name, Variable variable) +void DeclarativeEnvironmentRecord::put_into_environment_record(FlyString const& name, Variable variable) { m_variables.set(name, variable); } -bool DeclarativeEnvironmentRecord::delete_from_scope(FlyString const& name) +bool DeclarativeEnvironmentRecord::delete_from_environment_record(FlyString const& name) { return m_variables.remove(name); } diff --git a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.h b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.h index 43f255c8bf..502f961a77 100644 --- a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.h +++ b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.h @@ -37,9 +37,9 @@ public: virtual ~DeclarativeEnvironmentRecord() override; // ^EnvironmentRecord - virtual Optional<Variable> get_from_scope(FlyString const&) const override; - virtual void put_to_scope(FlyString const&, Variable) override; - virtual bool delete_from_scope(FlyString const&) override; + virtual Optional<Variable> get_from_environment_record(FlyString const&) const override; + virtual void put_into_environment_record(FlyString const&, Variable) override; + virtual bool delete_from_environment_record(FlyString const&) override; virtual bool has_this_binding() const override; virtual Value get_this_binding(GlobalObject&) const override; diff --git a/Userland/Libraries/LibJS/Runtime/EnvironmentRecord.h b/Userland/Libraries/LibJS/Runtime/EnvironmentRecord.h index 976eaa3d23..8f4ce18c55 100644 --- a/Userland/Libraries/LibJS/Runtime/EnvironmentRecord.h +++ b/Userland/Libraries/LibJS/Runtime/EnvironmentRecord.h @@ -19,9 +19,10 @@ class EnvironmentRecord : public Object { JS_OBJECT(EnvironmentRecord, Object); public: - virtual Optional<Variable> get_from_scope(FlyString const&) const = 0; - virtual void put_to_scope(FlyString const&, Variable) = 0; - virtual bool delete_from_scope(FlyString const&) = 0; + virtual Optional<Variable> get_from_environment_record(FlyString const&) const = 0; + virtual void put_into_environment_record(FlyString const&, Variable) = 0; + virtual bool delete_from_environment_record(FlyString const&) = 0; + virtual bool has_this_binding() const = 0; virtual Value get_this_binding(GlobalObject&) const = 0; diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index f0ec0f7426..aada03b332 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -328,7 +328,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_int) return Value(sign * number); } -Optional<Variable> GlobalObject::get_from_scope(const FlyString& name) const +Optional<Variable> GlobalObject::get_from_environment_record(FlyString const& name) const { auto value = get(name); if (value.is_empty()) @@ -336,12 +336,12 @@ Optional<Variable> GlobalObject::get_from_scope(const FlyString& name) const return Variable { value, DeclarationKind::Var }; } -void GlobalObject::put_to_scope(const FlyString& name, Variable variable) +void GlobalObject::put_into_environment_record(FlyString const& name, Variable variable) { put(name, variable.value); } -bool GlobalObject::delete_from_scope(FlyString const& name) +bool GlobalObject::delete_from_environment_record(FlyString const& name) { return delete_property(name); } diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.h b/Userland/Libraries/LibJS/Runtime/GlobalObject.h index 78a5065d9d..a96e9bc550 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.h +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.h @@ -21,9 +21,9 @@ public: virtual ~GlobalObject() override; - virtual Optional<Variable> get_from_scope(FlyString const&) const override; - virtual void put_to_scope(FlyString const&, Variable) override; - virtual bool delete_from_scope(FlyString const&) override; + virtual Optional<Variable> get_from_environment_record(FlyString const&) const override; + virtual void put_into_environment_record(FlyString const&, Variable) override; + virtual bool delete_from_environment_record(FlyString const&) override; virtual bool has_this_binding() const override; virtual Value get_this_binding(GlobalObject&) const override; diff --git a/Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.cpp b/Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.cpp index fb63fa6433..fae58a56f0 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.cpp @@ -21,7 +21,7 @@ void ObjectEnvironmentRecord::visit_edges(Cell::Visitor& visitor) visitor.visit(&m_object); } -Optional<Variable> ObjectEnvironmentRecord::get_from_scope(FlyString const& name) const +Optional<Variable> ObjectEnvironmentRecord::get_from_environment_record(FlyString const& name) const { auto value = m_object.get(name); if (value.is_empty()) @@ -29,12 +29,12 @@ Optional<Variable> ObjectEnvironmentRecord::get_from_scope(FlyString const& name return Variable { value, DeclarationKind::Var }; } -void ObjectEnvironmentRecord::put_to_scope(FlyString const& name, Variable variable) +void ObjectEnvironmentRecord::put_into_environment_record(FlyString const& name, Variable variable) { m_object.put(name, variable.value); } -bool ObjectEnvironmentRecord::delete_from_scope(FlyString const& name) +bool ObjectEnvironmentRecord::delete_from_environment_record(FlyString const& name) { return m_object.delete_property(name); } diff --git a/Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.h b/Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.h index 6949dc7bb8..d19c802691 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.h +++ b/Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.h @@ -16,9 +16,9 @@ class ObjectEnvironmentRecord : public EnvironmentRecord { public: ObjectEnvironmentRecord(Object&, EnvironmentRecord* parent_scope); - virtual Optional<Variable> get_from_scope(FlyString const&) const override; - virtual void put_to_scope(FlyString const&, Variable) override; - virtual bool delete_from_scope(FlyString const&) override; + virtual Optional<Variable> get_from_environment_record(FlyString const&) const override; + virtual void put_into_environment_record(FlyString const&, Variable) override; + virtual bool delete_from_environment_record(FlyString const&) override; virtual bool has_this_binding() const override; virtual Value get_this_binding(GlobalObject&) const override; diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index bc05eaac54..4092a1150d 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -136,7 +136,7 @@ void VM::set_variable(const FlyString& name, Value value, GlobalObject& global_o Optional<Variable> possible_match; if (!specific_scope && m_call_stack.size()) { for (auto* environment_record = current_scope(); environment_record; environment_record = environment_record->outer_environment()) { - possible_match = environment_record->get_from_scope(name); + possible_match = environment_record->get_from_environment_record(name); if (possible_match.has_value()) { specific_scope = environment_record; break; @@ -150,12 +150,12 @@ void VM::set_variable(const FlyString& name, Value value, GlobalObject& global_o return; } - specific_scope->put_to_scope(name, { value, possible_match.value().declaration_kind }); + specific_scope->put_into_environment_record(name, { value, possible_match.value().declaration_kind }); return; } if (specific_scope) { - specific_scope->put_to_scope(name, { value, DeclarationKind::Var }); + specific_scope->put_into_environment_record(name, { value, DeclarationKind::Var }); return; } @@ -168,7 +168,7 @@ bool VM::delete_variable(FlyString const& name) Optional<Variable> possible_match; if (!m_call_stack.is_empty()) { for (auto* environment_record = current_scope(); environment_record; environment_record = environment_record->outer_environment()) { - possible_match = environment_record->get_from_scope(name); + possible_match = environment_record->get_from_environment_record(name); if (possible_match.has_value()) { specific_scope = environment_record; break; @@ -182,7 +182,7 @@ bool VM::delete_variable(FlyString const& name) return false; VERIFY(specific_scope); - return specific_scope->delete_from_scope(name); + return specific_scope->delete_from_environment_record(name); } void VM::assign(const FlyString& target, Value value, GlobalObject& global_object, bool first_assignment, EnvironmentRecord* specific_scope) @@ -363,7 +363,7 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object) // a function parameter, or by a local var declaration, we use that. // Otherwise, we return a lazily constructed Array with all the argument values. // FIXME: Do something much more spec-compliant. - auto possible_match = current_scope()->get_from_scope(name); + auto possible_match = current_scope()->get_from_environment_record(name); if (possible_match.has_value()) return possible_match.value().value; if (!call_frame().arguments_object) { @@ -377,7 +377,7 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object) } for (auto* environment_record = current_scope(); environment_record; environment_record = environment_record->outer_environment()) { - auto possible_match = environment_record->get_from_scope(name); + auto possible_match = environment_record->get_from_environment_record(name); if (exception()) return {}; if (possible_match.has_value()) @@ -396,7 +396,7 @@ Reference VM::get_reference(const FlyString& name) for (auto* environment_record = current_scope(); environment_record; environment_record = environment_record->outer_environment()) { if (is<GlobalObject>(environment_record)) break; - auto possible_match = environment_record->get_from_scope(name); + auto possible_match = environment_record->get_from_environment_record(name); if (possible_match.has_value()) return { Reference::LocalVariable, name }; } |