diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 3197b84104..14e6697f76 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -22,12 +22,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include namespace JS { @@ -227,11 +227,11 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj new_object = &result.as_object(); } else if (is(*m_callee)) { // FIXME: This is merely a band-aid to make super() inside catch {} work (which constructs - // a new LexicalEnvironment without current function). Implement GetSuperConstructor() + // a new DeclarativeEnvironmentRecord without current function). Implement GetSuperConstructor() // and subsequently GetThisEnvironment() instead. auto* function_environment = interpreter.current_environment(); if (!function_environment->current_function()) - function_environment = static_cast(function_environment->parent()); + function_environment = static_cast(function_environment->parent()); auto* super_constructor = function_environment->current_function()->prototype(); // FIXME: Functions should track their constructor kind. @@ -306,8 +306,8 @@ Value WithStatement::execute(Interpreter& interpreter, GlobalObject& global_obje VERIFY(object); - auto* with_scope = interpreter.heap().allocate(global_object, *object, interpreter.vm().call_frame().scope); - TemporaryChange scope_change(interpreter.vm().call_frame().scope, with_scope); + auto* object_environment_record = interpreter.heap().allocate(global_object, *object, interpreter.vm().call_frame().environment_record); + TemporaryChange scope_change(interpreter.vm().call_frame().environment_record, object_environment_record); return interpreter.execute_statement(global_object, m_body).value_or(js_undefined()); } @@ -2055,8 +2055,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().call_frame().scope); - TemporaryChange scope_change(interpreter.vm().call_frame().scope, catch_scope); + auto* catch_scope = interpreter.heap().allocate(global_object, move(parameters), interpreter.vm().call_frame().environment_record); + TemporaryChange scope_change(interpreter.vm().call_frame().environment_record, 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 86c6990f53..77f589f66b 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()) { @@ -1219,7 +1219,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 LexicalEnvironment here + // FIXME: We need a separate DeclarativeEnvironmentRecord 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 a01ce99238..58139ffd4b 100644 --- a/Userland/Libraries/LibJS/Bytecode/Instruction.h +++ b/Userland/Libraries/LibJS/Bytecode/Instruction.h @@ -9,70 +9,70 @@ #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(PushLexicalEnvironment) \ - O(LoadArgument) \ - 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(PushDeclarativeEnvironmentRecord) \ + O(LoadArgument) \ + 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 4d4441cd7d..dfa96f32c1 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -48,7 +48,7 @@ Value Interpreter::run(Executable const& executable, BasicBlock const* entry_poi global_call_frame.this_value = &global_object(); static FlyString global_execution_context_name = "(*BC* global execution context)"; global_call_frame.function_name = global_execution_context_name; - global_call_frame.scope = &global_object(); + global_call_frame.environment_record = &global_object(); VERIFY(!vm().exception()); // FIXME: How do we know if we're in strict mode? Maybe the Bytecode::Block should know this? // global_call_frame.is_strict_mode = ???; diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index d925c54687..7274641c56 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -12,11 +12,11 @@ #include #include #include +#include +#include #include #include -#include #include -#include #include #include @@ -381,13 +381,13 @@ void ContinuePendingUnwind::replace_references_impl(BasicBlock const& from, Basi m_resume_target = Label { to }; } -void PushLexicalEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const +void PushDeclarativeEnvironmentRecord::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* block_lexical_environment = interpreter.vm().heap().allocate(interpreter.global_object(), move(resolved_variables), interpreter.vm().current_scope()); - interpreter.vm().call_frame().scope = block_lexical_environment; + auto* environment_record = interpreter.vm().heap().allocate(interpreter.global_object(), move(resolved_variables), interpreter.vm().current_scope()); + interpreter.vm().call_frame().environment_record = environment_record; } void Yield::execute_impl(Bytecode::Interpreter& interpreter) const @@ -639,10 +639,10 @@ String ContinuePendingUnwind::to_string_impl(Bytecode::Executable const&) const return String::formatted("ContinuePendingUnwind resume:{}", m_resume_target); } -String PushLexicalEnvironment::to_string_impl(const Bytecode::Executable& executable) const +String PushDeclarativeEnvironmentRecord::to_string_impl(const Bytecode::Executable& executable) const { StringBuilder builder; - builder.append("PushLexicalEnvironment"); + builder.append("PushDeclarativeEnvironmentRecord"); 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 177f2f66ed..055fdab701 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