annotate lib/lua/lua-5.2.2/lobject.h @ 1904:1a1c4040bee4

m
author Ritor1
date Mon, 21 Oct 2013 17:23:59 +0600
parents 41cc4dd3c122
children
rev   line source
1866
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
1 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
2 ** $Id: lobject.h,v 2.71 2012/09/11 18:21:44 roberto Exp $
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
3 ** Type definitions for Lua objects
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
4 ** See Copyright Notice in lua.h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
5 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
6
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
7
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
8 #ifndef lobject_h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
9 #define lobject_h
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
10
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
11
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
12 #include <stdarg.h>
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
13
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
14
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
15 #include "llimits.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
16 #include "lua.h"
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
17
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
18
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
19 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
20 ** Extra tags for non-values
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
21 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
22 #define LUA_TPROTO LUA_NUMTAGS
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
23 #define LUA_TUPVAL (LUA_NUMTAGS+1)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
24 #define LUA_TDEADKEY (LUA_NUMTAGS+2)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
25
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
26 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
27 ** number of all possible tags (including LUA_TNONE but excluding DEADKEY)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
28 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
29 #define LUA_TOTALTAGS (LUA_TUPVAL+2)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
30
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
31
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
32 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
33 ** tags for Tagged Values have the following use of bits:
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
34 ** bits 0-3: actual tag (a LUA_T* value)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
35 ** bits 4-5: variant bits
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
36 ** bit 6: whether value is collectable
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
37 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
38
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
39 #define VARBITS (3 << 4)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
40
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
41
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
42 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
43 ** LUA_TFUNCTION variants:
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
44 ** 0 - Lua function
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
45 ** 1 - light C function
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
46 ** 2 - regular C function (closure)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
47 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
48
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
49 /* Variant tags for functions */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
50 #define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
51 #define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
52 #define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
53
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
54
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
55 /* Variant tags for strings */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
56 #define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
57 #define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
58
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
59
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
60 /* Bit mark for collectable types */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
61 #define BIT_ISCOLLECTABLE (1 << 6)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
62
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
63 /* mark a tag as collectable */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
64 #define ctb(t) ((t) | BIT_ISCOLLECTABLE)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
65
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
66
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
67 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
68 ** Union of all collectable objects
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
69 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
70 typedef union GCObject GCObject;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
71
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
72
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
73 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
74 ** Common Header for all collectable objects (in macro form, to be
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
75 ** included in other objects)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
76 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
77 #define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
78
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
79
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
80 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
81 ** Common header in struct form
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
82 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
83 typedef struct GCheader {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
84 CommonHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
85 } GCheader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
86
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
87
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
88
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
89 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
90 ** Union of all Lua values
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
91 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
92 typedef union Value Value;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
93
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
94
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
95 #define numfield lua_Number n; /* numbers */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
96
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
97
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
98
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
99 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
100 ** Tagged Values. This is the basic representation of values in Lua,
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
101 ** an actual value plus a tag with its type.
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
102 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
103
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
104 #define TValuefields Value value_; int tt_
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
105
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
106 typedef struct lua_TValue TValue;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
107
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
108
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
109 /* macro defining a nil value */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
110 #define NILCONSTANT {NULL}, LUA_TNIL
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
111
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
112
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
113 #define val_(o) ((o)->value_)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
114 #define num_(o) (val_(o).n)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
115
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
116
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
117 /* raw type tag of a TValue */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
118 #define rttype(o) ((o)->tt_)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
119
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
120 /* tag with no variants (bits 0-3) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
121 #define novariant(x) ((x) & 0x0F)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
122
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
123 /* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
124 #define ttype(o) (rttype(o) & 0x3F)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
125
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
126 /* type tag of a TValue with no variants (bits 0-3) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
127 #define ttypenv(o) (novariant(rttype(o)))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
128
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
129
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
130 /* Macros to test type */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
131 #define checktag(o,t) (rttype(o) == (t))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
132 #define checktype(o,t) (ttypenv(o) == (t))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
133 #define ttisnumber(o) checktag((o), LUA_TNUMBER)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
134 #define ttisnil(o) checktag((o), LUA_TNIL)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
135 #define ttisboolean(o) checktag((o), LUA_TBOOLEAN)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
136 #define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
137 #define ttisstring(o) checktype((o), LUA_TSTRING)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
138 #define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
139 #define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
140 #define ttistable(o) checktag((o), ctb(LUA_TTABLE))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
141 #define ttisfunction(o) checktype(o, LUA_TFUNCTION)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
142 #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
143 #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
144 #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
145 #define ttislcf(o) checktag((o), LUA_TLCF)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
146 #define ttisuserdata(o) checktag((o), ctb(LUA_TUSERDATA))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
147 #define ttisthread(o) checktag((o), ctb(LUA_TTHREAD))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
148 #define ttisdeadkey(o) checktag((o), LUA_TDEADKEY)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
149
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
150 #define ttisequal(o1,o2) (rttype(o1) == rttype(o2))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
151
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
152 /* Macros to access values */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
153 #define nvalue(o) check_exp(ttisnumber(o), num_(o))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
154 #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
155 #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
156 #define rawtsvalue(o) check_exp(ttisstring(o), &val_(o).gc->ts)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
157 #define tsvalue(o) (&rawtsvalue(o)->tsv)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
158 #define rawuvalue(o) check_exp(ttisuserdata(o), &val_(o).gc->u)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
159 #define uvalue(o) (&rawuvalue(o)->uv)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
160 #define clvalue(o) check_exp(ttisclosure(o), &val_(o).gc->cl)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
161 #define clLvalue(o) check_exp(ttisLclosure(o), &val_(o).gc->cl.l)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
162 #define clCvalue(o) check_exp(ttisCclosure(o), &val_(o).gc->cl.c)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
163 #define fvalue(o) check_exp(ttislcf(o), val_(o).f)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
164 #define hvalue(o) check_exp(ttistable(o), &val_(o).gc->h)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
165 #define bvalue(o) check_exp(ttisboolean(o), val_(o).b)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
166 #define thvalue(o) check_exp(ttisthread(o), &val_(o).gc->th)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
167 /* a dead value may get the 'gc' field, but cannot access its contents */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
168 #define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
169
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
170 #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
171
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
172
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
173 #define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
174
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
175
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
176 /* Macros for internal tests */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
177 #define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
178
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
179 #define checkliveness(g,obj) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
180 lua_longassert(!iscollectable(obj) || \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
181 (righttt(obj) && !isdead(g,gcvalue(obj))))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
182
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
183
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
184 /* Macros to set values */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
185 #define settt_(o,t) ((o)->tt_=(t))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
186
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
187 #define setnvalue(obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
188 { TValue *io=(obj); num_(io)=(x); settt_(io, LUA_TNUMBER); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
189
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
190 #define setnilvalue(obj) settt_(obj, LUA_TNIL)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
191
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
192 #define setfvalue(obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
193 { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
194
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
195 #define setpvalue(obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
196 { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
197
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
198 #define setbvalue(obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
199 { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
200
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
201 #define setgcovalue(L,obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
202 { TValue *io=(obj); GCObject *i_g=(x); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
203 val_(io).gc=i_g; settt_(io, ctb(gch(i_g)->tt)); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
204
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
205 #define setsvalue(L,obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
206 { TValue *io=(obj); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
207 TString *x_ = (x); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
208 val_(io).gc=cast(GCObject *, x_); settt_(io, ctb(x_->tsv.tt)); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
209 checkliveness(G(L),io); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
210
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
211 #define setuvalue(L,obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
212 { TValue *io=(obj); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
213 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TUSERDATA)); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
214 checkliveness(G(L),io); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
215
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
216 #define setthvalue(L,obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
217 { TValue *io=(obj); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
218 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTHREAD)); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
219 checkliveness(G(L),io); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
220
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
221 #define setclLvalue(L,obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
222 { TValue *io=(obj); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
223 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TLCL)); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
224 checkliveness(G(L),io); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
225
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
226 #define setclCvalue(L,obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
227 { TValue *io=(obj); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
228 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TCCL)); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
229 checkliveness(G(L),io); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
230
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
231 #define sethvalue(L,obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
232 { TValue *io=(obj); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
233 val_(io).gc=cast(GCObject *, (x)); settt_(io, ctb(LUA_TTABLE)); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
234 checkliveness(G(L),io); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
235
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
236 #define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
237
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
238
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
239
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
240 #define setobj(L,obj1,obj2) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
241 { const TValue *io2=(obj2); TValue *io1=(obj1); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
242 io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
243 checkliveness(G(L),io1); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
244
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
245
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
246 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
247 ** different types of assignments, according to destination
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
248 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
249
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
250 /* from stack to (same) stack */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
251 #define setobjs2s setobj
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
252 /* to stack (not from same stack) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
253 #define setobj2s setobj
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
254 #define setsvalue2s setsvalue
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
255 #define sethvalue2s sethvalue
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
256 #define setptvalue2s setptvalue
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
257 /* from table to same table */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
258 #define setobjt2t setobj
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
259 /* to table */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
260 #define setobj2t setobj
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
261 /* to new object */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
262 #define setobj2n setobj
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
263 #define setsvalue2n setsvalue
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
264
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
265
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
266 /* check whether a number is valid (useful only for NaN trick) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
267 #define luai_checknum(L,o,c) { /* empty */ }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
268
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
269
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
270 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
271 ** {======================================================
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
272 ** NaN Trick
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
273 ** =======================================================
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
274 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
275 #if defined(LUA_NANTRICK)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
276
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
277 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
278 ** numbers are represented in the 'd_' field. All other values have the
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
279 ** value (NNMARK | tag) in 'tt__'. A number with such pattern would be
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
280 ** a "signaled NaN", which is never generated by regular operations by
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
281 ** the CPU (nor by 'strtod')
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
282 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
283
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
284 /* allows for external implementation for part of the trick */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
285 #if !defined(NNMARK) /* { */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
286
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
287
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
288 #if !defined(LUA_IEEEENDIAN)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
289 #error option 'LUA_NANTRICK' needs 'LUA_IEEEENDIAN'
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
290 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
291
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
292
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
293 #define NNMARK 0x7FF7A500
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
294 #define NNMASK 0x7FFFFF00
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
295
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
296 #undef TValuefields
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
297 #undef NILCONSTANT
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
298
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
299 #if (LUA_IEEEENDIAN == 0) /* { */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
300
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
301 /* little endian */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
302 #define TValuefields \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
303 union { struct { Value v__; int tt__; } i; double d__; } u
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
304 #define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}}
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
305 /* field-access macros */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
306 #define v_(o) ((o)->u.i.v__)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
307 #define d_(o) ((o)->u.d__)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
308 #define tt_(o) ((o)->u.i.tt__)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
309
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
310 #else /* }{ */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
311
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
312 /* big endian */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
313 #define TValuefields \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
314 union { struct { int tt__; Value v__; } i; double d__; } u
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
315 #define NILCONSTANT {{tag2tt(LUA_TNIL), {NULL}}}
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
316 /* field-access macros */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
317 #define v_(o) ((o)->u.i.v__)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
318 #define d_(o) ((o)->u.d__)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
319 #define tt_(o) ((o)->u.i.tt__)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
320
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
321 #endif /* } */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
322
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
323 #endif /* } */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
324
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
325
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
326 /* correspondence with standard representation */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
327 #undef val_
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
328 #define val_(o) v_(o)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
329 #undef num_
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
330 #define num_(o) d_(o)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
331
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
332
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
333 #undef numfield
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
334 #define numfield /* no such field; numbers are the entire struct */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
335
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
336 /* basic check to distinguish numbers from non-numbers */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
337 #undef ttisnumber
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
338 #define ttisnumber(o) ((tt_(o) & NNMASK) != NNMARK)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
339
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
340 #define tag2tt(t) (NNMARK | (t))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
341
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
342 #undef rttype
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
343 #define rttype(o) (ttisnumber(o) ? LUA_TNUMBER : tt_(o) & 0xff)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
344
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
345 #undef settt_
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
346 #define settt_(o,t) (tt_(o) = tag2tt(t))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
347
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
348 #undef setnvalue
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
349 #define setnvalue(obj,x) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
350 { TValue *io_=(obj); num_(io_)=(x); lua_assert(ttisnumber(io_)); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
351
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
352 #undef setobj
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
353 #define setobj(L,obj1,obj2) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
354 { const TValue *o2_=(obj2); TValue *o1_=(obj1); \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
355 o1_->u = o2_->u; \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
356 checkliveness(G(L),o1_); }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
357
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
358
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
359 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
360 ** these redefinitions are not mandatory, but these forms are more efficient
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
361 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
362
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
363 #undef checktag
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
364 #undef checktype
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
365 #define checktag(o,t) (tt_(o) == tag2tt(t))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
366 #define checktype(o,t) (ctb(tt_(o) | VARBITS) == ctb(tag2tt(t) | VARBITS))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
367
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
368 #undef ttisequal
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
369 #define ttisequal(o1,o2) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
370 (ttisnumber(o1) ? ttisnumber(o2) : (tt_(o1) == tt_(o2)))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
371
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
372
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
373 #undef luai_checknum
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
374 #define luai_checknum(L,o,c) { if (!ttisnumber(o)) c; }
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
375
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
376 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
377 /* }====================================================== */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
378
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
379
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
380
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
381 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
382 ** {======================================================
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
383 ** types and prototypes
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
384 ** =======================================================
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
385 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
386
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
387
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
388 union Value {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
389 GCObject *gc; /* collectable objects */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
390 void *p; /* light userdata */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
391 int b; /* booleans */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
392 lua_CFunction f; /* light C functions */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
393 numfield /* numbers */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
394 };
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
395
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
396
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
397 struct lua_TValue {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
398 TValuefields;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
399 };
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
400
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
401
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
402 typedef TValue *StkId; /* index to stack elements */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
403
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
404
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
405
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
406
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
407 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
408 ** Header for string value; string bytes follow the end of this structure
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
409 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
410 typedef union TString {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
411 L_Umaxalign dummy; /* ensures maximum alignment for strings */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
412 struct {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
413 CommonHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
414 lu_byte extra; /* reserved words for short strings; "has hash" for longs */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
415 unsigned int hash;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
416 size_t len; /* number of characters in string */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
417 } tsv;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
418 } TString;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
419
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
420
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
421 /* get the actual string (array of bytes) from a TString */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
422 #define getstr(ts) cast(const char *, (ts) + 1)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
423
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
424 /* get the actual string (array of bytes) from a Lua value */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
425 #define svalue(o) getstr(rawtsvalue(o))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
426
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
427
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
428 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
429 ** Header for userdata; memory area follows the end of this structure
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
430 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
431 typedef union Udata {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
432 L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
433 struct {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
434 CommonHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
435 struct Table *metatable;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
436 struct Table *env;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
437 size_t len; /* number of bytes */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
438 } uv;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
439 } Udata;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
440
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
441
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
442
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
443 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
444 ** Description of an upvalue for function prototypes
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
445 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
446 typedef struct Upvaldesc {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
447 TString *name; /* upvalue name (for debug information) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
448 lu_byte instack; /* whether it is in stack */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
449 lu_byte idx; /* index of upvalue (in stack or in outer function's list) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
450 } Upvaldesc;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
451
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
452
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
453 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
454 ** Description of a local variable for function prototypes
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
455 ** (used for debug information)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
456 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
457 typedef struct LocVar {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
458 TString *varname;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
459 int startpc; /* first point where variable is active */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
460 int endpc; /* first point where variable is dead */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
461 } LocVar;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
462
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
463
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
464 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
465 ** Function Prototypes
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
466 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
467 typedef struct Proto {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
468 CommonHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
469 TValue *k; /* constants used by the function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
470 Instruction *code;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
471 struct Proto **p; /* functions defined inside the function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
472 int *lineinfo; /* map from opcodes to source lines (debug information) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
473 LocVar *locvars; /* information about local variables (debug information) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
474 Upvaldesc *upvalues; /* upvalue information */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
475 union Closure *cache; /* last created closure with this prototype */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
476 TString *source; /* used for debug information */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
477 int sizeupvalues; /* size of 'upvalues' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
478 int sizek; /* size of `k' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
479 int sizecode;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
480 int sizelineinfo;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
481 int sizep; /* size of `p' */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
482 int sizelocvars;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
483 int linedefined;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
484 int lastlinedefined;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
485 GCObject *gclist;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
486 lu_byte numparams; /* number of fixed parameters */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
487 lu_byte is_vararg;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
488 lu_byte maxstacksize; /* maximum stack used by this function */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
489 } Proto;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
490
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
491
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
492
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
493 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
494 ** Lua Upvalues
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
495 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
496 typedef struct UpVal {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
497 CommonHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
498 TValue *v; /* points to stack or to its own value */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
499 union {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
500 TValue value; /* the value (when closed) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
501 struct { /* double linked list (when open) */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
502 struct UpVal *prev;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
503 struct UpVal *next;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
504 } l;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
505 } u;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
506 } UpVal;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
507
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
508
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
509 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
510 ** Closures
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
511 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
512
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
513 #define ClosureHeader \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
514 CommonHeader; lu_byte nupvalues; GCObject *gclist
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
515
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
516 typedef struct CClosure {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
517 ClosureHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
518 lua_CFunction f;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
519 TValue upvalue[1]; /* list of upvalues */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
520 } CClosure;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
521
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
522
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
523 typedef struct LClosure {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
524 ClosureHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
525 struct Proto *p;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
526 UpVal *upvals[1]; /* list of upvalues */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
527 } LClosure;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
528
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
529
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
530 typedef union Closure {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
531 CClosure c;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
532 LClosure l;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
533 } Closure;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
534
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
535
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
536 #define isLfunction(o) ttisLclosure(o)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
537
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
538 #define getproto(o) (clLvalue(o)->p)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
539
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
540
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
541 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
542 ** Tables
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
543 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
544
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
545 typedef union TKey {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
546 struct {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
547 TValuefields;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
548 struct Node *next; /* for chaining */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
549 } nk;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
550 TValue tvk;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
551 } TKey;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
552
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
553
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
554 typedef struct Node {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
555 TValue i_val;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
556 TKey i_key;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
557 } Node;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
558
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
559
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
560 typedef struct Table {
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
561 CommonHeader;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
562 lu_byte flags; /* 1<<p means tagmethod(p) is not present */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
563 lu_byte lsizenode; /* log2 of size of `node' array */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
564 struct Table *metatable;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
565 TValue *array; /* array part */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
566 Node *node;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
567 Node *lastfree; /* any free position is before this position */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
568 GCObject *gclist;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
569 int sizearray; /* size of `array' array */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
570 } Table;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
571
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
572
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
573
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
574 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
575 ** `module' operation for hashing (size is always a power of 2)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
576 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
577 #define lmod(s,size) \
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
578 (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
579
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
580
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
581 #define twoto(x) (1<<(x))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
582 #define sizenode(t) (twoto((t)->lsizenode))
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
583
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
584
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
585 /*
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
586 ** (address of) a fixed nil value
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
587 */
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
588 #define luaO_nilobject (&luaO_nilobject_)
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
589
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
590
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
591 LUAI_DDEC const TValue luaO_nilobject_;
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
592
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
593
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
594 LUAI_FUNC int luaO_int2fb (unsigned int x);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
595 LUAI_FUNC int luaO_fb2int (int x);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
596 LUAI_FUNC int luaO_ceillog2 (unsigned int x);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
597 LUAI_FUNC lua_Number luaO_arith (int op, lua_Number v1, lua_Number v2);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
598 LUAI_FUNC int luaO_str2d (const char *s, size_t len, lua_Number *result);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
599 LUAI_FUNC int luaO_hexavalue (int c);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
600 LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
601 va_list argp);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
602 LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
603 LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
604
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
605
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
606 #endif
41cc4dd3c122 Lua 5.2.2 added.
Nomad
parents:
diff changeset
607