The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions | Variables
ltable.cpp 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 "lstring.h"
#include "ltable.h"
#include "lvm.h"
Include dependency graph for ltable.cpp:

Go to the source code of this file.

Macros

#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 dummynode   (&dummynode_)
 
#define isdummy(n)   ((n) == 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)
 
void luaH_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)
 
void luaH_free (lua_State *L, Table *t)
 
static Nodegetfreepos (Table *t)
 
TValueluaH_newkey (lua_State *L, Table *t, const TValue *key)
 
const TValueluaH_getint (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)
 
void luaH_setint (lua_State *L, Table *t, int key, TValue *value)
 
static int unbound_search (Table *t, unsigned int j)
 
int luaH_getn (Table *t)
 

Variables

static const Node dummynode_
 

Macro Definition Documentation

#define dummynode   (&dummynode_)

Definition at line 66 of file ltable.cpp.

Referenced by setnodevector().

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

Definition at line 53 of file ltable.cpp.

Referenced by mainposition().

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

Definition at line 60 of file ltable.cpp.

Referenced by hashnum().

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

Definition at line 63 of file ltable.cpp.

Referenced by mainposition().

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

Definition at line 50 of file ltable.cpp.

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

Definition at line 52 of file ltable.cpp.

Referenced by luaH_getstr(), and mainposition().

#define isdummy (   n)    ((n) == dummynode)

Definition at line 68 of file ltable.cpp.

Referenced by luaH_free(), luaH_getn(), luaH_newkey(), luaH_resize(), and luaH_resizearray().

#define ltable_c

Definition at line 22 of file ltable.cpp.

#define LUA_CORE

Definition at line 23 of file ltable.cpp.

#define MAXASIZE   (1 << MAXBITS)

Definition at line 47 of file ltable.cpp.

Referenced by countint().

#define MAXBITS   (LUAI_BITSINT-2)

Definition at line 44 of file ltable.cpp.

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

Function Documentation

static int arrayindex ( const TValue key)
static

Definition at line 126 of file ltable.cpp.

References cast_num, lua_number2int, nvalue, and ttisnumber.

Referenced by countint(), and findindex().

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

Definition at line 195 of file ltable.cpp.

References i, and lua_assert.

Referenced by rehash().

static int countint ( const TValue key,
int nums 
)
static

Definition at line 217 of file ltable.cpp.

References arrayindex(), luaO_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 386 of file ltable.cpp.

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

Referenced by luaH_newkey().

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

Definition at line 79 of file ltable.cpp.

References cast, hashmod, i, and luai_hashnum.

Referenced by luaH_getint(), and mainposition().

void luaH_free ( lua_State L,
Table t 
)

Definition at line 378 of file ltable.cpp.

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

Referenced by freeobj().

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

Definition at line 559 of file ltable.cpp.

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

Referenced by lua_rawlen(), and luaV_objlen().

const TValue* luaH_getstr ( Table t,
TString key 
)
Table* luaH_new ( lua_State L)
TValue* luaH_newkey ( lua_State L,
Table t,
const TValue key 
)
int luaH_next ( lua_State L,
Table t,
StkId  key 
)

Definition at line 168 of file ltable.cpp.

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

Referenced by lua_next().

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

Definition at line 336 of file ltable.cpp.

References isdummy, luaH_resize(), Table::node, and sizenode.

Referenced by luaV_execute().

TValue* luaH_set ( lua_State L,
Table t,
const TValue key 
)
void luaH_setint ( lua_State L,
Table t,
int  key,
TValue value 
)
static Node* mainposition ( const Table t,
const TValue key 
)
static
static int numusearray ( const Table t,
int nums 
)
static

Definition at line 228 of file ltable.cpp.

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

Referenced by rehash().

static int numusehash ( const Table t,
int nums,
int pnasize 
)
static

Definition at line 253 of file ltable.cpp.

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

Referenced by rehash().

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

Definition at line 342 of file ltable.cpp.

References computesizes(), countint(), i, luaH_resize(), MAXBITS, numusearray(), and numusehash().

Referenced by luaH_newkey().

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

Definition at line 269 of file ltable.cpp.

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

Referenced by luaH_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 531 of file ltable.cpp.

References cast, i, luaH_getint(), MAX_INT, and ttisnil.

Referenced by luaH_getn().

Variable Documentation

const Node dummynode_
static
Initial value:
= {
{{NILCONSTANT, NULL}}
}
#define NILCONSTANT
Definition: lobject.h:109

Definition at line 70 of file ltable.cpp.