ltable.c File Reference

Go to the source code of this file.

Defines

#define ltable_c
#define LUA_CORE
#define MAXBITS   (LUAI_BITSINT-2)
#define MAXASIZE   (1 << MAXBITS)
#define hashpow2(t, n)   (gnode(t, lmod((n), sizenode(t))))
#define hashstr(t, str)   hashpow2(t, (str)->tsv.hash)
#define hashboolean(t, p)   hashpow2(t, p)
#define hashmod(t, n)   (gnode(t, ((n) % ((sizenode(t)-1)|1))))
#define hashpointer(t, p)   hashmod(t, IntPoint(p))
#define numints   cast_int(sizeof(lua_Number)/sizeof(int))
#define dummynode   (&dummynode_)

Functions

static Nodehashnum (const Table *t, lua_Number n)
static Nodemainposition (const Table *t, const TValue *key)
static int arrayindex (const TValue *key)
static int findindex (lua_State *L, Table *t, StkId key)
int luaH_next (lua_State *L, Table *t, StkId key)
static int computesizes (int nums[], int *narray)
static int countint (const TValue *key, int *nums)
static int numusearray (const Table *t, int *nums)
static int numusehash (const Table *t, int *nums, int *pnasize)
static void setarrayvector (lua_State *L, Table *t, int size)
static void setnodevector (lua_State *L, Table *t, int size)
static void resize (lua_State *L, Table *t, int nasize, int nhsize)
void luaH_resizearray (lua_State *L, Table *t, int nasize)
static void rehash (lua_State *L, Table *t, const TValue *ek)
TableluaH_new (lua_State *L, int narray, int nhash)
void luaH_free (lua_State *L, Table *t)
static Nodegetfreepos (Table *t)
static TValuenewkey (lua_State *L, Table *t, const TValue *key)
const TValueluaH_getnum (Table *t, int key)
const TValueluaH_getstr (Table *t, TString *key)
const TValueluaH_get (Table *t, const TValue *key)
TValueluaH_set (lua_State *L, Table *t, const TValue *key)
TValueluaH_setnum (lua_State *L, Table *t, int key)
TValueluaH_setstr (lua_State *L, Table *t, TString *key)
static int unbound_search (Table *t, unsigned int j)
int luaH_getn (Table *t)

Variables

static const Node dummynode_

Define Documentation

#define dummynode   (&dummynode_)

Definition at line 73 of file ltable.c.

Referenced by luaH_free(), luaH_getn(), luaH_new(), luaH_resizearray(), newkey(), resize(), and setnodevector().

#define hashboolean ( t,
 )     hashpow2(t, p)

Definition at line 53 of file ltable.c.

Referenced by mainposition().

#define hashmod ( t,
 )     (gnode(t, ((n) % ((sizenode(t)-1)|1))))

Definition at line 60 of file ltable.c.

Referenced by hashnum().

#define hashpointer ( t,
 )     hashmod(t, IntPoint(p))

Definition at line 63 of file ltable.c.

Referenced by mainposition().

#define hashpow2 ( t,
 )     (gnode(t, lmod((n), sizenode(t))))

Definition at line 50 of file ltable.c.

#define hashstr ( t,
str   )     hashpow2(t, (str)->tsv.hash)

Definition at line 52 of file ltable.c.

Referenced by luaH_getstr(), and mainposition().

#define ltable_c

Definition at line 24 of file ltable.c.

#define LUA_CORE

Definition at line 25 of file ltable.c.

#define MAXASIZE   (1 << MAXBITS)

Definition at line 47 of file ltable.c.

Referenced by countint().

#define MAXBITS   (LUAI_BITSINT-2)

Definition at line 44 of file ltable.c.

Referenced by numusearray(), rehash(), and setnodevector().

#define numints   cast_int(sizeof(lua_Number)/sizeof(int))

Definition at line 69 of file ltable.c.

Referenced by hashnum().


Function Documentation

static int arrayindex ( const TValue key  )  [static]

Definition at line 120 of file ltable.c.

References cast_num, lua_number2int, luai_numeq, nvalue, and ttisnumber.

Referenced by countint(), and findindex().

static int computesizes ( int  nums[],
int *  narray 
) [static]

Definition at line 189 of file ltable.c.

References lua_assert.

Referenced by rehash().

static int countint ( const TValue key,
int *  nums 
) [static]

Definition at line 211 of file ltable.c.

References arrayindex(), ceillog2, and MAXASIZE.

Referenced by numusehash(), and rehash().

static int findindex ( lua_State L,
Table t,
StkId  key 
) [static]
static Node* getfreepos ( Table t  )  [static]

Definition at line 382 of file ltable.c.

References gkey, Table::lastfree, Table::node, and ttisnil.

Referenced by newkey().

static Node* hashnum ( const Table t,
lua_Number  n 
) [static]

Definition at line 84 of file ltable.c.

References gnode, hashmod, luai_numeq, and numints.

Referenced by luaH_getnum(), and mainposition().

void luaH_free ( lua_State L,
Table t 
)

Definition at line 374 of file ltable.c.

References Table::array, dummynode, luaM_free, luaM_freearray, Table::node, Table::sizearray, and sizenode.

Referenced by freeobj().

const TValue* luaH_get ( Table t,
const TValue key 
)
int luaH_getn ( Table t  ) 

Definition at line 560 of file ltable.c.

References Table::array, dummynode, Table::node, Table::sizearray, ttisnil, and unbound_search().

Referenced by lua_objlen(), and luaV_execute().

const TValue* luaH_getnum ( Table t,
int  key 
)
const TValue* luaH_getstr ( Table t,
TString key 
)

Definition at line 455 of file ltable.c.

References gkey, gnext, gval, hashstr, luaO_nilobject, rawtsvalue, and ttisstring.

Referenced by luaH_get(), luaH_setstr(), luaT_gettm(), and luaT_gettmbyobj().

Table* luaH_new ( lua_State L,
int  narray,
int  nhash 
)
int luaH_next ( lua_State L,
Table t,
StkId  key 
)

Definition at line 162 of file ltable.c.

References Table::array, cast_num, findindex(), gnode, gval, key2tval, setnvalue, setobj2s, Table::sizearray, sizenode, and ttisnil.

Referenced by lua_next().

void luaH_resizearray ( lua_State L,
Table t,
int  nasize 
)

Definition at line 327 of file ltable.c.

References dummynode, Table::node, resize(), and sizenode.

Referenced by luaV_execute().

TValue* luaH_set ( lua_State L,
Table t,
const TValue key 
)
TValue* luaH_setnum ( lua_State L,
Table t,
int  key 
)
TValue* luaH_setstr ( lua_State L,
Table t,
TString key 
)

Definition at line 520 of file ltable.c.

References cast, luaH_getstr(), luaO_nilobject, newkey(), and setsvalue.

Referenced by adjust_varargs(), and luaX_newstring().

static Node* mainposition ( const Table t,
const TValue key 
) [static]
static TValue* newkey ( lua_State L,
Table t,
const TValue key 
) [static]
static int numusearray ( const Table t,
int *  nums 
) [static]

Definition at line 222 of file ltable.c.

References Table::array, MAXBITS, Table::sizearray, and ttisnil.

Referenced by rehash().

static int numusehash ( const Table t,
int *  nums,
int *  pnasize 
) [static]

Definition at line 247 of file ltable.c.

References countint(), gval, key2tval, Table::node, sizenode, and ttisnil.

Referenced by rehash().

static void rehash ( lua_State L,
Table t,
const TValue ek 
) [static]

Definition at line 333 of file ltable.c.

References computesizes(), countint(), MAXBITS, numusearray(), numusehash(), and resize().

Referenced by newkey().

static void resize ( lua_State L,
Table t,
int  nasize,
int  nhsize 
) [static]
static void setarrayvector ( lua_State L,
Table t,
int  size 
) [static]

Definition at line 263 of file ltable.c.

References Table::array, luaM_reallocvector, setnilvalue, and Table::sizearray.

Referenced by luaH_new(), and resize().

static void setnodevector ( lua_State L,
Table t,
int  size 
) [static]
static int unbound_search ( Table t,
unsigned int  j 
) [static]

Definition at line 532 of file ltable.c.

References cast, luaH_getnum(), MAX_INT, and ttisnil.

Referenced by luaH_getn().


Variable Documentation

const Node dummynode_ [static]
Initial value:
 {
  {{NULL}, LUA_TNIL},  
  {{{NULL}, LUA_TNIL, NULL}}  
}

Definition at line 75 of file ltable.c.


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:50:00 2011 by Doxygen 1.6.1