Skip to content

Commit

Permalink
kernel: convert more macros to static inline functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Aug 28, 2018
1 parent b969f31 commit 1fc77f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
4 changes: 4 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ VoidFunc debug_func_pointers[] = {
(VoidFunc)INT_INTOBJ,
(VoidFunc)INTOBJ_INT,
(VoidFunc)IS_BLIST_REP,
(VoidFunc)IS_COPYABLE_OBJ,
(VoidFunc)IS_DENSE_LIST,
(VoidFunc)IS_DENSE_PLIST,
(VoidFunc)IS_FFE,
Expand Down Expand Up @@ -226,7 +227,9 @@ VoidFunc debug_func_pointers[] = {
(VoidFunc)SET_PROF_FUNC,
(VoidFunc)SET_PTR_BAG,
(VoidFunc)SET_RNAM_PREC,
(VoidFunc)SET_TYPE_OBJ,
(VoidFunc)SET_VAL_MACFLOAT,
(VoidFunc)SHALLOW_COPY_OBJ,
(VoidFunc)SHRINK_PLIST,
(VoidFunc)SHRINK_STRING,
(VoidFunc)SIZE_BAG,
Expand All @@ -239,6 +242,7 @@ VoidFunc debug_func_pointers[] = {
(VoidFunc)TNAM_OBJ,
(VoidFunc)TNUM_BAG,
(VoidFunc)TNUM_OBJ,
(VoidFunc)TYPE_OBJ,
(VoidFunc)UNB_LIST,
(VoidFunc)VAL_MACFLOAT,
(VoidFunc)VisitStatIfHooked,
Expand Down
44 changes: 21 additions & 23 deletions src/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,12 @@ enum {
**
** 'TYPE_OBJ' returns the type of the object <obj>.
*/
#define TYPE_OBJ(obj) ((*TypeObjFuncs[ TNUM_OBJ(obj) ])( obj ))

extern Obj (*TypeObjFuncs[LAST_REAL_TNUM+1]) ( Obj obj );
static inline Obj TYPE_OBJ(Obj obj)
{
UInt tnum = TNUM_OBJ(obj);
return (*TypeObjFuncs[tnum])(obj);
}


/****************************************************************************
Expand All @@ -484,10 +487,12 @@ extern Obj (*TypeObjFuncs[LAST_REAL_TNUM+1]) ( Obj obj );
**
** 'SET_TYPE_OBJ' sets the kind <kind>of the object <obj>.
*/
#define SET_TYPE_OBJ(obj, kind) \
((*SetTypeObjFuncs[ TNUM_OBJ(obj) ])( obj, kind ))

extern void (*SetTypeObjFuncs[ LAST_REAL_TNUM+1 ]) ( Obj obj, Obj kind );
static inline void SET_TYPE_OBJ(Obj obj, Obj type)
{
UInt tnum = TNUM_OBJ(obj);
(*SetTypeObjFuncs[tnum])(obj, type);
}


/****************************************************************************
Expand Down Expand Up @@ -622,27 +627,27 @@ extern void LoadObjError( Obj obj );
** 'IS_COPYABLE_OBJ' returns 1 if the object <obj> is copyable (i.e., can be
** copied into a mutable object), and 0 otherwise.
*/
#define IS_COPYABLE_OBJ(obj) \
((IsCopyableObjFuncs[ TNUM_OBJ(obj) ])( obj ))

extern Int (*IsCopyableObjFuncs[LAST_REAL_TNUM+1]) ( Obj obj );
static inline Int IS_COPYABLE_OBJ(Obj obj)
{
UInt tnum = TNUM_OBJ(obj);
return (IsCopyableObjFuncs[tnum])(obj);
}


/****************************************************************************
**
*V ShallowCopyObjFuncs[<type>] . . . . . . . . . . shallow copier functions
*F SHALLOW_COPY_OBJ( <obj> ) . . . . . . . make a shallow copy of an object
**
** 'SHALLOW_COPY_OBJ' makes a shallow copy of the object <obj>.
*/
#define SHALLOW_COPY_OBJ(obj) \
((*ShallowCopyObjFuncs[ TNUM_OBJ(obj) ])( obj ))


/****************************************************************************
**
*V ShallowCopyObjFuncs[<type>] . . . . . . . . . . shallow copier functions
*/
extern Obj (*ShallowCopyObjFuncs[LAST_REAL_TNUM+1]) ( Obj obj );
static inline Obj SHALLOW_COPY_OBJ(Obj obj)
{
UInt tnum = TNUM_OBJ(obj);
return (ShallowCopyObjFuncs[tnum])(obj);
}


/****************************************************************************
Expand Down Expand Up @@ -744,11 +749,6 @@ extern void PrintObj (
** is the function '<func>(<obj>)' that should be called to print the object
** <obj> of this type.
*/
/* TL: extern Obj PrintObjThis; */

/* TL: extern Int PrintObjIndex; */
/* TL: extern Int PrintObjDepth; */

extern void (* PrintObjFuncs[LAST_REAL_TNUM+1]) ( Obj obj );


Expand All @@ -762,8 +762,6 @@ extern void ViewObj (
Obj obj );




/****************************************************************************
**
*V PrintPathFuncs[<type>] . . . . . . printer for subobjects of type <type>
Expand Down

0 comments on commit 1fc77f0

Please sign in to comment.