1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:07:34 +00:00

LibJS: Rename Environment Records so they match the spec :^)

This patch makes the following name changes:

- ScopeObject => EnvironmentRecord
- LexicalEnvironment => DeclarativeEnvironmentRecord
- WithScope => ObjectEnvironmentRecord
This commit is contained in:
Andreas Kling 2021-06-21 23:17:24 +02:00
parent e9b4a0a830
commit 6c6dbcfc36
35 changed files with 297 additions and 297 deletions

View file

@ -14,7 +14,7 @@
#include <LibJS/Bytecode/Op.h>
#include <LibJS/Bytecode/Register.h>
#include <LibJS/Bytecode/StringTable.h>
#include <LibJS/Runtime/ScopeObject.h>
#include <LibJS/Runtime/EnvironmentRecord.h>
namespace JS {
@ -63,7 +63,7 @@ void ScopeNode::generate_bytecode(Bytecode::Generator& generator) const
}
if (!scope_variables_with_declaration_kind.is_empty()) {
generator.emit<Bytecode::Op::PushLexicalEnvironment>(move(scope_variables_with_declaration_kind));
generator.emit<Bytecode::Op::PushDeclarativeEnvironmentRecord>(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<Bytecode::Op::LeaveUnwindContext>();
if (!m_handler->parameter().is_empty()) {
// FIXME: We need a separate LexicalEnvironment here
// FIXME: We need a separate DeclarativeEnvironmentRecord here
generator.emit<Bytecode::Op::SetVariable>(generator.intern_string(m_handler->parameter()));
}
m_handler->body().generate_bytecode(generator);

View file

@ -9,70 +9,70 @@
#include <AK/Forward.h>
#include <LibJS/Forward.h>
#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 {

View file

@ -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 = ???;

View file

@ -12,11 +12,11 @@
#include <LibJS/Bytecode/Op.h>
#include <LibJS/Runtime/Array.h>
#include <LibJS/Runtime/BigInt.h>
#include <LibJS/Runtime/DeclarativeEnvironmentRecord.h>
#include <LibJS/Runtime/EnvironmentRecord.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/IteratorOperations.h>
#include <LibJS/Runtime/LexicalEnvironment.h>
#include <LibJS/Runtime/RegExpObject.h>
#include <LibJS/Runtime/ScopeObject.h>
#include <LibJS/Runtime/ScriptFunction.h>
#include <LibJS/Runtime/Value.h>
@ -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<FlyString, Variable> 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<LexicalEnvironment>(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<DeclarativeEnvironmentRecord>(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<String> names;

View file

@ -14,7 +14,7 @@
#include <LibJS/Bytecode/Register.h>
#include <LibJS/Bytecode/StringTable.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Runtime/ScopeObject.h>
#include <LibJS/Runtime/EnvironmentRecord.h>
#include <LibJS/Runtime/Value.h>
namespace JS::Bytecode::Op {
@ -635,10 +635,10 @@ private:
Optional<Label> m_continuation_label;
};
class PushLexicalEnvironment final : public Instruction {
class PushDeclarativeEnvironmentRecord final : public Instruction {
public:
explicit PushLexicalEnvironment(HashMap<u32, Variable> variables)
: Instruction(Type::PushLexicalEnvironment)
explicit PushDeclarativeEnvironmentRecord(HashMap<u32, Variable> variables)
: Instruction(Type::PushDeclarativeEnvironmentRecord)
, m_variables(move(variables))
{
}