lobject.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  2. ** $Id: lobject.h,v 2.126 2017/10/31 17:54:35 roberto Exp roberto $
  3. ** Type definitions for Lua objects
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lobject_h
  7. #define lobject_h
  8. #include <stdarg.h>
  9. #include "llimits.h"
  10. #include "lua.h"
  11. /*
  12. ** Extra tags for non-values
  13. */
  14. #define LUA_TUPVAL LUA_NUMTAGS /* upvalues */
  15. #define LUA_TPROTO (LUA_NUMTAGS+1) /* function prototypes */
  16. /*
  17. ** number of all possible tags (including LUA_TNONE)
  18. */
  19. #define LUA_TOTALTAGS (LUA_TPROTO + 2)
  20. /*
  21. ** tags for Tagged Values have the following use of bits:
  22. ** bits 0-3: actual tag (a LUA_T* value)
  23. ** bits 4-5: variant bits
  24. ** bit 6: whether value is collectable
  25. */
  26. /*
  27. ** LUA_TFUNCTION variants:
  28. ** 0 - Lua function
  29. ** 1 - light C function
  30. ** 2 - regular C function (closure)
  31. */
  32. /* Variant tags for functions */
  33. #define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */
  34. #define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */
  35. #define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */
  36. /* Variant tags for strings */
  37. #define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */
  38. #define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */
  39. /* Variant tags for numbers */
  40. #define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4)) /* float numbers */
  41. #define LUA_TNUMINT (LUA_TNUMBER | (1 << 4)) /* integer numbers */
  42. /* Bit mark for collectable types */
  43. #define BIT_ISCOLLECTABLE (1 << 6)
  44. /* mark a tag as collectable */
  45. #define ctb(t) ((t) | BIT_ISCOLLECTABLE)
  46. /*
  47. ** Common type for all collectable objects
  48. */
  49. typedef struct GCObject GCObject;
  50. /*
  51. ** Common Header for all collectable objects (in macro form, to be
  52. ** included in other objects)
  53. */
  54. #define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
  55. /*
  56. ** Common type has only the common header
  57. */
  58. struct GCObject {
  59. CommonHeader;
  60. };
  61. /*
  62. ** Tagged Values. This is the basic representation of values in Lua,
  63. ** an actual value plus a tag with its type.
  64. */
  65. /*
  66. ** Union of all Lua values
  67. */
  68. typedef union Value {
  69. GCObject *gc; /* collectable objects */
  70. void *p; /* light userdata */
  71. int b; /* booleans */
  72. lua_CFunction f; /* light C functions */
  73. lua_Integer i; /* integer numbers */
  74. lua_Number n; /* float numbers */
  75. } Value;
  76. #define TValuefields Value value_; lu_byte tt_
  77. typedef struct TValue {
  78. TValuefields;
  79. } TValue;
  80. /* macro defining a nil value */
  81. #define NILCONSTANT {NULL}, LUA_TNIL
  82. #define val_(o) ((o)->value_)
  83. #define valraw(o) (&val_(o))
  84. /* raw type tag of a TValue */
  85. #define rttype(o) ((o)->tt_)
  86. /* tag with no variants (bits 0-3) */
  87. #define novariant(x) ((x) & 0x0F)
  88. /* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
  89. #define ttyperaw(t) ((t) & 0x3F)
  90. #define ttype(o) ttyperaw(rttype(o))
  91. /* type tag of a TValue with no variants (bits 0-3) */
  92. #define ttnov(o) (novariant(rttype(o)))
  93. /* Macros to test type */
  94. #define checktag(o,t) (rttype(o) == (t))
  95. #define checktype(o,t) (ttnov(o) == (t))
  96. #define ttisnumber(o) checktype((o), LUA_TNUMBER)
  97. #define ttisfloat(o) checktag((o), LUA_TNUMFLT)
  98. #define ttisinteger(o) checktag((o), LUA_TNUMINT)
  99. #define ttisnil(o) checktag((o), LUA_TNIL)
  100. #define ttisboolean(o) checktag((o), LUA_TBOOLEAN)
  101. #define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA)
  102. #define ttisstring(o) checktype((o), LUA_TSTRING)
  103. #define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR))
  104. #define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR))
  105. #define ttistable(o) checktag((o), ctb(LUA_TTABLE))
  106. #define ttisfunction(o) checktype(o, LUA_TFUNCTION)
  107. #define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION)
  108. #define ttisCclosure(o) checktag((o), ctb(LUA_TCCL))
  109. #define ttisLclosure(o) checktag((o), ctb(LUA_TLCL))
  110. #define ttislcf(o) checktag((o), LUA_TLCF)
  111. #define ttisfulluserdata(o) checktag((o), ctb(LUA_TUSERDATA))
  112. #define ttisthread(o) checktag((o), ctb(LUA_TTHREAD))
  113. /*
  114. ** Macros to access unstructured values (may come both from
  115. ** 'TValue's and table keys)
  116. */
  117. #define ivalueraw(v) ((v).i)
  118. #define fltvalueraw(v) ((v).n)
  119. #define gcvalueraw(v) ((v).gc)
  120. #define pvalueraw(v) ((v).p)
  121. #define tsvalueraw(v) (gco2ts((v).gc))
  122. #define fvalueraw(v) ((v).f)
  123. #define bvalueraw(v) ((v).b)
  124. /* Macros to access values */
  125. #define ivalue(o) check_exp(ttisinteger(o), val_(o).i)
  126. #define fltvalue(o) check_exp(ttisfloat(o), val_(o).n)
  127. #define nvalue(o) check_exp(ttisnumber(o), \
  128. (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o)))
  129. #define gcvalue(o) check_exp(iscollectable(o), val_(o).gc)
  130. #define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p)
  131. #define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc))
  132. #define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc))
  133. #define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc))
  134. #define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc))
  135. #define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc))
  136. #define fvalue(o) check_exp(ttislcf(o), val_(o).f)
  137. #define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc))
  138. #define bvalue(o) check_exp(ttisboolean(o), val_(o).b)
  139. #define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc))
  140. #define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
  141. #define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
  142. /*
  143. ** Protected access to objects in values
  144. */
  145. #define gcvalueN(o) (iscollectable(o) ? gcvalue(o) : NULL)
  146. /* Macros for internal tests */
  147. #define righttt(obj) (ttype(obj) == gcvalue(obj)->tt)
  148. #define checkliveness(L,obj) \
  149. lua_longassert(!iscollectable(obj) || \
  150. (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))
  151. /* Macros to set values */
  152. #define settt_(o,t) ((o)->tt_=(t))
  153. #define setfltvalue(obj,x) \
  154. { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); }
  155. #define chgfltvalue(obj,x) \
  156. { TValue *io=(obj); lua_assert(ttisfloat(io)); val_(io).n=(x); }
  157. #define setivalue(obj,x) \
  158. { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); }
  159. #define chgivalue(obj,x) \
  160. { TValue *io=(obj); lua_assert(ttisinteger(io)); val_(io).i=(x); }
  161. #define setnilvalue(obj) settt_(obj, LUA_TNIL)
  162. #define setfvalue(obj,x) \
  163. { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); }
  164. #define setpvalue(obj,x) \
  165. { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); }
  166. #define setbvalue(obj,x) \
  167. { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); }
  168. #define setgcovalue(L,obj,x) \
  169. { TValue *io = (obj); GCObject *i_g=(x); \
  170. val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); }
  171. #define setsvalue(L,obj,x) \
  172. { TValue *io = (obj); TString *x_ = (x); \
  173. val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \
  174. checkliveness(L,io); }
  175. #define setuvalue(L,obj,x) \
  176. { TValue *io = (obj); Udata *x_ = (x); \
  177. val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TUSERDATA)); \
  178. checkliveness(L,io); }
  179. #define setthvalue(L,obj,x) \
  180. { TValue *io = (obj); lua_State *x_ = (x); \
  181. val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTHREAD)); \
  182. checkliveness(L,io); }
  183. #define setclLvalue(L,obj,x) \
  184. { TValue *io = (obj); LClosure *x_ = (x); \
  185. val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TLCL)); \
  186. checkliveness(L,io); }
  187. #define setclCvalue(L,obj,x) \
  188. { TValue *io = (obj); CClosure *x_ = (x); \
  189. val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TCCL)); \
  190. checkliveness(L,io); }
  191. #define sethvalue(L,obj,x) \
  192. { TValue *io = (obj); Table *x_ = (x); \
  193. val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTABLE)); \
  194. checkliveness(L,io); }
  195. #define setobj(L,obj1,obj2) \
  196. { TValue *io1=(obj1); const TValue *io2=(obj2); \
  197. io1->value_ = io2->value_; io1->tt_ = io2->tt_; \
  198. (void)L; checkliveness(L,io1); }
  199. /*
  200. ** different types of assignments, according to destination
  201. */
  202. /* from stack to stack */
  203. #define setobjs2s(L,o1,o2) setobj(L,s2v(o1),s2v(o2))
  204. /* to stack (not from same stack) */
  205. #define setobj2s(L,o1,o2) setobj(L,s2v(o1),o2)
  206. #define setsvalue2s(L,o,s) setsvalue(L,s2v(o),s)
  207. #define sethvalue2s(L,o,h) sethvalue(L,s2v(o),h)
  208. #define setthvalue2s(L,o,t) setthvalue(L,s2v(o),t)
  209. #define setptvalue2s(L,o,p) setptvalue(L,s2v(o),p)
  210. #define setclLvalue2s(L,o,cl) setclLvalue(L,s2v(o),cl)
  211. /* from table to same table */
  212. #define setobjt2t setobj
  213. /* to new object */
  214. #define setobj2n setobj
  215. #define setsvalue2n setsvalue
  216. /* to table */
  217. #define setobj2t setobj
  218. /*
  219. ** {======================================================
  220. ** types and prototypes
  221. ** =======================================================
  222. */
  223. typedef union StackValue {
  224. TValue val;
  225. struct {
  226. TValuefields;
  227. lu_byte callstatus_;
  228. unsigned short previous; /* difference to previous 'func' */
  229. short nresults; /* expected number of results from this function */
  230. unsigned short framesize; /* stack space available for this function */
  231. } stkci;
  232. } StackValue;
  233. #define callstatus(ar) ((ar)->stkci.callstatus_)
  234. /* top of a function (first element after its frame) */
  235. #define functop(func) ((func) + (func)->stkci.framesize)
  236. /* set top of a function to a specific value */
  237. #define setfunctop(func,v) ((func)->stkci.framesize = (v) - (func))
  238. typedef StackValue *StkId; /* index to stack elements */
  239. /* convert a 'StackValue' to a 'TValue' */
  240. #define s2v(o) (&(o)->val)
  241. /*
  242. ** Header for string value; string bytes follow the end of this structure
  243. ** (aligned according to 'UTString'; see next).
  244. */
  245. typedef struct TString {
  246. CommonHeader;
  247. lu_byte extra; /* reserved words for short strings; "has hash" for longs */
  248. lu_byte shrlen; /* length for short strings */
  249. unsigned int hash;
  250. union {
  251. size_t lnglen; /* length for long strings */
  252. struct TString *hnext; /* linked list for hash table */
  253. } u;
  254. } TString;
  255. /*
  256. ** Ensures that address after this type is always fully aligned.
  257. */
  258. typedef union UTString {
  259. LUAI_MAXALIGN; /* ensures maximum alignment for strings */
  260. TString tsv;
  261. } UTString;
  262. /*
  263. ** Get the actual string (array of bytes) from a 'TString'.
  264. ** (Access to 'extra' ensures that value is really a 'TString'.)
  265. */
  266. #define getstr(ts) \
  267. check_exp(sizeof((ts)->extra), cast(char *, (ts)) + sizeof(UTString))
  268. /* get the actual string (array of bytes) from a Lua value */
  269. #define svalue(o) getstr(tsvalue(o))
  270. /* get string length from 'TString *s' */
  271. #define tsslen(s) ((s)->tt == LUA_TSHRSTR ? (s)->shrlen : (s)->u.lnglen)
  272. /* get string length from 'TValue *o' */
  273. #define vslen(o) tsslen(tsvalue(o))
  274. /*
  275. ** Header for userdata; memory area follows the end of this structure
  276. ** (aligned according to 'UUdata'; see next).
  277. */
  278. typedef struct Udata {
  279. CommonHeader;
  280. lu_byte ttuv_; /* user value's tag */
  281. struct Table *metatable;
  282. size_t len; /* number of bytes */
  283. union Value user_; /* user value */
  284. } Udata;
  285. /*
  286. ** Ensures that address after this type is always fully aligned.
  287. */
  288. typedef union UUdata {
  289. LUAI_MAXALIGN; /* ensures maximum alignment for 'local' udata */
  290. Udata uv;
  291. } UUdata;
  292. /*
  293. ** Get the address of memory block inside 'Udata'.
  294. ** (Access to 'ttuv_' ensures that value is really a 'Udata'.)
  295. */
  296. #define getudatamem(u) \
  297. check_exp(sizeof((u)->ttuv_), (cast(char*, (u)) + sizeof(UUdata)))
  298. #define setuservalue(L,u,o) \
  299. { const TValue *io=(o); Udata *iu = (u); \
  300. iu->user_ = io->value_; iu->ttuv_ = rttype(io); \
  301. checkliveness(L,io); }
  302. #define getuservalue(L,u,o) \
  303. { TValue *io=(o); const Udata *iu = (u); \
  304. io->value_ = iu->user_; settt_(io, iu->ttuv_); \
  305. checkliveness(L,io); }
  306. /*
  307. ** Description of an upvalue for function prototypes
  308. */
  309. typedef struct Upvaldesc {
  310. TString *name; /* upvalue name (for debug information) */
  311. lu_byte instack; /* whether it is in stack (register) */
  312. lu_byte idx; /* index of upvalue (in stack or in outer function's list) */
  313. } Upvaldesc;
  314. /*
  315. ** Description of a local variable for function prototypes
  316. ** (used for debug information)
  317. */
  318. typedef struct LocVar {
  319. TString *varname;
  320. int startpc; /* first point where variable is active */
  321. int endpc; /* first point where variable is dead */
  322. } LocVar;
  323. /*
  324. ** Associates the absolute line source for a given instruction ('pc').
  325. ** The array 'lineinfo' gives, for each instruction, the difference in
  326. ** lines from the previous instruction. When that difference does not
  327. ** fit into a byte, Lua saves the absolute line for that instruction.
  328. ** (Lua also saves the absolute line periodically, to speed up the
  329. ** computation of a line number: we can use binary search in the
  330. ** absolute-line array, but we must traverse the 'lineinfo' array
  331. ** linearly to compute a line.)
  332. */
  333. typedef struct AbsLineInfo {
  334. int pc;
  335. int line;
  336. } AbsLineInfo;
  337. /*
  338. ** Function Prototypes
  339. */
  340. typedef struct Proto {
  341. CommonHeader;
  342. lu_byte numparams; /* number of fixed parameters */
  343. lu_byte is_vararg;
  344. lu_byte maxstacksize; /* number of registers needed by this function */
  345. lu_byte cachemiss; /* count for successive misses for 'cache' field */
  346. int sizeupvalues; /* size of 'upvalues' */
  347. int sizek; /* size of 'k' */
  348. int sizecode;
  349. int sizelineinfo;
  350. int sizep; /* size of 'p' */
  351. int sizelocvars;
  352. int sizeabslineinfo; /* size of 'abslineinfo' */
  353. int linedefined; /* debug information */
  354. int lastlinedefined; /* debug information */
  355. TValue *k; /* constants used by the function */
  356. struct LClosure *cache; /* last-created closure with this prototype */
  357. Instruction *code; /* opcodes */
  358. struct Proto **p; /* functions defined inside the function */
  359. Upvaldesc *upvalues; /* upvalue information */
  360. ls_byte *lineinfo; /* information about source lines (debug information) */
  361. AbsLineInfo *abslineinfo; /* idem */
  362. LocVar *locvars; /* information about local variables (debug information) */
  363. TString *source; /* used for debug information */
  364. GCObject *gclist;
  365. } Proto;
  366. /*
  367. ** Upvalues for Lua closures
  368. */
  369. typedef struct UpVal {
  370. CommonHeader;
  371. TValue *v; /* points to stack or to its own value */
  372. union {
  373. struct { /* (when open) */
  374. struct UpVal *next; /* linked list */
  375. struct UpVal **previous;
  376. } open;
  377. TValue value; /* the value (when closed) */
  378. } u;
  379. } UpVal;
  380. /*
  381. ** Closures
  382. */
  383. #define ClosureHeader \
  384. CommonHeader; lu_byte nupvalues; GCObject *gclist
  385. typedef struct CClosure {
  386. ClosureHeader;
  387. lua_CFunction f;
  388. TValue upvalue[1]; /* list of upvalues */
  389. } CClosure;
  390. typedef struct LClosure {
  391. ClosureHeader;
  392. struct Proto *p;
  393. UpVal *upvals[1]; /* list of upvalues */
  394. } LClosure;
  395. typedef union Closure {
  396. CClosure c;
  397. LClosure l;
  398. } Closure;
  399. #define isLfunction(o) ttisLclosure(o)
  400. #define getproto(o) (clLvalue(o)->p)
  401. /*
  402. ** Tables
  403. */
  404. /*
  405. ** Nodes for Hash tables. A pack of two TValue's (key-value pairs)
  406. ** plus a 'next' field to link colliding entries. The distribuition
  407. ** of the key's fields ('key_tt' and 'key_val') not forming a proper
  408. ** 'TValue' allows for a smaller size for 'Node' both in 4-byte
  409. ** and 8-byte alignments.
  410. */
  411. typedef union Node {
  412. struct NodeKey {
  413. TValuefields; /* fields for value */
  414. lu_byte key_tt; /* key type */
  415. int next; /* for chaining */
  416. Value key_val; /* key value */
  417. } u;
  418. TValue i_val; /* direct access to node's value as a proper 'TValue' */
  419. } Node;
  420. /* copy a value into a key */
  421. #define setnodekey(L,node,obj) \
  422. { Node *n_=(node); const TValue *io_=(obj); \
  423. n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \
  424. (void)L; checkliveness(L,io_); }
  425. /* copy a value from a key */
  426. #define getnodekey(L,obj,node) \
  427. { TValue *io_=(obj); const Node *n_=(node); \
  428. io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \
  429. (void)L; checkliveness(L,io_); }
  430. typedef struct Table {
  431. CommonHeader;
  432. lu_byte flags; /* 1<<p means tagmethod(p) is not present */
  433. lu_byte lsizenode; /* log2 of size of 'node' array */
  434. unsigned int sizearray; /* size of 'array' array */
  435. TValue *array; /* array part */
  436. Node *node;
  437. Node *lastfree; /* any free position is before this position */
  438. struct Table *metatable;
  439. GCObject *gclist;
  440. } Table;
  441. /*
  442. ** Macros to manipulate keys inserted in nodes
  443. */
  444. #define keytt(node) ((node)->u.key_tt)
  445. #define keyval(node) ((node)->u.key_val)
  446. #define keyisnil(node) (keytt(node) == LUA_TNIL)
  447. #define keyisinteger(node) (keytt(node) == LUA_TNUMINT)
  448. #define keyival(node) (keyval(node).i)
  449. #define keyisshrstr(node) (keytt(node) == ctb(LUA_TSHRSTR))
  450. #define keystrval(node) (gco2ts(keyval(node).gc))
  451. #define setnilkey(node) (keytt(node) = LUA_TNIL)
  452. #define keyiscollectable(n) (keytt(n) & BIT_ISCOLLECTABLE)
  453. #define gckey(n) (keyval(n).gc)
  454. #define gckeyN(n) (keyiscollectable(n) ? gckey(n) : NULL)
  455. /*
  456. ** Use a "nil table" to mark dead keys in a table. Those keys serve
  457. ** only to keep space for removed entries, which may still be part of
  458. ** chains. Note that the 'keytt' does not have the BIT_ISCOLLECTABLE
  459. ** set, so these values are considered not collectable and are different
  460. ** from any valid value.
  461. */
  462. #define setdeadkey(n) (keytt(n) = LUA_TTABLE, gckey(n) = NULL)
  463. /*
  464. ** 'module' operation for hashing (size is always a power of 2)
  465. */
  466. #define lmod(s,size) \
  467. (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
  468. #define twoto(x) (1<<(x))
  469. #define sizenode(t) (twoto((t)->lsizenode))
  470. /*
  471. ** (address of) a fixed nil value
  472. */
  473. #define luaO_nilobject (&luaO_nilobject_)
  474. LUAI_DDEC const TValue luaO_nilobject_;
  475. /* size of buffer for 'luaO_utf8esc' function */
  476. #define UTF8BUFFSZ 8
  477. LUAI_FUNC int luaO_int2fb (unsigned int x);
  478. LUAI_FUNC int luaO_fb2int (int x);
  479. LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x);
  480. LUAI_FUNC int luaO_ceillog2 (unsigned int x);
  481. LUAI_FUNC int luaO_rawarith (lua_State *L, int op, const TValue *p1,
  482. const TValue *p2, TValue *res);
  483. LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1,
  484. const TValue *p2, StkId res);
  485. LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o);
  486. LUAI_FUNC int luaO_hexavalue (int c);
  487. LUAI_FUNC void luaO_tostring (lua_State *L, TValue *obj);
  488. LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
  489. va_list argp);
  490. LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
  491. LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
  492. #endif