Tamar 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/HISTORY +22 -5
- data/Tamar.gemspec +114 -1
- data/VERSION +1 -1
- data/src/lua/CMakeLists.txt +176 -0
- data/src/lua/COPYRIGHT +34 -0
- data/src/lua/FindReadline.cmake +25 -0
- data/src/lua/HISTORY +183 -0
- data/src/lua/INSTALL +99 -0
- data/src/lua/Makefile +128 -0
- data/src/lua/README +46 -0
- data/src/lua/dist.cmake +450 -0
- data/src/lua/dist.info +10 -0
- data/src/lua/doc/amazon.gif +0 -0
- data/src/lua/doc/contents.html +499 -0
- data/src/lua/doc/cover.png +0 -0
- data/src/lua/doc/logo.gif +0 -0
- data/src/lua/doc/lua.1 +163 -0
- data/src/lua/doc/lua.css +41 -0
- data/src/lua/doc/lua.html +172 -0
- data/src/lua/doc/luac.1 +136 -0
- data/src/lua/doc/luac.html +145 -0
- data/src/lua/doc/manual.css +13 -0
- data/src/lua/doc/manual.html +8801 -0
- data/src/lua/doc/readme.html +40 -0
- data/src/lua/etc/Makefile +44 -0
- data/src/lua/etc/README +37 -0
- data/src/lua/etc/all.c +38 -0
- data/src/lua/etc/lua.hpp +9 -0
- data/src/lua/etc/lua.ico +0 -0
- data/src/lua/etc/lua.pc +31 -0
- data/src/lua/etc/luavs.bat +28 -0
- data/src/lua/etc/min.c +39 -0
- data/src/lua/etc/noparser.c +50 -0
- data/src/lua/etc/strict.lua +41 -0
- data/src/lua/src/Makefile +182 -0
- data/src/lua/src/lapi.c +1087 -0
- data/src/lua/src/lapi.h +16 -0
- data/src/lua/src/lauxlib.c +652 -0
- data/src/lua/src/lauxlib.h +174 -0
- data/src/lua/src/lbaselib.c +653 -0
- data/src/lua/src/lcode.c +831 -0
- data/src/lua/src/lcode.h +76 -0
- data/src/lua/src/ldblib.c +398 -0
- data/src/lua/src/ldebug.c +638 -0
- data/src/lua/src/ldebug.h +33 -0
- data/src/lua/src/ldo.c +518 -0
- data/src/lua/src/ldo.h +57 -0
- data/src/lua/src/ldump.c +164 -0
- data/src/lua/src/lfunc.c +174 -0
- data/src/lua/src/lfunc.h +34 -0
- data/src/lua/src/lgc.c +711 -0
- data/src/lua/src/lgc.h +110 -0
- data/src/lua/src/linit.c +38 -0
- data/src/lua/src/liolib.c +556 -0
- data/src/lua/src/llex.c +463 -0
- data/src/lua/src/llex.h +81 -0
- data/src/lua/src/llimits.h +128 -0
- data/src/lua/src/lmathlib.c +263 -0
- data/src/lua/src/lmem.c +86 -0
- data/src/lua/src/lmem.h +49 -0
- data/src/lua/src/loadlib.c +666 -0
- data/src/lua/src/loadlib_rel.c +719 -0
- data/src/lua/src/lobject.c +214 -0
- data/src/lua/src/lobject.h +381 -0
- data/src/lua/src/lopcodes.c +102 -0
- data/src/lua/src/lopcodes.h +268 -0
- data/src/lua/src/loslib.c +243 -0
- data/src/lua/src/lparser.c +1339 -0
- data/src/lua/src/lparser.h +82 -0
- data/src/lua/src/lstate.c +214 -0
- data/src/lua/src/lstate.h +169 -0
- data/src/lua/src/lstring.c +111 -0
- data/src/lua/src/lstring.h +31 -0
- data/src/lua/src/lstrlib.c +871 -0
- data/src/lua/src/ltable.c +588 -0
- data/src/lua/src/ltable.h +40 -0
- data/src/lua/src/ltablib.c +287 -0
- data/src/lua/src/ltm.c +75 -0
- data/src/lua/src/ltm.h +54 -0
- data/src/lua/src/lua.c +392 -0
- data/src/lua/src/lua.def +131 -0
- data/src/lua/src/lua.h +388 -0
- data/src/lua/src/lua.rc +28 -0
- data/src/lua/src/lua_dll.rc +26 -0
- data/src/lua/src/luac.c +200 -0
- data/src/lua/src/luac.rc +1 -0
- data/src/lua/src/luaconf.h.in +724 -0
- data/src/lua/src/luaconf.h.orig +763 -0
- data/src/lua/src/lualib.h +53 -0
- data/src/lua/src/lundump.c +227 -0
- data/src/lua/src/lundump.h +36 -0
- data/src/lua/src/lvm.c +766 -0
- data/src/lua/src/lvm.h +36 -0
- data/src/lua/src/lzio.c +82 -0
- data/src/lua/src/lzio.h +67 -0
- data/src/lua/src/print.c +227 -0
- data/src/lua/test/README +26 -0
- data/src/lua/test/bisect.lua +27 -0
- data/src/lua/test/cf.lua +16 -0
- data/src/lua/test/echo.lua +5 -0
- data/src/lua/test/env.lua +7 -0
- data/src/lua/test/factorial.lua +32 -0
- data/src/lua/test/fib.lua +40 -0
- data/src/lua/test/fibfor.lua +13 -0
- data/src/lua/test/globals.lua +13 -0
- data/src/lua/test/hello.lua +3 -0
- data/src/lua/test/life.lua +111 -0
- data/src/lua/test/luac.lua +7 -0
- data/src/lua/test/printf.lua +7 -0
- data/src/lua/test/readonly.lua +12 -0
- data/src/lua/test/sieve.lua +29 -0
- data/src/lua/test/sort.lua +66 -0
- data/src/lua/test/table.lua +12 -0
- data/src/lua/test/trace-calls.lua +32 -0
- data/src/lua/test/trace-globals.lua +38 -0
- data/src/lua/test/xd.lua +14 -0
- metadata +115 -2
@@ -0,0 +1,53 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
|
3
|
+
** Lua standard libraries
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#ifndef lualib_h
|
9
|
+
#define lualib_h
|
10
|
+
|
11
|
+
#include "lua.h"
|
12
|
+
|
13
|
+
|
14
|
+
/* Key to file-handle type */
|
15
|
+
#define LUA_FILEHANDLE "FILE*"
|
16
|
+
|
17
|
+
|
18
|
+
#define LUA_COLIBNAME "coroutine"
|
19
|
+
LUALIB_API int (luaopen_base) (lua_State *L);
|
20
|
+
|
21
|
+
#define LUA_TABLIBNAME "table"
|
22
|
+
LUALIB_API int (luaopen_table) (lua_State *L);
|
23
|
+
|
24
|
+
#define LUA_IOLIBNAME "io"
|
25
|
+
LUALIB_API int (luaopen_io) (lua_State *L);
|
26
|
+
|
27
|
+
#define LUA_OSLIBNAME "os"
|
28
|
+
LUALIB_API int (luaopen_os) (lua_State *L);
|
29
|
+
|
30
|
+
#define LUA_STRLIBNAME "string"
|
31
|
+
LUALIB_API int (luaopen_string) (lua_State *L);
|
32
|
+
|
33
|
+
#define LUA_MATHLIBNAME "math"
|
34
|
+
LUALIB_API int (luaopen_math) (lua_State *L);
|
35
|
+
|
36
|
+
#define LUA_DBLIBNAME "debug"
|
37
|
+
LUALIB_API int (luaopen_debug) (lua_State *L);
|
38
|
+
|
39
|
+
#define LUA_LOADLIBNAME "package"
|
40
|
+
LUALIB_API int (luaopen_package) (lua_State *L);
|
41
|
+
|
42
|
+
|
43
|
+
/* open all previous libraries */
|
44
|
+
LUALIB_API void (luaL_openlibs) (lua_State *L);
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
#ifndef lua_assert
|
49
|
+
#define lua_assert(x) ((void)0)
|
50
|
+
#endif
|
51
|
+
|
52
|
+
|
53
|
+
#endif
|
@@ -0,0 +1,227 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
|
3
|
+
** load precompiled Lua chunks
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <string.h>
|
8
|
+
|
9
|
+
#define lundump_c
|
10
|
+
#define LUA_CORE
|
11
|
+
|
12
|
+
#include "lua.h"
|
13
|
+
|
14
|
+
#include "ldebug.h"
|
15
|
+
#include "ldo.h"
|
16
|
+
#include "lfunc.h"
|
17
|
+
#include "lmem.h"
|
18
|
+
#include "lobject.h"
|
19
|
+
#include "lstring.h"
|
20
|
+
#include "lundump.h"
|
21
|
+
#include "lzio.h"
|
22
|
+
|
23
|
+
typedef struct {
|
24
|
+
lua_State* L;
|
25
|
+
ZIO* Z;
|
26
|
+
Mbuffer* b;
|
27
|
+
const char* name;
|
28
|
+
} LoadState;
|
29
|
+
|
30
|
+
#ifdef LUAC_TRUST_BINARIES
|
31
|
+
#define IF(c,s)
|
32
|
+
#define error(S,s)
|
33
|
+
#else
|
34
|
+
#define IF(c,s) if (c) error(S,s)
|
35
|
+
|
36
|
+
static void error(LoadState* S, const char* why)
|
37
|
+
{
|
38
|
+
luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
|
39
|
+
luaD_throw(S->L,LUA_ERRSYNTAX);
|
40
|
+
}
|
41
|
+
#endif
|
42
|
+
|
43
|
+
#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
|
44
|
+
#define LoadByte(S) (lu_byte)LoadChar(S)
|
45
|
+
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
|
46
|
+
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
|
47
|
+
|
48
|
+
static void LoadBlock(LoadState* S, void* b, size_t size)
|
49
|
+
{
|
50
|
+
size_t r=luaZ_read(S->Z,b,size);
|
51
|
+
IF (r!=0, "unexpected end");
|
52
|
+
}
|
53
|
+
|
54
|
+
static int LoadChar(LoadState* S)
|
55
|
+
{
|
56
|
+
char x;
|
57
|
+
LoadVar(S,x);
|
58
|
+
return x;
|
59
|
+
}
|
60
|
+
|
61
|
+
static int LoadInt(LoadState* S)
|
62
|
+
{
|
63
|
+
int x;
|
64
|
+
LoadVar(S,x);
|
65
|
+
IF (x<0, "bad integer");
|
66
|
+
return x;
|
67
|
+
}
|
68
|
+
|
69
|
+
static lua_Number LoadNumber(LoadState* S)
|
70
|
+
{
|
71
|
+
lua_Number x;
|
72
|
+
LoadVar(S,x);
|
73
|
+
return x;
|
74
|
+
}
|
75
|
+
|
76
|
+
static TString* LoadString(LoadState* S)
|
77
|
+
{
|
78
|
+
size_t size;
|
79
|
+
LoadVar(S,size);
|
80
|
+
if (size==0)
|
81
|
+
return NULL;
|
82
|
+
else
|
83
|
+
{
|
84
|
+
char* s=luaZ_openspace(S->L,S->b,size);
|
85
|
+
LoadBlock(S,s,size);
|
86
|
+
return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
static void LoadCode(LoadState* S, Proto* f)
|
91
|
+
{
|
92
|
+
int n=LoadInt(S);
|
93
|
+
f->code=luaM_newvector(S->L,n,Instruction);
|
94
|
+
f->sizecode=n;
|
95
|
+
LoadVector(S,f->code,n,sizeof(Instruction));
|
96
|
+
}
|
97
|
+
|
98
|
+
static Proto* LoadFunction(LoadState* S, TString* p);
|
99
|
+
|
100
|
+
static void LoadConstants(LoadState* S, Proto* f)
|
101
|
+
{
|
102
|
+
int i,n;
|
103
|
+
n=LoadInt(S);
|
104
|
+
f->k=luaM_newvector(S->L,n,TValue);
|
105
|
+
f->sizek=n;
|
106
|
+
for (i=0; i<n; i++) setnilvalue(&f->k[i]);
|
107
|
+
for (i=0; i<n; i++)
|
108
|
+
{
|
109
|
+
TValue* o=&f->k[i];
|
110
|
+
int t=LoadChar(S);
|
111
|
+
switch (t)
|
112
|
+
{
|
113
|
+
case LUA_TNIL:
|
114
|
+
setnilvalue(o);
|
115
|
+
break;
|
116
|
+
case LUA_TBOOLEAN:
|
117
|
+
setbvalue(o,LoadChar(S)!=0);
|
118
|
+
break;
|
119
|
+
case LUA_TNUMBER:
|
120
|
+
setnvalue(o,LoadNumber(S));
|
121
|
+
break;
|
122
|
+
case LUA_TSTRING:
|
123
|
+
setsvalue2n(S->L,o,LoadString(S));
|
124
|
+
break;
|
125
|
+
default:
|
126
|
+
error(S,"bad constant");
|
127
|
+
break;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
n=LoadInt(S);
|
131
|
+
f->p=luaM_newvector(S->L,n,Proto*);
|
132
|
+
f->sizep=n;
|
133
|
+
for (i=0; i<n; i++) f->p[i]=NULL;
|
134
|
+
for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
|
135
|
+
}
|
136
|
+
|
137
|
+
static void LoadDebug(LoadState* S, Proto* f)
|
138
|
+
{
|
139
|
+
int i,n;
|
140
|
+
n=LoadInt(S);
|
141
|
+
f->lineinfo=luaM_newvector(S->L,n,int);
|
142
|
+
f->sizelineinfo=n;
|
143
|
+
LoadVector(S,f->lineinfo,n,sizeof(int));
|
144
|
+
n=LoadInt(S);
|
145
|
+
f->locvars=luaM_newvector(S->L,n,LocVar);
|
146
|
+
f->sizelocvars=n;
|
147
|
+
for (i=0; i<n; i++) f->locvars[i].varname=NULL;
|
148
|
+
for (i=0; i<n; i++)
|
149
|
+
{
|
150
|
+
f->locvars[i].varname=LoadString(S);
|
151
|
+
f->locvars[i].startpc=LoadInt(S);
|
152
|
+
f->locvars[i].endpc=LoadInt(S);
|
153
|
+
}
|
154
|
+
n=LoadInt(S);
|
155
|
+
f->upvalues=luaM_newvector(S->L,n,TString*);
|
156
|
+
f->sizeupvalues=n;
|
157
|
+
for (i=0; i<n; i++) f->upvalues[i]=NULL;
|
158
|
+
for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
|
159
|
+
}
|
160
|
+
|
161
|
+
static Proto* LoadFunction(LoadState* S, TString* p)
|
162
|
+
{
|
163
|
+
Proto* f;
|
164
|
+
if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
|
165
|
+
f=luaF_newproto(S->L);
|
166
|
+
setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
|
167
|
+
f->source=LoadString(S); if (f->source==NULL) f->source=p;
|
168
|
+
f->linedefined=LoadInt(S);
|
169
|
+
f->lastlinedefined=LoadInt(S);
|
170
|
+
f->nups=LoadByte(S);
|
171
|
+
f->numparams=LoadByte(S);
|
172
|
+
f->is_vararg=LoadByte(S);
|
173
|
+
f->maxstacksize=LoadByte(S);
|
174
|
+
LoadCode(S,f);
|
175
|
+
LoadConstants(S,f);
|
176
|
+
LoadDebug(S,f);
|
177
|
+
IF (!luaG_checkcode(f), "bad code");
|
178
|
+
S->L->top--;
|
179
|
+
S->L->nCcalls--;
|
180
|
+
return f;
|
181
|
+
}
|
182
|
+
|
183
|
+
static void LoadHeader(LoadState* S)
|
184
|
+
{
|
185
|
+
char h[LUAC_HEADERSIZE];
|
186
|
+
char s[LUAC_HEADERSIZE];
|
187
|
+
luaU_header(h);
|
188
|
+
LoadBlock(S,s,LUAC_HEADERSIZE);
|
189
|
+
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
|
190
|
+
}
|
191
|
+
|
192
|
+
/*
|
193
|
+
** load precompiled chunk
|
194
|
+
*/
|
195
|
+
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
|
196
|
+
{
|
197
|
+
LoadState S;
|
198
|
+
if (*name=='@' || *name=='=')
|
199
|
+
S.name=name+1;
|
200
|
+
else if (*name==LUA_SIGNATURE[0])
|
201
|
+
S.name="binary string";
|
202
|
+
else
|
203
|
+
S.name=name;
|
204
|
+
S.L=L;
|
205
|
+
S.Z=Z;
|
206
|
+
S.b=buff;
|
207
|
+
LoadHeader(&S);
|
208
|
+
return LoadFunction(&S,luaS_newliteral(L,"=?"));
|
209
|
+
}
|
210
|
+
|
211
|
+
/*
|
212
|
+
* make header
|
213
|
+
*/
|
214
|
+
void luaU_header (char* h)
|
215
|
+
{
|
216
|
+
int x=1;
|
217
|
+
memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
|
218
|
+
h+=sizeof(LUA_SIGNATURE)-1;
|
219
|
+
*h++=(char)LUAC_VERSION;
|
220
|
+
*h++=(char)LUAC_FORMAT;
|
221
|
+
*h++=(char)*(char*)&x; /* endianness */
|
222
|
+
*h++=(char)sizeof(int);
|
223
|
+
*h++=(char)sizeof(size_t);
|
224
|
+
*h++=(char)sizeof(Instruction);
|
225
|
+
*h++=(char)sizeof(lua_Number);
|
226
|
+
*h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
|
227
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/*
|
2
|
+
** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $
|
3
|
+
** load precompiled Lua chunks
|
4
|
+
** See Copyright Notice in lua.h
|
5
|
+
*/
|
6
|
+
|
7
|
+
#ifndef lundump_h
|
8
|
+
#define lundump_h
|
9
|
+
|
10
|
+
#include "lobject.h"
|
11
|
+
#include "lzio.h"
|
12
|
+
|
13
|
+
/* load one chunk; from lundump.c */
|
14
|
+
LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
|
15
|
+
|
16
|
+
/* make header; from lundump.c */
|
17
|
+
LUAI_FUNC void luaU_header (char* h);
|
18
|
+
|
19
|
+
/* dump one chunk; from ldump.c */
|
20
|
+
LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
|
21
|
+
|
22
|
+
#ifdef luac_c
|
23
|
+
/* print one chunk; from print.c */
|
24
|
+
LUAI_FUNC void luaU_print (const Proto* f, int full);
|
25
|
+
#endif
|
26
|
+
|
27
|
+
/* for header of binary files -- this is Lua 5.1 */
|
28
|
+
#define LUAC_VERSION 0x51
|
29
|
+
|
30
|
+
/* for header of binary files -- this is the official format */
|
31
|
+
#define LUAC_FORMAT 0
|
32
|
+
|
33
|
+
/* size of header of binary files */
|
34
|
+
#define LUAC_HEADERSIZE 12
|
35
|
+
|
36
|
+
#endif
|