lua/ltable.c File Reference

#include <string.h>
#include "lua.h"
#include "ldebug.h"
#include "ldo.h"
#include "lgc.h"
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
#include "ltable.h"

Go to the source code of this file.

Defines

#define ltable_c
#define MAXBITS   (BITS_INT-2)
#define toobig(x)   ((((x)-1) >> MAXBITS) != 0)
#define lua_number2int(i, n)   ((i)=(int)(n))
#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))

Functions

static Nodehashnum (const Table *t, lua_Number n)
NodeluaH_mainposition (const Table *t, const TObject *key)
static int arrayindex (const TObject *key)
static int luaH_index (lua_State *L, Table *t, StkId key)
int luaH_next (lua_State *L, Table *t, StkId key)
static void computesizes (int nums[], int ntotal, int *narray, int *nhash)
static void numuse (const Table *t, int *narray, int *nhash)
static void setarrayvector (lua_State *L, Table *t, int size)
static void setnodevector (lua_State *L, Table *t, int lsize)
static void resize (lua_State *L, Table *t, int nasize, int nhsize)
static void rehash (lua_State *L, Table *t)
TableluaH_new (lua_State *L, int narray, int lnhash)
void luaH_free (lua_State *L, Table *t)
static TObjectnewkey (lua_State *L, Table *t, const TObject *key)
static const TObjectluaH_getany (Table *t, const TObject *key)
const TObjectluaH_getnum (Table *t, int key)
const TObjectluaH_getstr (Table *t, TString *key)
const TObjectluaH_get (Table *t, const TObject *key)
TObjectluaH_set (lua_State *L, Table *t, const TObject *key)
TObjectluaH_setnum (lua_State *L, Table *t, int key)


Define Documentation

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

Definition at line 61 of file ltable.c.

Referenced by luaH_mainposition().

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

Definition at line 68 of file ltable.c.

Referenced by hashnum().

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

Definition at line 71 of file ltable.c.

Referenced by luaH_mainposition().

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

Definition at line 58 of file ltable.c.

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

Definition at line 60 of file ltable.c.

Referenced by luaH_getstr(), and luaH_mainposition().

#define ltable_c

Definition at line 26 of file ltable.c.

#define lua_number2int ( i,
 )     ((i)=(int)(n))

Definition at line 54 of file ltable.c.

Referenced by arrayindex(), and luaH_get().

#define MAXBITS   (BITS_INT-2)

Definition at line 45 of file ltable.c.

Referenced by numuse(), and setnodevector().

#define numints   cast(int, sizeof(lua_Number)/sizeof(int))

Definition at line 77 of file ltable.c.

Referenced by hashnum().

#define toobig (  )     ((((x)-1) >> MAXBITS) != 0)

Definition at line 49 of file ltable.c.

Referenced by arrayindex().


Function Documentation

static int arrayindex ( const TObject key  )  [static]

Definition at line 121 of file ltable.c.

References cast, lua_number2int, nvalue, toobig, and ttisnumber.

Referenced by luaH_index().

static void computesizes ( int  nums[],
int  ntotal,
int *  narray,
int *  nhash 
) [static]

Definition at line 186 of file ltable.c.

References lua_assert, and twoto.

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

Definition at line 83 of file ltable.c.

References cast, hashmod, lua_assert, and numints.

Referenced by luaH_getnum(), and luaH_mainposition().

void luaH_free ( lua_State L,
Table t 
)

Definition at line 361 of file ltable.c.

References Table::array, Table::lsizenode, luaM_freearray, luaM_freelem, Table::node, Table::sizearray, and sizenode.

Referenced by freeobj().

const TObject* luaH_get ( Table t,
const TObject key 
)

Definition at line 495 of file ltable.c.

References cast, lua_number2int, luaH_getany(), luaH_getnum(), luaH_getstr(), nvalue, tsvalue, and ttype.

Referenced by addk(), lua_rawget(), luaH_index(), luaH_set(), luaV_gettable(), and newkey().

static const TObject* luaH_getany ( Table t,
const TObject key 
) [static]

Definition at line 444 of file ltable.c.

References gkey, gval, luaH_mainposition(), luaO_nilobject, luaO_rawequalObj(), and ttisnil.

Referenced by luaH_get().

const TObject* luaH_getnum ( Table t,
int  key 
)

Definition at line 462 of file ltable.c.

References Table::array, cast, gkey, gval, hashnum(), luaO_nilobject, nvalue, and ttisnumber.

Referenced by lua_rawgeti(), luaH_get(), and luaH_setnum().

const TObject* luaH_getstr ( Table t,
TString key 
)

Definition at line 481 of file ltable.c.

References gkey, gval, hashstr, luaO_nilobject, tsvalue, and ttisstring.

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

static int luaH_index ( lua_State L,
Table t,
StkId  key 
) [static]

Definition at line 139 of file ltable.c.

References arrayindex(), cast, gnode, gval, luaG_runerror(), luaH_get(), luaO_nilobject, Table::sizearray, and ttisnil.

Referenced by luaH_next().

Node* luaH_mainposition ( const Table t,
const TObject key 
)

Definition at line 101 of file ltable.c.

References bvalue, gcvalue, hashboolean, hashnum(), hashpointer, hashstr, nvalue, pvalue, tsvalue, and ttype.

Referenced by luaH_getany(), and newkey().

Table* luaH_new ( lua_State L,
int  narray,
int  lnhash 
)

Definition at line 345 of file ltable.c.

References Table::array, cast, defaultmeta, Table::flags, hvalue, Table::lsizenode, luaC_link(), luaM_new, Table::metatable, Table::node, setarrayvector(), setnodevector(), Table::sizearray, and valtogco.

Referenced by adjust_varargs(), f_luaopen(), lua_newtable(), and open_func().

int luaH_next ( lua_State L,
Table t,
StkId  key 
)

Definition at line 159 of file ltable.c.

References Table::array, cast, luaH_index(), setnvalue, setobj2s, Table::sizearray, and ttisnil.

Referenced by lua_next().

TObject* luaH_set ( lua_State L,
Table t,
const TObject key 
)

Definition at line 510 of file ltable.c.

References cast, Table::flags, luaG_runerror(), luaH_get(), luaO_nilobject, newkey(), nvalue, ttisnil, and ttisnumber.

Referenced by addk(), adjust_varargs(), lua_rawset(), luaV_settable(), and resize().

TObject* luaH_setnum ( lua_State L,
Table t,
int  key 
)

Definition at line 526 of file ltable.c.

References cast, luaH_getnum(), luaO_nilobject, newkey(), and setnvalue.

Referenced by adjust_varargs(), lua_rawseti(), and resize().

static TObject* newkey ( lua_State L,
Table t,
const TObject key 
) [static]

Definition at line 397 of file ltable.c.

References cast, Table::firstfree, gkey, gval, lua_assert, luaH_get(), luaH_mainposition(), Node::next, Table::node, rehash(), setbvalue, setnilvalue, setobj2t, ttisboolean, and ttisnil.

Referenced by luaH_set(), and luaH_setnum().

static void numuse ( const Table t,
int *  narray,
int *  nhash 
) [static]

Definition at line 209 of file ltable.c.

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

Referenced by rehash().

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

Definition at line 330 of file ltable.c.

References luaO_log2(), numuse(), and resize().

Referenced by newkey().

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

Definition at line 286 of file ltable.c.

References Table::array, G, gkey, gval, Table::lsizenode, lua_assert, luaH_set(), luaH_setnum(), luaM_freearray, luaM_reallocvector, Table::node, setarrayvector(), setnilvalue, setnodevector(), setobjt2t, Table::sizearray, ttisnil, and twoto.

Referenced by rehash().

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

Definition at line 249 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  lsize 
) [static]

Definition at line 260 of file ltable.c.

References cast, Table::firstfree, G, gkey, gnode, gval, Table::lsizenode, lua_assert, luaG_runerror(), luaM_newvector, MAXBITS, Node::next, Table::node, setnilvalue, ttisnil, and twoto.

Referenced by luaH_new(), and resize().


Generated on Fri Oct 12 08:44:56 2007 for rpm by  doxygen 1.5.2