misc/liblua/print.c
author Wuzzy <Wuzzy2@mail.ru>
Tue, 21 May 2019 14:38:10 +0200
changeset 15025 fa597f6e301d
parent 10017 de822cd3df3a
permissions -rw-r--r--
ACF2: Fix Lua error when hog dies during cyborg choice phase
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     1
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     2
** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     3
** print bytecodes
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     4
** See Copyright Notice in lua.h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     5
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     6
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     7
#include <ctype.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     8
#include <stdio.h>
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     9
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    10
#define luac_c
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    11
#define LUA_CORE
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    12
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    13
#include "ldebug.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    14
#include "lobject.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    15
#include "lopcodes.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    16
#include "lundump.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    17
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    18
#define PrintFunction   luaU_print
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    19
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    20
#define Sizeof(x)   ((int)sizeof(x))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    21
#define VOID(p)     ((const void*)(p))
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    22
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    23
static void PrintString(const TString* ts)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    24
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    25
 const char* s=getstr(ts);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    26
 size_t i,n=ts->tsv.len;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    27
 putchar('"');
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    28
 for (i=0; i<n; i++)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    29
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    30
  int c=s[i];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    31
  switch (c)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    32
  {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    33
   case '"': printf("\\\""); break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    34
   case '\\': printf("\\\\"); break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    35
   case '\a': printf("\\a"); break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    36
   case '\b': printf("\\b"); break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    37
   case '\f': printf("\\f"); break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    38
   case '\n': printf("\\n"); break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    39
   case '\r': printf("\\r"); break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    40
   case '\t': printf("\\t"); break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    41
   case '\v': printf("\\v"); break;
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    42
   default: if (isprint((unsigned char)c))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    43
            putchar(c);
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    44
        else
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    45
            printf("\\%03u",(unsigned char)c);
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    46
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    47
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    48
 putchar('"');
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    49
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    50
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    51
static void PrintConstant(const Proto* f, int i)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    52
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    53
 const TValue* o=&f->k[i];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    54
 switch (ttype(o))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    55
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    56
  case LUA_TNIL:
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    57
    printf("nil");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    58
    break;
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    59
  case LUA_TBOOLEAN:
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    60
    printf(bvalue(o) ? "true" : "false");
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    61
    break;
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    62
  case LUA_TNUMBER:
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    63
    printf(LUA_NUMBER_FMT,nvalue(o));
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    64
    break;
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    65
  case LUA_TSTRING:
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    66
    PrintString(rawtsvalue(o));
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    67
    break;
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    68
  default:              /* cannot happen */
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    69
    printf("? type=%d",ttype(o));
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    70
    break;
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    71
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    72
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    73
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    74
static void PrintCode(const Proto* f)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    75
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    76
 const Instruction* code=f->code;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    77
 int pc,n=f->sizecode;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    78
 for (pc=0; pc<n; pc++)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    79
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    80
  Instruction i=code[pc];
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    81
  OpCode o=GET_OPCODE(i);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    82
  int a=GETARG_A(i);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    83
  int b=GETARG_B(i);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    84
  int c=GETARG_C(i);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    85
  int bx=GETARG_Bx(i);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    86
  int sbx=GETARG_sBx(i);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    87
  int line=getline(f,pc);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    88
  printf("\t%d\t",pc+1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    89
  if (line>0) printf("[%d]\t",line); else printf("[-]\t");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    90
  printf("%-9s\t",luaP_opnames[o]);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    91
  switch (getOpMode(o))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    92
  {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    93
   case iABC:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    94
    printf("%d",a);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    95
    if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    96
    if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    97
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    98
   case iABx:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    99
    if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   100
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   101
   case iAsBx:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   102
    if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   103
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   104
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   105
  switch (o)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   106
  {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   107
   case OP_LOADK:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   108
    printf("\t; "); PrintConstant(f,bx);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   109
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   110
   case OP_GETUPVAL:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   111
   case OP_SETUPVAL:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   112
    printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   113
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   114
   case OP_GETGLOBAL:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   115
   case OP_SETGLOBAL:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   116
    printf("\t; %s",svalue(&f->k[bx]));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   117
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   118
   case OP_GETTABLE:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   119
   case OP_SELF:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   120
    if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   121
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   122
   case OP_SETTABLE:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   123
   case OP_ADD:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   124
   case OP_SUB:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   125
   case OP_MUL:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   126
   case OP_DIV:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   127
   case OP_POW:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   128
   case OP_EQ:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   129
   case OP_LT:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   130
   case OP_LE:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   131
    if (ISK(b) || ISK(c))
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   132
    {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   133
     printf("\t; ");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   134
     if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   135
     printf(" ");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   136
     if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   137
    }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   138
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   139
   case OP_JMP:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   140
   case OP_FORLOOP:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   141
   case OP_FORPREP:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   142
    printf("\t; to %d",sbx+pc+2);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   143
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   144
   case OP_CLOSURE:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   145
    printf("\t; %p",VOID(f->p[bx]));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   146
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   147
   case OP_SETLIST:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   148
    if (c==0) printf("\t; %d",(int)code[++pc]);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   149
    else printf("\t; %d",c);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   150
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   151
   default:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   152
    break;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   153
  }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   154
  printf("\n");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   155
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   156
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   157
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
   158
#define SS(x)   (x==1)?"":"s"
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
   159
#define S(x)    x,SS(x)
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   160
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   161
static void PrintHeader(const Proto* f)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   162
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   163
 const char* s=getstr(f->source);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   164
 if (*s=='@' || *s=='=')
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   165
  s++;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   166
 else if (*s==LUA_SIGNATURE[0])
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   167
  s="(bstring)";
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   168
 else
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   169
  s="(string)";
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   170
 printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n",
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
   171
    (f->linedefined==0)?"main":"function",s,
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
   172
    f->linedefined,f->lastlinedefined,
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
   173
    S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f));
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   174
 printf("%d%s param%s, %d slot%s, %d upvalue%s, ",
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
   175
    f->numparams,f->is_vararg?"+":"",SS(f->numparams),
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
   176
    S(f->maxstacksize),S(f->nups));
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   177
 printf("%d local%s, %d constant%s, %d function%s\n",
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
   178
    S(f->sizelocvars),S(f->sizek),S(f->sizep));
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   179
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   180
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   181
static void PrintConstants(const Proto* f)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   182
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   183
 int i,n=f->sizek;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   184
 printf("constants (%d) for %p:\n",n,VOID(f));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   185
 for (i=0; i<n; i++)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   186
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   187
  printf("\t%d\t",i+1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   188
  PrintConstant(f,i);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   189
  printf("\n");
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   190
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   191
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   192
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   193
static void PrintLocals(const Proto* f)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   194
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   195
 int i,n=f->sizelocvars;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   196
 printf("locals (%d) for %p:\n",n,VOID(f));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   197
 for (i=0; i<n; i++)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   198
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   199
  printf("\t%d\t%s\t%d\t%d\n",
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   200
  i,getstr(f->locvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   201
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   202
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   203
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   204
static void PrintUpvalues(const Proto* f)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   205
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   206
 int i,n=f->sizeupvalues;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   207
 printf("upvalues (%d) for %p:\n",n,VOID(f));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   208
 if (f->upvalues==NULL) return;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   209
 for (i=0; i<n; i++)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   210
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   211
  printf("\t%d\t%s\n",i,getstr(f->upvalues[i]));
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   212
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   213
}
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   214
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   215
void PrintFunction(const Proto* f, int full)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   216
{
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   217
 int i,n=f->sizep;
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   218
 PrintHeader(f);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   219
 PrintCode(f);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   220
 if (full)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   221
 {
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   222
  PrintConstants(f);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   223
  PrintLocals(f);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   224
  PrintUpvalues(f);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   225
 }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   226
 for (i=0; i<n; i++) PrintFunction(f->p[i],full);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   227
}