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(), and numuse().

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.

Referenced by numuse().

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 
)

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(), Node::next, 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, Node::next, 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, Node::next, tsvalue, and ttisstring.

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

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 
)

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

Definition at line 159 of file ltable.c.

References Table::array, cast, gkey, gnode, gval, luaH_index(), setnvalue, setobj2s, Table::sizearray, sizenode, and ttisnil.

Referenced by lua_next().

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

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(), luaV_execute(), and resize().

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

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

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]

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]


Generated on Fri Dec 12 13:02:11 2008 for rpm by  doxygen 1.5.6