2009-05-21 19:01:41 +00:00
|
|
|
/*
|
2014-04-02 18:46:06 +00:00
|
|
|
** $Id$
|
2009-05-21 19:01:41 +00:00
|
|
|
** Type definitions for Lua objects
|
|
|
|
** See Copyright Notice in lua.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef lobject_h
|
|
|
|
#define lobject_h
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "llimits.h"
|
|
|
|
#include "lua.h"
|
|
|
|
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
/* tags for values visible from Lua */
|
|
|
|
#define LAST_TAG LUA_TTHREAD
|
2009-05-21 19:01:41 +00:00
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
#define NUM_TAGS (LAST_TAG+1)
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-04-02 18:46:06 +00:00
|
|
|
** Extra tags for non-values
|
2009-05-21 19:01:41 +00:00
|
|
|
*/
|
2014-04-02 18:46:06 +00:00
|
|
|
#define LUA_TPROTO (LAST_TAG+1)
|
|
|
|
#define LUA_TUPVAL (LAST_TAG+2)
|
|
|
|
#define LUA_TDEADKEY (LAST_TAG+3)
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Union of all collectable objects
|
|
|
|
*/
|
|
|
|
typedef union GCObject GCObject;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Common Header for all collectable objects (in macro form, to be
|
|
|
|
** included in other objects)
|
|
|
|
*/
|
|
|
|
#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Common header in struct form
|
|
|
|
*/
|
|
|
|
typedef struct GCheader {
|
|
|
|
CommonHeader;
|
|
|
|
} GCheader;
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
/*
|
|
|
|
** Union of all Lua values
|
|
|
|
*/
|
2014-04-02 18:46:06 +00:00
|
|
|
typedef union {
|
|
|
|
GCObject *gc;
|
|
|
|
void *p;
|
|
|
|
lua_Number n;
|
|
|
|
int b;
|
|
|
|
} Value;
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-04-02 18:46:06 +00:00
|
|
|
** Tagged Values
|
2009-05-21 19:01:41 +00:00
|
|
|
*/
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
#define TValuefields Value value; int tt
|
Update lua plugin to 5.2.3
Prior to this patch the Lua plugin used version 5.1.4. This change
reduces the number of modifications in the Lua source using some new
defines and because the upstream source is now more flexible.
Unless otherwise stated, l*.[ch] files are taken unmodified from the
upstream lua-5.2.3.
fscanf.c:
file descriptors in rockbox are just ints, they are hidden behind a
void* now so liolib requires less modifications. fscanf is updated to
use void* too.
getc.c: this is a new file required for getc implementation in lauxlib.c
lauxlib.c: LoadF replaced FILE* with int, the rockbox file
descriptor int are cast to FILE* (actually void* due to typedef).
getc uses the PREFIX version. stdin is not used, as per 5.1.4.
lbaselib.c: now uses strspn in the number parsing. print uses DEBUGF now
rather than being commented out.
lbitlib.c: use the built-in version from 5.2.3 rather than Reuben
Thomas's external library. Backwards compatible and adds some new bit
operations.
ldo.c: the LUAI_THROW/TRY defines are now in the core lua code, so have
been removed from rockconf.h
liolib.c: here the implementation has changed to use the LStream from
the original source, and cast the FILE* pointers to int. This has
reduced the number of modifications from the upstream version.
llex.c: the only change from upstream is to remove the locale include.
lmathlib.c: updated from the 5.2.3 version and re-applied the changes
that were made vs 5.1.4 for random numbers and to remove unsupported
float functions.
loadlib.c: upstream version, with the 5.1.4 changes for missing
functions.
lobject.c: upstream version, with ctype.h added and sprintf changed to
snprintf.
loslib.c: upstream version with locale.h removed and 5.1.4 changes for
unsupportable functions.
lstrlib.c: sprintf changed to snprintf.
ltable.c: upstream with the hashnum function from 5.1.4 to avoid frexp
in luai_hashnum.
luaconf.h: updated to 5.2.3 version, restored relevant parts from the
original 5.1.4 configuration. The COMPAT defines that are no longer
available are not included.
lundump.c: VERSION macro conflicts with the core Rockbox equivalent.
rocklib.c: luaL_reg is no longer available, replaced by luaL_Reg
equivalent. Moved checkboolean/optboolean functions to this file and out
of core lua files. luaL_getn is no longer available, replaced by
luaL_rawlen. luaL_register is deprecated, use the newlib/setfuncs
replacements. rli_init has to be called before setting up the newlib to
avoid overwriting the rb table.
rocklib_aux.pl: use rli_checkboolean from rocklib.c.
rocklua.c: new default bits library used, update the library loading
code with idiomatic 5.2 code.
strcspn.c: no longer needed, but strspn.c is required for strspn in
lbaselib.c
Change-Id: I0c7945c755f79083afe98ec117e1e8cf13de2651
Reviewed-on: http://gerrit.rockbox.org/774
Tested: Richard Quirk <richard.quirk@gmail.com>
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-03-19 18:31:31 +00:00
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
typedef struct lua_TValue {
|
|
|
|
TValuefields;
|
|
|
|
} TValue;
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Macros to test type */
|
2014-04-02 18:46:06 +00:00
|
|
|
#define ttisnil(o) (ttype(o) == LUA_TNIL)
|
|
|
|
#define ttisnumber(o) (ttype(o) == LUA_TNUMBER)
|
|
|
|
#define ttisstring(o) (ttype(o) == LUA_TSTRING)
|
|
|
|
#define ttistable(o) (ttype(o) == LUA_TTABLE)
|
|
|
|
#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION)
|
|
|
|
#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN)
|
|
|
|
#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA)
|
|
|
|
#define ttisthread(o) (ttype(o) == LUA_TTHREAD)
|
|
|
|
#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA)
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
/* Macros to access values */
|
2014-04-02 18:46:06 +00:00
|
|
|
#define ttype(o) ((o)->tt)
|
|
|
|
#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc)
|
|
|
|
#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p)
|
|
|
|
#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n)
|
|
|
|
#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts)
|
2009-05-21 19:01:41 +00:00
|
|
|
#define tsvalue(o) (&rawtsvalue(o)->tsv)
|
2014-04-02 18:46:06 +00:00
|
|
|
#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u)
|
2009-05-21 19:01:41 +00:00
|
|
|
#define uvalue(o) (&rawuvalue(o)->uv)
|
2014-04-02 18:46:06 +00:00
|
|
|
#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl)
|
|
|
|
#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h)
|
|
|
|
#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b)
|
|
|
|
#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th)
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0))
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
/*
|
|
|
|
** for internal debug only
|
|
|
|
*/
|
|
|
|
#define checkconsistency(obj) \
|
|
|
|
lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt))
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
#define checkliveness(g,obj) \
|
2014-04-02 18:46:06 +00:00
|
|
|
lua_assert(!iscollectable(obj) || \
|
|
|
|
((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc)))
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Macros to set values */
|
2014-04-02 18:46:06 +00:00
|
|
|
#define setnilvalue(obj) ((obj)->tt=LUA_TNIL)
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
#define setnvalue(obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ lua_Number i_x = (x); TValue *i_o=(obj); i_o->value.n=i_x; i_o->tt=LUA_TNUMBER; }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
#define setpvalue(obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ void *i_x = (x); TValue *i_o=(obj); i_o->value.p=i_x; i_o->tt=LUA_TLIGHTUSERDATA; }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
#define setbvalue(obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ int i_x = (x); TValue *i_o=(obj); i_o->value.b=i_x; i_o->tt=LUA_TBOOLEAN; }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
#define setsvalue(L,obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ GCObject *i_x = cast(GCObject *, (x)); \
|
|
|
|
TValue *i_o=(obj); \
|
|
|
|
i_o->value.gc=i_x; i_o->tt=LUA_TSTRING; \
|
2014-04-02 18:46:06 +00:00
|
|
|
checkliveness(G(L),i_o); }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
#define setuvalue(L,obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ GCObject *i_x = cast(GCObject *, (x)); \
|
|
|
|
TValue *i_o=(obj); \
|
|
|
|
i_o->value.gc=i_x; i_o->tt=LUA_TUSERDATA; \
|
2014-04-02 18:46:06 +00:00
|
|
|
checkliveness(G(L),i_o); }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
#define setthvalue(L,obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ GCObject *i_x = cast(GCObject *, (x)); \
|
|
|
|
TValue *i_o=(obj); \
|
|
|
|
i_o->value.gc=i_x; i_o->tt=LUA_TTHREAD; \
|
2014-04-02 18:46:06 +00:00
|
|
|
checkliveness(G(L),i_o); }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
#define setclvalue(L,obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ GCObject *i_x = cast(GCObject *, (x)); \
|
|
|
|
TValue *i_o=(obj); \
|
|
|
|
i_o->value.gc=i_x; i_o->tt=LUA_TFUNCTION; \
|
2014-04-02 18:46:06 +00:00
|
|
|
checkliveness(G(L),i_o); }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
Update lua plugin to 5.2.3
Prior to this patch the Lua plugin used version 5.1.4. This change
reduces the number of modifications in the Lua source using some new
defines and because the upstream source is now more flexible.
Unless otherwise stated, l*.[ch] files are taken unmodified from the
upstream lua-5.2.3.
fscanf.c:
file descriptors in rockbox are just ints, they are hidden behind a
void* now so liolib requires less modifications. fscanf is updated to
use void* too.
getc.c: this is a new file required for getc implementation in lauxlib.c
lauxlib.c: LoadF replaced FILE* with int, the rockbox file
descriptor int are cast to FILE* (actually void* due to typedef).
getc uses the PREFIX version. stdin is not used, as per 5.1.4.
lbaselib.c: now uses strspn in the number parsing. print uses DEBUGF now
rather than being commented out.
lbitlib.c: use the built-in version from 5.2.3 rather than Reuben
Thomas's external library. Backwards compatible and adds some new bit
operations.
ldo.c: the LUAI_THROW/TRY defines are now in the core lua code, so have
been removed from rockconf.h
liolib.c: here the implementation has changed to use the LStream from
the original source, and cast the FILE* pointers to int. This has
reduced the number of modifications from the upstream version.
llex.c: the only change from upstream is to remove the locale include.
lmathlib.c: updated from the 5.2.3 version and re-applied the changes
that were made vs 5.1.4 for random numbers and to remove unsupported
float functions.
loadlib.c: upstream version, with the 5.1.4 changes for missing
functions.
lobject.c: upstream version, with ctype.h added and sprintf changed to
snprintf.
loslib.c: upstream version with locale.h removed and 5.1.4 changes for
unsupportable functions.
lstrlib.c: sprintf changed to snprintf.
ltable.c: upstream with the hashnum function from 5.1.4 to avoid frexp
in luai_hashnum.
luaconf.h: updated to 5.2.3 version, restored relevant parts from the
original 5.1.4 configuration. The COMPAT defines that are no longer
available are not included.
lundump.c: VERSION macro conflicts with the core Rockbox equivalent.
rocklib.c: luaL_reg is no longer available, replaced by luaL_Reg
equivalent. Moved checkboolean/optboolean functions to this file and out
of core lua files. luaL_getn is no longer available, replaced by
luaL_rawlen. luaL_register is deprecated, use the newlib/setfuncs
replacements. rli_init has to be called before setting up the newlib to
avoid overwriting the rb table.
rocklib_aux.pl: use rli_checkboolean from rocklib.c.
rocklua.c: new default bits library used, update the library loading
code with idiomatic 5.2 code.
strcspn.c: no longer needed, but strspn.c is required for strspn in
lbaselib.c
Change-Id: I0c7945c755f79083afe98ec117e1e8cf13de2651
Reviewed-on: http://gerrit.rockbox.org/774
Tested: Richard Quirk <richard.quirk@gmail.com>
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-03-19 18:31:31 +00:00
|
|
|
#define sethvalue(L,obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ GCObject *i_x = cast(GCObject *, (x)); \
|
|
|
|
TValue *i_o=(obj); \
|
|
|
|
i_o->value.gc=i_x; i_o->tt=LUA_TTABLE; \
|
2014-04-02 18:46:06 +00:00
|
|
|
checkliveness(G(L),i_o); }
|
|
|
|
|
|
|
|
#define setptvalue(L,obj,x) \
|
2019-07-12 10:23:52 +00:00
|
|
|
{ GCObject *i_x = cast(GCObject *, (x)); \
|
|
|
|
TValue *i_o=(obj); \
|
|
|
|
i_o->value.gc=i_x; i_o->tt=LUA_TPROTO; \
|
2014-04-02 18:46:06 +00:00
|
|
|
checkliveness(G(L),i_o); }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define setobj(L,obj1,obj2) \
|
2014-04-02 18:46:06 +00:00
|
|
|
{ const TValue *o2=(obj2); TValue *o1=(obj1); \
|
|
|
|
o1->value = o2->value; o1->tt=o2->tt; \
|
|
|
|
checkliveness(G(L),o1); }
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-04-02 18:46:06 +00:00
|
|
|
** different types of sets, according to destination
|
2009-05-21 19:01:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* from stack to (same) stack */
|
|
|
|
#define setobjs2s setobj
|
|
|
|
/* to stack (not from same stack) */
|
|
|
|
#define setobj2s setobj
|
|
|
|
#define setsvalue2s setsvalue
|
|
|
|
#define sethvalue2s sethvalue
|
|
|
|
#define setptvalue2s setptvalue
|
|
|
|
/* from table to same table */
|
|
|
|
#define setobjt2t setobj
|
|
|
|
/* to table */
|
|
|
|
#define setobj2t setobj
|
|
|
|
/* to new object */
|
|
|
|
#define setobj2n setobj
|
|
|
|
#define setsvalue2n setsvalue
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
#define setttype(obj, tt) (ttype(obj) = (tt))
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
#define iscollectable(o) (ttype(o) >= LUA_TSTRING)
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef TValue *StkId; /* index to stack elements */
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-04-02 18:46:06 +00:00
|
|
|
** String headers for string table
|
2009-05-21 19:01:41 +00:00
|
|
|
*/
|
|
|
|
typedef union TString {
|
|
|
|
L_Umaxalign dummy; /* ensures maximum alignment for strings */
|
|
|
|
struct {
|
|
|
|
CommonHeader;
|
2014-04-02 18:46:06 +00:00
|
|
|
lu_byte reserved;
|
2018-11-11 23:27:19 +00:00
|
|
|
lu_byte type;
|
2009-05-21 19:01:41 +00:00
|
|
|
unsigned int hash;
|
2014-04-02 18:46:06 +00:00
|
|
|
size_t len;
|
2009-05-21 19:01:41 +00:00
|
|
|
} tsv;
|
|
|
|
} TString;
|
|
|
|
|
|
|
|
|
2018-11-11 23:27:19 +00:00
|
|
|
#define getstr(ts) (luaO_getstring(ts)) /* ROCKLUA ADDED */
|
Update lua plugin to 5.2.3
Prior to this patch the Lua plugin used version 5.1.4. This change
reduces the number of modifications in the Lua source using some new
defines and because the upstream source is now more flexible.
Unless otherwise stated, l*.[ch] files are taken unmodified from the
upstream lua-5.2.3.
fscanf.c:
file descriptors in rockbox are just ints, they are hidden behind a
void* now so liolib requires less modifications. fscanf is updated to
use void* too.
getc.c: this is a new file required for getc implementation in lauxlib.c
lauxlib.c: LoadF replaced FILE* with int, the rockbox file
descriptor int are cast to FILE* (actually void* due to typedef).
getc uses the PREFIX version. stdin is not used, as per 5.1.4.
lbaselib.c: now uses strspn in the number parsing. print uses DEBUGF now
rather than being commented out.
lbitlib.c: use the built-in version from 5.2.3 rather than Reuben
Thomas's external library. Backwards compatible and adds some new bit
operations.
ldo.c: the LUAI_THROW/TRY defines are now in the core lua code, so have
been removed from rockconf.h
liolib.c: here the implementation has changed to use the LStream from
the original source, and cast the FILE* pointers to int. This has
reduced the number of modifications from the upstream version.
llex.c: the only change from upstream is to remove the locale include.
lmathlib.c: updated from the 5.2.3 version and re-applied the changes
that were made vs 5.1.4 for random numbers and to remove unsupported
float functions.
loadlib.c: upstream version, with the 5.1.4 changes for missing
functions.
lobject.c: upstream version, with ctype.h added and sprintf changed to
snprintf.
loslib.c: upstream version with locale.h removed and 5.1.4 changes for
unsupportable functions.
lstrlib.c: sprintf changed to snprintf.
ltable.c: upstream with the hashnum function from 5.1.4 to avoid frexp
in luai_hashnum.
luaconf.h: updated to 5.2.3 version, restored relevant parts from the
original 5.1.4 configuration. The COMPAT defines that are no longer
available are not included.
lundump.c: VERSION macro conflicts with the core Rockbox equivalent.
rocklib.c: luaL_reg is no longer available, replaced by luaL_Reg
equivalent. Moved checkboolean/optboolean functions to this file and out
of core lua files. luaL_getn is no longer available, replaced by
luaL_rawlen. luaL_register is deprecated, use the newlib/setfuncs
replacements. rli_init has to be called before setting up the newlib to
avoid overwriting the rb table.
rocklib_aux.pl: use rli_checkboolean from rocklib.c.
rocklua.c: new default bits library used, update the library loading
code with idiomatic 5.2 code.
strcspn.c: no longer needed, but strspn.c is required for strspn in
lbaselib.c
Change-Id: I0c7945c755f79083afe98ec117e1e8cf13de2651
Reviewed-on: http://gerrit.rockbox.org/774
Tested: Richard Quirk <richard.quirk@gmail.com>
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-03-19 18:31:31 +00:00
|
|
|
#define svalue(o) getstr(rawtsvalue(o))
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
typedef union Udata {
|
|
|
|
L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
|
|
|
|
struct {
|
|
|
|
CommonHeader;
|
|
|
|
struct Table *metatable;
|
|
|
|
struct Table *env;
|
2014-04-02 18:46:06 +00:00
|
|
|
size_t len;
|
2009-05-21 19:01:41 +00:00
|
|
|
} uv;
|
|
|
|
} Udata;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Function Prototypes
|
|
|
|
*/
|
|
|
|
typedef struct Proto {
|
|
|
|
CommonHeader;
|
|
|
|
TValue *k; /* constants used by the function */
|
|
|
|
Instruction *code;
|
|
|
|
struct Proto **p; /* functions defined inside the function */
|
2019-08-05 05:03:08 +00:00
|
|
|
#ifdef LUA_OPTIMIZE_DEBUG
|
|
|
|
unsigned char *packedlineinfo;
|
|
|
|
#else
|
2014-04-02 18:46:06 +00:00
|
|
|
int *lineinfo; /* map from opcodes to source lines */
|
2019-08-05 05:03:08 +00:00
|
|
|
#endif
|
2014-04-02 18:46:06 +00:00
|
|
|
struct LocVar *locvars; /* information about local variables */
|
|
|
|
TString **upvalues; /* upvalue names */
|
|
|
|
TString *source;
|
|
|
|
int sizeupvalues;
|
2009-05-21 19:01:41 +00:00
|
|
|
int sizek; /* size of `k' */
|
|
|
|
int sizecode;
|
|
|
|
int sizelineinfo;
|
|
|
|
int sizep; /* size of `p' */
|
|
|
|
int sizelocvars;
|
|
|
|
int linedefined;
|
|
|
|
int lastlinedefined;
|
|
|
|
GCObject *gclist;
|
2014-04-02 18:46:06 +00:00
|
|
|
lu_byte nups; /* number of upvalues */
|
|
|
|
lu_byte numparams;
|
2009-05-21 19:01:41 +00:00
|
|
|
lu_byte is_vararg;
|
2014-04-02 18:46:06 +00:00
|
|
|
lu_byte maxstacksize;
|
2009-05-21 19:01:41 +00:00
|
|
|
} Proto;
|
|
|
|
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
/* masks for new-style vararg */
|
|
|
|
#define VARARG_HASARG 1
|
|
|
|
#define VARARG_ISVARARG 2
|
|
|
|
#define VARARG_NEEDSARG 4
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct LocVar {
|
|
|
|
TString *varname;
|
|
|
|
int startpc; /* first point where variable is active */
|
|
|
|
int endpc; /* first point where variable is dead */
|
|
|
|
} LocVar;
|
|
|
|
|
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
/*
|
2014-04-02 18:46:06 +00:00
|
|
|
** Upvalues
|
2009-05-21 19:01:41 +00:00
|
|
|
*/
|
2014-04-02 18:46:06 +00:00
|
|
|
|
2009-05-21 19:01:41 +00:00
|
|
|
typedef struct UpVal {
|
|
|
|
CommonHeader;
|
|
|
|
TValue *v; /* points to stack or to its own value */
|
|
|
|
union {
|
|
|
|
TValue value; /* the value (when closed) */
|
|
|
|
struct { /* double linked list (when open) */
|
|
|
|
struct UpVal *prev;
|
|
|
|
struct UpVal *next;
|
|
|
|
} l;
|
|
|
|
} u;
|
|
|
|
} UpVal;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Closures
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define ClosureHeader \
|
2014-04-02 18:46:06 +00:00
|
|
|
CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \
|
|
|
|
struct Table *env
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
typedef struct CClosure {
|
|
|
|
ClosureHeader;
|
|
|
|
lua_CFunction f;
|
2014-04-02 18:46:06 +00:00
|
|
|
TValue upvalue[1];
|
2009-05-21 19:01:41 +00:00
|
|
|
} CClosure;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct LClosure {
|
|
|
|
ClosureHeader;
|
|
|
|
struct Proto *p;
|
2014-04-02 18:46:06 +00:00
|
|
|
UpVal *upvals[1];
|
2009-05-21 19:01:41 +00:00
|
|
|
} LClosure;
|
|
|
|
|
|
|
|
|
|
|
|
typedef union Closure {
|
|
|
|
CClosure c;
|
|
|
|
LClosure l;
|
|
|
|
} Closure;
|
|
|
|
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC)
|
|
|
|
#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC)
|
2009-05-21 19:01:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Tables
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef union TKey {
|
|
|
|
struct {
|
|
|
|
TValuefields;
|
|
|
|
struct Node *next; /* for chaining */
|
|
|
|
} nk;
|
|
|
|
TValue tvk;
|
|
|
|
} TKey;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct Node {
|
|
|
|
TValue i_val;
|
|
|
|
TKey i_key;
|
|
|
|
} Node;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct Table {
|
|
|
|
CommonHeader;
|
2014-04-02 18:46:06 +00:00
|
|
|
lu_byte flags; /* 1<<p means tagmethod(p) is not present */
|
2009-05-21 19:01:41 +00:00
|
|
|
lu_byte lsizenode; /* log2 of size of `node' array */
|
|
|
|
struct Table *metatable;
|
|
|
|
TValue *array; /* array part */
|
|
|
|
Node *node;
|
|
|
|
Node *lastfree; /* any free position is before this position */
|
|
|
|
GCObject *gclist;
|
|
|
|
int sizearray; /* size of `array' array */
|
|
|
|
} Table;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** `module' operation for hashing (size is always a power of 2)
|
|
|
|
*/
|
|
|
|
#define lmod(s,size) \
|
|
|
|
(check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1)))))
|
|
|
|
|
|
|
|
|
|
|
|
#define twoto(x) (1<<(x))
|
|
|
|
#define sizenode(t) (twoto((t)->lsizenode))
|
|
|
|
|
|
|
|
|
|
|
|
#define luaO_nilobject (&luaO_nilobject_)
|
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
LUAI_DATA const TValue luaO_nilobject_;
|
2009-05-21 19:01:41 +00:00
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
#define ceillog2(x) (luaO_log2((x)-1) + 1)
|
2009-05-21 19:01:41 +00:00
|
|
|
|
2014-04-02 18:46:06 +00:00
|
|
|
LUAI_FUNC int luaO_log2 (unsigned int x);
|
2009-05-21 19:01:41 +00:00
|
|
|
LUAI_FUNC int luaO_int2fb (unsigned int x);
|
|
|
|
LUAI_FUNC int luaO_fb2int (int x);
|
2014-04-02 18:46:06 +00:00
|
|
|
LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2);
|
|
|
|
LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result);
|
2018-11-11 23:27:19 +00:00
|
|
|
LUAI_FUNC const char *luaO_getstring(const TString * ts); /* ROCKLUA ADDED */
|
2009-05-21 19:01:41 +00:00
|
|
|
LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt,
|
|
|
|
va_list argp);
|
|
|
|
LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
|
|
|
|
LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|