summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/lua/lvm.h
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-12-02 20:06:38 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-12-02 20:06:38 +0000
commit179fab6819d67b04d2d8caa13bc9fe936aff3a3c (patch)
treee402a57cb8a45e297e8fe2fcda2be0ceff5c9e2c /plugins/MirLua/src/lua/lvm.h
parent5291f58e733e19f44be355d76c97be4a83ab43d1 (diff)
MirLua: updated lua to 5.3.2
git-svn-id: http://svn.miranda-ng.org/main/trunk@15807 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/lua/lvm.h')
-rw-r--r--plugins/MirLua/src/lua/lvm.h56
1 files changed, 51 insertions, 5 deletions
diff --git a/plugins/MirLua/src/lua/lvm.h b/plugins/MirLua/src/lua/lvm.h
index 0613826a62..fd0e748d4e 100644
--- a/plugins/MirLua/src/lua/lvm.h
+++ b/plugins/MirLua/src/lua/lvm.h
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.h,v 2.35 2015/02/20 14:27:53 roberto Exp $
+** $Id: lvm.h,v 2.39 2015/09/09 13:44:07 roberto Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -48,15 +48,61 @@
#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2)
+/*
+** fast track for 'gettable': 1 means 'aux' points to resulted value;
+** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is
+** the raw get function to use.
+*/
+#define luaV_fastget(L,t,k,aux,f) \
+ (!ttistable(t) \
+ ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \
+ : (aux = f(hvalue(t), k), /* else, do raw access */ \
+ !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \
+ : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\
+ aux != NULL ? 0 /* has metamethod? must call it */ \
+ : (aux = luaO_nilobject, 1)))) /* else, final result is nil */
+
+/*
+** standard implementation for 'gettable'
+*/
+#define luaV_gettable(L,t,k,v) { const TValue *aux; \
+ if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \
+ else luaV_finishget(L,t,k,v,aux); }
+
+
+/*
+** Fast track for set table. If 't' is a table and 't[k]' is not nil,
+** call GC barrier, do a raw 't[k]=v', and return true; otherwise,
+** return false with 'slot' equal to NULL (if 't' is not a table) or
+** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro
+** returns true, there is no need to 'invalidateTMcache', because the
+** call is not creating a new entry.
+*/
+#define luaV_fastset(L,t,k,slot,f,v) \
+ (!ttistable(t) \
+ ? (slot = NULL, 0) \
+ : (slot = f(hvalue(t), k), \
+ ttisnil(slot) ? 0 \
+ : (luaC_barrierback(L, hvalue(t), v), \
+ setobj2t(L, cast(TValue *,slot), v), \
+ 1)))
+
+
+#define luaV_settable(L,t,k,v) { const TValue *slot; \
+ if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \
+ luaV_finishset(L,t,k,v,slot); }
+
+
+
LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2);
LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r);
LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n);
LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode);
-LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key,
- StkId val);
-LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key,
- StkId val);
+LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
+ StkId val, const TValue *tm);
+LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
+ StkId val, const TValue *oldval);
LUAI_FUNC void luaV_finishOp (lua_State *L);
LUAI_FUNC void luaV_execute (lua_State *L);
LUAI_FUNC void luaV_concat (lua_State *L, int total);