diff --git a/src/calls.c b/src/calls.c index 3d42217457..e812798fe7 100644 --- a/src/calls.c +++ b/src/calls.c @@ -1581,7 +1581,6 @@ static void SaveFunction(Obj func) SaveSubObj(header->nloc); SaveSubObj(header->body); SaveSubObj(header->envi); - SaveSubObj(header->fexs); if (IS_OPERATION(func)) SaveOperationExtras( func ); } @@ -1603,7 +1602,6 @@ static void LoadFunction(Obj func) header->nloc = LoadSubObj(); header->body = LoadSubObj(); header->envi = LoadSubObj(); - header->fexs = LoadSubObj(); if (IS_OPERATION(func)) LoadOperationExtras( func ); } diff --git a/src/calls.h b/src/calls.h index ac9d37e4ec..1d0c9ae336 100644 --- a/src/calls.h +++ b/src/calls.h @@ -70,7 +70,6 @@ typedef Obj (* ObjFunc_6ARGS) (Obj self, Obj a1, Obj a2, Obj a3, Obj a4, Obj a5, *F NLOC_FUNC() . . . . . . . . . . . . number of locals of a function *F BODY_FUNC() . . . . . . . . . . . . . . . . . . body of a function *F ENVI_FUNC() . . . . . . . . . . . . . . . environment of a function -*F FEXS_FUNC() . . . . . . . . . . . . func. expr. list of a function ** ** These macros make it possible to access the various components of a ** function. @@ -96,9 +95,6 @@ typedef Obj (* ObjFunc_6ARGS) (Obj self, Obj a1, Obj a2, Obj a3, Obj a4, Obj a5, ** 'ENVI_FUNC()' is the environment (i.e., the local variables bag) ** that was current when was created. ** -** 'FEXS_FUNC()' is the function expressions list (i.e., the list of -** the function expressions of the functions defined inside of ). -** ** 'LCKS_FUNC()' is a string that contains the lock mode for the ** arguments of . Each byte corresponds to the mode for an argument: ** 0 means no lock, 1 means a read-only lock, 2 means a read-write lock. @@ -114,7 +110,6 @@ typedef struct { Obj nloc; Obj body; Obj envi; - Obj fexs; #ifdef HPCGAP Obj locks; #endif @@ -177,11 +172,6 @@ EXPORT_INLINE Obj ENVI_FUNC(Obj func) return CONST_FUNC(func)->envi; } -EXPORT_INLINE Obj FEXS_FUNC(Obj func) -{ - return CONST_FUNC(func)->fexs; -} - #ifdef HPCGAP EXPORT_INLINE Obj LCKS_FUNC(Obj func) { @@ -229,11 +219,6 @@ EXPORT_INLINE void SET_ENVI_FUNC(Obj func, Obj envi) FUNC(func)->envi = envi; } -EXPORT_INLINE void SET_FEXS_FUNC(Obj func, Obj fexs) -{ - FUNC(func)->fexs = fexs; -} - #ifdef HPCGAP EXPORT_INLINE void SET_LCKS_FUNC(Obj func, Obj locks) { diff --git a/src/code.c b/src/code.c index 380f290593..3297e3060a 100644 --- a/src/code.c +++ b/src/code.c @@ -812,7 +812,6 @@ void CodeFuncExprBegin ( Int startLine) { Obj fexp; /* function expression bag */ - Obj fexs; /* function expressions list */ Bag body; /* function body */ Bag old; /* old frame */ Stat stat1; /* first statement in body */ @@ -830,11 +829,6 @@ void CodeFuncExprBegin ( #endif CHANGED_BAG( fexp ); - /* give it a functions expressions list */ - fexs = NEW_PLIST( T_PLIST, 0 ); - SET_FEXS_FUNC( fexp, fexs ); - CHANGED_BAG( fexp ); - /* give it a body */ body = NewBag( T_BODY, 1024*sizeof(Stat) ); SET_BODY_FUNC( fexp, body ); @@ -864,7 +858,6 @@ void CodeFuncExprEnd(UInt nr) Expr expr; /* function expression, result */ Stat stat1; /* single statement of body */ Obj fexp; /* function expression bag */ - Obj fexs; /* funct. expr. list of outer func */ UInt len; /* length of func. expr. list */ UInt i; /* loop variable */ @@ -906,9 +899,6 @@ void CodeFuncExprEnd(UInt nr) WRITE_STAT(OFFSET_FIRST_STAT, nr - i, stat1); } - // make the function expression list immutable - MakeImmutable( FEXS_FUNC( fexp ) ); - // make the body values list (if any) immutable Obj values = ((BodyHeader *)STATE(PtrBody))->values; if (values) @@ -927,8 +917,7 @@ void CodeFuncExprEnd(UInt nr) /* if this was inside another function definition, make the expression */ /* and store it in the function expression list of the outer function */ if (STATE(CurrLVars) != CS(CodeLVars)) { - fexs = FEXS_FUNC( CURR_FUNC() ); - len = PushPlist( fexs, fexp ); + len = PushValue(fexp); expr = NewExpr( T_FUNC_EXPR, sizeof(Expr) ); WRITE_EXPR(expr, 0, len); PushExpr( expr ); diff --git a/src/code.h b/src/code.h index 699c7e0a7b..b111367b18 100644 --- a/src/code.h +++ b/src/code.h @@ -104,6 +104,10 @@ void SET_ENDLINE_BODY(Obj body, UInt val); Obj GET_VALUE_FROM_CURRENT_BODY(Int ix); +EXPORT_INLINE Obj VALUES_BODY(Obj body) +{ + return BODY_HEADER(body)->values; +} /**************************************************************************** ** diff --git a/src/compiler.c b/src/compiler.c index b57ab8bc69..8bc094a491 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -1117,13 +1117,11 @@ static CVar CompFuncExpr(Expr expr) CVar func; /* function, result */ CVar tmp; /* dummy body */ - Obj fexs; /* function expressions list */ Obj fexp; /* function expression */ Int nr; /* number of the function */ /* get the number of the function */ - fexs = FEXS_FUNC( CURR_FUNC() ); - fexp = ELM_PLIST(fexs, READ_EXPR(expr, 0)); + fexp = GET_VALUE_FROM_CURRENT_BODY(READ_EXPR(expr, 0)); nr = NR_INFO( INFO_FEXP( fexp ) ); /* allocate a new temporary for the function */ @@ -5034,7 +5032,6 @@ static void CompFunc(Obj func) Bag info; /* info bag for this function */ Int narg; /* number of arguments */ Int nloc; /* number of locals */ - Obj fexs; /* function expression list */ Bag oldFrame; /* old frame */ Int i; /* loop variable */ Int prevarargs; /* we have varargs with a prefix */ @@ -5073,10 +5070,15 @@ static void CompFunc(Obj func) /* get the info bag */ info = INFO_FEXP( CURR_FUNC() ); - /* compile the innner functions */ - fexs = FEXS_FUNC(func); - for ( i = 1; i <= LEN_PLIST(fexs); i++ ) { - CompFunc( ELM_PLIST( fexs, i ) ); + /* compile the inner functions */ + Obj values = VALUES_BODY(BODY_FUNC(func)); + if (values) { + UInt len = LEN_PLIST(values); + for (i = 1; i <= len; i++) { + Obj val = ELM_PLIST(values, i); + if (IS_FUNC(val)) + CompFunc(val); + } } /* emit the code for the function header and the arguments */ diff --git a/src/funcs.c b/src/funcs.c index f003fa23ae..d332d5dbb5 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -660,7 +660,6 @@ Obj MakeFunction ( #ifdef HPCGAP SET_LCKS_FUNC( func, LCKS_FUNC( fexp ) ); #endif - SET_FEXS_FUNC( func, FEXS_FUNC( fexp ) ); /* return the function */ return func; @@ -675,12 +674,8 @@ Obj MakeFunction ( */ static Obj EvalFuncExpr(Expr expr) { - Obj fexs; /* func. expr. list of curr. func. */ - Obj fexp; /* function expression bag */ - /* get the function expression bag */ - fexs = FEXS_FUNC( CURR_FUNC() ); - fexp = ELM_PLIST(fexs, READ_EXPR(expr, 0)); + Obj fexp = GET_VALUE_FROM_CURRENT_BODY(READ_EXPR(expr, 0)); /* and make the function */ return MakeFunction( fexp ); @@ -695,14 +690,9 @@ static Obj EvalFuncExpr(Expr expr) */ static void PrintFuncExpr(Expr expr) { - Obj fexs; /* func. expr. list of curr. func. */ - Obj fexp; /* function expression bag */ - /* get the function expression bag */ - fexs = FEXS_FUNC( CURR_FUNC() ); - fexp = ELM_PLIST(fexs, READ_EXPR(expr, 0)); + Obj fexp = GET_VALUE_FROM_CURRENT_BODY(READ_EXPR(expr, 0)); PrintFunction( fexp ); - /* Pr("function ... end",0L,0L); */ } diff --git a/src/syntaxtree.c b/src/syntaxtree.c index 8f33533aa8..8126317633 100644 --- a/src/syntaxtree.c +++ b/src/syntaxtree.c @@ -163,11 +163,7 @@ static Obj SyntaxTreeFunccall(Obj result, Expr expr) static Obj SyntaxTreeFuncExpr(Obj result, Expr expr) { - Obj fexs; - Obj fexp; - - fexs = FEXS_FUNC(CURR_FUNC()); - fexp = ELM_PLIST(fexs, READ_EXPR(expr, 0)); + Obj fexp = GET_VALUE_FROM_CURRENT_BODY(READ_EXPR(expr, 0)); SyntaxTreeFunc(result, fexp);