浏览代码

LibJS/Bytecode: Rename GetVariable => GetBinding

Andreas Kling 1 年之前
父节点
当前提交
6ca94bd0b1

+ 3 - 3
Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

@@ -397,7 +397,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> Identifier::generate_by
     if (is_global()) {
         generator.emit<Bytecode::Op::GetGlobal>(dst, generator.intern_identifier(m_string), generator.next_global_variable_cache());
     } else {
-        generator.emit<Bytecode::Op::GetVariable>(dst, generator.intern_identifier(m_string));
+        generator.emit<Bytecode::Op::GetBinding>(dst, generator.intern_identifier(m_string));
     }
     return dst;
 }
@@ -520,7 +520,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> AssignmentExpression::g
                         generator.emit<Bytecode::Op::ResolveSuperBase>(*base);
                     }
                 } else if (is<Identifier>(*lhs)) {
-                    // NOTE: For Identifiers, we cannot perform GetVariable and then write into the reference it retrieves, only SetVariable can do this.
+                    // NOTE: For Identifiers, we cannot perform GetBinding and then write into the reference it retrieves, only SetVariable can do this.
                     // FIXME: However, this breaks spec as we are doing variable lookup after evaluating the RHS. This is observable in an object environment, where we visibly perform HasOwnProperty and Get(@@unscopables) on the binded object.
                 } else {
                     (void)TRY(lhs->generate_bytecode(generator));
@@ -1150,7 +1150,7 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> FunctionDeclaration::ge
         Bytecode::Generator::SourceLocationScope scope(generator, *this);
         auto index = generator.intern_identifier(name());
         auto value = generator.allocate_register();
-        generator.emit<Bytecode::Op::GetVariable>(value, index);
+        generator.emit<Bytecode::Op::GetBinding>(value, index);
         generator.emit<Bytecode::Op::SetVariableBinding>(index, value);
     }
     return Optional<ScopedOperand> {};

+ 1 - 1
Userland/Libraries/LibJS/Bytecode/Generator.cpp

@@ -133,7 +133,7 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
                     if (id.is_local()) {
                         emit<Op::Mov>(initial_value, local(id.local_variable_index()));
                     } else {
-                        emit<Op::GetVariable>(initial_value, intern_identifier(id.string()));
+                        emit<Op::GetBinding>(initial_value, intern_identifier(id.string()));
                     }
                 }
 

+ 1 - 1
Userland/Libraries/LibJS/Bytecode/Instruction.h

@@ -63,7 +63,7 @@
     O(GetObjectFromIteratorRecord)     \
     O(GetObjectPropertyIterator)       \
     O(GetPrivateById)                  \
-    O(GetVariable)                     \
+    O(GetBinding)                      \
     O(GreaterThan)                     \
     O(GreaterThanEquals)               \
     O(HasPrivateId)                    \

+ 4 - 4
Userland/Libraries/LibJS/Bytecode/Interpreter.cpp

@@ -577,7 +577,7 @@ FLATTEN_ON_CLANG void Interpreter::run_bytecode(size_t entry_point)
             HANDLE_INSTRUCTION(GetObjectFromIteratorRecord);
             HANDLE_INSTRUCTION(GetObjectPropertyIterator);
             HANDLE_INSTRUCTION(GetPrivateById);
-            HANDLE_INSTRUCTION(GetVariable);
+            HANDLE_INSTRUCTION(GetBinding);
             HANDLE_INSTRUCTION(GreaterThan);
             HANDLE_INSTRUCTION(GreaterThanEquals);
             HANDLE_INSTRUCTION(HasPrivateId);
@@ -1237,7 +1237,7 @@ ThrowCompletionOr<void> ConcatString::execute_impl(Bytecode::Interpreter& interp
     return {};
 }
 
-ThrowCompletionOr<void> GetVariable::execute_impl(Bytecode::Interpreter& interpreter) const
+ThrowCompletionOr<void> GetBinding::execute_impl(Bytecode::Interpreter& interpreter) const
 {
     auto& vm = interpreter.vm();
     auto& executable = interpreter.current_executable();
@@ -2122,9 +2122,9 @@ ByteString GetCalleeAndThisFromEnvironment::to_byte_string_impl(Bytecode::Execut
         executable.identifier_table->get(m_identifier));
 }
 
-ByteString GetVariable::to_byte_string_impl(Bytecode::Executable const& executable) const
+ByteString GetBinding::to_byte_string_impl(Bytecode::Executable const& executable) const
 {
-    return ByteString::formatted("GetVariable {}, {}",
+    return ByteString::formatted("GetBinding {}, {}",
         format_operand("dst"sv, dst(), executable),
         executable.identifier_table->get(m_identifier));
 }

+ 3 - 3
Userland/Libraries/LibJS/Bytecode/Op.h

@@ -846,10 +846,10 @@ private:
     mutable EnvironmentCoordinate m_cache;
 };
 
-class GetVariable final : public Instruction {
+class GetBinding final : public Instruction {
 public:
-    explicit GetVariable(Operand dst, IdentifierTableIndex identifier)
-        : Instruction(Type::GetVariable)
+    explicit GetBinding(Operand dst, IdentifierTableIndex identifier)
+        : Instruction(Type::GetBinding)
         , m_dst(dst)
         , m_identifier(identifier)
     {