Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IsKernelFunction #876

Merged
merged 2 commits into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ void PrintFunction (
}

/* print the body */
if ( BODY_FUNC(func) == 0 || SIZE_OBJ(BODY_FUNC(func)) == NUMBER_HEADER_ITEMS_BODY*sizeof(Obj) ) {
if (FuncIsKernelFunction(0L, func) == True) {
outputtedfunc = 0;
if ( BODY_FUNC(func) ) {
Obj body = BODY_FUNC(func);
Expand Down Expand Up @@ -1915,7 +1915,10 @@ Obj FuncUNPROFILE_FUNC(
Obj FuncIsKernelFunction(Obj self, Obj func) {
if (!IS_FUNC(func))
return Fail;
else return (BODY_FUNC(func) == 0 || SIZE_OBJ(BODY_FUNC(func)) == 0) ? True : False;
else
return ((BODY_FUNC(func) == 0) ||
(SIZE_OBJ(BODY_FUNC(func))
== NUMBER_HEADER_ITEMS_BODY*sizeof(Obj))) ? True : False;
}

Obj FuncHandlerCookieOfFunction(Obj self, Obj func)
Expand Down
12 changes: 12 additions & 0 deletions src/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,18 @@ extern void PrintFunction (
Obj func );


/****************************************************************************
*
*F FuncIsKernelFunction( <self>, <func> ) . . . . . . . . print a function
**
** 'FuncIsKernelFunction' returns Fail if <func> is not a function, True if
** <func> is a function, and is installed as a kernel function, and False
** otherwise.
*/
extern Obj FuncIsKernelFunction(
Obj self,
Obj func);

/****************************************************************************
**
*F FuncCALL_FUNC_LIST( <self>, <func>, <list> ) . . . . . . call a function
Expand Down
10 changes: 10 additions & 0 deletions tst/testinstall/function.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
gap> START_TEST("function.tst");
gap> IsKernelFunction(IsKernelFunction);
true
gap> IsKernelFunction(function(x) return 1; end);
false
gap> IsKernelFunction(5);
fail
gap> IsKernelFunction(rec( a := function() return 0; end ));
fail
gap> STOP_TEST("function.tst", 1);