浏览代码

LibJS/Bytecode: Pretty-print the `this` register as "this"

Andreas Kling 1 年之前
父节点
当前提交
9d22db2802
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      Userland/Libraries/LibJS/Bytecode/Interpreter.cpp

+ 5 - 1
Userland/Libraries/LibJS/Bytecode/Interpreter.cpp

@@ -46,7 +46,11 @@ static ByteString format_operand(StringView name, Operand operand, Bytecode::Exe
         builder.appendff("\033[32m{}\033[0m:", name);
     switch (operand.type()) {
     case Operand::Type::Register:
-        builder.appendff("\033[33mreg{}\033[0m", operand.index());
+        if (operand.index() == Register::this_value().index()) {
+            builder.appendff("\033[33mthis\033[0m");
+        } else {
+            builder.appendff("\033[33mreg{}\033[0m", operand.index());
+        }
         break;
     case Operand::Type::Local:
         // FIXME: Show local name.