aboutsummaryrefslogtreecommitdiff
path: root/lvm.h
diff options
context:
space:
mode:
Diffstat (limited to 'lvm.h')
-rw-r--r--lvm.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/lvm.h b/lvm.h
index a50fb981..9f7d028f 100644
--- a/lvm.h
+++ b/lvm.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.h,v 2.34 2014/08/01 17:24:02 roberto Exp roberto $ 2** $Id: lvm.h,v 2.35 2015/02/20 14:27:53 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -48,13 +48,35 @@
48#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) 48#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2)
49 49
50 50
51/*
52** fast track for 'gettable': 1 means 'aux' points to resulted value;
53** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is
54** the raw get function to use.
55*/
56#define luaV_fastget(L,t,k,aux,f) \
57 (!ttistable(t) \
58 ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \
59 : (aux = f(hvalue(t), k), /* else, do raw access */ \
60 !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \
61 : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\
62 aux != NULL ? 0 /* has metamethod? must call it */ \
63 : (aux = luaO_nilobject, 1)))) /* else, final result is nil */
64
65/*
66** standard implementation for 'gettable'
67*/
68#define luaV_gettable(L,t,k,v) { const TValue *aux; \
69 if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \
70 else luaV_finishget(L,t,k,v,aux); }
71
72
51LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); 73LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2);
52LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 74LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
53LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 75LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r);
54LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 76LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n);
55LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode); 77LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode);
56LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 78LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
57 StkId val); 79 StkId val, const TValue *tm);
58LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 80LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
59 StkId val); 81 StkId val);
60LUAI_FUNC void luaV_finishOp (lua_State *L); 82LUAI_FUNC void luaV_finishOp (lua_State *L);