diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-04-04 12:35:37 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-04-04 12:35:37 -0300 |
commit | 9319735744404831f7153653930d56826a4d2f6a (patch) | |
tree | 114f2d15772ce3e184d51ceba259a5a9c9dbecc6 | |
parent | 1ea6e8064cdfa13ba2298783eb87de58568ea998 (diff) | |
download | lua-9319735744404831f7153653930d56826a4d2f6a.tar.gz lua-9319735744404831f7153653930d56826a4d2f6a.tar.bz2 lua-9319735744404831f7153653930d56826a4d2f6a.zip |
using new lib auxlib.
-rw-r--r-- | hash.c | 13 | ||||
-rw-r--r-- | table.c | 35 |
2 files changed, 18 insertions, 30 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** hash manager for lua | 3 | ** hash manager for lua |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_hash="$Id: hash.c,v 2.38 1997/03/31 14:02:58 roberto Exp roberto $"; | 6 | char *rcs_hash="$Id: hash.c,v 2.39 1997/03/31 14:17:09 roberto Exp roberto $"; |
7 | 7 | ||
8 | 8 | ||
9 | #include "luamem.h" | 9 | #include "luamem.h" |
@@ -11,6 +11,7 @@ char *rcs_hash="$Id: hash.c,v 2.38 1997/03/31 14:02:58 roberto Exp roberto $"; | |||
11 | #include "hash.h" | 11 | #include "hash.h" |
12 | #include "table.h" | 12 | #include "table.h" |
13 | #include "lua.h" | 13 | #include "lua.h" |
14 | #include "auxlib.h" | ||
14 | 15 | ||
15 | 16 | ||
16 | #define nhash(t) ((t)->nhash) | 17 | #define nhash(t) ((t)->nhash) |
@@ -82,7 +83,7 @@ int lua_equalObj (TObject *t1, TObject *t2) | |||
82 | case LUA_T_FUNCTION: return t1->value.tf == t2->value.tf; | 83 | case LUA_T_FUNCTION: return t1->value.tf == t2->value.tf; |
83 | case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2); | 84 | case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2); |
84 | default: | 85 | default: |
85 | lua_error("internal error at `lua_equalObj'"); | 86 | lua_error("internal error in `lua_equalObj'"); |
86 | return 0; /* UNREACHEABLE */ | 87 | return 0; /* UNREACHEABLE */ |
87 | } | 88 | } |
88 | } | 89 | } |
@@ -301,12 +302,8 @@ void lua_next (void) | |||
301 | Hash *t; | 302 | Hash *t; |
302 | lua_Object o = lua_getparam(1); | 303 | lua_Object o = lua_getparam(1); |
303 | lua_Object r = lua_getparam(2); | 304 | lua_Object r = lua_getparam(2); |
304 | if (o == LUA_NOOBJECT || r == LUA_NOOBJECT) | 305 | luaL_arg_check(lua_istable(o), "next", 1, "table expected"); |
305 | lua_error ("too few arguments to function `next'"); | 306 | luaL_arg_check(r != LUA_NOOBJECT, "next", 2, "value expected"); |
306 | if (lua_getparam(3) != LUA_NOOBJECT) | ||
307 | lua_error ("too many arguments to function `next'"); | ||
308 | if (!lua_istable(o)) | ||
309 | lua_error ("first argument of function `next' is not a table"); | ||
310 | t = avalue(luaI_Address(o)); | 307 | t = avalue(luaI_Address(o)); |
311 | if (lua_isnil(r)) | 308 | if (lua_isnil(r)) |
312 | { | 309 | { |
@@ -3,9 +3,10 @@ | |||
3 | ** Module to control static tables | 3 | ** Module to control static tables |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_table="$Id: table.c,v 2.64 1997/03/31 14:02:58 roberto Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.65 1997/03/31 14:17:09 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include "luamem.h" | 8 | #include "luamem.h" |
9 | #include "auxlib.h" | ||
9 | #include "opcode.h" | 10 | #include "opcode.h" |
10 | #include "tree.h" | 11 | #include "tree.h" |
11 | #include "hash.h" | 12 | #include "hash.h" |
@@ -203,27 +204,17 @@ void lua_pack (void) | |||
203 | */ | 204 | */ |
204 | void luaI_nextvar (void) | 205 | void luaI_nextvar (void) |
205 | { | 206 | { |
206 | Word next; | 207 | Word next; |
207 | lua_Object o = lua_getparam(1); | 208 | if (lua_isnil(lua_getparam(1))) |
208 | if (o == LUA_NOOBJECT) | 209 | next = 0; |
209 | lua_error("too few arguments to function `nextvar'"); | 210 | else |
210 | if (lua_getparam(2) != LUA_NOOBJECT) | 211 | next = luaI_findsymbolbyname(luaL_check_string(1, "nextvar")) + 1; |
211 | lua_error("too many arguments to function `nextvar'"); | 212 | while (next < lua_ntable && s_ttype(next) == LUA_T_NIL) |
212 | if (lua_isnil(o)) | 213 | next++; |
213 | next = 0; | 214 | if (next < lua_ntable) { |
214 | else if (!lua_isstring(o)) | 215 | lua_pushstring(lua_table[next].varname->str); |
215 | { | 216 | luaI_pushobject(&s_object(next)); |
216 | lua_error("incorrect argument to function `nextvar'"); | 217 | } |
217 | return; /* to avoid warnings */ | ||
218 | } | ||
219 | else | ||
220 | next = luaI_findsymbolbyname(lua_getstring(o)) + 1; | ||
221 | while (next < lua_ntable && s_ttype(next) == LUA_T_NIL) next++; | ||
222 | if (next < lua_ntable) | ||
223 | { | ||
224 | lua_pushstring(lua_table[next].varname->str); | ||
225 | luaI_pushobject(&s_object(next)); | ||
226 | } | ||
227 | } | 218 | } |
228 | 219 | ||
229 | 220 | ||