Tamar 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.gitmodules +3 -0
  2. data/HISTORY +22 -5
  3. data/Tamar.gemspec +114 -1
  4. data/VERSION +1 -1
  5. data/src/lua/CMakeLists.txt +176 -0
  6. data/src/lua/COPYRIGHT +34 -0
  7. data/src/lua/FindReadline.cmake +25 -0
  8. data/src/lua/HISTORY +183 -0
  9. data/src/lua/INSTALL +99 -0
  10. data/src/lua/Makefile +128 -0
  11. data/src/lua/README +46 -0
  12. data/src/lua/dist.cmake +450 -0
  13. data/src/lua/dist.info +10 -0
  14. data/src/lua/doc/amazon.gif +0 -0
  15. data/src/lua/doc/contents.html +499 -0
  16. data/src/lua/doc/cover.png +0 -0
  17. data/src/lua/doc/logo.gif +0 -0
  18. data/src/lua/doc/lua.1 +163 -0
  19. data/src/lua/doc/lua.css +41 -0
  20. data/src/lua/doc/lua.html +172 -0
  21. data/src/lua/doc/luac.1 +136 -0
  22. data/src/lua/doc/luac.html +145 -0
  23. data/src/lua/doc/manual.css +13 -0
  24. data/src/lua/doc/manual.html +8801 -0
  25. data/src/lua/doc/readme.html +40 -0
  26. data/src/lua/etc/Makefile +44 -0
  27. data/src/lua/etc/README +37 -0
  28. data/src/lua/etc/all.c +38 -0
  29. data/src/lua/etc/lua.hpp +9 -0
  30. data/src/lua/etc/lua.ico +0 -0
  31. data/src/lua/etc/lua.pc +31 -0
  32. data/src/lua/etc/luavs.bat +28 -0
  33. data/src/lua/etc/min.c +39 -0
  34. data/src/lua/etc/noparser.c +50 -0
  35. data/src/lua/etc/strict.lua +41 -0
  36. data/src/lua/src/Makefile +182 -0
  37. data/src/lua/src/lapi.c +1087 -0
  38. data/src/lua/src/lapi.h +16 -0
  39. data/src/lua/src/lauxlib.c +652 -0
  40. data/src/lua/src/lauxlib.h +174 -0
  41. data/src/lua/src/lbaselib.c +653 -0
  42. data/src/lua/src/lcode.c +831 -0
  43. data/src/lua/src/lcode.h +76 -0
  44. data/src/lua/src/ldblib.c +398 -0
  45. data/src/lua/src/ldebug.c +638 -0
  46. data/src/lua/src/ldebug.h +33 -0
  47. data/src/lua/src/ldo.c +518 -0
  48. data/src/lua/src/ldo.h +57 -0
  49. data/src/lua/src/ldump.c +164 -0
  50. data/src/lua/src/lfunc.c +174 -0
  51. data/src/lua/src/lfunc.h +34 -0
  52. data/src/lua/src/lgc.c +711 -0
  53. data/src/lua/src/lgc.h +110 -0
  54. data/src/lua/src/linit.c +38 -0
  55. data/src/lua/src/liolib.c +556 -0
  56. data/src/lua/src/llex.c +463 -0
  57. data/src/lua/src/llex.h +81 -0
  58. data/src/lua/src/llimits.h +128 -0
  59. data/src/lua/src/lmathlib.c +263 -0
  60. data/src/lua/src/lmem.c +86 -0
  61. data/src/lua/src/lmem.h +49 -0
  62. data/src/lua/src/loadlib.c +666 -0
  63. data/src/lua/src/loadlib_rel.c +719 -0
  64. data/src/lua/src/lobject.c +214 -0
  65. data/src/lua/src/lobject.h +381 -0
  66. data/src/lua/src/lopcodes.c +102 -0
  67. data/src/lua/src/lopcodes.h +268 -0
  68. data/src/lua/src/loslib.c +243 -0
  69. data/src/lua/src/lparser.c +1339 -0
  70. data/src/lua/src/lparser.h +82 -0
  71. data/src/lua/src/lstate.c +214 -0
  72. data/src/lua/src/lstate.h +169 -0
  73. data/src/lua/src/lstring.c +111 -0
  74. data/src/lua/src/lstring.h +31 -0
  75. data/src/lua/src/lstrlib.c +871 -0
  76. data/src/lua/src/ltable.c +588 -0
  77. data/src/lua/src/ltable.h +40 -0
  78. data/src/lua/src/ltablib.c +287 -0
  79. data/src/lua/src/ltm.c +75 -0
  80. data/src/lua/src/ltm.h +54 -0
  81. data/src/lua/src/lua.c +392 -0
  82. data/src/lua/src/lua.def +131 -0
  83. data/src/lua/src/lua.h +388 -0
  84. data/src/lua/src/lua.rc +28 -0
  85. data/src/lua/src/lua_dll.rc +26 -0
  86. data/src/lua/src/luac.c +200 -0
  87. data/src/lua/src/luac.rc +1 -0
  88. data/src/lua/src/luaconf.h.in +724 -0
  89. data/src/lua/src/luaconf.h.orig +763 -0
  90. data/src/lua/src/lualib.h +53 -0
  91. data/src/lua/src/lundump.c +227 -0
  92. data/src/lua/src/lundump.h +36 -0
  93. data/src/lua/src/lvm.c +766 -0
  94. data/src/lua/src/lvm.h +36 -0
  95. data/src/lua/src/lzio.c +82 -0
  96. data/src/lua/src/lzio.h +67 -0
  97. data/src/lua/src/print.c +227 -0
  98. data/src/lua/test/README +26 -0
  99. data/src/lua/test/bisect.lua +27 -0
  100. data/src/lua/test/cf.lua +16 -0
  101. data/src/lua/test/echo.lua +5 -0
  102. data/src/lua/test/env.lua +7 -0
  103. data/src/lua/test/factorial.lua +32 -0
  104. data/src/lua/test/fib.lua +40 -0
  105. data/src/lua/test/fibfor.lua +13 -0
  106. data/src/lua/test/globals.lua +13 -0
  107. data/src/lua/test/hello.lua +3 -0
  108. data/src/lua/test/life.lua +111 -0
  109. data/src/lua/test/luac.lua +7 -0
  110. data/src/lua/test/printf.lua +7 -0
  111. data/src/lua/test/readonly.lua +12 -0
  112. data/src/lua/test/sieve.lua +29 -0
  113. data/src/lua/test/sort.lua +66 -0
  114. data/src/lua/test/table.lua +12 -0
  115. data/src/lua/test/trace-calls.lua +32 -0
  116. data/src/lua/test/trace-globals.lua +38 -0
  117. data/src/lua/test/xd.lua +14 -0
  118. metadata +115 -2
@@ -0,0 +1,164 @@
1
+ /*
2
+ ** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $
3
+ ** save precompiled Lua chunks
4
+ ** See Copyright Notice in lua.h
5
+ */
6
+
7
+ #include <stddef.h>
8
+
9
+ #define ldump_c
10
+ #define LUA_CORE
11
+
12
+ #include "lua.h"
13
+
14
+ #include "lobject.h"
15
+ #include "lstate.h"
16
+ #include "lundump.h"
17
+
18
+ typedef struct {
19
+ lua_State* L;
20
+ lua_Writer writer;
21
+ void* data;
22
+ int strip;
23
+ int status;
24
+ } DumpState;
25
+
26
+ #define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
27
+ #define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
28
+
29
+ static void DumpBlock(const void* b, size_t size, DumpState* D)
30
+ {
31
+ if (D->status==0)
32
+ {
33
+ lua_unlock(D->L);
34
+ D->status=(*D->writer)(D->L,b,size,D->data);
35
+ lua_lock(D->L);
36
+ }
37
+ }
38
+
39
+ static void DumpChar(int y, DumpState* D)
40
+ {
41
+ char x=(char)y;
42
+ DumpVar(x,D);
43
+ }
44
+
45
+ static void DumpInt(int x, DumpState* D)
46
+ {
47
+ DumpVar(x,D);
48
+ }
49
+
50
+ static void DumpNumber(lua_Number x, DumpState* D)
51
+ {
52
+ DumpVar(x,D);
53
+ }
54
+
55
+ static void DumpVector(const void* b, int n, size_t size, DumpState* D)
56
+ {
57
+ DumpInt(n,D);
58
+ DumpMem(b,n,size,D);
59
+ }
60
+
61
+ static void DumpString(const TString* s, DumpState* D)
62
+ {
63
+ if (s==NULL || getstr(s)==NULL)
64
+ {
65
+ size_t size=0;
66
+ DumpVar(size,D);
67
+ }
68
+ else
69
+ {
70
+ size_t size=s->tsv.len+1; /* include trailing '\0' */
71
+ DumpVar(size,D);
72
+ DumpBlock(getstr(s),size,D);
73
+ }
74
+ }
75
+
76
+ #define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D)
77
+
78
+ static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
79
+
80
+ static void DumpConstants(const Proto* f, DumpState* D)
81
+ {
82
+ int i,n=f->sizek;
83
+ DumpInt(n,D);
84
+ for (i=0; i<n; i++)
85
+ {
86
+ const TValue* o=&f->k[i];
87
+ DumpChar(ttype(o),D);
88
+ switch (ttype(o))
89
+ {
90
+ case LUA_TNIL:
91
+ break;
92
+ case LUA_TBOOLEAN:
93
+ DumpChar(bvalue(o),D);
94
+ break;
95
+ case LUA_TNUMBER:
96
+ DumpNumber(nvalue(o),D);
97
+ break;
98
+ case LUA_TSTRING:
99
+ DumpString(rawtsvalue(o),D);
100
+ break;
101
+ default:
102
+ lua_assert(0); /* cannot happen */
103
+ break;
104
+ }
105
+ }
106
+ n=f->sizep;
107
+ DumpInt(n,D);
108
+ for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
109
+ }
110
+
111
+ static void DumpDebug(const Proto* f, DumpState* D)
112
+ {
113
+ int i,n;
114
+ n= (D->strip) ? 0 : f->sizelineinfo;
115
+ DumpVector(f->lineinfo,n,sizeof(int),D);
116
+ n= (D->strip) ? 0 : f->sizelocvars;
117
+ DumpInt(n,D);
118
+ for (i=0; i<n; i++)
119
+ {
120
+ DumpString(f->locvars[i].varname,D);
121
+ DumpInt(f->locvars[i].startpc,D);
122
+ DumpInt(f->locvars[i].endpc,D);
123
+ }
124
+ n= (D->strip) ? 0 : f->sizeupvalues;
125
+ DumpInt(n,D);
126
+ for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
127
+ }
128
+
129
+ static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
130
+ {
131
+ DumpString((f->source==p || D->strip) ? NULL : f->source,D);
132
+ DumpInt(f->linedefined,D);
133
+ DumpInt(f->lastlinedefined,D);
134
+ DumpChar(f->nups,D);
135
+ DumpChar(f->numparams,D);
136
+ DumpChar(f->is_vararg,D);
137
+ DumpChar(f->maxstacksize,D);
138
+ DumpCode(f,D);
139
+ DumpConstants(f,D);
140
+ DumpDebug(f,D);
141
+ }
142
+
143
+ static void DumpHeader(DumpState* D)
144
+ {
145
+ char h[LUAC_HEADERSIZE];
146
+ luaU_header(h);
147
+ DumpBlock(h,LUAC_HEADERSIZE,D);
148
+ }
149
+
150
+ /*
151
+ ** dump Lua function as precompiled chunk
152
+ */
153
+ int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
154
+ {
155
+ DumpState D;
156
+ D.L=L;
157
+ D.writer=w;
158
+ D.data=data;
159
+ D.strip=strip;
160
+ D.status=0;
161
+ DumpHeader(&D);
162
+ DumpFunction(f,NULL,&D);
163
+ return D.status;
164
+ }
@@ -0,0 +1,174 @@
1
+ /*
2
+ ** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $
3
+ ** Auxiliary functions to manipulate prototypes and closures
4
+ ** See Copyright Notice in lua.h
5
+ */
6
+
7
+
8
+ #include <stddef.h>
9
+
10
+ #define lfunc_c
11
+ #define LUA_CORE
12
+
13
+ #include "lua.h"
14
+
15
+ #include "lfunc.h"
16
+ #include "lgc.h"
17
+ #include "lmem.h"
18
+ #include "lobject.h"
19
+ #include "lstate.h"
20
+
21
+
22
+
23
+ Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
24
+ Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
25
+ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
26
+ c->c.isC = 1;
27
+ c->c.env = e;
28
+ c->c.nupvalues = cast_byte(nelems);
29
+ return c;
30
+ }
31
+
32
+
33
+ Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
34
+ Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
35
+ luaC_link(L, obj2gco(c), LUA_TFUNCTION);
36
+ c->l.isC = 0;
37
+ c->l.env = e;
38
+ c->l.nupvalues = cast_byte(nelems);
39
+ while (nelems--) c->l.upvals[nelems] = NULL;
40
+ return c;
41
+ }
42
+
43
+
44
+ UpVal *luaF_newupval (lua_State *L) {
45
+ UpVal *uv = luaM_new(L, UpVal);
46
+ luaC_link(L, obj2gco(uv), LUA_TUPVAL);
47
+ uv->v = &uv->u.value;
48
+ setnilvalue(uv->v);
49
+ return uv;
50
+ }
51
+
52
+
53
+ UpVal *luaF_findupval (lua_State *L, StkId level) {
54
+ global_State *g = G(L);
55
+ GCObject **pp = &L->openupval;
56
+ UpVal *p;
57
+ UpVal *uv;
58
+ while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
59
+ lua_assert(p->v != &p->u.value);
60
+ if (p->v == level) { /* found a corresponding upvalue? */
61
+ if (isdead(g, obj2gco(p))) /* is it dead? */
62
+ changewhite(obj2gco(p)); /* ressurect it */
63
+ return p;
64
+ }
65
+ pp = &p->next;
66
+ }
67
+ uv = luaM_new(L, UpVal); /* not found: create a new one */
68
+ uv->tt = LUA_TUPVAL;
69
+ uv->marked = luaC_white(g);
70
+ uv->v = level; /* current value lives in the stack */
71
+ uv->next = *pp; /* chain it in the proper position */
72
+ *pp = obj2gco(uv);
73
+ uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */
74
+ uv->u.l.next = g->uvhead.u.l.next;
75
+ uv->u.l.next->u.l.prev = uv;
76
+ g->uvhead.u.l.next = uv;
77
+ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
78
+ return uv;
79
+ }
80
+
81
+
82
+ static void unlinkupval (UpVal *uv) {
83
+ lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
84
+ uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
85
+ uv->u.l.prev->u.l.next = uv->u.l.next;
86
+ }
87
+
88
+
89
+ void luaF_freeupval (lua_State *L, UpVal *uv) {
90
+ if (uv->v != &uv->u.value) /* is it open? */
91
+ unlinkupval(uv); /* remove from open list */
92
+ luaM_free(L, uv); /* free upvalue */
93
+ }
94
+
95
+
96
+ void luaF_close (lua_State *L, StkId level) {
97
+ UpVal *uv;
98
+ global_State *g = G(L);
99
+ while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
100
+ GCObject *o = obj2gco(uv);
101
+ lua_assert(!isblack(o) && uv->v != &uv->u.value);
102
+ L->openupval = uv->next; /* remove from `open' list */
103
+ if (isdead(g, o))
104
+ luaF_freeupval(L, uv); /* free upvalue */
105
+ else {
106
+ unlinkupval(uv);
107
+ setobj(L, &uv->u.value, uv->v);
108
+ uv->v = &uv->u.value; /* now current value lives here */
109
+ luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */
110
+ }
111
+ }
112
+ }
113
+
114
+
115
+ Proto *luaF_newproto (lua_State *L) {
116
+ Proto *f = luaM_new(L, Proto);
117
+ luaC_link(L, obj2gco(f), LUA_TPROTO);
118
+ f->k = NULL;
119
+ f->sizek = 0;
120
+ f->p = NULL;
121
+ f->sizep = 0;
122
+ f->code = NULL;
123
+ f->sizecode = 0;
124
+ f->sizelineinfo = 0;
125
+ f->sizeupvalues = 0;
126
+ f->nups = 0;
127
+ f->upvalues = NULL;
128
+ f->numparams = 0;
129
+ f->is_vararg = 0;
130
+ f->maxstacksize = 0;
131
+ f->lineinfo = NULL;
132
+ f->sizelocvars = 0;
133
+ f->locvars = NULL;
134
+ f->linedefined = 0;
135
+ f->lastlinedefined = 0;
136
+ f->source = NULL;
137
+ return f;
138
+ }
139
+
140
+
141
+ void luaF_freeproto (lua_State *L, Proto *f) {
142
+ luaM_freearray(L, f->code, f->sizecode, Instruction);
143
+ luaM_freearray(L, f->p, f->sizep, Proto *);
144
+ luaM_freearray(L, f->k, f->sizek, TValue);
145
+ luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
146
+ luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
147
+ luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
148
+ luaM_free(L, f);
149
+ }
150
+
151
+
152
+ void luaF_freeclosure (lua_State *L, Closure *c) {
153
+ int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
154
+ sizeLclosure(c->l.nupvalues);
155
+ luaM_freemem(L, c, size);
156
+ }
157
+
158
+
159
+ /*
160
+ ** Look for n-th local variable at line `line' in function `func'.
161
+ ** Returns NULL if not found.
162
+ */
163
+ const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
164
+ int i;
165
+ for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
166
+ if (pc < f->locvars[i].endpc) { /* is variable active? */
167
+ local_number--;
168
+ if (local_number == 0)
169
+ return getstr(f->locvars[i].varname);
170
+ }
171
+ }
172
+ return NULL; /* not found */
173
+ }
174
+
@@ -0,0 +1,34 @@
1
+ /*
2
+ ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $
3
+ ** Auxiliary functions to manipulate prototypes and closures
4
+ ** See Copyright Notice in lua.h
5
+ */
6
+
7
+ #ifndef lfunc_h
8
+ #define lfunc_h
9
+
10
+
11
+ #include "lobject.h"
12
+
13
+
14
+ #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
15
+ cast(int, sizeof(TValue)*((n)-1)))
16
+
17
+ #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
18
+ cast(int, sizeof(TValue *)*((n)-1)))
19
+
20
+
21
+ LUAI_FUNC Proto *luaF_newproto (lua_State *L);
22
+ LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
23
+ LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
24
+ LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
25
+ LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
26
+ LUAI_FUNC void luaF_close (lua_State *L, StkId level);
27
+ LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
28
+ LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c);
29
+ LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv);
30
+ LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
31
+ int pc);
32
+
33
+
34
+ #endif