mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
no need for tags in boxed values :-(
This commit is contained in:
parent
9a231afa97
commit
e506b864cd
3
ldo.c
3
ldo.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.118 2001/01/29 15:35:17 roberto Exp roberto $
|
** $Id: ldo.c,v 1.119 2001/01/29 19:34:02 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -172,7 +172,6 @@ void luaD_call (lua_State *L, StkId func, int nResults) {
|
|||||||
setclvalue(func, tm); /* tag method is the new function to be called */
|
setclvalue(func, tm); /* tag method is the new function to be called */
|
||||||
}
|
}
|
||||||
cl = clvalue(func);
|
cl = clvalue(func);
|
||||||
ci.v.ttype = LUA_TMARK;
|
|
||||||
ci.func = cl;
|
ci.func = cl;
|
||||||
setivalue(func, &ci);
|
setivalue(func, &ci);
|
||||||
callhook = L->callhook;
|
callhook = L->callhook;
|
||||||
|
3
lfunc.c
3
lfunc.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lfunc.c,v 1.37 2001/01/19 13:20:30 roberto Exp roberto $
|
** $Id: lfunc.c,v 1.38 2001/01/29 19:34:02 roberto Exp roberto $
|
||||||
** Auxiliary functions to manipulate prototypes and closures
|
** Auxiliary functions to manipulate prototypes and closures
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
Closure *luaF_newclosure (lua_State *L, int nelems) {
|
Closure *luaF_newclosure (lua_State *L, int nelems) {
|
||||||
Closure *c = (Closure *)luaM_malloc(L, sizeclosure(nelems));
|
Closure *c = (Closure *)luaM_malloc(L, sizeclosure(nelems));
|
||||||
c->v.ttype = LUA_TFUNCTION;
|
|
||||||
c->next = G(L)->rootcl;
|
c->next = G(L)->rootcl;
|
||||||
G(L)->rootcl = c;
|
G(L)->rootcl = c;
|
||||||
c->mark = c;
|
c->mark = c;
|
||||||
|
4
lgc.c
4
lgc.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lgc.c,v 1.82 2001/01/29 17:16:58 roberto Exp roberto $
|
** $Id: lgc.c,v 1.83 2001/01/29 19:34:02 roberto Exp roberto $
|
||||||
** Garbage Collector
|
** Garbage Collector
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -66,8 +66,6 @@ static void marktable (GCState *st, Hash *h) {
|
|||||||
|
|
||||||
|
|
||||||
static void markobject (GCState *st, TObject *o) {
|
static void markobject (GCState *st, TObject *o) {
|
||||||
lua_assert(ttype(o) == LUA_TNUMBER ||
|
|
||||||
ttype(o) == ((TValue *)(o->value.v))->ttype);
|
|
||||||
switch (ttype(o)) {
|
switch (ttype(o)) {
|
||||||
case LUA_TUSERDATA: case LUA_TSTRING:
|
case LUA_TUSERDATA: case LUA_TSTRING:
|
||||||
strmark(tsvalue(o));
|
strmark(tsvalue(o));
|
||||||
|
20
lobject.h
20
lobject.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 1.90 2001/01/29 17:16:58 roberto Exp roberto $
|
** $Id: lobject.h,v 1.91 2001/01/29 19:34:02 roberto Exp roberto $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -41,13 +41,6 @@
|
|||||||
#define is_T_MARK(t) (ttype(t) == LUA_TMARK)
|
#define is_T_MARK(t) (ttype(t) == LUA_TMARK)
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
** tag at the start of all "boxed" Lua values
|
|
||||||
*/
|
|
||||||
typedef struct TValue {
|
|
||||||
char ttype;
|
|
||||||
} TValue;
|
|
||||||
|
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
void *v;
|
void *v;
|
||||||
@ -116,8 +109,6 @@ typedef struct lua_TObject {
|
|||||||
#define TSPACK ((int)sizeof(int))
|
#define TSPACK ((int)sizeof(int))
|
||||||
|
|
||||||
typedef struct TString {
|
typedef struct TString {
|
||||||
TValue v;
|
|
||||||
unsigned char marked;
|
|
||||||
union {
|
union {
|
||||||
struct { /* for strings */
|
struct { /* for strings */
|
||||||
luint32 hash;
|
luint32 hash;
|
||||||
@ -129,6 +120,7 @@ typedef struct TString {
|
|||||||
} d;
|
} d;
|
||||||
} u;
|
} u;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
int marked;
|
||||||
struct TString *nexthash; /* chain for hash table */
|
struct TString *nexthash; /* chain for hash table */
|
||||||
char str[TSPACK]; /* variable length string!! must be the last field! */
|
char str[TSPACK]; /* variable length string!! must be the last field! */
|
||||||
} TString;
|
} TString;
|
||||||
@ -138,7 +130,6 @@ typedef struct TString {
|
|||||||
** Function Prototypes
|
** Function Prototypes
|
||||||
*/
|
*/
|
||||||
typedef struct Proto {
|
typedef struct Proto {
|
||||||
TValue v;
|
|
||||||
lua_Number *knum; /* numbers used by the function */
|
lua_Number *knum; /* numbers used by the function */
|
||||||
int sizeknum; /* size of `knum' */
|
int sizeknum; /* size of `knum' */
|
||||||
struct TString **kstr; /* strings used by the function */
|
struct TString **kstr; /* strings used by the function */
|
||||||
@ -173,15 +164,14 @@ typedef struct LocVar {
|
|||||||
** Closures
|
** Closures
|
||||||
*/
|
*/
|
||||||
typedef struct Closure {
|
typedef struct Closure {
|
||||||
TValue v;
|
int isC; /* 0 for Lua functions, 1 for C functions */
|
||||||
char isC; /* 0 for Lua functions, 1 for C functions */
|
|
||||||
short nupvalues;
|
|
||||||
union {
|
union {
|
||||||
lua_CFunction c; /* C functions */
|
lua_CFunction c; /* C functions */
|
||||||
struct Proto *l; /* Lua functions */
|
struct Proto *l; /* Lua functions */
|
||||||
} f;
|
} f;
|
||||||
struct Closure *next;
|
struct Closure *next;
|
||||||
struct Closure *mark; /* marked closures (point to itself when not marked) */
|
struct Closure *mark; /* marked closures (point to itself when not marked) */
|
||||||
|
int nupvalues;
|
||||||
TObject upvalue[1];
|
TObject upvalue[1];
|
||||||
} Closure;
|
} Closure;
|
||||||
|
|
||||||
@ -198,7 +188,6 @@ typedef struct Node {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct Hash {
|
typedef struct Hash {
|
||||||
TValue v;
|
|
||||||
Node *node;
|
Node *node;
|
||||||
int htag;
|
int htag;
|
||||||
int size;
|
int size;
|
||||||
@ -223,7 +212,6 @@ typedef struct Hash {
|
|||||||
** informations about a call (for debugging)
|
** informations about a call (for debugging)
|
||||||
*/
|
*/
|
||||||
typedef struct CallInfo {
|
typedef struct CallInfo {
|
||||||
TValue v;
|
|
||||||
struct Closure *func; /* function being called */
|
struct Closure *func; /* function being called */
|
||||||
const Instruction **pc; /* current pc of called function */
|
const Instruction **pc; /* current pc of called function */
|
||||||
int lastpc; /* last pc traced */
|
int lastpc; /* last pc traced */
|
||||||
|
9
lstate.h
9
lstate.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstate.h,v 1.47 2001/01/25 16:45:36 roberto Exp roberto $
|
** $Id: lstate.h,v 1.48 2001/01/26 11:45:51 roberto Exp roberto $
|
||||||
** Global State
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -32,6 +32,12 @@ extern int islocked;
|
|||||||
#define LUA_UNLOCK
|
#define LUA_UNLOCK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** macro to allow the inclusion of user information in Lua state
|
||||||
|
*/
|
||||||
|
#ifndef LUA_USERSTATE
|
||||||
|
#define LUA_USERSTATE
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef TObject *StkId; /* index to stack elements */
|
typedef TObject *StkId; /* index to stack elements */
|
||||||
|
|
||||||
@ -90,6 +96,7 @@ typedef struct global_State {
|
|||||||
** "per thread" state
|
** "per thread" state
|
||||||
*/
|
*/
|
||||||
struct lua_State {
|
struct lua_State {
|
||||||
|
LUA_USERSTATE
|
||||||
StkId top; /* first free slot in the stack */
|
StkId top; /* first free slot in the stack */
|
||||||
StkId stack; /* stack base */
|
StkId stack; /* stack base */
|
||||||
StkId stack_last; /* last free slot in the stack */
|
StkId stack_last; /* last free slot in the stack */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstring.c,v 1.53 2001/01/29 19:34:02 roberto Exp roberto $
|
** $Id: lstring.c,v 1.54 2001/02/01 13:56:49 roberto Exp roberto $
|
||||||
** String table (keeps all strings handled by Lua)
|
** String table (keeps all strings handled by Lua)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -76,7 +76,6 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
|
|||||||
}
|
}
|
||||||
/* not found */
|
/* not found */
|
||||||
ts = (TString *)luaM_malloc(L, sizestring(l));
|
ts = (TString *)luaM_malloc(L, sizestring(l));
|
||||||
ts->v.ttype = LUA_TSTRING;
|
|
||||||
ts->marked = 0;
|
ts->marked = 0;
|
||||||
ts->nexthash = NULL;
|
ts->nexthash = NULL;
|
||||||
ts->len = l;
|
ts->len = l;
|
||||||
@ -92,7 +91,6 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
|
|||||||
TString *luaS_newudata (lua_State *L, size_t s, void *udata) {
|
TString *luaS_newudata (lua_State *L, size_t s, void *udata) {
|
||||||
union L_UTString *uts = (union L_UTString *)luaM_malloc(L, sizeudata(s));
|
union L_UTString *uts = (union L_UTString *)luaM_malloc(L, sizeudata(s));
|
||||||
TString *ts = &uts->ts;
|
TString *ts = &uts->ts;
|
||||||
ts->v.ttype = LUA_TUSERDATA;
|
|
||||||
ts->marked = 0;
|
ts->marked = 0;
|
||||||
ts->nexthash = NULL;
|
ts->nexthash = NULL;
|
||||||
ts->len = s;
|
ts->len = s;
|
||||||
|
3
ltable.c
3
ltable.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltable.c,v 1.73 2001/01/29 19:34:02 roberto Exp roberto $
|
** $Id: ltable.c,v 1.74 2001/01/30 19:48:37 roberto Exp roberto $
|
||||||
** Lua tables (hash)
|
** Lua tables (hash)
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -98,7 +98,6 @@ static void setnodevector (lua_State *L, Hash *t, luint32 size) {
|
|||||||
|
|
||||||
Hash *luaH_new (lua_State *L, int size) {
|
Hash *luaH_new (lua_State *L, int size) {
|
||||||
Hash *t = luaM_new(L, Hash);
|
Hash *t = luaM_new(L, Hash);
|
||||||
t->v.ttype = LUA_TTABLE;
|
|
||||||
t->htag = TagDefault;
|
t->htag = TagDefault;
|
||||||
t->next = G(L)->roottable;
|
t->next = G(L)->roottable;
|
||||||
G(L)->roottable = t;
|
G(L)->roottable = t;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user