The Battle for Wesnoth  1.15.1+dev
Classes | Macros | Functions | Variables
ltable.cpp File Reference
#include "lprefix.h"
#include <math.h>
#include <limits.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.

Classes

struct  AuxsetnodeT
 

Macros

#define ltable_c
 
#define LUA_CORE
 
#define MAXABITS   cast_int(sizeof(int) * CHAR_BIT - 1)
 
#define MAXASIZE   (1u << MAXABITS)
 
#define MAXHBITS   (MAXABITS - 1)
 
#define hashpow2(t, n)   (gnode(t, lmod((n), sizenode(t))))
 
#define hashstr(t, str)   hashpow2(t, (str)->hash)
 
#define hashboolean(t, p)   hashpow2(t, p)
 
#define hashint(t, i)   hashpow2(t, i)
 
#define hashmod(t, n)   (gnode(t, ((n) % ((sizenode(t)-1)|1))))
 
#define hashpointer(t, p)   hashmod(t, point2uint(p))
 
#define dummynode   (&dummynode_)
 

Functions

static int l_hashfloat (lua_Number n)
 
static Nodemainposition (const Table *t, const TValue *key)
 
static unsigned int arrayindex (const TValue *key)
 
static unsigned int findindex (lua_State *L, Table *t, StkId key)
 
int luaH_next (lua_State *L, Table *t, StkId key)
 
static unsigned int computesizes (unsigned int nums[], unsigned int *pna)
 
static int countint (const TValue *key, unsigned int *nums)
 
static unsigned int numusearray (const Table *t, unsigned int *nums)
 
static int numusehash (const Table *t, unsigned int *nums, unsigned int *pna)
 
static void setarrayvector (lua_State *L, Table *t, unsigned int size)
 
static void setnodevector (lua_State *L, Table *t, unsigned int size)
 
static void auxsetnode (lua_State *L, void *ud)
 
void luaH_resize (lua_State *L, Table *t, unsigned int nasize, unsigned int nhsize)
 
void luaH_resizearray (lua_State *L, Table *t, unsigned 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, lua_Integer key)
 
const TValueluaH_getshortstr (Table *t, TString *key)
 
static const TValuegetgeneric (Table *t, const TValue *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, lua_Integer key, TValue *value)
 
static lua_Unsigned unbound_search (Table *t, lua_Unsigned j)
 
lua_Unsigned luaH_getn (Table *t)
 

Variables

static const Node dummynode_
 

Macro Definition Documentation

◆ dummynode

#define dummynode   (&dummynode_)

Definition at line 75 of file ltable.cpp.

Referenced by setnodevector().

◆ hashboolean

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

Definition at line 61 of file ltable.cpp.

Referenced by mainposition().

◆ hashint

#define hashint (   t,
  i 
)    hashpow2(t, i)

Definition at line 62 of file ltable.cpp.

Referenced by luaH_getint(), and mainposition().

◆ hashmod

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

Definition at line 69 of file ltable.cpp.

Referenced by mainposition().

◆ hashpointer

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

Definition at line 72 of file ltable.cpp.

Referenced by mainposition().

◆ hashpow2

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

Definition at line 58 of file ltable.cpp.

Referenced by mainposition().

◆ hashstr

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

Definition at line 60 of file ltable.cpp.

Referenced by luaH_getshortstr(), and mainposition().

◆ ltable_c

#define ltable_c

Definition at line 7 of file ltable.cpp.

◆ LUA_CORE

#define LUA_CORE

Definition at line 8 of file ltable.cpp.

◆ MAXABITS

#define MAXABITS   cast_int(sizeof(int) * CHAR_BIT - 1)

Definition at line 46 of file ltable.cpp.

Referenced by numusearray(), and rehash().

◆ MAXASIZE

#define MAXASIZE   (1u << MAXABITS)

Definition at line 47 of file ltable.cpp.

Referenced by arrayindex().

◆ MAXHBITS

#define MAXHBITS   (MAXABITS - 1)

Definition at line 55 of file ltable.cpp.

Referenced by setnodevector().

Function Documentation

◆ arrayindex()

static unsigned int arrayindex ( const TValue key)
static

Definition at line 144 of file ltable.cpp.

References cast, ivalue, MAXASIZE, and ttisinteger.

Referenced by countint(), and findindex().

◆ auxsetnode()

static void auxsetnode ( lua_State L,
void *  ud 
)
static

Definition at line 341 of file ltable.cpp.

References cast, AuxsetnodeT::nhsize, setnodevector(), and AuxsetnodeT::t.

Referenced by luaH_resize().

◆ computesizes()

static unsigned int computesizes ( unsigned int  nums[],
unsigned int *  pna 
)
static

Definition at line 219 of file ltable.cpp.

References a, i, and lua_assert.

Referenced by rehash().

◆ countint()

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

Definition at line 243 of file ltable.cpp.

References arrayindex(), and luaO_ceillog2().

Referenced by numusehash(), and rehash().

◆ findindex()

static unsigned int findindex ( lua_State L,
Table t,
StkId  key 
)
static

◆ getfreepos()

static Node* getfreepos ( Table t)
static

Definition at line 441 of file ltable.cpp.

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

Referenced by luaH_newkey().

◆ getgeneric()

static const TValue* getgeneric ( Table t,
const TValue key 
)
static

Definition at line 560 of file ltable.cpp.

References gkey, gnext, gval, luaO_nilobject, luaV_rawequalobj, mainposition(), and n.

Referenced by luaH_get(), and luaH_getstr().

◆ l_hashfloat()

static int l_hashfloat ( lua_Number  n)
static

Definition at line 97 of file ltable.cpp.

References cast, cast_int, cast_num, i, l_mathop, lua_assert, lua_numbertointeger, luai_numisnan, and n.

Referenced by mainposition().

◆ luaH_free()

void luaH_free ( lua_State L,
Table t 
)

Definition at line 433 of file ltable.cpp.

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

Referenced by freeobj().

◆ luaH_get()

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

◆ luaH_getint()

const TValue* luaH_getint ( Table t,
lua_Integer  key 
)

◆ luaH_getn()

lua_Unsigned luaH_getn ( Table t)

Definition at line 660 of file ltable.cpp.

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

Referenced by lua_rawlen(), and luaV_objlen().

◆ luaH_getshortstr()

const TValue* luaH_getshortstr ( Table t,
TString key 
)

◆ luaH_getstr()

const TValue* luaH_getstr ( Table t,
TString key 
)

Definition at line 575 of file ltable.cpp.

References cast, getgeneric(), LUA_TSHRSTR, luaH_getshortstr(), and setsvalue.

Referenced by auxgetstr(), auxsetstr(), and luaV_execute().

◆ luaH_new()

Table* luaH_new ( lua_State L)

◆ luaH_newkey()

TValue* luaH_newkey ( lua_State L,
Table t,
const TValue key 
)

◆ luaH_next()

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

Definition at line 186 of file ltable.cpp.

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

Referenced by lua_next().

◆ luaH_resize()

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

◆ luaH_resizearray()

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

Definition at line 387 of file ltable.cpp.

References allocsizenode, and luaH_resize().

Referenced by luaV_execute().

◆ luaH_set()

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

Definition at line 610 of file ltable.cpp.

References cast, luaH_get(), luaH_newkey(), luaO_nilobject, and p.

Referenced by addk(), lua_rawset(), lua_rawsetp(), luaH_newkey(), luaH_resize(), and luaX_newstring().

◆ luaH_setint()

void luaH_setint ( lua_State L,
Table t,
lua_Integer  key,
TValue value 
)

◆ mainposition()

static Node* mainposition ( const Table t,
const TValue key 
)
static

◆ numusearray()

static unsigned int numusearray ( const Table t,
unsigned int *  nums 
)
static

Definition at line 259 of file ltable.cpp.

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

Referenced by rehash().

◆ numusehash()

static int numusehash ( const Table t,
unsigned int *  nums,
unsigned int *  pna 
)
static

Definition at line 285 of file ltable.cpp.

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

Referenced by rehash().

◆ rehash()

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

Definition at line 395 of file ltable.cpp.

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

Referenced by luaH_newkey().

◆ setarrayvector()

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

Definition at line 301 of file ltable.cpp.

References Table::array, i, luaM_reallocvector, setnilvalue, utf8::size(), and Table::sizearray.

Referenced by luaH_resize().

◆ setnodevector()

static void setnodevector ( lua_State L,
Table t,
unsigned int  size 
)
static

◆ unbound_search()

static lua_Unsigned unbound_search ( Table t,
lua_Unsigned  j 
)
static

Definition at line 632 of file ltable.cpp.

References i, l_castS2U, luaH_getint(), and ttisnil.

Referenced by luaH_getn().

Variable Documentation

◆ dummynode_

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

Definition at line 77 of file ltable.cpp.