ofs | hex dump | ascii |
---|
0000 | 4f 67 67 53 00 02 00 00 00 00 00 00 00 00 0a 41 c0 2e 00 00 00 00 5c b9 a3 f1 01 1e 01 76 6f 72 | OggS...........A......\......vor |
0020 | 62 69 73 00 00 00 00 01 44 ac 00 00 00 00 00 00 30 a9 03 00 00 00 00 00 b8 01 4f 67 67 53 00 00 | bis.....D.......0.........OggS.. |
0040 | 00 00 00 00 00 00 00 00 0a 41 c0 2e 01 00 00 00 fd 51 f5 da 11 3c ff ff ff ff ff ff ff ff ff ff | .........A.......Q...<.......... |
0060 | ff ff ff ff ff d5 03 76 6f 72 62 69 73 2c 00 00 00 58 69 70 68 2e 4f 72 67 20 6c 69 62 56 6f 72 | .......vorbis,...Xiph.Org.libVor |
0080 | 62 69 73 20 49 20 32 30 31 35 30 31 30 35 20 28 e2 9b 84 e2 9b 84 e2 9b 84 e2 9b 84 29 00 00 00 | bis.I.20150105.(............)... |
00a0 | 00 01 05 76 6f 72 62 69 73 2b 42 43 56 01 00 08 00 00 00 31 4c 20 c5 80 d0 90 55 00 00 10 00 00 | ...vorbis+BCV......1L.....U..... |
00c0 | 60 24 29 0e 93 66 49 29 a5 94 a1 28 79 98 94 48 49 29 a5 94 c5 30 89 98 94 89 c5 18 63 8c 31 c6 | `$)..fI)...(y..HI)...0......c.1. |
00e0 | 18 63 8c 31 c6 18 63 8c 20 34 64 15 00 00 04 00 80 28 09 8e a3 e6 49 6a ce 39 67 18 27 8e 72 a0 | .c.1..c..4d......(....Ij.9g.'.r. |
0100 | 39 69 4e 38 a7 20 07 8a 51 e0 39 09 c2 f5 26 63 6e a6 b4 a6 6b 6e ce 29 25 08 0d 59 05 00 00 02 | 9iN8....Q.9...&cn...kn.)%..Y.... |
0120 | 00 40 48 21 85 14 52 48 21 85 14 62 88 21 86 18 62 88 21 87 1c 72 c8 21 a7 9c 72 0a 2a a8 a0 82 | .@H!..RH!..b.!..b.!..r.!..r.*... |
0140 | 0a 32 c8 20 83 4c 32 e9 a4 93 4e 3a e9 a8 a3 8e 3a ea 28 b4 d0 42 0b 2d b4 d2 4a 4c 31 d5 56 63 | .2...L2...N:....:.(..B.-..JL1.Vc |
0160 | ae bd 06 5d 7c 73 ce 39 e7 9c 73 ce 39 e7 9c 73 ce 09 42 43 56 01 00 20 00 00 04 42 06 19 64 10 | ...]|s.9..s.9..s..BCV......B..d. |
0180 | 42 08 21 85 14 52 88 29 a6 98 72 0a 32 c8 80 d0 90 55 00 00 20 00 80 00 00 00 00 47 91 14 49 b1 | B.!..R.)..r.2....U.........G..I. |
01a0 | 14 cb b1 1c cd d1 24 4f f2 2c 51 13 35 d1 33 45 53 54 4d 55 55 55 55 75 5d 57 76 65 d7 76 75 d7 | ......$O.,Q.5.3ESTMUUUUu]Wve.vu. |
01c0 | 76 7d 59 98 85 5b b8 7d 59 b8 85 5b d8 85 5d f7 85 61 18 86 61 18 86 61 18 86 61 f8 7d df f7 7d | v}Y..[.}Y..[..]..a..a..a..a.}..} |
01e0 | df f7 7d 20 34 64 15 00 20 01 00 a0 23 39 96 e3 29 a2 22 1a a2 e2 39 a2 03 84 86 ac 02 00 64 00 | ..}.4d......#9..)."...9.......d. |
0200 | 00 04 00 20 09 92 22 29 92 a3 49 a6 66 6a ae 69 9b b6 68 ab b6 6d cb b2 2c cb b2 0c 84 86 ac 02 | ......")..I.fj.i..h..m..,....... |
0220 | 00 00 01 00 04 00 00 00 00 00 a0 69 9a a6 69 9a a6 69 9a a6 69 9a a6 69 9a a6 69 9a a6 69 9a 66 | ...........i..i..i..i..i..i..i.f |
0240 | 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 65 59 96 | Y.eY.eY.eY.eY.eY.eY.eY.eY.eY.eY. |
0260 | 65 59 96 65 59 40 68 c8 2a 00 40 02 00 40 c7 71 1c c7 71 24 45 52 24 c7 72 2c 07 08 0d 59 05 00 | eY.eY@h.*.@..@.q..q$ER$.r,...Y.. |
0280 | c8 00 00 08 00 40 52 2c c5 72 34 47 73 34 c7 73 3c c7 73 3c 47 74 44 c9 94 4c cd f4 4c 0f 08 0d | .....@R,.r4Gs4.s<.s<GtD..L..L... |
02a0 | 59 05 00 00 02 00 08 00 00 00 00 00 40 31 1c c5 71 1c c9 d1 24 4f 52 2d d3 72 35 57 73 3d d7 73 | Y...........@1..q...$OR-.r5Ws=.s |
02c0 | 4d d7 75 5d 57 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 | M.u]WUUUUUUUUUUUUUUUUUUUUUUUUUUU |
02e0 | 55 55 55 55 55 55 55 81 d0 90 55 00 00 04 00 00 21 9d 66 96 6a 80 08 33 90 61 20 34 64 15 00 80 | UUUUUUU...U.....!.f.j..3.a.4d... |
0300 | 00 00 00 18 a1 08 43 0c 08 0d 59 05 00 00 04 00 00 88 a1 e4 20 9a d0 9a f3 cd 39 0e 9a e5 a0 a9 | ......C...Y...............9..... |
0320 | 14 9b d3 c1 89 54 9b 27 b9 a9 98 9b 73 ce 39 e7 9c 6c ce 19 e3 9c 73 ce 29 ca 99 c5 a0 99 d0 9a | .....T.'....s.9..l....s.)....... |
0340 | 73 ce 49 0c 9a a5 a0 99 d0 9/*
** $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;
}
|