ソースを参照

corrected wrong index in printer

Kajetan Johannes Hammerle 3 年 前
コミット
c43f1f7f56
1 ファイル変更4 行追加4 行削除
  1. 4 4
      ByteCodePrinter.c

+ 4 - 4
ByteCodePrinter.c

@@ -27,7 +27,7 @@ static void btAdd(const char* format, ...) {
 static void btFillBase() {
     buffer[0] = '\0';
     bIndex = 0;
-    btAdd("| %6d | %5d |", readIndex, line);
+    btAdd("| %6d | %5d |", readIndex - 1, line);
 }
 
 static void btRead(void* buffer, int length) {
@@ -64,7 +64,7 @@ static void btAddFiller() {
 static void sPrintLine() {
     btRead(&line, 2);
     printf("| %6d |-------|----------------------|------------|------------|\n",
-           readIndex);
+           readIndex - 3);
 }
 
 static void btPrintOp(const char* op) {
@@ -100,11 +100,11 @@ static void btPrintFloat(const char* op) {
 }
 
 static void btPrintString(const char* msg) {
+    btFillBase();
     int length = 0;
     btRead(&length, sizeof(int));
     char* s = (char*)(code->code + readIndex);
     readIndex += length;
-    btFillBase();
     btAddOperation(msg);
     btAdd(" %10s |", s);
     btAddFiller();
@@ -180,4 +180,4 @@ void btPrint(ByteCode* bt) {
     while(readIndex < code->length) {
         btConsumeOperation();
     }
-}
+}