Go to the documentation of this file.
29 #define luaU_print PrintFunction
31 #define PROGNAME "luac"
32 #define OUTPUT PROGNAME ".out"
42 static void fatal(
const char* message)
54 static void usage(
const char* message)
61 "usage: %s [options] [filenames]\n"
62 "Available options are:\n"
63 " -l list (use -l -l for full listing)\n"
64 " -o name output to file 'name' (default is \"%s\")\n"
66 " -s strip debug information\n"
67 " -v show version information\n"
68 " -- stop handling options\n"
69 " - stop handling options and process stdin\n"
74 #define IS(s) (strcmp(argv[i],s)==0)
76 static int doargs(
int argc,
char* argv[])
80 if (argv[0]!=NULL && *argv[0]!=0)
progname=argv[0];
81 for (i=1; i<argc; i++)
99 usage(
"'-o' needs argument");
119 if (
version==argc-1) exit(EXIT_SUCCESS);
124 #define FUNCTION "(function()end)();"
141 #define toproto(L,i) getproto(s2v(L->top+(i)))
156 if (
f->p[i]->sizeupvalues>0)
f->p[i]->upvalues[0].instack=0;
166 return (fwrite(p,
size,1,(FILE*)u)!=1) && (
size!=0);
177 for (i=0; i<argc; i++)
179 const char* filename=
IS(
"-") ? NULL : argv[i];
191 if (ferror(
D))
cannot(
"write");
192 if (fclose(
D))
cannot(
"close");
197 int main(
int argc,
char* argv[])
202 if (argc<=0)
usage(
"no input files given");
204 if (L==NULL)
fatal(
"cannot create state: not enough memory");
217 #define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-")
218 #define VOID(p) ((const void*)(p))
219 #define eventname(i) (getstr(tmname[i]))
228 int c=(
int)(
unsigned char)
s[i];
259 if (isprint(c))
printf(
"%c",c);
else printf(
"\\%03d",c);
314 if (buff[strspn(buff,
"-0123456789")]==
'\0')
printf(
".0");
330 #define COMMENT "\t; "
331 #define EXTRAARG GETARG_Ax(code[pc+1])
332 #define EXTRAARGC (EXTRAARG*(MAXARG_C+1))
333 #define ISK (isk ? "k" : "")
338 int pc,n=
f->sizecode;
339 for (pc=0; pc<n; pc++)
354 if (line>0)
printf(
"[%d]\t",line);
else printf(
"[-]\t");
439 printf(
"%d %d %d",a,b,sc);
482 printf(
"%d %d %d",a,b,sc);
485 printf(
"%d %d %d",a,b,sc);
528 printf(
"%d %d %d %d",a,sb,c,isk);
533 printf(
"%d %d %d %d",a,b,c,isk);
563 printf(
"%d %d %d",a,b,isk);
566 printf(
"%d %d %d",a,b,isk);
569 printf(
"%d %d %d",a,b,isk);
572 printf(
"%d %d %d",a,b,isk);
576 printf(
"%d %d %d",a,sb,isk);
579 printf(
"%d %d %d",a,sb,isk);
582 printf(
"%d %d %d",a,sb,isk);
585 printf(
"%d %d %d",a,sb,isk);
588 printf(
"%d %d %d",a,sb,isk);
594 printf(
"%d %d %d",a,b,isk);
666 #define SS(x) ((x==1)?"":"s")
667 #define S(x) (int)(x),SS(x)
671 const char*
s=
f->source ?
getstr(
f->source) :
"=?";
672 if (*
s==
'@' || *
s==
'=')
678 printf(
"\n%s <%s:%d,%d> (%d instruction%s at %p)\n",
679 (
f->linedefined==0)?
"main":
"function",
s,
680 f->linedefined,
f->lastlinedefined,
682 printf(
"%d%s param%s, %d slot%s, %d upvalue%s, ",
683 (
int)(
f->numparams),
f->is_vararg?
"+":
"",
SS(
f->numparams),
684 S(
f->maxstacksize),
S(
f->sizeupvalues));
685 printf(
"%d local%s, %d constant%s, %d function%s\n",
686 S(
f->sizelocvars),
S(
f->sizek),
S(
f->sizep));
705 printf(
"\t%d\t%s\t%d\t%d\n",
706 i,
getstr(
f->locvars[i].varname),
f->locvars[i].startpc+1,
f->locvars[i].endpc+1);
712 printf(
"\t%d\t%s\t%d\t%d\n",
713 i,
UPVALNAME(i),
f->upvalues[i].instack,
f->upvalues[i].idx);
#define lua_pcall(L, n, r, f)
#define lua_tostring(L, i)
auto printf(string_view fmt, const T &... args) -> int
LUA_API int lua_checkstack(lua_State *L, int n)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
static void PrintConstant(const Proto *f, int i)
static const char * progname
static void PrintCode(const Proto *f)
#define luaL_loadfile(L, f)
span_constexpr std::size_t size(span< T, Extent > const &spn)
static void PrintFunction(const Proto *f, int full)
#define lua_tointeger(L, i)
static void PrintHeader(const Proto *f)
void version(int *major_, int *minor_, int *patch_)
static const char * output
static int writer(lua_State *L, const void *p, size_t size, void *u)
static int doargs(int argc, char *argv[])
LUA_API void * lua_touserdata(lua_State *L, int idx)
static void fatal(const char *message)
static void cannot(const char *what)
LUA_API void lua_close(lua_State *L)
#define lua_pushcfunction(L, f)
int main(int argc, char *argv[])
static void usage(const char *message)
static const char * reader(lua_State *L, void *ud, size_t *size)
static void PrintType(const Proto *f, int i)
static const char *const opnames[]
static int pmain(lua_State *L)
int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, int strip)
static void PrintDebug(const Proto *f)
int luaG_getfuncline(const Proto *f, int pc)
LUALIB_API lua_State * luaL_newstate(void)
static const Proto * combine(lua_State *L, int n)
static void PrintString(const TString *ts)
LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode)
auto sprintf(const S &fmt, const T &... args) -> std::basic_string< Char >
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45