summaryrefslogtreecommitdiff
path: root/opcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-04 14:13:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1995-10-04 14:13:02 -0300
commit68f337dfa617732646a4a974eb33b25daf45a1e2 (patch)
tree81e72eaf0ada8a2246c6cf1af2d96ddaef41d117 /opcode.c
parentf132ac03bcaf0163f1f86b5114c93a753e17f28b (diff)
downloadlua-github-68f337dfa617732646a4a974eb33b25daf45a1e2.tar.gz
Garbage collection of functions + header structure for functions
Diffstat (limited to 'opcode.c')
-rw-r--r--opcode.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/opcode.c b/opcode.c
index d68db2ad..78fabf25 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio
*/
-char *rcs_opcode="$Id: opcode.c,v 3.38 1995/05/16 17:23:58 roberto Exp roberto $";
+char *rcs_opcode="$Id: opcode.c,v 3.38 1995/05/16 17:23:58 roberto Exp $";
#include <setjmp.h>
#include <stdlib.h>
@@ -259,7 +259,7 @@ static void do_call (Object *func, StkId base, int nResults, StkId whereRes)
if (tag(func) == LUA_T_CFUNCTION)
firstResult = callC(fvalue(func), base);
else if (tag(func) == LUA_T_FUNCTION)
- firstResult = lua_execute(bvalue(func), base);
+ firstResult = lua_execute(func->value.tf->code, base);
else
{ /* func is not a function */
call_funcFB(func, base, nResults, whereRes);
@@ -360,24 +360,26 @@ static int do_protectedrun (Object *function, int nResults)
static int do_protectedmain (void)
{
- Byte *code = NULL;
+ TFunc tf;
int status;
StkId oldCBase = CBase;
jmp_buf myErrorJmp;
jmp_buf *oldErr = errorJmp;
errorJmp = &myErrorJmp;
+ tf.code = NULL;
if (setjmp(myErrorJmp) == 0)
{
Object f;
- lua_parse(&code);
- tag(&f) = LUA_T_FUNCTION; bvalue(&f) = code;
+ f.tag = LUA_T_FUNCTION;
+ f.value.tf = &tf;
+ lua_parse(&tf);
do_call(&f, CBase, 0, CBase);
status = 0;
}
else
status = 1;
- if (code)
- luaI_free(code);
+ if (tf.code)
+ luaI_free(tf.code);
errorJmp = oldErr;
CBase = oldCBase;
top = stack+CBase;
@@ -793,7 +795,9 @@ static StkId lua_execute (Byte *pc, StkId base)
{
CodeCode code;
get_code(code,pc);
- tag(top) = LUA_T_FUNCTION; bvalue(top) = code.b;
+ luaI_insertfunction(code.tf); /* may take part in GC */
+ top->tag = LUA_T_FUNCTION;
+ top->value.tf = code.tf;
incr_top;
}
break;
@@ -1116,7 +1120,7 @@ static StkId lua_execute (Byte *pc, StkId base)
CodeWord func;
get_code(file,pc);
get_word(func,pc);
- lua_pushfunction ((char *)file.b, func.w);
+ lua_pushfunction ((char *)file.tf, func.w);
}
break;