From 44221756ab7515617450400bf23d0e8df486c2b7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 1 Jul 2021 12:24:46 +0200 Subject: LibJS: Drop "Record" suffix from all the *Environment record classes "Records" in the spec are basically C++ classes, so let's drop this mouthful of a suffix. --- Userland/Libraries/LibJS/AST.cpp | 18 +- Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 6 +- Userland/Libraries/LibJS/Bytecode/Instruction.h | 126 ++++++------ Userland/Libraries/LibJS/Bytecode/Interpreter.cpp | 6 +- Userland/Libraries/LibJS/Bytecode/Op.cpp | 16 +- Userland/Libraries/LibJS/Bytecode/Op.h | 8 +- Userland/Libraries/LibJS/CMakeLists.txt | 10 +- Userland/Libraries/LibJS/Forward.h | 10 +- Userland/Libraries/LibJS/Heap/Cell.h | 2 +- Userland/Libraries/LibJS/Interpreter.cpp | 26 +-- Userland/Libraries/LibJS/Interpreter.h | 6 +- .../Libraries/LibJS/Runtime/AbstractOperations.cpp | 26 +-- .../Libraries/LibJS/Runtime/AbstractOperations.h | 8 +- Userland/Libraries/LibJS/Runtime/BoundFunction.cpp | 4 +- Userland/Libraries/LibJS/Runtime/BoundFunction.h | 2 +- .../LibJS/Runtime/DeclarativeEnvironment.cpp | 158 +++++++++++++++ .../LibJS/Runtime/DeclarativeEnvironment.h | 61 ++++++ .../LibJS/Runtime/DeclarativeEnvironmentRecord.cpp | 158 --------------- .../LibJS/Runtime/DeclarativeEnvironmentRecord.h | 61 ------ Userland/Libraries/LibJS/Runtime/Environment.cpp | 29 +++ Userland/Libraries/LibJS/Runtime/Environment.h | 72 +++++++ .../Libraries/LibJS/Runtime/EnvironmentRecord.cpp | 29 --- .../Libraries/LibJS/Runtime/EnvironmentRecord.h | 72 ------- .../LibJS/Runtime/FunctionEnvironment.cpp | 83 ++++++++ .../Libraries/LibJS/Runtime/FunctionEnvironment.h | 66 +++++++ .../LibJS/Runtime/FunctionEnvironmentRecord.cpp | 83 -------- .../LibJS/Runtime/FunctionEnvironmentRecord.h | 66 ------- Userland/Libraries/LibJS/Runtime/FunctionObject.h | 4 +- .../Libraries/LibJS/Runtime/GeneratorObject.cpp | 8 +- Userland/Libraries/LibJS/Runtime/GeneratorObject.h | 4 +- .../Libraries/LibJS/Runtime/GlobalEnvironment.cpp | 214 +++++++++++++++++++++ .../Libraries/LibJS/Runtime/GlobalEnvironment.h | 61 ++++++ .../LibJS/Runtime/GlobalEnvironmentRecord.cpp | 214 --------------------- .../LibJS/Runtime/GlobalEnvironmentRecord.h | 61 ------ Userland/Libraries/LibJS/Runtime/GlobalObject.cpp | 6 +- Userland/Libraries/LibJS/Runtime/GlobalObject.h | 6 +- .../Libraries/LibJS/Runtime/NativeFunction.cpp | 2 +- Userland/Libraries/LibJS/Runtime/NativeFunction.h | 2 +- .../Libraries/LibJS/Runtime/ObjectEnvironment.cpp | 116 +++++++++++ .../Libraries/LibJS/Runtime/ObjectEnvironment.h | 56 ++++++ .../LibJS/Runtime/ObjectEnvironmentRecord.cpp | 116 ----------- .../LibJS/Runtime/ObjectEnvironmentRecord.h | 56 ------ .../LibJS/Runtime/OrdinaryFunctionObject.cpp | 14 +- .../LibJS/Runtime/OrdinaryFunctionObject.h | 10 +- Userland/Libraries/LibJS/Runtime/ProxyObject.cpp | 4 +- Userland/Libraries/LibJS/Runtime/ProxyObject.h | 2 +- Userland/Libraries/LibJS/Runtime/Reference.cpp | 16 +- Userland/Libraries/LibJS/Runtime/Reference.h | 20 +- Userland/Libraries/LibJS/Runtime/VM.cpp | 70 +++---- Userland/Libraries/LibJS/Runtime/VM.h | 24 +-- 50 files changed, 1149 insertions(+), 1149 deletions(-) create mode 100644 Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp create mode 100644 Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.h delete mode 100644 Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.cpp delete mode 100644 Userland/Libraries/LibJS/Runtime/DeclarativeEnvironmentRecord.h create mode 100644 Userland/Libraries/LibJS/Runtime/Environment.cpp create mode 100644 Userland/Libraries/LibJS/Runtime/Environment.h delete mode 100644 Userland/Libraries/LibJS/Runtime/EnvironmentRecord.cpp delete mode 100644 Userland/Libraries/LibJS/Runtime/EnvironmentRecord.h create mode 100644 Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp create mode 100644 Userland/Libraries/LibJS/Runtime/FunctionEnvironment.h delete mode 100644 Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.cpp delete mode 100644 Userland/Libraries/LibJS/Runtime/FunctionEnvironmentRecord.h create mode 100644 Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp create mode 100644 Userland/Libraries/LibJS/Runtime/GlobalEnvironment.h delete mode 100644 Userland/Libraries/LibJS/Runtime/GlobalEnvironmentRecord.cpp delete mode 100644 Userland/Libraries/LibJS/Runtime/GlobalEnvironmentRecord.h create mode 100644 Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp create mode 100644 Userland/Libraries/LibJS/Runtime/ObjectEnvironment.h delete mode 100644 Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.cpp delete mode 100644 Userland/Libraries/LibJS/Runtime/ObjectEnvironmentRecord.h (limited to 'Userland') diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index dd32e7f7c2..66d90aa2bf 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -19,12 +19,12 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #include #include #include @@ -133,7 +133,7 @@ CallExpression::ThisAndCallee CallExpression::compute_this_and_callee(Interprete Value this_value; if (is(member_expression.object())) { - auto super_base = interpreter.current_function_environment_record()->get_super_base(); + auto super_base = interpreter.current_function_environment()->get_super_base(); if (super_base.is_nullish()) { vm.throw_exception(global_object, ErrorType::ObjectPrototypeNullOrUndefinedOnSuperPropertyAccess, super_base.to_string_without_side_effects()); return {}; @@ -242,7 +242,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj return {}; auto& this_er = get_this_environment(interpreter.vm()); - verify_cast(this_er).bind_this_value(global_object, result); + verify_cast(this_er).bind_this_value(global_object, result); } else { result = vm.call(function, this_value, move(arguments)); } @@ -305,8 +305,8 @@ Value WithStatement::execute(Interpreter& interpreter, GlobalObject& global_obje VERIFY(object); - auto* object_environment_record = new_object_environment(*object, true, interpreter.vm().running_execution_context().lexical_environment); - TemporaryChange scope_change(interpreter.vm().running_execution_context().lexical_environment, object_environment_record); + auto* object_environment = new_object_environment(*object, true, interpreter.vm().running_execution_context().lexical_environment); + TemporaryChange scope_change(interpreter.vm().running_execution_context().lexical_environment, object_environment); return interpreter.execute_statement(global_object, m_body).value_or(js_undefined()); } @@ -854,7 +854,7 @@ Value ClassDeclaration::execute(Interpreter& interpreter, GlobalObject& global_o if (interpreter.exception()) return {}; - interpreter.lexical_environment()->put_into_environment_record(m_class_expression->name(), { class_constructor, DeclarationKind::Let }); + interpreter.lexical_environment()->put_into_environment(m_class_expression->name(), { class_constructor, DeclarationKind::Let }); return {}; } @@ -2049,8 +2049,8 @@ Value TryStatement::execute(Interpreter& interpreter, GlobalObject& global_objec HashMap parameters; parameters.set(m_handler->parameter(), Variable { exception->value(), DeclarationKind::Var }); - auto* catch_scope = interpreter.heap().allocate(global_object, move(parameters), interpreter.vm().running_execution_context().lexical_environment); - TemporaryChange scope_change(interpreter.vm().running_execution_context().lexical_environment, catch_scope); + auto* catch_scope = interpreter.heap().allocate(global_object, move(parameters), interpreter.vm().running_execution_context().lexical_environment); + TemporaryChange scope_change(interpreter.vm().running_execution_context().lexical_environment, catch_scope); result = interpreter.execute_statement(global_object, m_handler->body()); } } diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 0c9232c39f..7f02bb0d56 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace JS { @@ -63,7 +63,7 @@ void ScopeNode::generate_bytecode(Bytecode::Generator& generator) const } if (!scope_variables_with_declaration_kind.is_empty()) { - generator.emit(move(scope_variables_with_declaration_kind)); + generator.emit(move(scope_variables_with_declaration_kind)); } for (auto& child : children()) { @@ -1214,7 +1214,7 @@ void TryStatement::generate_bytecode(Bytecode::Generator& generator) const if (!m_finalizer) generator.emit(); if (!m_handler->parameter().is_empty()) { - // FIXME: We need a separate DeclarativeEnvironmentRecord here + // FIXME: We need a separate DeclarativeEnvironment here generator.emit(generator.intern_string(m_handler->parameter())); } m_handler->body().generate_bytecode(generator); diff --git a/Userland/Libraries/LibJS/Bytecode/Instruction.h b/Userland/Libraries/LibJS/Bytecode/Instruction.h index 8c0e9289dc..2064c4a2b1 100644 --- a/Userland/Libraries/LibJS/Bytecode/Instruction.h +++ b/Userland/Libraries/LibJS/Bytecode/Instruction.h @@ -9,69 +9,69 @@ #include #include -#define ENUMERATE_BYTECODE_OPS(O) \ - O(Load) \ - O(LoadImmediate) \ - O(Store) \ - O(Add) \ - O(Sub) \ - O(Mul) \ - O(Div) \ - O(Mod) \ - O(Exp) \ - O(GreaterThan) \ - O(GreaterThanEquals) \ - O(LessThan) \ - O(LessThanEquals) \ - O(AbstractInequals) \ - O(AbstractEquals) \ - O(TypedInequals) \ - O(TypedEquals) \ - O(NewBigInt) \ - O(NewArray) \ - O(IteratorToArray) \ - O(NewString) \ - O(NewObject) \ - O(NewRegExp) \ - O(CopyObjectExcludingProperties) \ - O(GetVariable) \ - O(SetVariable) \ - O(PutById) \ - O(GetById) \ - O(PutByValue) \ - O(GetByValue) \ - O(Jump) \ - O(JumpConditional) \ - O(JumpNullish) \ - O(JumpUndefined) \ - O(Call) \ - O(NewFunction) \ - O(Return) \ - O(BitwiseAnd) \ - O(BitwiseOr) \ - O(BitwiseXor) \ - O(BitwiseNot) \ - O(Not) \ - O(UnaryPlus) \ - O(UnaryMinus) \ - O(Typeof) \ - O(LeftShift) \ - O(RightShift) \ - O(UnsignedRightShift) \ - O(In) \ - O(InstanceOf) \ - O(ConcatString) \ - O(Increment) \ - O(Decrement) \ - O(Throw) \ - O(PushDeclarativeEnvironmentRecord) \ - O(EnterUnwindContext) \ - O(LeaveUnwindContext) \ - O(ContinuePendingUnwind) \ - O(Yield) \ - O(GetIterator) \ - O(IteratorNext) \ - O(IteratorResultDone) \ +#define ENUMERATE_BYTECODE_OPS(O) \ + O(Load) \ + O(LoadImmediate) \ + O(Store) \ + O(Add) \ + O(Sub) \ + O(Mul) \ + O(Div) \ + O(Mod) \ + O(Exp) \ + O(GreaterThan) \ + O(GreaterThanEquals) \ + O(LessThan) \ + O(LessThanEquals) \ + O(AbstractInequals) \ + O(AbstractEquals) \ + O(TypedInequals) \ + O(TypedEquals) \ + O(NewBigInt) \ + O(NewArray) \ + O(IteratorToArray) \ + O(NewString) \ + O(NewObject) \ + O(NewRegExp) \ + O(CopyObjectExcludingProperties) \ + O(GetVariable) \ + O(SetVariable) \ + O(PutById) \ + O(GetById) \ + O(PutByValue) \ + O(GetByValue) \ + O(Jump) \ + O(JumpConditional) \ + O(JumpNullish) \ + O(JumpUndefined) \ + O(Call) \ + O(NewFunction) \ + O(Return) \ + O(BitwiseAnd) \ + O(BitwiseOr) \ + O(BitwiseXor) \ + O(BitwiseNot) \ + O(Not) \ + O(UnaryPlus) \ + O(UnaryMinus) \ + O(Typeof) \ + O(LeftShift) \ + O(RightShift) \ + O(UnsignedRightShift) \ + O(In) \ + O(InstanceOf) \ + O(ConcatString) \ + O(Increment) \ + O(Decrement) \ + O(Throw) \ + O(PushDeclarativeEnvironment) \ + O(EnterUnwindContext) \ + O(LeaveUnwindContext) \ + O(ContinuePendingUnwind) \ + O(Yield) \ + O(GetIterator) \ + O(IteratorNext) \ + O(IteratorResultDone) \ O(IteratorResultValue) namespace JS::Bytecode { diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 77072459ba..9e6f04b26f 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include namespace JS::Bytecode { @@ -49,8 +49,8 @@ Value Interpreter::run(Executable const& executable, BasicBlock const* entry_poi execution_context.this_value = &global_object(); static FlyString global_execution_context_name = "(*BC* global execution context)"; execution_context.function_name = global_execution_context_name; - execution_context.lexical_environment = &global_object().environment_record(); - execution_context.variable_environment = &global_object().environment_record(); + execution_context.lexical_environment = &global_object().environment(); + execution_context.variable_environment = &global_object().environment(); VERIFY(!vm().exception()); // FIXME: How do we know if we're in strict mode? Maybe the Bytecode::Block should know this? // execution_context.is_strict_mode = ???; diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 521d523c45..c4c6be890f 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -12,8 +12,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -381,14 +381,14 @@ void ContinuePendingUnwind::replace_references_impl(BasicBlock const& from, Basi m_resume_target = Label { to }; } -void PushDeclarativeEnvironmentRecord::execute_impl(Bytecode::Interpreter& interpreter) const +void PushDeclarativeEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const { HashMap resolved_variables; for (auto& it : m_variables) resolved_variables.set(interpreter.current_executable().get_string(it.key), it.value); - auto* environment_record = interpreter.vm().heap().allocate(interpreter.global_object(), move(resolved_variables), interpreter.vm().lexical_environment()); - interpreter.vm().running_execution_context().lexical_environment = environment_record; - interpreter.vm().running_execution_context().variable_environment = environment_record; + auto* environment = interpreter.vm().heap().allocate(interpreter.global_object(), move(resolved_variables), interpreter.vm().lexical_environment()); + interpreter.vm().running_execution_context().lexical_environment = environment; + interpreter.vm().running_execution_context().variable_environment = environment; } void Yield::execute_impl(Bytecode::Interpreter& interpreter) const @@ -635,10 +635,10 @@ String ContinuePendingUnwind::to_string_impl(Bytecode::Executable const&) const return String::formatted("ContinuePendingUnwind resume:{}", m_resume_target); } -String PushDeclarativeEnvironmentRecord::to_string_impl(const Bytecode::Executable& executable) const +String PushDeclarativeEnvironment::to_string_impl(const Bytecode::Executable& executable) const { StringBuilder builder; - builder.append("PushDeclarativeEnvironmentRecord"); + builder.append("PushDeclarativeEnvironment"); if (!m_variables.is_empty()) { builder.append(" {"); Vector names; diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 85cb43d43f..eafbda878f 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include namespace JS::Bytecode::Op { @@ -635,10 +635,10 @@ private: Optional