summaryrefslogtreecommitdiff
path: root/src/print.c
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2010-01-08 12:00:00 +0000
committerrepogen <>2010-01-08 12:00:00 +0000
commit22912c77c80f8de8f7accd3319c726f7c5349fd3 (patch)
treecaf064ecca31cd2ef1c919c585ee6b3d5e6d25d6 /src/print.c
parent300cd56eb905be061aa75bb665549b3b85109bbe (diff)
downloadlua-github-5.2.0-work1.tar.gz
Lua 5.2.0-work15.2.0-work1
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/print.c b/src/print.c
index e240cfc3..fb491e7e 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1,5 +1,5 @@
/*
-** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $
+** $Id: print.c,v 1.58 2008/09/11 12:05:06 lhf Exp $
** print bytecodes
** See Copyright Notice in lua.h
*/
@@ -30,7 +30,7 @@ static void PrintString(const TString* ts)
int c=s[i];
switch (c)
{
- case '"': printf("\\\""); break;
+ case '"': printf("\\\""); break;
case '\\': printf("\\\\"); break;
case '\a': printf("\\a"); break;
case '\b': printf("\\b"); break;
@@ -84,7 +84,10 @@ static void PrintCode(const Proto* f)
int c=GETARG_C(i);
int bx=GETARG_Bx(i);
int sbx=GETARG_sBx(i);
- int line=getline(f,pc);
+ int line=getfuncline(f,pc);
+#ifdef LUAC_DUMP_INSTRUCTIONS
+ printf("%0*X",2*sizeof(i),i);
+#endif
printf("\t%d\t",pc+1);
if (line>0) printf("[%d]\t",line); else printf("[-]\t");
printf("%-9s\t",luaP_opnames[o]);
@@ -109,7 +112,7 @@ static void PrintCode(const Proto* f)
break;
case OP_GETUPVAL:
case OP_SETUPVAL:
- printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-");
+ printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b].name) : "-");
break;
case OP_GETGLOBAL:
case OP_SETGLOBAL:
@@ -155,7 +158,7 @@ static void PrintCode(const Proto* f)
}
}
-#define SS(x) (x==1)?"":"s"
+#define SS(x) ((x==1)?"":"s")
#define S(x) x,SS(x)
static void PrintHeader(const Proto* f)
@@ -173,14 +176,15 @@ static void PrintHeader(const Proto* f)
S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f));
printf("%d%s param%s, %d slot%s, %d upvalue%s, ",
f->numparams,f->is_vararg?"+":"",SS(f->numparams),
- S(f->maxstacksize),S(f->nups));
+ S(f->maxstacksize),S(f->sizeupvalues));
printf("%d local%s, %d constant%s, %d function%s\n",
S(f->sizelocvars),S(f->sizek),S(f->sizep));
}
-static void PrintConstants(const Proto* f)
+static void PrintDebug(const Proto* f)
{
- int i,n=f->sizek;
+ int i,n;
+ n=f->sizek;
printf("constants (%d) for %p:\n",n,VOID(f));
for (i=0; i<n; i++)
{
@@ -188,27 +192,19 @@ static void PrintConstants(const Proto* f)
PrintConstant(f,i);
printf("\n");
}
-}
-
-static void PrintLocals(const Proto* f)
-{
- int i,n=f->sizelocvars;
+ n=f->sizelocvars;
printf("locals (%d) for %p:\n",n,VOID(f));
for (i=0; i<n; i++)
{
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);
}
-}
-
-static void PrintUpvalues(const Proto* f)
-{
- int i,n=f->sizeupvalues;
+ n=f->sizeupvalues;
printf("upvalues (%d) for %p:\n",n,VOID(f));
if (f->upvalues==NULL) return;
for (i=0; i<n; i++)
{
- printf("\t%d\t%s\n",i,getstr(f->upvalues[i]));
+ printf("\t%d\t%s\n",i,getstr(f->upvalues[i].name));
}
}
@@ -217,11 +213,6 @@ void PrintFunction(const Proto* f, int full)
int i,n=f->sizep;
PrintHeader(f);
PrintCode(f);
- if (full)
- {
- PrintConstants(f);
- PrintLocals(f);
- PrintUpvalues(f);
- }
+ if (full) PrintDebug(f);
for (i=0; i<n; i++) PrintFunction(f->p[i],full);
}