diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-19 12:09:37 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-19 12:09:37 -0300 |
| commit | e43612aaf62bbb92fd7555b132d9ee1c0394dc58 (patch) | |
| tree | 552eabfbbdce5a60754200d36f23e84ddf0e2adc /lapi.c | |
| parent | 2898e2fd12db741c58813671e56e628039d9bdc7 (diff) | |
| download | lua-e43612aaf62bbb92fd7555b132d9ee1c0394dc58.tar.gz lua-e43612aaf62bbb92fd7555b132d9ee1c0394dc58.tar.bz2 lua-e43612aaf62bbb92fd7555b132d9ee1c0394dc58.zip | |
put the restriction that 'luaC_barrierback' works only on tables
in its prototype
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 40 |
1 files changed, 23 insertions, 17 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 2.227 2014/07/18 12:17:54 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.228 2014/07/18 14:46:47 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -755,42 +755,48 @@ LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { | |||
| 755 | 755 | ||
| 756 | 756 | ||
| 757 | LUA_API void lua_rawset (lua_State *L, int idx) { | 757 | LUA_API void lua_rawset (lua_State *L, int idx) { |
| 758 | StkId t; | 758 | StkId o; |
| 759 | Table *t; | ||
| 759 | lua_lock(L); | 760 | lua_lock(L); |
| 760 | api_checknelems(L, 2); | 761 | api_checknelems(L, 2); |
| 761 | t = index2addr(L, idx); | 762 | o = index2addr(L, idx); |
| 762 | api_check(ttistable(t), "table expected"); | 763 | api_check(ttistable(o), "table expected"); |
| 763 | setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); | 764 | t = hvalue(o); |
| 764 | invalidateTMcache(hvalue(t)); | 765 | setobj2t(L, luaH_set(L, t, L->top-2), L->top-1); |
| 765 | luaC_barrierback(L, gcvalue(t), L->top-1); | 766 | invalidateTMcache(t); |
| 767 | luaC_barrierback(L, t, L->top-1); | ||
| 766 | L->top -= 2; | 768 | L->top -= 2; |
| 767 | lua_unlock(L); | 769 | lua_unlock(L); |
| 768 | } | 770 | } |
| 769 | 771 | ||
| 770 | 772 | ||
| 771 | LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) { | 773 | LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) { |
| 772 | StkId t; | 774 | StkId o; |
| 775 | Table *t; | ||
| 773 | lua_lock(L); | 776 | lua_lock(L); |
| 774 | api_checknelems(L, 1); | 777 | api_checknelems(L, 1); |
| 775 | t = index2addr(L, idx); | 778 | o = index2addr(L, idx); |
| 776 | api_check(ttistable(t), "table expected"); | 779 | api_check(ttistable(o), "table expected"); |
| 777 | luaH_setint(L, hvalue(t), n, L->top - 1); | 780 | t = hvalue(o); |
| 778 | luaC_barrierback(L, gcvalue(t), L->top-1); | 781 | luaH_setint(L, t, n, L->top - 1); |
| 782 | luaC_barrierback(L, t, L->top-1); | ||
| 779 | L->top--; | 783 | L->top--; |
| 780 | lua_unlock(L); | 784 | lua_unlock(L); |
| 781 | } | 785 | } |
| 782 | 786 | ||
| 783 | 787 | ||
| 784 | LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { | 788 | LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { |
| 785 | StkId t; | 789 | StkId o; |
| 790 | Table *t; | ||
| 786 | TValue k; | 791 | TValue k; |
| 787 | lua_lock(L); | 792 | lua_lock(L); |
| 788 | api_checknelems(L, 1); | 793 | api_checknelems(L, 1); |
| 789 | t = index2addr(L, idx); | 794 | o = index2addr(L, idx); |
| 790 | api_check(ttistable(t), "table expected"); | 795 | api_check(ttistable(o), "table expected"); |
| 796 | t = hvalue(o); | ||
| 791 | setpvalue(&k, cast(void *, p)); | 797 | setpvalue(&k, cast(void *, p)); |
| 792 | setobj2t(L, luaH_set(L, hvalue(t), &k), L->top - 1); | 798 | setobj2t(L, luaH_set(L, t, &k), L->top - 1); |
| 793 | luaC_barrierback(L, gcvalue(t), L->top - 1); | 799 | luaC_barrierback(L, t, L->top - 1); |
| 794 | L->top--; | 800 | L->top--; |
| 795 | lua_unlock(L); | 801 | lua_unlock(L); |
| 796 | } | 802 | } |
