MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / PrintCode

Function PrintCode

xrepo/packages/l/lua/port/lua/src/luac.c:336–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334#define ISK (isk ? "k" : "")
335
336static void PrintCode(const Proto* f)
337{
338 const Instruction* code=f->code;
339 int pc,n=f->sizecode;
340 for (pc=0; pc<n; pc++)
341 {
342 Instruction i=code[pc];
343 OpCode o=GET_OPCODE(i);
344 int a=GETARG_A(i);
345 int b=GETARG_B(i);
346 int c=GETARG_C(i);
347 int ax=GETARG_Ax(i);
348 int bx=GETARG_Bx(i);
349 int sb=GETARG_sB(i);
350 int sc=GETARG_sC(i);
351 int sbx=GETARG_sBx(i);
352 int isk=GETARG_k(i);
353 int line=luaG_getfuncline(f,pc);
354 printf("\t%d\t",pc+1);
355 if (line>0) printf("[%d]\t",line); else printf("[-]\t");
356 printf("%-9s\t",opnames[o]);
357 switch (o)
358 {
359 case OP_MOVE:
360 printf("%d %d",a,b);
361 break;
362 case OP_LOADI:
363 printf("%d %d",a,sbx);
364 break;
365 case OP_LOADF:
366 printf("%d %d",a,sbx);
367 break;
368 case OP_LOADK:
369 printf("%d %d",a,bx);
370 printf(COMMENT); PrintConstant(f,bx);
371 break;
372 case OP_LOADKX:
373 printf("%d",a);
374 printf(COMMENT); PrintConstant(f,EXTRAARG);
375 break;
376 case OP_LOADFALSE:
377 printf("%d",a);
378 break;
379 case OP_LFALSESKIP:
380 printf("%d",a);
381 break;
382 case OP_LOADTRUE:
383 printf("%d",a);
384 break;
385 case OP_LOADNIL:
386 printf("%d %d",a,b);
387 printf(COMMENT "%d out",b+1);
388 break;
389 case OP_GETUPVAL:
390 printf("%d %d",a,b);
391 printf(COMMENT "%s",UPVALNAME(b));
392 break;
393 case OP_SETUPVAL:

Callers 1

PrintFunctionFunction · 0.85

Calls 2

luaG_getfunclineFunction · 0.85
PrintConstantFunction · 0.85

Tested by

no test coverage detected