ソースを参照

Add comment explaining the SETLIST has_extra_arg

Hugo Musso Gualandi 4 年 前
コミット
b514ad0c5b
1 ファイル変更5 行追加0 行削除
  1. 5 0
      src/luaot.c

+ 5 - 0
src/luaot.c

@@ -1388,6 +1388,11 @@ void create_function(Proto *f)
                 break;
                 break;
             }
             }
             case OP_SETLIST: {
             case OP_SETLIST: {
+                // We should take care to only generate code for the extra argument if it actually exists.
+                // In a previous version of this compiler, we were putting the "if" in the generated code
+                // instead of in the code generator and that resulted in compile-time warnings from gcc.
+                // Sometimes, the last += GETARG_Ax" line would overflow and the C compiler would naturally
+                // complain (even though the offending line was never executed).
                 int has_extra_arg = TESTARG_k(instr);
                 int has_extra_arg = TESTARG_k(instr);
                 println("        int n = GETARG_B(i);");
                 println("        int n = GETARG_B(i);");
                 println("        unsigned int last = GETARG_C(i);");
                 println("        unsigned int last = GETARG_C(i);");