| 286 | #define MYK(x) (-1-(x)) |
| 287 | |
| 288 | static void PrintCode(const Proto* f) |
| 289 | { |
| 290 | const Instruction* code=f->code; |
| 291 | int pc,n=f->sizecode; |
| 292 | for (pc=0; pc<n; pc++) |
| 293 | { |
| 294 | Instruction i=code[pc]; |
| 295 | OpCode o=GET_OPCODE(i); |
| 296 | int a=GETARG_A(i); |
| 297 | int b=GETARG_B(i); |
| 298 | int c=GETARG_C(i); |
| 299 | int ax=GETARG_Ax(i); |
| 300 | int bx=GETARG_Bx(i); |
| 301 | int sbx=GETARG_sBx(i); |
| 302 | int line=getfuncline(f,pc); |
| 303 | printf("\t%d\t",pc+1); |
| 304 | if (line>0) printf("[%d]\t",line); else printf("[-]\t"); |
| 305 | printf("%-9s\t",luaP_opnames[o]); |
| 306 | switch (getOpMode(o)) |
| 307 | { |
| 308 | case iABC: |
| 309 | printf("%d",a); |
| 310 | if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (MYK(INDEXK(b))) : b); |
| 311 | if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (MYK(INDEXK(c))) : c); |
| 312 | break; |
| 313 | case iABx: |
| 314 | printf("%d",a); |
| 315 | if (getBMode(o)==OpArgK) printf(" %d",MYK(bx)); |
| 316 | if (getBMode(o)==OpArgU) printf(" %d",bx); |
| 317 | break; |
| 318 | case iAsBx: |
| 319 | printf("%d %d",a,sbx); |
| 320 | break; |
| 321 | case iAx: |
| 322 | printf("%d",MYK(ax)); |
| 323 | break; |
| 324 | } |
| 325 | switch (o) |
| 326 | { |
| 327 | case OP_LOADK: |
| 328 | printf("\t; "); PrintConstant(f,bx); |
| 329 | break; |
| 330 | case OP_GETUPVAL: |
| 331 | case OP_SETUPVAL: |
| 332 | printf("\t; %s",UPVALNAME(b)); |
| 333 | break; |
| 334 | case OP_GETTABUP: |
| 335 | printf("\t; %s",UPVALNAME(b)); |
| 336 | if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); } |
| 337 | break; |
| 338 | case OP_SETTABUP: |
| 339 | printf("\t; %s",UPVALNAME(a)); |
| 340 | if (ISK(b)) { printf(" "); PrintConstant(f,INDEXK(b)); } |
| 341 | if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); } |
| 342 | break; |
| 343 | case OP_GETTABLE: |
| 344 | case OP_SELF: |
| 345 | if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } |
no test coverage detected