diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-01-22 16:46:11 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-01-22 16:46:11 -0200 |
commit | 3314f49ec46edae53c34ecc1cedf7a9d0e345840 (patch) | |
tree | 75562e2435a55c74ddad0ea833e01c257673ce73 | |
parent | bc930aa5ff75dcf4e560efac42d731d9e341fb1a (diff) | |
download | lua-3314f49ec46edae53c34ecc1cedf7a9d0e345840.tar.gz lua-3314f49ec46edae53c34ecc1cedf7a9d0e345840.tar.bz2 lua-3314f49ec46edae53c34ecc1cedf7a9d0e345840.zip |
C cannot initialize a struct.
-rw-r--r-- | lbuiltin.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbuiltin.c,v 1.44 1999/01/04 12:55:09 roberto Exp roberto $ | 2 | ** $Id: lbuiltin.c,v 1.45 1999/01/04 17:34:49 roberto Exp roberto $ |
3 | ** Built-in functions | 3 | ** Built-in functions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -325,12 +325,12 @@ static void luaB_assert (void) { | |||
325 | 325 | ||
326 | static void luaB_foreachi (void) { | 326 | static void luaB_foreachi (void) { |
327 | Hash *t = gethash(1); | 327 | Hash *t = gethash(1); |
328 | TObject f = *luaA_Address(luaL_functionarg(2)); | 328 | TObject *f = luaA_Address(luaL_functionarg(2)); |
329 | int i; | 329 | int i; |
330 | int n = (int)getnarg(t); | 330 | int n = (int)getnarg(t); |
331 | luaD_checkstack(3); /* for f, ref, and val */ | 331 | luaD_checkstack(3); /* for f, ref, and val */ |
332 | for (i=1; i<=n; i++) { | 332 | for (i=1; i<=n; i++) { |
333 | *(L->stack.top++) = f; | 333 | *(L->stack.top++) = *f; |
334 | ttype(L->stack.top) = LUA_T_NUMBER; nvalue(L->stack.top++) = i; | 334 | ttype(L->stack.top) = LUA_T_NUMBER; nvalue(L->stack.top++) = i; |
335 | *(L->stack.top++) = *luaH_getint(t, i); | 335 | *(L->stack.top++) = *luaH_getint(t, i); |
336 | luaD_calln(2, 1); | 336 | luaD_calln(2, 1); |
@@ -343,13 +343,13 @@ static void luaB_foreachi (void) { | |||
343 | 343 | ||
344 | static void luaB_foreach (void) { | 344 | static void luaB_foreach (void) { |
345 | Hash *a = gethash(1); | 345 | Hash *a = gethash(1); |
346 | TObject f = *luaA_Address(luaL_functionarg(2)); | 346 | TObject *f = luaA_Address(luaL_functionarg(2)); |
347 | int i; | 347 | int i; |
348 | luaD_checkstack(3); /* for f, ref, and val */ | 348 | luaD_checkstack(3); /* for f, ref, and val */ |
349 | for (i=0; i<a->nhash; i++) { | 349 | for (i=0; i<a->nhash; i++) { |
350 | Node *nd = &(a->node[i]); | 350 | Node *nd = &(a->node[i]); |
351 | if (ttype(ref(nd)) != LUA_T_NIL && ttype(val(nd)) != LUA_T_NIL) { | 351 | if (ttype(ref(nd)) != LUA_T_NIL && ttype(val(nd)) != LUA_T_NIL) { |
352 | *(L->stack.top++) = f; | 352 | *(L->stack.top++) = *f; |
353 | *(L->stack.top++) = *ref(nd); | 353 | *(L->stack.top++) = *ref(nd); |
354 | *(L->stack.top++) = *val(nd); | 354 | *(L->stack.top++) = *val(nd); |
355 | luaD_calln(2, 1); | 355 | luaD_calln(2, 1); |
@@ -362,7 +362,7 @@ static void luaB_foreach (void) { | |||
362 | 362 | ||
363 | 363 | ||
364 | static void luaB_foreachvar (void) { | 364 | static void luaB_foreachvar (void) { |
365 | TObject f = *luaA_Address(luaL_functionarg(1)); | 365 | TObject *f = luaA_Address(luaL_functionarg(1)); |
366 | GCnode *g; | 366 | GCnode *g; |
367 | StkId name = L->Cstack.base++; /* place to keep var name (to avoid GC) */ | 367 | StkId name = L->Cstack.base++; /* place to keep var name (to avoid GC) */ |
368 | luaD_checkstack(4); /* for var name, f, s, and globalvar */ | 368 | luaD_checkstack(4); /* for var name, f, s, and globalvar */ |
@@ -373,7 +373,7 @@ static void luaB_foreachvar (void) { | |||
373 | if (s->u.s.globalval.ttype != LUA_T_NIL) { | 373 | if (s->u.s.globalval.ttype != LUA_T_NIL) { |
374 | ttype(L->stack.stack+name) = LUA_T_STRING; | 374 | ttype(L->stack.stack+name) = LUA_T_STRING; |
375 | tsvalue(L->stack.stack+name) = s; /* keep s on stack to avoid GC */ | 375 | tsvalue(L->stack.stack+name) = s; /* keep s on stack to avoid GC */ |
376 | *(L->stack.top++) = f; | 376 | *(L->stack.top++) = *f; |
377 | pushtagstring(s); | 377 | pushtagstring(s); |
378 | *(L->stack.top++) = s->u.s.globalval; | 378 | *(L->stack.top++) = s->u.s.globalval; |
379 | luaD_calln(2, 1); | 379 | luaD_calln(2, 1); |
@@ -407,12 +407,11 @@ static void luaB_tremove (void) { | |||
407 | Hash *a = gethash(1); | 407 | Hash *a = gethash(1); |
408 | int n = (int)getnarg(a); | 408 | int n = (int)getnarg(a); |
409 | int pos = luaL_opt_int(2, n); | 409 | int pos = luaL_opt_int(2, n); |
410 | TObject v = *luaH_getint(a, pos); | ||
411 | if (n <= 0) return; /* table is "empty" */ | 410 | if (n <= 0) return; /* table is "empty" */ |
411 | luaA_pushobject(luaH_getint(a, pos)); /* push result */ | ||
412 | luaV_setn(a, n-1); /* decrement field "n" */ | 412 | luaV_setn(a, n-1); /* decrement field "n" */ |
413 | for ( ;pos<n; pos++) | 413 | for ( ;pos<n; pos++) |
414 | luaH_move(a, pos+1, pos); | 414 | luaH_move(a, pos+1, pos); |
415 | luaA_pushobject(&v); | ||
416 | } | 415 | } |
417 | 416 | ||
418 | 417 | ||
@@ -421,7 +420,8 @@ static void luaB_tremove (void) { | |||
421 | */ | 420 | */ |
422 | 421 | ||
423 | static void swap (Hash *a, int i, int j) { | 422 | static void swap (Hash *a, int i, int j) { |
424 | TObject temp = *luaH_getint(a, i); | 423 | TObject temp; |
424 | temp = *luaH_getint(a, i); | ||
425 | luaH_move(a, j, i); | 425 | luaH_move(a, j, i); |
426 | luaH_setint(a, j, &temp); | 426 | luaH_setint(a, j, &temp); |
427 | } | 427 | } |