ofs | hex dump | ascii |
---|
0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 04 00 00 00 04 00 08 03 00 00 00 48 c3 db | .PNG........IHDR.............H.. |
0020 | b1 00 00 00 4e 50 4c 54 45 00 00 00 ff ff ff de de de 8c 8c 8c f7 f7 f7 bd bd bd a5 a5 a5 63 63 | ....NPLTE.....................cc |
0040 | 63 ef ef ef 7b 7b 7b e7 e7 e7 ce ce ce d6 d6 d6 94 9c 94 ad b5 ad c6 c6 c6 f7 ff f7 bd c6 bd ef | c...{{{......................... |
0060 | f7 ef d6 de d6 e7 ef e7 ad ad ad b5 bd b5 c6 ce c6 de e7 de b5 b5 b5 46 01 57 84 00 00 00 01 74 | .......................F.W.....t |
0080 | 52 4e 53 00 40 e6 d8 66 00 01 07 7d 49 44 41 54 78 5e ec fd 89 76 e3 3a cc 35 0a 72 73 9e 24 7d | RNS.@..f...}IDATx^...v.:.5.rs.$} |
00a0 | ff 70 6f 77 bf ff 8b f6 32 20 2c 50 a1 15 c5 b1 ab 52 55 c7 38 a7 42 00 e2 3c 6c 53 b4 b4 6d fe | .pow....2.,P.....RU.8.B..<lS..m. |
00c0 | 32 79 cb 5b de 12 61 77 cd 22 de 82 8a 7a 0b 36 6c 06 c6 18 c0 00 1c 31 9e e7 f0 77 ca 5b de f2 | 2y.[..aw."...z.6l......1...w.[.. |
00e0 | 16 e7 1b 85 cd 3b 0a 5a 6a 37 07 08 02 06 00 f0 c9 5f e4 f0 05 81 f9 07 e4 2d 0d 8b 79 85 00 aa | .....;.Zj7......._.......-..y... |
0100 | fc 5b 02 fc 9a 36 2d 68 8f 55 03 b3 92 57 f3 1d f1 c9 3f de 01 5c ec 06 b3 a2 08 00 98 62 61 0b | .[...6-h.U...W....?..\.......ba. |
0120 | 47 8b 59 50 c6 24 6f 8d f5 e9 4b 38 e1 60 8d 59 32 f2 62 8c b3 54 88 eb 40 5d 77 25 73 2f ad 5c | G.YP.$o...K8.`.Y2.b..T..@]w%s/.\ |
0140 | 05 70 eb 4b 87 8f 64 b3 a3 79 10 72 6d 9e f2 b9 96 a5 02 bd 8c 9e 8e ce 7d ca 39 99 96 91 23 f5 | .p.K..d..y.rm...........}.9...#. |
0160 | 71 4b 5a 92 84 c6 34 2a 8a 54 f1 b3 0e c1 59 8f d5 e8 58 35 d3 e8 c2 46 f1 a5 c5 00 90 83 99 6d | qKZ...4*.T....Y...X5...F.......m |
0180 | 13 32 d0 1d 39 34 4b c0 64 38 e3 90 c9 66 8f 45 a4 ad 9b bd e5 bd c1 0e 95 bd 79 ad 6c 0a b9 6f | .2..94K.d8...f.E..........y.l..o |
01a0 | 01 67 0e d2 fc bc 8a 45 66 67 cc 18 ec 49 65 45 5b fd 13 68 a0 15 e5 ba e4 38 b7 47 a5 c3 07 b5 | .g.....Efg...IeE[..h.....8.G.... |
01c0 | 2a f7 61 35 80 29 1d 00 ee 00 00 e0 e3 57 d6 2b a0 eb 43 97 6c 94 85 7b fc ac 8d 75 ec 2d 56 93 | *.a5.).......W.+..C.l..{...u.-V. |
01e0 | 85 4d 43 ea 49 31 0e 12 7f 98 c4 d7 e1 86 6d 4f 4e a2 d3 9d e5 33 00 a8 d5 74 7f 4b c0 11 6d 30 | .MC.I1........mON....3...t.K..m0 |
0200 | c1 72 34 0f 13 f7 aa 34 9a a4 cd 98 be 25 a4 ad 9b 4f c4 52 dc 6e 3a 9c b1 8e 0a b1 8b 31 01 41 | .r4....4.....%...O.R.n:......1.A |
0220 | 94 5b fe c9 43 aa 40 56 4d a6 ed 3a bc 2c 01 13 b0 99 0d ce 5c 4b 2f a6 20 33 12 f8 8d ab ef f7 | .[..C.@VM..:.,......\K/..3...... |
0240 | da af e8 c6 54 ef 4c ea 37 3b 65 2f 25 6b c8 d7 37 b6 f5 cf d8 5f 15 6d 4c 57 4d e5 e9 48 ce 42 | ....T.L.7;e/%k..7...._.mLWM..H.B |
0260 | 2d 2e 7b 6f 6d bb 9d c8 a6 d1 09 58 8d 59 ac 94 a9 85 74 ac 54 c3 ca 39 a3 12 1c 64 38 13 e1 8d | -.{om......X.Y....t.T..9...d8... |
0280 | f1 88 8c 70 82 19 11 4e eb 45 fd c8 c8 ac 52 fb 03 00 e0 c9 b8 06 00 35 9e 90 67 d2 67 38 4e ee | ...p...N.E....R........5..g.g8N. |
02a0 | 90 ef e6 c9 7f db ad 3b f5 5a bc 45 ce 88 06 30 1e c5 8c 12 32 72 60 15 de 4c 32 c7 32 ba 3e b4 | .......;.Z.E...0....2r`..L2.2.>. |
02c0 | 21 05 fb c2 ed f5 90 8c 21 fb b8 da 3b 1c fa 27 00 00 20 88 66 64 12 5f 87 0a 04 01 0b a5 d4 e9 | !.......!...;..'....fd._........ |
02e0 | 7e b9 03 c0 66 7c 37 c6 a2 20 35 ae 0a 04 00 d2 1e 3b a1 12 98 26 93 e8 a3 59 fc 27 1b 00 05 0c | ~...f|7...5......;...&...Y.'.... |
0300 | 89 a5 7d 2c 2e 7b 00 80 8d b6 ad a2 37 fd 74 a4 b0 99 83 c4 aa 7a 8d 87 76 d1 3a 63 38 4c 00 92 | ..},.{......7.t......z..v.:c8L.. |
0320 | 2e b3 15 41 e2 98 88 6d 02 80 20 d7 4f 01 60 43 1d bc 00 e4 1f ad 7a 69 31 27 f5 93 6d 3c cf da | ...A...m....O.`C......zi1'..m<.. |
0340 | 19 00 18 e4 82 b1 e0 8b d6 98 8a 40 60 96 b1 2c a4 90 2e c3 99 fb 90 4f 45 8c a8 8f ad 37 60 32 | ...........@`..,.......OE....7`2 |
0360 | 2e d6 e7 8f 03 c0 3c 32 b3 60 02 34 b6 97 05 8c f8 15 76 39 e0 64 32 a9 57 dd 04 a9 cc b1 c6 42 | ......<2.`.4......v9.d2.W......B |
0380 | 70 68 c8 b6 e9 c2 1d c4 4f 00 20 58 fa f9 0e 60 44 22 9e c4 d7 a1 02 81 e5 02 64 ba 5f 02 80 1b | ph......O..X...`D"........d._... |
03a0 | 37 a4 d8 11 2e 5a 01 cf 75 8f bd 91 b6 62 bb 00 00 d9 00 ec 0b 37 8f b1 92 68 2b da 2d ef 65 04 | 7....Z..u....b.......7...h+.-.e. |
03c0 | 80 aa 79 11 4e 37 da 01 08 10 e4 01 af 5c d3 8d 3b 2b cd 19 96 76 ab 1f ec 8e 35 11 40 54 00 b0 | ..y.N7.......\..;+...v....5.@T.. |
</*
** $Id: luac.c,v 1.54 2006/06/02 17:37:11 lhf Exp $
** Lua compiler (saves bytecodes to files; also list bytecodes)
** See Copyright Notice in lua.h
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define luac_c
#define LUA_CORE
#include "lua.h"
#include "lauxlib.h"
#include "ldo.h"
#include "lfunc.h"
#include "lmem.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lstring.h"
#include "lundump.h"
#define PROGNAME "luac" /* default program name */
#define OUTPUT PROGNAME ".out" /* default output file */
static int listing=0; /* list bytecodes? */
static int dumping=1; /* dump bytecodes? */
static int stripping=0; /* strip debug information? */
static char Output[]={ OUTPUT }; /* default output file name */
static const char* output=Output; /* actual output file name */
static const char* progname=PROGNAME; /* actual program name */
static void fatal(const char* message)
{
fprintf(stderr,"%s: %s\n",progname,message);
exit(EXIT_FAILURE);
}
static void cannot(const char* what)
{
fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno));
exit(EXIT_FAILURE);
}
static void usage(const char* message)
{
if (*message=='-')
fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message);
else
fprintf(stderr,"%s: %s\n",progname,message);
fprintf(stderr,
"usage: %s [options] [filenames].\n"
"Available options are:\n"
" - process stdin\n"
" -l list\n"
" -o name output to file " LUA_QL("name") " (default is \"%s\")\n"
" -p parse only\n"
" -s strip debug information\n"
" -v show version information\n"
" -- stop handling options\n",
progname,Output);
exit(EXIT_FAILURE);
}
#define IS(s) (strcmp(argv[i],s)==0)
static int doargs(int argc, char* argv[])
{
int i;
int version=0;
if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0];
for (i=1; i<argc; i++)
{
if (*argv[i]!='-') /* end of options; keep it */
break;
else if (IS("--")) /* end of options; skip it */
{
++i;
if (version) ++version;
break;
}
else if (IS("-")) /* end of options; use stdin */
break;
else if (IS("-l")) /* list */
++listing;
else if (IS("-o")) /* output file */
{
output=argv[++i];
if (output==NULL || *output==0) usage(LUA_QL("-o") " needs argument");
if (IS("-")) output=NULL;
}
else if (IS("-p")) /* parse only */
dumping=0;
else if (IS("-s")) /* strip debug information */
stripping=1;
else if (IS("-v")) /* show version */
++version;
else /* unknown option */
usage(argv[i]);
}
if (i==argc && (listing || !dumping))
{
dumping=0;
argv[--i]=Output;
}
if (version)
{
printf("%s %s\n",LUA_RELEASE,LUA_COPYRIGHT);
if (version==argc-1) exit(EXIT_SUCCESS);
}
return i;
}
#define toproto(L,i) (clvalue(L->top+(i))->l.p)
static const Proto* combine(lua_State* L, int n)
{
if (n==1)
return toproto(L,-1);
else
{
int i,pc;
Proto* f=luaF_newproto(L);
setptvalue2s(L,L->top,f); incr_top(L);
f->source=luaS_newliteral(L,"=(" PROGNAME ")");
f->maxstacksize=1;
pc=2*n+1;
f->code=luaM_newvector(L,pc,Instruction);
f->sizecode=pc;
f->p=luaM_newvector(L,n,Proto*);
f->sizep=n;
pc=0;
for (i=0; i<n; i++)
{
f->p[i]=toproto(L,i-n-1);
f->code[pc++]=CREATE_ABx(OP_CLOSURE,0,i);
f->code[pc++]=CREATE_ABC(OP_CALL,0,1,1);
}
f->code[pc++]=CREATE_ABC(OP_RETURN,0,1,0);
return f;
}
}
static int writer(lua_State* L, const void* p, size_t size, void* u)
{
UNUSED(L);
return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0);
}
struct Smain {
int argc;
char** argv;
};
static int pmain(lua_State* L)
{
struct Smain* s = (struct Smain*)lua_touserdata(L, 1);
int argc=s->argc;
char** argv=s->argv;
const Proto* f;
int i;
if (!lua_checkstack(L,argc)) fatal("too many input files");
for (i=0; i<argc; i++)
{
const char* filename=IS("-") ? NULL : argv[i];
if (luaL_loadfile(L,filename)!=0) fatal(lua_tostring(L,-1));
}
f=combine(L,argc);
if (listing) luaU_print(f,listing>1);
if (dumping)
{
FILE* D= (output==NULL) ? stdout : fopen(output,"wb");
if (D==NULL) cannot("open");
lua_lock(L);
luaU_dump(L,f,writer,D,stripping);
lua_unlock(L);
if (ferror(D)) cannot("write");
if (fclose(D)) cannot("close");
}
return 0;
}
int main(int argc, char* argv[])
{
lua_State* L;
struct Smain s;
int i=doargs(argc,argv);
argc-=i; argv+=i;
if (argc<=0) usage("no input files given");
L=lua_open();
if (L==NULL) fatal("not enough memory for state");
s.argc=argc;
s.argv=argv;
if (lua_cpcall(L,pmain,&s)!=0) fatal(lua_tostring(L,-1));
lua_close(L);
return EXIT_SUCCESS;
}