Skip to content

Commit

Permalink
Add Undefined object
Browse files Browse the repository at this point in the history
This adds the `Undefined` object from HPC-GAP. This should never be exposed
to GAP-Level code.
  • Loading branch information
markuspf committed Feb 3, 2016
1 parent 3c1b847 commit d26aadd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/bool.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@
#include "lists.h" /* generic lists */
#include "stringobj.h" /* strings */

#include "code.h" /* coder */
#include "hpc/thread.h" /* threads */
#include "hpc/tls.h" /* thread-local storage */
#include "code.h" /* coder */
#include "hpc/thread.h" /* threads */
#include "hpc/tls.h" /* thread-local storage */


/****************************************************************************
**
*V True . . . . . . . . . . . . . . . . . . . . . . . . . . . . true value
**
** 'True' is the value 'true'.
Expand Down Expand Up @@ -78,10 +77,21 @@ Obj Fail;
*/
Obj SuPeRfail;


/****************************************************************************
**
*V Undefined . . . . . . . . . . . . . . . . . . . . . . . undefined value
**
** 'Undefined' is a special object that is used in lieu of (Obj) 0 in places
** where the kernel cannot handle a null reference easily. This object is
** never exposed to GAP code and only used within the kernel.
*/
Obj Undefined;




/****************************************************************************
**
*F TypeBool( <bool> ) . . . . . . . . . . . . . . . type of a boolean value
**
** 'TypeBool' returns the type of boolean values.
Expand Down Expand Up @@ -118,6 +128,9 @@ void PrintBool (
else if ( bool == SuPeRfail ) {
Pr( "SuPeRfail", 0L, 0L );
}
else if ( bool == Undefined ) {
Pr( "Undefined", 0L, 0L );
}
else {
Pr( "<<very strange boolean value>>", 0L, 0L );
}
Expand Down Expand Up @@ -403,6 +416,7 @@ static Int InitKernel (
InitGlobalBag( &False, "src/bool.c:FALSE" );
InitGlobalBag( &Fail, "src/bool.c:FAIL" );
InitGlobalBag( &SuPeRfail, "src/bool.c:SUPERFAIL" );
InitGlobalBag( &Undefined, "src/bool.c:UNDEFINED" );

/* install the saving functions */
SaveObjFuncs[ T_BOOL ] = SaveBool;
Expand All @@ -417,6 +431,7 @@ static Int InitKernel (
EqFuncs[ T_BOOL ][ T_BOOL ] = EqBool;
LtFuncs[ T_BOOL ][ T_BOOL ] = LtBool;

MakeBagTypePublic(T_BOOL);
/* return success */
return 0;
}
Expand Down Expand Up @@ -451,6 +466,9 @@ static Int InitLibrary (
AssGVar( gvar, SuPeRfail );
MakeReadOnlyGVar(gvar);

/* Undefined is an internal value */
Undefined = NewBag( T_BOOL, 0 );

/* make and install the 'RETURN_TRUE' function */
tmp = NewFunctionC( "RETURN_TRUE", -1L, "arg", ReturnTrue1 );
HDLR_FUNC( tmp, 1 ) = ReturnTrue1;
Expand Down
10 changes: 10 additions & 0 deletions src/bool.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ extern Obj Fail;
*/
extern Obj SuPeRfail;

/****************************************************************************
**
*V Undefined . . . . . . . . . . . . . . . . . . . . . . . undefined value
**
** 'Undefined' is a special object that is used in lieu of (Obj) 0 in places
** where the kernel cannot handle a null reference easily. This object is
** never exposed to GAP code and only used within the kernel.
*/
extern Obj Undefined;


/****************************************************************************
**
Expand Down

0 comments on commit d26aadd

Please sign in to comment.