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