C:\JS_KRESREAL\HBP_konverzia\lua\luac.c C:\JS_LUA\lua-5.2.0\src\luac.c
/* /*
** $Id: luac.c,v 1.69 2011/11/29 17:46:33 lhf Exp $ ** $Id: luac.c,v 1.69 2011/11/29 17:46:33 lhf Exp $
** Lua compiler (saves bytecodes to files; also list bytecodes) ** Lua compiler (saves bytecodes to files; also list bytecodes)
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/  */ 
   
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
   
#define luac_c #define luac_c
#define LUA_CORE #define LUA_CORE
   
#include "lua.h" #include "lua.h"
#include "lauxlib.h" #include "lauxlib.h"
   
#include "lobject.h" #include "lobject.h"
#include "lstate.h" #include "lstate.h"
#include "lundump.h" #include "lundump.h"
   
static void PrintFunction(const Proto* f, int full); static void PrintFunction(const Proto* f, int full);
#define luaU_print  PrintFunction #define luaU_print  PrintFunction
   
#define PROGNAME    "luac"      /* default program name */  #define PROGNAME    "luac"      /* default program name */ 
#define OUTPUT      PROGNAME ".out" /* default output file */  #define OUTPUT      PROGNAME ".out" /* default output file */ 
   
static int listing=0;            /* list bytecodes? */  static int listing=0;            /* list bytecodes? */ 
static int dumping=1;            /* dump bytecodes? */  static int dumping=1;            /* dump bytecodes? */ 
static int stripping=0;            /* strip debug information? */  static int stripping=0;            /* strip debug information? */ 
static char Output[]={ OUTPUT };    /* default output file name */  static char Output[]={ OUTPUT };    /* default output file name */ 
static const char* output=Output;    /* actual output file name */  static const char* output=Output;    /* actual output file name */ 
static const char* progname=PROGNAME;    /* actual program name */  static const char* progname=PROGNAME;    /* actual program name */ 
   
static void fatal(const char* message) static void fatal(const char* message)
{ {
fprintf(stderr,"%s: %s\n",progname,message); fprintf(stderr,"%s: %s\n",progname,message);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
   
static void cannot(const char* what) static void cannot(const char* what)
{ {
fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno)); fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
   
static void usage(const char* message) static void usage(const char* message)
{ {
if (*message=='-') if (*message=='-')
 fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message);  fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message);
else else
 fprintf(stderr,"%s: %s\n",progname,message);  fprintf(stderr,"%s: %s\n",progname,message);
fprintf(stderr, fprintf(stderr,
 "usage: %s [options] [filenames]\n"   "usage: %s [options] [filenames]\n" 
 "Available options are:\n"   "Available options are:\n" 
 "  -l       list (use -l -l for full listing)\n"   "  -l       list (use -l -l for full listing)\n" 
 "  -o name  output to file " LUA_QL("name") " (default is \"%s\")\n"   "  -o name  output to file " LUA_QL("name") " (default is \"%s\")\n" 
 "  -p       parse only\n"   "  -p       parse only\n" 
 "  -s       strip debug information\n"   "  -s       strip debug information\n" 
 "  -v       show version information\n"   "  -v       show version information\n" 
 "  --       stop handling options\n"   "  --       stop handling options\n" 
 "  -        stop handling options and process stdin\n"   "  -        stop handling options and process stdin\n" 
 ,progname,Output);  ,progname,Output);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
   
#define IS(s)   (strcmp(argv[i],s)==0) #define IS(s)   (strcmp(argv[i],s)==0)
   
static int doargs(int argc, char* argv[]) static int doargs(int argc, char* argv[])
{ {
int i; int i;
int version=0; int version=0;
if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0]; if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0];
for (i=1; i<argc; i++) for (i=1; i<argc; i++)
{ {
 if (*argv[i]!='-')            /* end of options; keep it */   if (*argv[i]!='-')            /* end of options; keep it */ 
  break;   break;
 else if (IS("--"))            /* end of options; skip it */   else if (IS("--"))            /* end of options; skip it */ 
 {  {
  ++i;   ++i;
  if (version) ++version;   if (version) ++version;
  break;   break;
 }  }
 else if (IS("-"))            /* end of options; use stdin */   else if (IS("-"))            /* end of options; use stdin */ 
  break;   break;
 else if (IS("-l"))            /* list */   else if (IS("-l"))            /* list */ 
  ++listing;   ++listing;
 else if (IS("-o"))            /* output file */   else if (IS("-o"))            /* output file */ 
 {  {
  output=argv[++i];   output=argv[++i];
  if (output==NULL || *output==0 || (*output=='-' && output[1]!=0))   if (output==NULL || *output==0 || (*output=='-' && output[1]!=0))
   usage(LUA_QL("-o") " needs argument");    usage(LUA_QL("-o") " needs argument");
  if (IS("-")) output=NULL;   if (IS("-")) output=NULL;
 }  }
 else if (IS("-p"))            /* parse only */   else if (IS("-p"))            /* parse only */ 
  dumping=0;   dumping=0;
 else if (IS("-s"))            /* strip debug information */   else if (IS("-s"))            /* strip debug information */ 
  stripping=1;   stripping=1;
 else if (IS("-v"))            /* show version */   else if (IS("-v"))            /* show version */ 
  ++version;   ++version;
 else                    /* unknown option */   else                    /* unknown option */ 
  usage(argv[i]);   usage(argv[i]);
} }
if (i==argc && (listing || !dumping)) if (i==argc && (listing || !dumping))
{ {
 dumping=0;  dumping=0;
 argv[--i]=Output;  argv[--i]=Output;
} }
if (version) if (version)
{ {
 printf("%s\n",LUA_COPYRIGHT);  printf("%s\n",LUA_COPYRIGHT);
 if (version==argc-1) exit(EXIT_SUCCESS);  if (version==argc-1) exit(EXIT_SUCCESS);
} }
return i; return i;
} }
   
#define FUNCTION "(function()end)();" #define FUNCTION "(function()end)();"
   
static const char* reader(lua_State *L, void *ud, size_t *size) static const char* reader(lua_State *L, void *ud, size_t *size)
{ {
UNUSED(L); UNUSED(L);
if ((*(int*)ud)--) if ((*(int*)ud)--)
{ {
 *size=sizeof(FUNCTION)-1;  *size=sizeof(FUNCTION)-1;
 return FUNCTION;  return FUNCTION;
} }
else else
{ {
 *size=0;  *size=0;
 return NULL;  return NULL;
} }
} }
   
#define toproto(L,i) getproto(L->top+(i)) #define toproto(L,i) getproto(L->top+(i))
   
static const Proto* combine(lua_State* L, int n) static const Proto* combine(lua_State* L, int n)
{ {
if (n==1) if (n==1)
 return toproto(L,-1);  return toproto(L,-1);
else else
{ {
 Proto* f;  Proto* f;
 int i=n;  int i=n;
 if (lua_load(L,reader,&i,"=(" PROGNAME ")",NULL)!=LUA_OK) fatal(lua_tostring(L,-1));  if (lua_load(L,reader,&i,"=(" PROGNAME ")",NULL)!=LUA_OK) fatal(lua_tostring(L,-1));
 f=toproto(L,-1);  f=toproto(L,-1);
 for (i=0; i<n; i++)  for (i=0; i<n; i++)
 {  {
  f->p[i]=toproto(L,i-n-1);   f->p[i]=toproto(L,i-n-1);
  if (f->p[i]->sizeupvalues>0) f->p[i]->upvalues[0].instack=0;   if (f->p[i]->sizeupvalues>0) f->p[i]->upvalues[0].instack=0;
 }  }
 f->sizelineinfo=0;  f->sizelineinfo=0;
 return f;  return f;
} }
} }
   
static int writer(lua_State* L, const void* p, size_t size, void* u) static int writer(lua_State* L, const void* p, size_t size, void* u)
{ {
UNUSED(L); UNUSED(L);
return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0); return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0);
} }
   
static int pmain(lua_State* L) static int pmain(lua_State* L)
{ {
int argc=(int)lua_tointeger(L,1); int argc=(int)lua_tointeger(L,1);
char** argv=(char**)lua_touserdata(L,2); char** argv=(char**)lua_touserdata(L,2);
const Proto* f; const Proto* f;
int i; int i;
if (!lua_checkstack(L,argc)) fatal("too many input files"); if (!lua_checkstack(L,argc)) fatal("too many input files");
for (i=0; i<argc; i++) for (i=0; i<argc; i++)
{ {
 const char* filename=IS("-") ? NULL : argv[i];  const char* filename=IS("-") ? NULL : argv[i];
 if (luaL_loadfile(L,filename)!=LUA_OK) fatal(lua_tostring(L,-1));  if (luaL_loadfile(L,filename)!=LUA_OK) fatal(lua_tostring(L,-1));
} }
f=combine(L,argc); f=combine(L,argc);
if (listing) luaU_print(f,listing>1); if (listing) luaU_print(f,listing>1);
if (dumping) if (dumping)
{ {
 FILE* D= (output==NULL) ? stdout : fopen(output,"wb");  FILE* D= (output==NULL) ? stdout : fopen(output,"wb");
 if (D==NULL) cannot("open");  if (D==NULL) cannot("open");
 lua_lock(L);  lua_lock(L);
 luaU_dump(L,f,writer,D,stripping);  luaU_dump(L,f,writer,D,stripping);
 lua_unlock(L);  lua_unlock(L);
 if (ferror(D)) cannot("write");  if (ferror(D)) cannot("write");
 if (fclose(D)) cannot("close");  if (fclose(D)) cannot("close");
} }
return 0; return 0;
} }
   
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
lua_State* L; lua_State* L;
int i=doargs(argc,argv); int i=doargs(argc,argv);
argc-=i; argv+=i; argc-=i; argv+=i;
if (argc<=0) usage("no input files given"); if (argc<=0) usage("no input files given");
L=luaL_newstate(); L=luaL_newstate();
if (L==NULL) fatal("cannot create state: not enough memory"); if (L==NULL) fatal("cannot create state: not enough memory");
lua_pushcfunction(L,&pmain); lua_pushcfunction(L,&pmain);
lua_pushinteger(L,argc); lua_pushinteger(L,argc);
lua_pushlightuserdata(L,argv); lua_pushlightuserdata(L,argv);
if (lua_pcall(L,2,0,0)!=LUA_OK) fatal(lua_tostring(L,-1)); if (lua_pcall(L,2,0,0)!=LUA_OK) fatal(lua_tostring(L,-1));
lua_close(L); lua_close(L);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
   
/* /*
** $Id: print.c,v 1.68 2011/09/30 10:21:20 lhf Exp $ ** $Id: print.c,v 1.68 2011/09/30 10:21:20 lhf Exp $
** print bytecodes ** print bytecodes
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/  */ 
   
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
   
#define luac_c #define luac_c
#define LUA_CORE #define LUA_CORE
   
#include "ldebug.h" #include "ldebug.h"
#include "lobject.h" #include "lobject.h"
#include "lopcodes.h" #include "lopcodes.h"
   
#define VOID(p)     ((const void*)(p)) #define VOID(p)     ((const void*)(p))
   
static void PrintString(const TString* ts) static void PrintString(const TString* ts)
{ {
const char* s=getstr(ts); const char* s=getstr(ts);
size_t i,n=ts->tsv.len; size_t i,n=ts->tsv.len;
printf("%c",'"'); printf("%c",'"');
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
 int c=(int)(unsigned char)s[i];  int c=(int)(unsigned char)s[i];
 switch (c)  switch (c)
 {  {
  case '"':  printf("\\\""); break;   case '"':  printf("\\\""); break;
  case '\\': printf("\\\\"); break;   case '\\': printf("\\\\"); break;
  case '\a': printf("\\a"); break;   case '\a': printf("\\a"); break;
  case '\b': printf("\\b"); break;   case '\b': printf("\\b"); break;
  case '\f': printf("\\f"); break;   case '\f': printf("\\f"); break;
  case '\n': printf("\\n"); break;   case '\n': printf("\\n"); break;
  case '\r': printf("\\r"); break;   case '\r': printf("\\r"); break;
  case '\t': printf("\\t"); break;   case '\t': printf("\\t"); break;
  case '\v': printf("\\v"); break;   case '\v': printf("\\v"); break;
  default:    if (isprint(c))   default:    if (isprint(c))
              printf("%c",c);               printf("%c",c);
       else        else
           printf("\\%03d",c);            printf("\\%03d",c);
 }  }
} }
printf("%c",'"'); printf("%c",'"');
} }
   
static void PrintConstant(const Proto* f, int i) static void PrintConstant(const Proto* f, int i)
{ {
const TValue* o=&f->k[i]; const TValue* o=&f->k[i];
switch (ttype(o)) switch (ttype(o))
{ {
 case LUA_TNIL:  case LUA_TNIL:
   printf("nil");    printf("nil");
   break;    break;
 case LUA_TBOOLEAN:  case LUA_TBOOLEAN:
   printf(bvalue(o) ? "true" : "false");    printf(bvalue(o) ? "true" : "false");
   break;    break;
 case LUA_TNUMBER:  case LUA_TNUMBER:
   printf(LUA_NUMBER_FMT,nvalue(o));    printf(LUA_NUMBER_FMT,nvalue(o));
   break;    break;
 case LUA_TSTRING:  case LUA_TSTRING:
   PrintString(rawtsvalue(o));    PrintString(rawtsvalue(o));
   break;    break;
 default:                /* cannot happen */   default:                /* cannot happen */ 
   printf("? type=%d",ttype(o));    printf("? type=%d",ttype(o));
   break;    break;
} }
} }
   
#define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-") #define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-")
#define MYK(x)      (-1-(x)) #define MYK(x)      (-1-(x))
   
static void PrintCode(const Proto* f) static void PrintCode(const Proto* f)
{ {
const Instruction* code=f->code; const Instruction* code=f->code;
int pc,n=f->sizecode; int pc,n=f->sizecode;
for (pc=0; pc<n; pc++) for (pc=0; pc<n; pc++)
{ {
 Instruction i=code[pc];  Instruction i=code[pc];
 OpCode o=GET_OPCODE(i);  OpCode o=GET_OPCODE(i);
 int a=GETARG_A(i);  int a=GETARG_A(i);
 int b=GETARG_B(i);  int b=GETARG_B(i);
 int c=GETARG_C(i);  int c=GETARG_C(i);
 int ax=GETARG_Ax(i);  int ax=GETARG_Ax(i);
 int bx=GETARG_Bx(i);  int bx=GETARG_Bx(i);
 int sbx=GETARG_sBx(i);  int sbx=GETARG_sBx(i);
 int line=getfuncline(f,pc);  int line=getfuncline(f,pc);
 printf("\t%d\t",pc+1);  printf("\t%d\t",pc+1);
 if (line>0) printf("[%d]\t",line); else printf("[-]\t");  if (line>0) printf("[%d]\t",line); else printf("[-]\t");
 printf("%-9s\t",luaP_opnames[o]);  printf("%-9s\t",luaP_opnames[o]);
 switch (getOpMode(o))  switch (getOpMode(o))
 {  {
  case iABC:   case iABC:
   printf("%d",a);    printf("%d",a);
   if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (MYK(INDEXK(b))) : b);    if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (MYK(INDEXK(b))) : b);
   if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (MYK(INDEXK(c))) : c);    if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (MYK(INDEXK(c))) : c);
   break;    break;
  case iABx:   case iABx:
   printf("%d",a);    printf("%d",a);
   if (getBMode(o)==OpArgK) printf(" %d",MYK(bx));    if (getBMode(o)==OpArgK) printf(" %d",MYK(bx));
   if (getBMode(o)==OpArgU) printf(" %d",bx);    if (getBMode(o)==OpArgU) printf(" %d",bx);
   break;    break;
  case iAsBx:   case iAsBx:
   printf("%d %d",a,sbx);    printf("%d %d",a,sbx);
   break;    break;
  case iAx:   case iAx:
   printf("%d",MYK(ax));    printf("%d",MYK(ax));
   break;    break;
 }  }
 switch (o)  switch (o)
 {  {
  case OP_LOADK:   case OP_LOADK:
   printf("\t; "); PrintConstant(f,bx);    printf("\t; "); PrintConstant(f,bx);
   break;    break;
  case OP_GETUPVAL:   case OP_GETUPVAL:
  case OP_SETUPVAL:   case OP_SETUPVAL:
   printf("\t; %s",UPVALNAME(b));    printf("\t; %s",UPVALNAME(b));
   break;    break;
  case OP_GETTABUP:   case OP_GETTABUP:
   printf("\t; %s",UPVALNAME(b));    printf("\t; %s",UPVALNAME(b));
   if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }    if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }
   break;    break;
  case OP_SETTABUP:   case OP_SETTABUP:
   printf("\t; %s",UPVALNAME(a));    printf("\t; %s",UPVALNAME(a));
   if (ISK(b)) { printf(" "); PrintConstant(f,INDEXK(b)); }    if (ISK(b)) { printf(" "); PrintConstant(f,INDEXK(b)); }
   if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }    if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }
   break;    break;
  case OP_GETTABLE:   case OP_GETTABLE:
  case OP_SELF:   case OP_SELF:
   if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); }    if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); }
   break;    break;
  case OP_SETTABLE:   case OP_SETTABLE:
  case OP_ADD:   case OP_ADD:
  case OP_SUB:   case OP_SUB:
  case OP_MUL:   case OP_MUL:
  case OP_DIV:   case OP_DIV:
  case OP_POW:   case OP_POW:
#ifdef GCW_BIT  
  case OP_BAND:  
  case OP_BOR:  
  case OP_BXOR:  
  case OP_BLSH:  
  case OP_BRSH:  
   
  case OP_LAND:  
  case OP_LOR:  
#endif  
  case OP_EQ:   case OP_EQ:
  case OP_LT:   case OP_LT:
  case OP_LE:   case OP_LE:
   if (ISK(b) || ISK(c))    if (ISK(b) || ISK(c))
   {    {
    printf("\t; ");     printf("\t; ");
    if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-");     if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-");
    printf(" ");     printf(" ");
    if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-");     if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-");
   }    }
   break;    break;
  case OP_JMP:   case OP_JMP:
  case OP_FORLOOP:   case OP_FORLOOP:
  case OP_FORPREP:   case OP_FORPREP:
  case OP_TFORLOOP:   case OP_TFORLOOP:
   printf("\t; to %d",sbx+pc+2);    printf("\t; to %d",sbx+pc+2);
   break;    break;
  case OP_CLOSURE:   case OP_CLOSURE:
   printf("\t; %p",VOID(f->p[bx]));    printf("\t; %p",VOID(f->p[bx]));
   break;    break;
  case OP_SETLIST:   case OP_SETLIST:
   if (c==0) printf("\t; %d",(int)code[++pc]); else printf("\t; %d",c);    if (c==0) printf("\t; %d",(int)code[++pc]); else printf("\t; %d",c);
   break;    break;
  case OP_EXTRAARG:   case OP_EXTRAARG:
   printf("\t; "); PrintConstant(f,ax);    printf("\t; "); PrintConstant(f,ax);
   break;    break;
  default:   default:
   break;    break;
 }  }
 printf("\n");  printf("\n");
} }
} }
   
#define SS(x)   ((x==1)?"":"s") #define SS(x)   ((x==1)?"":"s")
#define S(x)    (int)(x),SS(x) #define S(x)    (int)(x),SS(x)
   
static void PrintHeader(const Proto* f) static void PrintHeader(const Proto* f)
{ {
const char* s=f->source ? getstr(f->source) : "=?"; const char* s=f->source ? getstr(f->source) : "=?";
if (*s=='@' || *s=='=') if (*s=='@' || *s=='=')
 s++;  s++;
else if (*s==LUA_SIGNATURE[0]) else if (*s==LUA_SIGNATURE[0])
 s="(bstring)";  s="(bstring)";
else else
 s="(string)";  s="(string)";
printf("\n%s <%s:%d,%d> (%d instruction%s at %p)\n", printf("\n%s <%s:%d,%d> (%d instruction%s at %p)\n",
    (f->linedefined==0)?"main":"function",s,     (f->linedefined==0)?"main":"function",s,
   f->linedefined,f->lastlinedefined,    f->linedefined,f->lastlinedefined,
   S(f->sizecode),VOID(f));    S(f->sizecode),VOID(f));
printf("%d%s param%s, %d slot%s, %d upvalue%s, ", printf("%d%s param%s, %d slot%s, %d upvalue%s, ",
   (int)(f->numparams),f->is_vararg?"+":"",SS(f->numparams),    (int)(f->numparams),f->is_vararg?"+":"",SS(f->numparams),
   S(f->maxstacksize),S(f->sizeupvalues));    S(f->maxstacksize),S(f->sizeupvalues));
printf("%d local%s, %d constant%s, %d function%s\n", printf("%d local%s, %d constant%s, %d function%s\n",
   S(f->sizelocvars),S(f->sizek),S(f->sizep));    S(f->sizelocvars),S(f->sizek),S(f->sizep));
} }
   
static void PrintDebug(const Proto* f) static void PrintDebug(const Proto* f)
{ {
int i,n; int i,n;
n=f->sizek; n=f->sizek;
printf("constants (%d) for %p:\n",n,VOID(f)); printf("constants (%d) for %p:\n",n,VOID(f));
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
 printf("\t%d\t",i+1);  printf("\t%d\t",i+1);
 PrintConstant(f,i);  PrintConstant(f,i);
 printf("\n");  printf("\n");
} }
n=f->sizelocvars; n=f->sizelocvars;
printf("locals (%d) for %p:\n",n,VOID(f)); printf("locals (%d) for %p:\n",n,VOID(f));
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
 printf("\t%d\t%s\t%d\t%d\n",  printf("\t%d\t%s\t%d\t%d\n",
 i,getstr(f->locvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1);  i,getstr(f->locvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1);
} }
n=f->sizeupvalues; n=f->sizeupvalues;
printf("upvalues (%d) for %p:\n",n,VOID(f)); printf("upvalues (%d) for %p:\n",n,VOID(f));
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
 printf("\t%d\t%s\t%d\t%d\n",  printf("\t%d\t%s\t%d\t%d\n",
 i,UPVALNAME(i),f->upvalues[i].instack,f->upvalues[i].idx);  i,UPVALNAME(i),f->upvalues[i].instack,f->upvalues[i].idx);
} }
} }
   
static void PrintFunction(const Proto* f, int full) static void PrintFunction(const Proto* f, int full)
{ {
int i,n=f->sizep; int i,n=f->sizep;
PrintHeader(f); PrintHeader(f);
PrintCode(f); PrintCode(f);
if (full) PrintDebug(f); if (full) PrintDebug(f);
for (i=0; i<n; i++) PrintFunction(f->p[i],full); for (i=0; i<n; i++) PrintFunction(f->p[i],full);
} }