diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-10-04 14:13:02 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-10-04 14:13:02 -0300 |
| commit | 68f337dfa617732646a4a974eb33b25daf45a1e2 (patch) | |
| tree | 81e72eaf0ada8a2246c6cf1af2d96ddaef41d117 | |
| parent | f132ac03bcaf0163f1f86b5114c93a753e17f28b (diff) | |
| download | lua-68f337dfa617732646a4a974eb33b25daf45a1e2.tar.gz lua-68f337dfa617732646a4a974eb33b25daf45a1e2.tar.bz2 lua-68f337dfa617732646a4a974eb33b25daf45a1e2.zip | |
Garbage collection of functions + header structure for functions
| -rw-r--r-- | fallback.c | 9 | ||||
| -rw-r--r-- | fallback.h | 3 | ||||
| -rw-r--r-- | hash.c | 6 | ||||
| -rw-r--r-- | inout.c | 4 | ||||
| -rw-r--r-- | lua.stx | 31 | ||||
| -rw-r--r-- | opcode.c | 22 | ||||
| -rw-r--r-- | opcode.h | 11 | ||||
| -rw-r--r-- | table.c | 6 |
8 files changed, 56 insertions, 36 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_fallback="$Id: fallback.c,v 1.12 1995/05/02 18:43:03 roberto Exp roberto $"; | 6 | char *rcs_fallback="$Id: fallback.c,v 1.13 1995/10/02 17:03:33 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include <string.h> | 9 | #include <string.h> |
| @@ -168,3 +168,10 @@ void luaI_travlock (void (*fn)(Object *)) | |||
| 168 | fn(&lockArray[i]); | 168 | fn(&lockArray[i]); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | |||
| 172 | void luaI_travfallbacks (void (*fn)(Object *)) | ||
| 173 | { | ||
| 174 | Word i; | ||
| 175 | for (i=0; i<N_FB; i++) | ||
| 176 | fn(&luaI_fallBacks[i].function); | ||
| 177 | } | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: fallback.h,v 1.6 1994/11/21 13:30:15 roberto Exp roberto $ | 2 | ** $Id: fallback.h,v 1.7 1994/11/21 18:22:58 roberto Stab roberto $ |
| 3 | */ | 3 | */ |
| 4 | 4 | ||
| 5 | #ifndef fallback_h | 5 | #ifndef fallback_h |
| @@ -26,6 +26,7 @@ void luaI_setfallback (void); | |||
| 26 | int luaI_lock (Object *object); | 26 | int luaI_lock (Object *object); |
| 27 | Object *luaI_getlocked (int ref); | 27 | Object *luaI_getlocked (int ref); |
| 28 | void luaI_travlock (void (*fn)(Object *)); | 28 | void luaI_travlock (void (*fn)(Object *)); |
| 29 | void luaI_travfallbacks (void (*fn)(Object *)); | ||
| 29 | 30 | ||
| 30 | #endif | 31 | #endif |
| 31 | 32 | ||
| @@ -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.24 1995/02/06 19:34:03 roberto Exp roberto $"; | 6 | char *rcs_hash="$Id: hash.c,v 2.25 1995/05/02 18:43:03 roberto Exp $"; |
| 7 | 7 | ||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | 9 | ||
| @@ -70,7 +70,7 @@ static Word hashindex (Hash *t, Object *ref) /* hash function */ | |||
| 70 | return (Word)h%nhash(t); /* make it a valid index */ | 70 | return (Word)h%nhash(t); /* make it a valid index */ |
| 71 | } | 71 | } |
| 72 | case LUA_T_FUNCTION: | 72 | case LUA_T_FUNCTION: |
| 73 | return (((IntPoint)bvalue(ref))%nhash(t)); | 73 | return (((IntPoint)ref->value.tf)%nhash(t)); |
| 74 | case LUA_T_CFUNCTION: | 74 | case LUA_T_CFUNCTION: |
| 75 | return (((IntPoint)fvalue(ref))%nhash(t)); | 75 | return (((IntPoint)fvalue(ref))%nhash(t)); |
| 76 | case LUA_T_ARRAY: | 76 | case LUA_T_ARRAY: |
| @@ -89,7 +89,7 @@ Bool lua_equalObj (Object *t1, Object *t2) | |||
| 89 | case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); | 89 | case LUA_T_NUMBER: return nvalue(t1) == nvalue(t2); |
| 90 | case LUA_T_STRING: return streq(svalue(t1), svalue(t2)); | 90 | case LUA_T_STRING: return streq(svalue(t1), svalue(t2)); |
| 91 | case LUA_T_ARRAY: return avalue(t1) == avalue(t2); | 91 | case LUA_T_ARRAY: return avalue(t1) == avalue(t2); |
| 92 | case LUA_T_FUNCTION: return bvalue(t1) == bvalue(t2); | 92 | case LUA_T_FUNCTION: return t1->value.tf == t2->value.tf; |
| 93 | case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2); | 93 | case LUA_T_CFUNCTION: return fvalue(t1) == fvalue(t2); |
| 94 | default: return uvalue(t1) == uvalue(t2); | 94 | default: return uvalue(t1) == uvalue(t2); |
| 95 | } | 95 | } |
| @@ -5,7 +5,7 @@ | |||
| 5 | ** Also provides some predefined lua functions. | 5 | ** Also provides some predefined lua functions. |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | char *rcs_inout="$Id: inout.c,v 2.19 1995/05/02 18:43:03 roberto Exp roberto $"; | 8 | char *rcs_inout="$Id: inout.c,v 2.20 1995/05/16 17:23:58 roberto Exp $"; |
| 9 | 9 | ||
| 10 | #include <stdio.h> | 10 | #include <stdio.h> |
| 11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
| @@ -222,7 +222,7 @@ void lua_print (void) | |||
| 222 | { | 222 | { |
| 223 | if (lua_isnumber(obj)) printf("%g\n",lua_getnumber(obj)); | 223 | if (lua_isnumber(obj)) printf("%g\n",lua_getnumber(obj)); |
| 224 | else if (lua_isstring(obj)) printf("%s\n",lua_getstring(obj)); | 224 | else if (lua_isstring(obj)) printf("%s\n",lua_getstring(obj)); |
| 225 | else if (lua_isfunction(obj)) printf("function: %p\n",bvalue(luaI_Address(obj))); | 225 | else if (lua_isfunction(obj)) printf("function: %p\n",(luaI_Address(obj))->value.tf); |
| 226 | else if (lua_iscfunction(obj)) printf("cfunction: %p\n",lua_getcfunction(obj) | 226 | else if (lua_iscfunction(obj)) printf("cfunction: %p\n",lua_getcfunction(obj) |
| 227 | ); | 227 | ); |
| 228 | else if (lua_isuserdata(obj)) printf("userdata: %p\n",lua_getuserdata(obj)); | 228 | else if (lua_isuserdata(obj)) printf("userdata: %p\n",lua_getuserdata(obj)); |
| @@ -1,6 +1,6 @@ | |||
| 1 | %{ | 1 | %{ |
| 2 | 2 | ||
| 3 | char *rcs_luastx = "$Id: lua.stx,v 3.18 1995/04/11 17:56:30 celes Exp roberto $"; | 3 | char *rcs_luastx = "$Id: lua.stx,v 3.19 1995/06/08 19:47:28 roberto Exp $"; |
| 4 | 4 | ||
| 5 | #include <stdio.h> | 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
| @@ -13,6 +13,7 @@ char *rcs_luastx = "$Id: lua.stx,v 3.18 1995/04/11 17:56:30 celes Exp roberto $" | |||
| 13 | #include "tree.h" | 13 | #include "tree.h" |
| 14 | #include "table.h" | 14 | #include "table.h" |
| 15 | #include "lua.h" | 15 | #include "lua.h" |
| 16 | #include "func.h" | ||
| 16 | 17 | ||
| 17 | /* to avoid warnings generated by yacc */ | 18 | /* to avoid warnings generated by yacc */ |
| 18 | int yyparse (void); | 19 | int yyparse (void); |
| @@ -84,10 +85,10 @@ static void code_float (float n) | |||
| 84 | code_byte(code.m.c4); | 85 | code_byte(code.m.c4); |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 87 | static void code_code (Byte *b) | 88 | static void code_code (TFunc *tf) |
| 88 | { | 89 | { |
| 89 | CodeCode code; | 90 | CodeCode code; |
| 90 | code.b = b; | 91 | code.tf = tf; |
| 91 | code_byte(code.m.c1); | 92 | code_byte(code.m.c1); |
| 92 | code_byte(code.m.c2); | 93 | code_byte(code.m.c2); |
| 93 | code_byte(code.m.c3); | 94 | code_byte(code.m.c3); |
| @@ -246,7 +247,7 @@ static void init_function (TreeNode *func) | |||
| 246 | if (lua_debug) | 247 | if (lua_debug) |
| 247 | { | 248 | { |
| 248 | code_byte(SETFUNCTION); | 249 | code_byte(SETFUNCTION); |
| 249 | code_code((Byte *)luaI_strdup(lua_file[lua_nfile-1])); | 250 | code_code((TFunc *)luaI_strdup(lua_file[lua_nfile-1])); |
| 250 | code_word(luaI_findconstant(func)); | 251 | code_word(luaI_findconstant(func)); |
| 251 | } | 252 | } |
| 252 | } | 253 | } |
| @@ -353,14 +354,15 @@ static void yyerror (char *s) | |||
| 353 | /* | 354 | /* |
| 354 | ** Parse LUA code. | 355 | ** Parse LUA code. |
| 355 | */ | 356 | */ |
| 356 | void lua_parse (Byte **code) | 357 | void lua_parse (TFunc *tf) |
| 357 | { | 358 | { |
| 358 | initcode = code; | 359 | initcode = &(tf->code); |
| 359 | *initcode = newvector(CODE_BLOCK, Byte); | 360 | *initcode = newvector(CODE_BLOCK, Byte); |
| 360 | maincode = 0; | 361 | maincode = 0; |
| 361 | maxmain = CODE_BLOCK; | 362 | maxmain = CODE_BLOCK; |
| 362 | if (yyparse ()) lua_error("parse error"); | 363 | if (yyparse ()) lua_error("parse error"); |
| 363 | (*initcode)[maincode++] = RETCODE0; | 364 | (*initcode)[maincode++] = RETCODE0; |
| 365 | tf->size = maincode; | ||
| 364 | #if LISTING | 366 | #if LISTING |
| 365 | { static void PrintCode (Byte *c, Byte *end); | 367 | { static void PrintCode (Byte *c, Byte *end); |
| 366 | PrintCode(*initcode,*initcode+maincode); } | 368 | PrintCode(*initcode,*initcode+maincode); } |
| @@ -378,7 +380,7 @@ void lua_parse (Byte **code) | |||
| 378 | char *pChar; | 380 | char *pChar; |
| 379 | Word vWord; | 381 | Word vWord; |
| 380 | Long vLong; | 382 | Long vLong; |
| 381 | Byte *pByte; | 383 | TFunc *pFunc; |
| 382 | TreeNode *pNode; | 384 | TreeNode *pNode; |
| 383 | } | 385 | } |
| 384 | 386 | ||
| @@ -401,7 +403,7 @@ void lua_parse (Byte **code) | |||
| 401 | %type <vInt> ffieldlist, ffieldlist1, semicolonpart | 403 | %type <vInt> ffieldlist, ffieldlist1, semicolonpart |
| 402 | %type <vInt> lfieldlist, lfieldlist1 | 404 | %type <vInt> lfieldlist, lfieldlist1 |
| 403 | %type <vLong> var, singlevar | 405 | %type <vLong> var, singlevar |
| 404 | %type <pByte> body | 406 | %type <pFunc> body |
| 405 | 407 | ||
| 406 | %left AND OR | 408 | %left AND OR |
| 407 | %left EQ NE '>' '<' LE GE | 409 | %left EQ NE '>' '<' LE GE |
| @@ -437,8 +439,9 @@ function : FUNCTION NAME | |||
| 437 | body | 439 | body |
| 438 | { | 440 | { |
| 439 | Word func = luaI_findsymbol($2); | 441 | Word func = luaI_findsymbol($2); |
| 442 | luaI_insertfunction($4); /* may take part in GC */ | ||
| 440 | s_tag(func) = LUA_T_FUNCTION; | 443 | s_tag(func) = LUA_T_FUNCTION; |
| 441 | s_bvalue(func) = $4; | 444 | lua_table[func].object.value.tf = $4; |
| 442 | } | 445 | } |
| 443 | ; | 446 | ; |
| 444 | 447 | ||
| @@ -465,8 +468,10 @@ method : FUNCTION NAME ':' NAME | |||
| 465 | body : '(' parlist ')' block END | 468 | body : '(' parlist ')' block END |
| 466 | { | 469 | { |
| 467 | codereturn(); | 470 | codereturn(); |
| 468 | $$ = newvector(pc, Byte); | 471 | $$ = new(TFunc); |
| 469 | memcpy($$, basepc, pc*sizeof(Byte)); | 472 | $$->size = pc; |
| 473 | $$->code = newvector(pc, Byte); | ||
| 474 | memcpy($$->code, basepc, pc*sizeof(Byte)); | ||
| 470 | funcCode = basepc; maxcode=maxcurr; | 475 | funcCode = basepc; maxcode=maxcurr; |
| 471 | #if LISTING | 476 | #if LISTING |
| 472 | PrintCode(funcCode,funcCode+pc); | 477 | PrintCode(funcCode,funcCode+pc); |
| @@ -805,7 +810,7 @@ static void PrintCode (Byte *code, Byte *end) | |||
| 805 | int n = p-code; | 810 | int n = p-code; |
| 806 | p++; | 811 | p++; |
| 807 | get_code(c,p); | 812 | get_code(c,p); |
| 808 | printf ("%d PUSHFUNCTION %p\n", n, c.b); | 813 | printf ("%d PUSHFUNCTION %p\n", n, c.tf); |
| 809 | } | 814 | } |
| 810 | break; | 815 | break; |
| 811 | 816 | ||
| @@ -969,7 +974,7 @@ static void PrintCode (Byte *code, Byte *end) | |||
| 969 | p++; | 974 | p++; |
| 970 | get_code(c1,p); | 975 | get_code(c1,p); |
| 971 | get_word(c2,p); | 976 | get_word(c2,p); |
| 972 | printf ("%d SETFUNCTION %s %d\n", n, (char *)c1.b, c2.w); | 977 | printf ("%d SETFUNCTION %s %d\n", n, (char *)c1.tf, c2.w); |
| 973 | } | 978 | } |
| 974 | break; | 979 | break; |
| 975 | case SETLINE: | 980 | case SETLINE: |
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_opcode="$Id: opcode.c,v 3.38 1995/05/16 17:23:58 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.38 1995/05/16 17:23:58 roberto Exp $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| @@ -259,7 +259,7 @@ static void do_call (Object *func, StkId base, int nResults, StkId whereRes) | |||
| 259 | if (tag(func) == LUA_T_CFUNCTION) | 259 | if (tag(func) == LUA_T_CFUNCTION) |
| 260 | firstResult = callC(fvalue(func), base); | 260 | firstResult = callC(fvalue(func), base); |
| 261 | else if (tag(func) == LUA_T_FUNCTION) | 261 | else if (tag(func) == LUA_T_FUNCTION) |
| 262 | firstResult = lua_execute(bvalue(func), base); | 262 | firstResult = lua_execute(func->value.tf->code, base); |
| 263 | else | 263 | else |
| 264 | { /* func is not a function */ | 264 | { /* func is not a function */ |
| 265 | call_funcFB(func, base, nResults, whereRes); | 265 | call_funcFB(func, base, nResults, whereRes); |
| @@ -360,24 +360,26 @@ static int do_protectedrun (Object *function, int nResults) | |||
| 360 | 360 | ||
| 361 | static int do_protectedmain (void) | 361 | static int do_protectedmain (void) |
| 362 | { | 362 | { |
| 363 | Byte *code = NULL; | 363 | TFunc tf; |
| 364 | int status; | 364 | int status; |
| 365 | StkId oldCBase = CBase; | 365 | StkId oldCBase = CBase; |
| 366 | jmp_buf myErrorJmp; | 366 | jmp_buf myErrorJmp; |
| 367 | jmp_buf *oldErr = errorJmp; | 367 | jmp_buf *oldErr = errorJmp; |
| 368 | errorJmp = &myErrorJmp; | 368 | errorJmp = &myErrorJmp; |
| 369 | tf.code = NULL; | ||
| 369 | if (setjmp(myErrorJmp) == 0) | 370 | if (setjmp(myErrorJmp) == 0) |
| 370 | { | 371 | { |
| 371 | Object f; | 372 | Object f; |
| 372 | lua_parse(&code); | 373 | f.tag = LUA_T_FUNCTION; |
| 373 | tag(&f) = LUA_T_FUNCTION; bvalue(&f) = code; | 374 | f.value.tf = &tf; |
| 375 | lua_parse(&tf); | ||
| 374 | do_call(&f, CBase, 0, CBase); | 376 | do_call(&f, CBase, 0, CBase); |
| 375 | status = 0; | 377 | status = 0; |
| 376 | } | 378 | } |
| 377 | else | 379 | else |
| 378 | status = 1; | 380 | status = 1; |
| 379 | if (code) | 381 | if (tf.code) |
| 380 | luaI_free(code); | 382 | luaI_free(tf.code); |
| 381 | errorJmp = oldErr; | 383 | errorJmp = oldErr; |
| 382 | CBase = oldCBase; | 384 | CBase = oldCBase; |
| 383 | top = stack+CBase; | 385 | top = stack+CBase; |
| @@ -793,7 +795,9 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 793 | { | 795 | { |
| 794 | CodeCode code; | 796 | CodeCode code; |
| 795 | get_code(code,pc); | 797 | get_code(code,pc); |
| 796 | tag(top) = LUA_T_FUNCTION; bvalue(top) = code.b; | 798 | luaI_insertfunction(code.tf); /* may take part in GC */ |
| 799 | top->tag = LUA_T_FUNCTION; | ||
| 800 | top->value.tf = code.tf; | ||
| 797 | incr_top; | 801 | incr_top; |
| 798 | } | 802 | } |
| 799 | break; | 803 | break; |
| @@ -1116,7 +1120,7 @@ static StkId lua_execute (Byte *pc, StkId base) | |||
| 1116 | CodeWord func; | 1120 | CodeWord func; |
| 1117 | get_code(file,pc); | 1121 | get_code(file,pc); |
| 1118 | get_word(func,pc); | 1122 | get_word(func,pc); |
| 1119 | lua_pushfunction ((char *)file.b, func.w); | 1123 | lua_pushfunction ((char *)file.tf, func.w); |
| 1120 | } | 1124 | } |
| 1121 | break; | 1125 | break; |
| 1122 | 1126 | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** TeCGraf - PUC-Rio | 2 | ** TeCGraf - PUC-Rio |
| 3 | ** $Id: opcode.h,v 3.10 1994/12/20 21:20:36 roberto Exp celes $ | 3 | ** $Id: opcode.h,v 3.11 1995/04/11 17:56:30 celes Exp $ |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #ifndef opcode_h | 6 | #ifndef opcode_h |
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "lua.h" | 9 | #include "lua.h" |
| 10 | #include "types.h" | 10 | #include "types.h" |
| 11 | #include "tree.h" | 11 | #include "tree.h" |
| 12 | #include "func.h" | ||
| 12 | 13 | ||
| 13 | #ifndef real | 14 | #ifndef real |
| 14 | #define real float | 15 | #define real float |
| @@ -83,7 +84,7 @@ typedef union | |||
| 83 | Cfunction f; | 84 | Cfunction f; |
| 84 | real n; | 85 | real n; |
| 85 | TaggedString *ts; | 86 | TaggedString *ts; |
| 86 | Byte *b; | 87 | TFunc *tf; |
| 87 | struct Hash *a; | 88 | struct Hash *a; |
| 88 | void *u; | 89 | void *u; |
| 89 | } Value; | 90 | } Value; |
| @@ -104,7 +105,6 @@ typedef struct | |||
| 104 | #define nvalue(o) ((o)->value.n) | 105 | #define nvalue(o) ((o)->value.n) |
| 105 | #define svalue(o) ((o)->value.ts->str) | 106 | #define svalue(o) ((o)->value.ts->str) |
| 106 | #define tsvalue(o) ((o)->value.ts) | 107 | #define tsvalue(o) ((o)->value.ts) |
| 107 | #define bvalue(o) ((o)->value.b) | ||
| 108 | #define avalue(o) ((o)->value.a) | 108 | #define avalue(o) ((o)->value.a) |
| 109 | #define fvalue(o) ((o)->value.f) | 109 | #define fvalue(o) ((o)->value.f) |
| 110 | #define uvalue(o) ((o)->value.u) | 110 | #define uvalue(o) ((o)->value.u) |
| @@ -114,7 +114,6 @@ typedef struct | |||
| 114 | #define s_tag(i) (tag(&s_object(i))) | 114 | #define s_tag(i) (tag(&s_object(i))) |
| 115 | #define s_nvalue(i) (nvalue(&s_object(i))) | 115 | #define s_nvalue(i) (nvalue(&s_object(i))) |
| 116 | #define s_svalue(i) (svalue(&s_object(i))) | 116 | #define s_svalue(i) (svalue(&s_object(i))) |
| 117 | #define s_bvalue(i) (bvalue(&s_object(i))) | ||
| 118 | #define s_avalue(i) (avalue(&s_object(i))) | 117 | #define s_avalue(i) (avalue(&s_object(i))) |
| 119 | #define s_fvalue(i) (fvalue(&s_object(i))) | 118 | #define s_fvalue(i) (fvalue(&s_object(i))) |
| 120 | #define s_uvalue(i) (uvalue(&s_object(i))) | 119 | #define s_uvalue(i) (uvalue(&s_object(i))) |
| @@ -137,7 +136,7 @@ typedef union | |||
| 137 | typedef union | 136 | typedef union |
| 138 | { | 137 | { |
| 139 | struct {char c1; char c2; char c3; char c4;} m; | 138 | struct {char c1; char c2; char c3; char c4;} m; |
| 140 | Byte *b; | 139 | TFunc *tf; |
| 141 | } CodeCode; | 140 | } CodeCode; |
| 142 | #define get_code(code,pc) {code.m.c1 = *pc++; code.m.c2 = *pc++;\ | 141 | #define get_code(code,pc) {code.m.c1 = *pc++; code.m.c2 = *pc++;\ |
| 143 | code.m.c3 = *pc++; code.m.c4 = *pc++;} | 142 | code.m.c3 = *pc++; code.m.c4 = *pc++;} |
| @@ -149,7 +148,7 @@ char *lua_strdup (char *l); | |||
| 149 | void lua_setinput (Input fn); /* from "lex.c" module */ | 148 | void lua_setinput (Input fn); /* from "lex.c" module */ |
| 150 | char *lua_lasttext (void); /* from "lex.c" module */ | 149 | char *lua_lasttext (void); /* from "lex.c" module */ |
| 151 | int yylex (void); /* from "lex.c" module */ | 150 | int yylex (void); /* from "lex.c" module */ |
| 152 | void lua_parse (Byte **code); /* from "lua.stx" module */ | 151 | void lua_parse (TFunc *tf); /* from "lua.stx" module */ |
| 153 | void lua_travstack (void (*fn)(Object *)); | 152 | void lua_travstack (void (*fn)(Object *)); |
| 154 | Object *luaI_Address (lua_Object o); | 153 | Object *luaI_Address (lua_Object o); |
| 155 | void luaI_pushobject (Object *o); | 154 | void luaI_pushobject (Object *o); |
| @@ -3,7 +3,7 @@ | |||
| 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.31 1995/05/16 19:23:55 celes Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 2.32 1995/09/15 20:47:53 roberto Exp $"; |
| 7 | 7 | ||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | 9 | ||
| @@ -166,6 +166,8 @@ void lua_markobject (Object *o) | |||
| 166 | tsvalue(o)->marked = 1; | 166 | tsvalue(o)->marked = 1; |
| 167 | else if (tag(o) == LUA_T_ARRAY) | 167 | else if (tag(o) == LUA_T_ARRAY) |
| 168 | lua_hashmark (avalue(o)); | 168 | lua_hashmark (avalue(o)); |
| 169 | else if (o->tag == LUA_T_FUNCTION && !o->value.tf->marked) | ||
| 170 | o->value.tf->marked = 1; | ||
| 169 | } | 171 | } |
| 170 | 172 | ||
| 171 | 173 | ||
| @@ -182,8 +184,10 @@ void lua_pack (void) | |||
| 182 | lua_travstack(lua_markobject); /* mark stack objects */ | 184 | lua_travstack(lua_markobject); /* mark stack objects */ |
| 183 | lua_travsymbol(lua_markobject); /* mark symbol table objects */ | 185 | lua_travsymbol(lua_markobject); /* mark symbol table objects */ |
| 184 | luaI_travlock(lua_markobject); /* mark locked objects */ | 186 | luaI_travlock(lua_markobject); /* mark locked objects */ |
| 187 | luaI_travfallbacks(lua_markobject); /* mark fallbacks */ | ||
| 185 | recovered += lua_strcollector(); | 188 | recovered += lua_strcollector(); |
| 186 | recovered += lua_hashcollector(); | 189 | recovered += lua_hashcollector(); |
| 190 | recovered += luaI_funccollector(); | ||
| 187 | nentity = 0; /* reset counter */ | 191 | nentity = 0; /* reset counter */ |
| 188 | block=(16*block-7*recovered)/12; /* adapt block size */ | 192 | block=(16*block-7*recovered)/12; /* adapt block size */ |
| 189 | if (block < MIN_GARBAGE_BLOCK) block = MIN_GARBAGE_BLOCK; | 193 | if (block < MIN_GARBAGE_BLOCK) block = MIN_GARBAGE_BLOCK; |
