Skip to content

Commit

Permalink
Rename FunctionHeader -> FuncBag, FUNC_HEADER->FUNC
Browse files Browse the repository at this point in the history
Struct FuncBag really describes the full T_FUNC bag, not just its header.
  • Loading branch information
fingolfin authored and ChrisJefferson committed Jan 10, 2018
1 parent e77c926 commit 73d4536
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions src/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
void SET_NAME_FUNC(Obj func, Obj name)
{
GAP_ASSERT(name == 0 || IS_STRING_REP(name));
FUNC_HEADER(func)->name = name;
FUNC(func)->name = name;
}

Char * NAMI_FUNC(Obj func, Int i)
Expand Down Expand Up @@ -1115,7 +1115,7 @@ Obj NewFunction (
Obj nams,
ObjFunc hdlr )
{
return NewFunctionT( T_FUNCTION, sizeof(FunctionHeader), name, narg, nams, hdlr );
return NewFunctionT( T_FUNCTION, sizeof(FuncBag), name, narg, nams, hdlr );
}


Expand All @@ -1132,7 +1132,7 @@ Obj NewFunctionC (
const Char * nams,
ObjFunc hdlr )
{
return NewFunctionCT( T_FUNCTION, sizeof(FunctionHeader), name, narg, nams, hdlr );
return NewFunctionCT( T_FUNCTION, sizeof(FuncBag), name, narg, nams, hdlr );
}


Expand Down Expand Up @@ -1947,7 +1947,7 @@ Obj FuncHandlerCookieOfFunction(Obj self, Obj func)
*/
void SaveFunction ( Obj func )
{
FunctionHeader * header = FUNC_HEADER(func);
FuncBag * header = FUNC(func);
for (UInt i = 0; i <= 7; i++)
SaveHandler(header->handlers[i]);
SaveSubObj(header->name);
Expand All @@ -1958,7 +1958,7 @@ void SaveFunction ( Obj func )
SaveSubObj(header->body);
SaveSubObj(header->envi);
SaveSubObj(header->fexs);
if (SIZE_OBJ(func) != sizeof(FunctionHeader))
if (SIZE_OBJ(func) != sizeof(FuncBag))
SaveOperationExtras( func );
}

Expand All @@ -1969,7 +1969,7 @@ void SaveFunction ( Obj func )
*/
void LoadFunction ( Obj func )
{
FunctionHeader * header = FUNC_HEADER(func);
FuncBag * header = FUNC(func);
for (UInt i = 0; i <= 7; i++)
header->handlers[i] = LoadHandler();
header->name = LoadSubObj();
Expand All @@ -1980,7 +1980,7 @@ void LoadFunction ( Obj func )
header->body = LoadSubObj();
header->envi = LoadSubObj();
header->fexs = LoadSubObj();
if (SIZE_OBJ(func) != sizeof(FunctionHeader))
if (SIZE_OBJ(func) != sizeof(FuncBag))
LoadOperationExtras( func );
}

Expand Down
44 changes: 22 additions & 22 deletions src/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,72 +118,72 @@ typedef struct {
Obj locks;
#endif
// additional data follows for operations
} FunctionHeader;
} FuncBag;

static inline FunctionHeader * FUNC_HEADER(Obj func)
static inline FuncBag * FUNC(Obj func)
{
GAP_ASSERT(TNUM_OBJ(func) == T_FUNCTION);
return (FunctionHeader *)ADDR_OBJ(func);
return (FuncBag *)ADDR_OBJ(func);
}

static inline ObjFunc HDLR_FUNC(Obj func, Int i)
{
return FUNC_HEADER(func)->handlers[i];
return FUNC(func)->handlers[i];
}

static inline Obj NAME_FUNC(Obj func)
{
return FUNC_HEADER(func)->name;
return FUNC(func)->name;
}

static inline Int NARG_FUNC(Obj func)
{
return FUNC_HEADER(func)->nargs;
return FUNC(func)->nargs;
}

static inline Obj NAMS_FUNC(Obj func)
{
return FUNC_HEADER(func)->namesOfLocals;
return FUNC(func)->namesOfLocals;
}

extern Char * NAMI_FUNC(Obj func, Int i);

static inline Obj PROF_FUNC(Obj func)
{
return FUNC_HEADER(func)->prof;
return FUNC(func)->prof;
}

static inline UInt NLOC_FUNC(Obj func)
{
return FUNC_HEADER(func)->nloc;
return FUNC(func)->nloc;
}

static inline Obj BODY_FUNC(Obj func)
{
return FUNC_HEADER(func)->body;
return FUNC(func)->body;
}

static inline Obj ENVI_FUNC(Obj func)
{
return FUNC_HEADER(func)->envi;
return FUNC(func)->envi;
}

static inline Obj FEXS_FUNC(Obj func)
{
return FUNC_HEADER(func)->fexs;
return FUNC(func)->fexs;
}

#ifdef HPCGAP
static inline Obj LCKS_FUNC(Obj func)
{
return FUNC_HEADER(func)->locks;
return FUNC(func)->locks;
}

#endif

static inline void SET_HDLR_FUNC(Obj func, Int i, ObjFunc hdlr)
{
FunctionHeader *header = FUNC_HEADER(func);
FuncBag *header = FUNC(func);
GAP_ASSERT(0 <= i && i < ARRAY_SIZE(header->handlers));
header->handlers[i] = hdlr;
}
Expand All @@ -192,44 +192,44 @@ extern void SET_NAME_FUNC(Obj func, Obj name);

static inline void SET_NARG_FUNC(Obj func, Int nargs)
{
FUNC_HEADER(func)->nargs = nargs;
FUNC(func)->nargs = nargs;
}

static inline void SET_NAMS_FUNC(Obj func, Obj namesOfLocals)
{
FUNC_HEADER(func)->namesOfLocals = namesOfLocals;
FUNC(func)->namesOfLocals = namesOfLocals;
}

static inline void SET_PROF_FUNC(Obj func, Obj prof)
{
FUNC_HEADER(func)->prof = prof;
FUNC(func)->prof = prof;
}

static inline void SET_NLOC_FUNC(Obj func, UInt nloc)
{
FUNC_HEADER(func)->nloc = nloc;
FUNC(func)->nloc = nloc;
}

static inline void SET_BODY_FUNC(Obj func, Obj body)
{
GAP_ASSERT(TNUM_OBJ(body) == T_BODY);
FUNC_HEADER(func)->body = body;
FUNC(func)->body = body;
}

static inline void SET_ENVI_FUNC(Obj func, Obj envi)
{
FUNC_HEADER(func)->envi = envi;
FUNC(func)->envi = envi;
}

static inline void SET_FEXS_FUNC(Obj func, Obj fexs)
{
FUNC_HEADER(func)->fexs = fexs;
FUNC(func)->fexs = fexs;
}

#ifdef HPCGAP
static inline void SET_LCKS_FUNC(Obj func, Obj locks)
{
FUNC_HEADER(func)->locks = locks;
FUNC(func)->locks = locks;
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ void CodeFuncExprBegin (
PushLoopNesting();

/* create a function expression */
fexp = NewBag( T_FUNCTION, sizeof(FunctionHeader) );
fexp = NewBag( T_FUNCTION, sizeof(FuncBag) );
SET_NARG_FUNC( fexp, narg );
SET_NLOC_FUNC( fexp, nloc );
SET_NAMS_FUNC( fexp, nams );
Expand Down
2 changes: 1 addition & 1 deletion src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ VoidFunc debug_func_pointers[] = {
(VoidFunc)FEXS_FUNC,
(VoidFunc)FibHash,
(VoidFunc)FillInVersion,
(VoidFunc)FUNC_HEADER,
(VoidFunc)FUNC,
#ifdef HPCGAP
(VoidFunc)GetTLS,
#endif
Expand Down

0 comments on commit 73d4536

Please sign in to comment.