native Lua  0.5.0-devel
Lua on the platform you use with the compiler you choose
lobject.h
Go to the documentation of this file.
1 /*
2 ** $Id: lobject.h $
3 ** Type definitions for Lua objects
4 ** See Copyright Notice in lua.h
5 */
6 
7 
8 #ifndef lobject_h
9 #define lobject_h
10 
11 
12 #include <stdarg.h>
13 
14 
15 #include "llimits.h"
16 #include "lua.h"
17 
18 #include "_native_lua_config.h" /* native Lua */
19 
20 
21 /*
22 ** Extra types for collectable non-values
23 */
24 #define LUA_TUPVAL LUA_NUMTYPES /* upvalues */
25 #define LUA_TPROTO (LUA_NUMTYPES+1) /* function prototypes */
26 
27 
28 /*
29 ** number of all possible types (including LUA_TNONE)
30 */
31 #define LUA_TOTALTYPES (LUA_TPROTO + 2)
32 
33 
34 /*
35 ** tags for Tagged Values have the following use of bits:
36 ** bits 0-3: actual tag (a LUA_T* constant)
37 ** bits 4-5: variant bits
38 ** bit 6: whether value is collectable
39 */
40 
41 /* add variant bits to a type */
42 #define makevariant(t,v) ((t) | ((v) << 4))
43 
44 
45 
46 /*
47 ** Union of all Lua values
48 */
49 typedef union Value {
50  struct GCObject *gc; /* collectable objects */
51  void *p; /* light userdata */
52  lua_CFunction f; /* light C functions */
53  lua_Integer i; /* integer numbers */
54  lua_Number n; /* float numbers */
56 
57 
58 /*
59 ** Tagged Values. This is the basic representation of values in Lua:
60 ** an actual value plus a tag with its type.
61 */
62 
63 #define TValuefields Value value_; lu_byte tt_
64 
65 typedef struct TValue {
68 
69 
70 #define val_(o) ((o)->value_)
71 #define valraw(o) (&val_(o))
72 
73 
74 /* raw type tag of a TValue */
75 #define rawtt(o) ((o)->tt_)
76 
77 /* tag with no variants (bits 0-3) */
78 #define novariant(t) ((t) & 0x0F)
79 
80 /* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
81 #define withvariant(t) ((t) & 0x3F)
82 #define ttypetag(o) withvariant(rawtt(o))
83 
84 /* type of a TValue */
85 #define ttype(o) (novariant(rawtt(o)))
86 
87 
88 /* Macros to test type */
89 #define checktag(o,t) (rawtt(o) == (t))
90 #define checktype(o,t) (ttype(o) == (t))
91 
92 
93 /* Macros for internal tests */
94 
95 /* collectable object has the same tag as the original value */
96 #define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt)
97 
98 /*
99 ** Any value being manipulated by the program either is non
100 ** collectable, or the collectable object has the right tag
101 ** and it is not dead.
102 */
103 #define checkliveness(L,obj) \
104  ((void)L, lua_longassert(!iscollectable(obj) || \
105  (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj))))))
106 
107 
108 /* Macros to set values */
109 
110 /* set a value's tag */
111 #define settt_(o,t) ((o)->tt_=(t))
112 
113 
114 /* main macro to copy values (from 'obj1' to 'obj2') */
115 #define setobj(L,obj1,obj2) \
116  { TValue *io1=(obj1); const TValue *io2=(obj2); \
117  io1->value_ = io2->value_; settt_(io1, io2->tt_); \
118  checkliveness(L,io1); lua_assert(!isnonstrictnil(io1)); }
119 
120 /*
121 ** Different types of assignments, according to source and destination.
122 ** (They are mostly equal now, but may be different in the future.)
123 */
124 
125 /* from stack to stack */
126 #define setobjs2s(L,o1,o2) setobj(L,s2v(o1),s2v(o2))
127 /* to stack (not from same stack) */
128 #define setobj2s(L,o1,o2) setobj(L,s2v(o1),o2)
129 /* from table to same table */
130 #define setobjt2t setobj
131 /* to new object */
132 #define setobj2n setobj
133 /* to table */
134 #define setobj2t setobj
135 
136 
137 /*
138 ** Entries in the Lua stack
139 */
140 typedef union StackValue {
143 
144 
145 /* index to stack elements */
146 typedef StackValue *StkId;
147 
148 /* convert a 'StackValue' to a 'TValue' */
149 #define s2v(o) (&(o)->val)
150 
151 
152 
153 /*
154 ** {==================================================================
155 ** Nil
156 ** ===================================================================
157 */
158 
159 /* Standard nil */
160 #define LUA_VNIL makevariant(LUA_TNIL, 0)
161 
162 /* Empty slot (which might be different from a slot containing nil) */
163 #define LUA_VEMPTY makevariant(LUA_TNIL, 1)
164 
165 /* Value returned for a key not found in a table (absent key) */
166 #define LUA_VABSTKEY makevariant(LUA_TNIL, 2)
167 
168 
169 /* macro to test for (any kind of) nil */
170 #define ttisnil(v) checktype((v), LUA_TNIL)
171 
172 
173 /* macro to test for a standard nil */
174 #define ttisstrictnil(o) checktag((o), LUA_VNIL)
175 
176 
177 #define setnilvalue(obj) settt_(obj, LUA_VNIL)
178 
179 
180 #define isabstkey(v) checktag((v), LUA_VABSTKEY)
181 
182 
183 /*
184 ** macro to detect non-standard nils (used only in assertions)
185 */
186 #define isnonstrictnil(v) (ttisnil(v) && !ttisstrictnil(v))
187 
188 
189 /*
190 ** By default, entries with any kind of nil are considered empty.
191 ** (In any definition, values associated with absent keys must also
192 ** be accepted as empty.)
193 */
194 #define isempty(v) ttisnil(v)
195 
196 
197 /* macro defining a value corresponding to an absent key */
198 #define ABSTKEYCONSTANT {NULL}, LUA_VABSTKEY
199 
200 
201 /* mark an entry as empty */
202 #define setempty(v) settt_(v, LUA_VEMPTY)
203 
204 
205 
206 /* }================================================================== */
207 
208 
209 /*
210 ** {==================================================================
211 ** Booleans
212 ** ===================================================================
213 */
214 
215 
216 #define LUA_VFALSE makevariant(LUA_TBOOLEAN, 0)
217 #define LUA_VTRUE makevariant(LUA_TBOOLEAN, 1)
218 
219 #define ttisboolean(o) checktype((o), LUA_TBOOLEAN)
220 #define ttisfalse(o) checktag((o), LUA_VFALSE)
221 #define ttistrue(o) checktag((o), LUA_VTRUE)
222 
223 
224 #define l_isfalse(o) (ttisfalse(o) || ttisnil(o))
225 
226 
227 #define setbfvalue(obj) settt_(obj, LUA_VFALSE)
228 #define setbtvalue(obj) settt_(obj, LUA_VTRUE)
229 
230 /* }================================================================== */
231 
232 
233 /*
234 ** {==================================================================
235 ** Threads
236 ** ===================================================================
237 */
238 
239 #define LUA_VTHREAD makevariant(LUA_TTHREAD, 0)
240 
241 #define ttisthread(o) checktag((o), ctb(LUA_VTHREAD))
242 
243 #define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc))
244 
245 #define setthvalue(L,obj,x) \
246  { TValue *io = (obj); lua_State *x_ = (x); \
247  val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTHREAD)); \
248  checkliveness(L,io); }
249 
250 #define setthvalue2s(L,o,t) setthvalue(L,s2v(o),t)
251 
252 /* }================================================================== */
253 
254 
255 /*
256 ** {==================================================================
257 ** Collectable Objects
258 ** ===================================================================
259 */
260 
261 /*
262 ** Common Header for all collectable objects (in macro form, to be
263 ** included in other objects)
264 */
265 #define CommonHeader struct GCObject *next; lu_byte tt; lu_byte marked
266 
267 
268 /* Common type for all collectable objects */
269 typedef struct GCObject {
272 
273 
274 /* Bit mark for collectable types */
275 #define BIT_ISCOLLECTABLE (1 << 6)
276 
277 #define iscollectable(o) (rawtt(o) & BIT_ISCOLLECTABLE)
278 
279 /* mark a tag as collectable */
280 #define ctb(t) ((t) | BIT_ISCOLLECTABLE)
281 
282 #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
283 
284 #define gcvalueraw(v) ((v).gc)
285 
286 #define setgcovalue(L,obj,x) \
287  { TValue *io = (obj); GCObject *i_g=(x); \
288  val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); }
289 
290 /* }================================================================== */
291 
292 
293 /*
294 ** {==================================================================
295 ** Numbers
296 ** ===================================================================
297 */
298 
299 /* Variant tags for numbers */
300 #define LUA_VNUMINT makevariant(LUA_TNUMBER, 0) /* integer numbers */
301 #define LUA_VNUMFLT makevariant(LUA_TNUMBER, 1) /* float numbers */
302 
303 #define ttisnumber(o) checktype((o), LUA_TNUMBER)
304 #define ttisfloat(o) checktag((o), LUA_VNUMFLT)
305 #define ttisinteger(o) checktag((o), LUA_VNUMINT)
306 
307 #define nvalue(o) check_exp(ttisnumber(o), \
308  (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o)))
309 #define fltvalue(o) check_exp(ttisfloat(o), val_(o).n)
310 #define ivalue(o) check_exp(ttisinteger(o), val_(o).i)
311 
312 #define fltvalueraw(v) ((v).n)
313 #define ivalueraw(v) ((v).i)
314 
315 #define setfltvalue(obj,x) \
316  { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_VNUMFLT); }
317 
318 #define chgfltvalue(obj,x) \
319  { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); }
320 
321 #define setivalue(obj,x) \
322  { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_VNUMINT); }
323 
324 #define chgivalue(obj,x) \
325  { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); }
326 
327 /* }================================================================== */
328 
329 
330 /*
331 ** {==================================================================
332 ** Strings
333 ** ===================================================================
334 */
335 
336 /* Variant tags for strings */
337 #define LUA_VSHRSTR makevariant(LUA_TSTRING, 0) /* short strings */
338 #define LUA_VLNGSTR makevariant(LUA_TSTRING, 1) /* long strings */
339 
340 #define ttisstring(o) checktype((o), LUA_TSTRING)
341 #define ttisshrstring(o) checktag((o), ctb(LUA_VSHRSTR))
342 #define ttislngstring(o) checktag((o), ctb(LUA_VLNGSTR))
343 
344 #define tsvalueraw(v) (gco2ts((v).gc))
345 
346 #define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc))
347 
348 #define setsvalue(L,obj,x) \
349  { TValue *io = (obj); TString *x_ = (x); \
350  val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \
351  checkliveness(L,io); }
352 
353 /* set a string to the stack */
354 #define setsvalue2s(L,o,s) setsvalue(L,s2v(o),s)
355 
356 /* set a string to a new object */
357 #define setsvalue2n setsvalue
358 
359 
360 /*
361 ** Header for a string value.
362 */
363 typedef struct TString {
365  lu_byte extra; /* reserved words for short strings; "has hash" for longs */
366  lu_byte shrlen; /* length for short strings */
367  unsigned int hash;
368  union {
369  size_t lnglen; /* length for long strings */
370  struct TString *hnext; /* linked list for hash table */
371  } u;
372  char contents[1];
374 
375 
376 
377 /*
378 ** Get the actual string (array of bytes) from a 'TString'.
379 */
380 #define getstr(ts) ((ts)->contents)
381 
382 
383 /* get the actual string (array of bytes) from a Lua value */
384 #define svalue(o) getstr(tsvalue(o))
385 
386 /* get string length from 'TString *s' */
387 #define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen)
388 
389 /* get string length from 'TValue *o' */
390 #define vslen(o) tsslen(tsvalue(o))
391 
392 /* }================================================================== */
393 
394 
395 /*
396 ** {==================================================================
397 ** Userdata
398 ** ===================================================================
399 */
400 
401 
402 /*
403 ** Light userdata should be a variant of userdata, but for compatibility
404 ** reasons they are also different types.
405 */
406 #define LUA_VLIGHTUSERDATA makevariant(LUA_TLIGHTUSERDATA, 0)
407 
408 #define LUA_VUSERDATA makevariant(LUA_TUSERDATA, 0)
409 
410 #define ttislightuserdata(o) checktag((o), LUA_VLIGHTUSERDATA)
411 #define ttisfulluserdata(o) checktag((o), ctb(LUA_VUSERDATA))
412 
413 #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
414 #define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc))
415 
416 #define pvalueraw(v) ((v).p)
417 
418 #define setpvalue(obj,x) \
419  { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_VLIGHTUSERDATA); }
420 
421 #define setuvalue(L,obj,x) \
422  { TValue *io = (obj); Udata *x_ = (x); \
423  val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VUSERDATA)); \
424  checkliveness(L,io); }
425 
426 
427 /* Ensures that addresses after this type are always fully aligned. */
428 typedef union UValue {
430  LUAI_MAXALIGN; /* ensures maximum alignment for udata bytes */
432 
433 
434 /*
435 ** Header for userdata with user values;
436 ** memory area follows the end of this structure.
437 */
438 typedef struct Udata {
440  unsigned short nuvalue; /* number of user values */
441  size_t len; /* number of bytes */
442  struct Table *metatable;
444  UValue uv[1]; /* user values */
446 
447 
448 /*
449 ** Header for userdata with no user values. These userdata do not need
450 ** to be gray during GC, and therefore do not need a 'gclist' field.
451 ** To simplify, the code always use 'Udata' for both kinds of userdata,
452 ** making sure it never accesses 'gclist' on userdata with no user values.
453 ** This structure here is used only to compute the correct size for
454 ** this representation. (The 'bindata' field in its end ensures correct
455 ** alignment for binary data following this header.)
456 */
457 typedef struct Udata0 {
459  unsigned short nuvalue; /* number of user values */
460  size_t len; /* number of bytes */
461  struct Table *metatable;
464 
465 
466 /* compute the offset of the memory area of a userdata */
467 #define udatamemoffset(nuv) \
468  ((nuv) == 0 ? offsetof(Udata0, bindata) \
469  : offsetof(Udata, uv) + (sizeof(UValue) * (nuv)))
470 
471 /* get the address of the memory block inside 'Udata' */
472 #define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue))
473 
474 /* compute the size of a userdata */
475 #define sizeudata(nuv,nb) (udatamemoffset(nuv) + (nb))
476 
477 /* }================================================================== */
478 
479 
480 /*
481 ** {==================================================================
482 ** Prototypes
483 ** ===================================================================
484 */
485 
486 #define LUA_VPROTO makevariant(LUA_TPROTO, 0)
487 
488 
489 /*
490 ** Description of an upvalue for function prototypes
491 */
492 typedef struct Upvaldesc {
493  TString *name; /* upvalue name (for debug information) */
494  lu_byte instack; /* whether it is in stack (register) */
495  lu_byte idx; /* index of upvalue (in stack or in outer function's list) */
496  lu_byte kind; /* kind of corresponding variable */
498 
499 
500 /*
501 ** Description of a local variable for function prototypes
502 ** (used for debug information)
503 */
504 typedef struct LocVar {
506  int startpc; /* first point where variable is active */
507  int endpc; /* first point where variable is dead */
509 
510 
511 /*
512 ** Associates the absolute line source for a given instruction ('pc').
513 ** The array 'lineinfo' gives, for each instruction, the difference in
514 ** lines from the previous instruction. When that difference does not
515 ** fit into a byte, Lua saves the absolute line for that instruction.
516 ** (Lua also saves the absolute line periodically, to speed up the
517 ** computation of a line number: we can use binary search in the
518 ** absolute-line array, but we must traverse the 'lineinfo' array
519 ** linearly to compute a line.)
520 */
521 typedef struct AbsLineInfo {
522  int pc;
523  int line;
525 
526 /*
527 ** Function Prototypes
528 */
529 typedef struct Proto {
531  lu_byte numparams; /* number of fixed (named) parameters */
533  lu_byte maxstacksize; /* number of registers needed by this function */
534  int sizeupvalues; /* size of 'upvalues' */
535  int sizek; /* size of 'k' */
536  int sizecode;
538  int sizep; /* size of 'p' */
540  int sizeabslineinfo; /* size of 'abslineinfo' */
541  int linedefined; /* debug information */
542  int lastlinedefined; /* debug information */
543  TValue *k; /* constants used by the function */
544  Instruction *code; /* opcodes */
545  struct Proto **p; /* functions defined inside the function */
546  Upvaldesc *upvalues; /* upvalue information */
547  ls_byte *lineinfo; /* information about source lines (debug information) */
549  LocVar *locvars; /* information about local variables (debug information) */
550  TString *source; /* used for debug information */
553 
554 /* }================================================================== */
555 
556 
557 /*
558 ** {==================================================================
559 ** Closures
560 ** ===================================================================
561 */
562 
563 #define LUA_VUPVAL makevariant(LUA_TUPVAL, 0)
564 
565 
566 /* Variant tags for functions */
567 #define LUA_VLCL makevariant(LUA_TFUNCTION, 0) /* Lua closure */
568 #define LUA_VLCF makevariant(LUA_TFUNCTION, 1) /* light C function */
569 #define LUA_VCCL makevariant(LUA_TFUNCTION, 2) /* C closure */
570 
571 #define ttisfunction(o) checktype(o, LUA_TFUNCTION)
572 #define ttisclosure(o) ((rawtt(o) & 0x1F) == LUA_VLCL)
573 #define ttisLclosure(o) checktag((o), ctb(LUA_VLCL))
574 #define ttislcf(o) checktag((o), LUA_VLCF)
575 #define ttisCclosure(o) checktag((o), ctb(LUA_VCCL))
576 
577 #define isLfunction(o) ttisLclosure(o)
578 
579 #define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc))
580 #define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc))
581 #define fvalue(o) check_exp(ttislcf(o), val_(o).f)
582 #define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc))
583 
584 #define fvalueraw(v) ((v).f)
585 
586 #define setclLvalue(L,obj,x) \
587  { TValue *io = (obj); LClosure *x_ = (x); \
588  val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VLCL)); \
589  checkliveness(L,io); }
590 
591 #define setclLvalue2s(L,o,cl) setclLvalue(L,s2v(o),cl)
592 
593 #define setfvalue(obj,x) \
594  { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_VLCF); }
595 
596 #define setclCvalue(L,obj,x) \
597  { TValue *io = (obj); CClosure *x_ = (x); \
598  val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VCCL)); \
599  checkliveness(L,io); }
600 
601 
602 /*
603 ** Upvalues for Lua closures
604 */
605 typedef struct UpVal {
607  lu_byte tbc; /* true if it represents a to-be-closed variable */
608  TValue *v; /* points to stack or to its own value */
609  union {
610  struct { /* (when open) */
611  struct UpVal *next; /* linked list */
612  struct UpVal **previous;
613  } open;
614  TValue value; /* the value (when closed) */
615  } u;
617 
618 
619 
620 #define ClosureHeader \
621  CommonHeader; lu_byte nupvalues; GCObject *gclist
622 
623 typedef struct CClosure {
626  TValue upvalue[1]; /* list of upvalues */
628 
629 
630 typedef struct LClosure {
632  struct Proto *p;
633  UpVal *upvals[1]; /* list of upvalues */
635 
636 
637 typedef union Closure {
641 
642 
643 #define getproto(o) (clLvalue(o)->p)
644 
645 /* }================================================================== */
646 
647 
648 /*
649 ** {==================================================================
650 ** Tables
651 ** ===================================================================
652 */
653 
654 #define LUA_VTABLE makevariant(LUA_TTABLE, 0)
655 
656 #define ttistable(o) checktag((o), ctb(LUA_VTABLE))
657 
658 #define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc))
659 
660 #define sethvalue(L,obj,x) \
661  { TValue *io = (obj); Table *x_ = (x); \
662  val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_VTABLE)); \
663  checkliveness(L,io); }
664 
665 #define sethvalue2s(L,o,h) sethvalue(L,s2v(o),h)
666 
667 
668 /*
669 ** Nodes for Hash tables: A pack of two TValue's (key-value pairs)
670 ** plus a 'next' field to link colliding entries. The distribution
671 ** of the key's fields ('key_tt' and 'key_val') not forming a proper
672 ** 'TValue' allows for a smaller size for 'Node' both in 4-byte
673 ** and 8-byte alignments.
674 */
675 typedef union Node {
676  struct NodeKey {
677  TValuefields; /* fields for value */
678  lu_byte key_tt; /* key type */
679  int next; /* for chaining */
680  Value key_val; /* key value */
681  } u;
682  TValue i_val; /* direct access to node's value as a proper 'TValue' */
684 
685 
686 /* copy a value into a key */
687 #define setnodekey(L,node,obj) \
688  { Node *n_=(node); const TValue *io_=(obj); \
689  n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \
690  checkliveness(L,io_); }
691 
692 
693 /* copy a value from a key */
694 #define getnodekey(L,obj,node) \
695  { TValue *io_=(obj); const Node *n_=(node); \
696  io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \
697  checkliveness(L,io_); }
698 
699 
700 /*
701 ** About 'alimit': if 'isrealasize(t)' is true, then 'alimit' is the
702 ** real size of 'array'. Otherwise, the real size of 'array' is the
703 ** smallest power of two not smaller than 'alimit' (or zero iff 'alimit'
704 ** is zero); 'alimit' is then used as a hint for #t.
705 */
706 
707 #define BITRAS (1 << 7)
708 #define isrealasize(t) (!((t)->marked & BITRAS))
709 #define setrealasize(t) ((t)->marked &= cast_byte(~BITRAS))
710 #define setnorealasize(t) ((t)->marked |= BITRAS)
711 
712 
713 typedef struct Table {
715  lu_byte flags; /* 1<<p means tagmethod(p) is not present */
716  lu_byte lsizenode; /* log2 of size of 'node' array */
717  unsigned int alimit; /* "limit" of 'array' array */
718  TValue *array; /* array part */
720  Node *lastfree; /* any free position is before this position */
721  struct Table *metatable;
724 
725 
726 /*
727 ** Macros to manipulate keys inserted in nodes
728 */
729 #define keytt(node) ((node)->u.key_tt)
730 #define keyval(node) ((node)->u.key_val)
731 
732 #define keyisnil(node) (keytt(node) == LUA_TNIL)
733 #define keyisinteger(node) (keytt(node) == LUA_VNUMINT)
734 #define keyival(node) (keyval(node).i)
735 #define keyisshrstr(node) (keytt(node) == ctb(LUA_VSHRSTR))
736 #define keystrval(node) (gco2ts(keyval(node).gc))
737 
738 #define setnilkey(node) (keytt(node) = LUA_TNIL)
739 
740 #define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE)
741 
742 #define gckey(n) (keyval(n).gc)
743 #define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL)
744 
745 
746 /*
747 ** Use a "nil table" to mark dead keys in a table. Those keys serve
748 ** to keep space for removed entries, which may still be part of
749 ** chains. Note that the 'keytt' does not have the BIT_ISCOLLECTABLE
750 ** set, so these values are considered not collectable and are different
751 ** from any valid value.
752 */
753 #define setdeadkey(n) (keytt(n) = LUA_TTABLE, gckey(n) = NULL)
754 
755 /* }================================================================== */
756 
757 
758 
759 /*
760 ** 'module' operation for hashing (size is always a power of 2)
761 */
762 #define lmod(s,size) \
763  (check_exp((size&(size-1))==0, (cast_int((s) & ((size)-1)))))
764 
765 
766 #define twoto(x) (1<<(x))
767 #define sizenode(t) (twoto((t)->lsizenode))
768 
769 
770 /* size of buffer for 'luaO_utf8esc' function */
771 #define UTF8BUFFSZ 8
772 
773 LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x);
774 LUAI_FUNC int luaO_ceillog2 (unsigned int x);
775 LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1,
776  const TValue *p2, TValue *res);
777 LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1,
778  const TValue *p2, StkId res);
779 LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o);
780 LUAI_FUNC int luaO_hexavalue (int c);
781 LUAI_FUNC void luaO_tostring (lua_State *L, TValue *obj);
782 LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
783  va_list argp);
784 LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
785 LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t srclen);
786 
787 
788 #endif
UpVal::CommonHeader
CommonHeader
Definition: lobject.h:606
LClosure
struct LClosure LClosure
Proto::upvalues
Upvaldesc * upvalues
Definition: lobject.h:546
Upvaldesc::kind
lu_byte kind
Definition: lobject.h:496
Table::flags
lu_byte flags
Definition: lobject.h:715
TString
struct TString TString
TString::u
union TString::@1 u
GCObject::CommonHeader
CommonHeader
Definition: lobject.h:270
ls_byte
signed char ls_byte
Definition: llimits.h:39
Udata0
Definition: lobject.h:457
LUAI_FUNC
#define LUAI_FUNC
Definition: luaconf.h:324
Proto::code
Instruction * code
Definition: lobject.h:544
Value::p
void * p
Definition: lobject.h:51
UpVal::u
union UpVal::@3 u
AbsLineInfo::pc
int pc
Definition: lobject.h:522
Node::NodeKey::key_tt
lu_byte key_tt
Definition: lobject.h:678
Closure
union Closure Closure
Proto::sizeabslineinfo
int sizeabslineinfo
Definition: lobject.h:540
LClosure::ClosureHeader
ClosureHeader
Definition: lobject.h:631
GCObject
struct GCObject GCObject
Value::i
lua_Integer i
Definition: lobject.h:53
TString::CommonHeader
CommonHeader
Definition: lobject.h:364
UpVal::next
struct UpVal * next
Definition: lobject.h:611
StackValue::val
TValue val
Definition: lobject.h:141
Table::CommonHeader
CommonHeader
Definition: lobject.h:714
luaO_hexavalue
LUAI_FUNC int luaO_hexavalue(int c)
Definition: lobject.c:135
LocVar::varname
TString * varname
Definition: lobject.h:505
_native_lua_config.h
native Lua configuration file
Proto::lastlinedefined
int lastlinedefined
Definition: lobject.h:542
Value::f
lua_CFunction f
Definition: lobject.h:52
Proto::p
struct Proto ** p
Definition: lobject.h:545
Udata0::LUAI_MAXALIGN
LUAI_MAXALIGN
Definition: lobject.h:462
Udata0::nuvalue
unsigned short nuvalue
Definition: lobject.h:459
Proto::is_vararg
lu_byte is_vararg
Definition: lobject.h:532
Udata::uv
UValue uv[1]
Definition: lobject.h:444
Udata::nuvalue
unsigned short nuvalue
Definition: lobject.h:440
Node::NodeKey::next
int next
Definition: lobject.h:679
lua_Number
LUA_NUMBER lua_Number
Definition: lua.h:92
llimits.h
Upvaldesc::name
TString * name
Definition: lobject.h:493
Proto::sizecode
int sizecode
Definition: lobject.h:536
TString::extra
lu_byte extra
Definition: lobject.h:365
CClosure::ClosureHeader
ClosureHeader
Definition: lobject.h:624
StackValue
Definition: lobject.h:140
Node::i_val
TValue i_val
Definition: lobject.h:682
Udata0
struct Udata0 Udata0
Proto::sizep
int sizep
Definition: lobject.h:538
Proto
struct Proto Proto
StackValue
union StackValue StackValue
UValue::uv
TValue uv
Definition: lobject.h:429
Proto::source
TString * source
Definition: lobject.h:550
Udata0::CommonHeader
CommonHeader
Definition: lobject.h:458
Table::lastfree
Node * lastfree
Definition: lobject.h:720
UValue::LUAI_MAXALIGN
LUAI_MAXALIGN
Definition: lobject.h:430
LocVar::startpc
int startpc
Definition: lobject.h:506
Proto::numparams
lu_byte numparams
Definition: lobject.h:531
UValue
union UValue UValue
Proto::linedefined
int linedefined
Definition: lobject.h:541
lua.h
UpVal::tbc
lu_byte tbc
Definition: lobject.h:607
UpVal
Definition: lobject.h:605
Udata::len
size_t len
Definition: lobject.h:441
TString::hash
unsigned int hash
Definition: lobject.h:367
Proto::abslineinfo
AbsLineInfo * abslineinfo
Definition: lobject.h:548
CClosure
struct CClosure CClosure
Value::gc
struct GCObject * gc
Definition: lobject.h:50
Udata::gclist
GCObject * gclist
Definition: lobject.h:443
TString::hnext
struct TString * hnext
Definition: lobject.h:370
Value::n
lua_Number n
Definition: lobject.h:54
CClosure
Definition: lobject.h:623
AbsLineInfo::line
int line
Definition: lobject.h:523
luaO_str2num
LUAI_FUNC size_t luaO_str2num(const char *s, TValue *o)
Definition: lobject.c:303
luaO_chunkid
LUAI_FUNC void luaO_chunkid(char *out, const char *source, size_t srclen)
Definition: lobject.c:548
Node::NodeKey
Definition: lobject.h:676
TString
Definition: lobject.h:363
UValue
Definition: lobject.h:428
luaO_tostring
LUAI_FUNC void luaO_tostring(lua_State *L, TValue *obj)
Definition: lobject.c:362
luaO_pushvfstring
LUAI_FUNC const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)
Definition: lobject.c:460
Proto::sizek
int sizek
Definition: lobject.h:535
lu_byte
unsigned char lu_byte
Definition: llimits.h:38
TString::lnglen
size_t lnglen
Definition: lobject.h:369
CClosure::f
lua_CFunction f
Definition: lobject.h:625
Proto::lineinfo
ls_byte * lineinfo
Definition: lobject.h:547
CClosure::upvalue
TValue upvalue[1]
Definition: lobject.h:626
Proto::gclist
GCObject * gclist
Definition: lobject.h:551
TString::contents
char contents[1]
Definition: lobject.h:372
Table
Definition: lobject.h:713
Udata
Definition: lobject.h:438
Table::metatable
struct Table * metatable
Definition: lobject.h:721
Node::NodeKey::key_val
Value key_val
Definition: lobject.h:680
UpVal
struct UpVal UpVal
lua_State
Definition: lstate.h:283
Table::gclist
GCObject * gclist
Definition: lobject.h:722
lua_Integer
LUA_INTEGER lua_Integer
Definition: lua.h:96
LClosure::p
struct Proto * p
Definition: lobject.h:632
Udata0::bindata
union Udata0::@2 bindata
TValue
Definition: lobject.h:65
Upvaldesc
struct Upvaldesc Upvaldesc
AbsLineInfo
Definition: lobject.h:521
Node::NodeKey::TValuefields
TValuefields
Definition: lobject.h:677
UpVal::value
TValue value
Definition: lobject.h:614
UpVal::v
TValue * v
Definition: lobject.h:608
Table::array
TValue * array
Definition: lobject.h:718
Proto::k
TValue * k
Definition: lobject.h:543
Table::alimit
unsigned int alimit
Definition: lobject.h:717
LClosure
Definition: lobject.h:630
Proto::sizelineinfo
int sizelineinfo
Definition: lobject.h:537
Proto::maxstacksize
lu_byte maxstacksize
Definition: lobject.h:533
Upvaldesc::instack
lu_byte instack
Definition: lobject.h:494
Closure::c
CClosure c
Definition: lobject.h:638
Proto::sizeupvalues
int sizeupvalues
Definition: lobject.h:534
Instruction
l_uint32 Instruction
Definition: llimits.h:188
Udata0::metatable
struct Table * metatable
Definition: lobject.h:461
StkId
StackValue * StkId
Definition: lobject.h:146
luaO_pushfstring
LUAI_FUNC const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
Definition: lobject.c:530
luaO_rawarith
LUAI_FUNC int luaO_rawarith(lua_State *L, int op, const TValue *p1, const TValue *p2, TValue *res)
Definition: lobject.c:89
LocVar
struct LocVar LocVar
Proto
Definition: lobject.h:529
Value
Definition: lobject.h:49
Udata::CommonHeader
CommonHeader
Definition: lobject.h:439
Value
union Value Value
Node::u
struct Node::NodeKey u
Table
struct Table Table
UpVal::open
struct UpVal::@3::@4 open
AbsLineInfo
struct AbsLineInfo AbsLineInfo
luaO_arith
LUAI_FUNC void luaO_arith(lua_State *L, int op, const TValue *p1, const TValue *p2, StkId res)
Definition: lobject.c:126
Upvaldesc
Definition: lobject.h:492
Upvaldesc::idx
lu_byte idx
Definition: lobject.h:495
lua_CFunction
int(* lua_CFunction)(lua_State *L)
Definition: lua.h:108
Node
Definition: lobject.h:675
TString::shrlen
lu_byte shrlen
Definition: lobject.h:366
Udata::metatable
struct Table * metatable
Definition: lobject.h:442
Udata
struct Udata Udata
LocVar
Definition: lobject.h:504
GCObject
Definition: lobject.h:269
luaO_ceillog2
LUAI_FUNC int luaO_ceillog2(unsigned int x)
Definition: lobject.c:35
Proto::CommonHeader
CommonHeader
Definition: lobject.h:530
UpVal::previous
struct UpVal ** previous
Definition: lobject.h:612
Table::lsizenode
lu_byte lsizenode
Definition: lobject.h:716
Proto::locvars
LocVar * locvars
Definition: lobject.h:549
TValue::TValuefields
TValuefields
Definition: lobject.h:66
LocVar::endpc
int endpc
Definition: lobject.h:507
luaO_utf8esc
LUAI_FUNC int luaO_utf8esc(char *buff, unsigned long x)
Definition: lobject.c:318
Proto::sizelocvars
int sizelocvars
Definition: lobject.h:539
Node
union Node Node
Closure
Definition: lobject.h:637
Table::node
Node * node
Definition: lobject.h:719
LClosure::upvals
UpVal * upvals[1]
Definition: lobject.h:633
TValue
struct TValue TValue
Udata0::len
size_t len
Definition: lobject.h:460
Closure::l
LClosure l
Definition: lobject.h:639