From 541eb281d6ee180b639c7e9f27e4352ba51e2dd6 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 9 Mar 2018 16:08:34 +0100 Subject: [PATCH] lib: improve LocationFunc for kernel funcs Before: gap> LocationFunc(APPEND_LIST_INTR); "" After: gap> LocationFunc(APPEND_LIST_INTR); "src/listfunc.c:APPEND_LIST_INTR" --- lib/function.g | 14 ++++++++++++-- tst/testinstall/opers/LocationFunc.tst | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tst/testinstall/opers/LocationFunc.tst diff --git a/lib/function.g b/lib/function.g index 011bd9ede0..fde53d9fb7 100644 --- a/lib/function.g +++ b/lib/function.g @@ -344,13 +344,23 @@ BIND_GLOBAL( "LocationFunc", function(x) if not(IS_FUNCTION(x)) then return ""; fi; + ret := ""; nam := FILENAME_FUNC(x); + if nam = fail then + return ret; + fi; line := STARTLINE_FUNC(x); - ret := ""; - if nam <> fail and line <> fail then + if line <> fail then APPEND_LIST(ret, nam); APPEND_LIST(ret, ":"); APPEND_LIST(ret, STRING_INT(line)); + return ret; + fi; + line := LOCATION_FUNC(x); + if line <> fail then + APPEND_LIST(ret, nam); + APPEND_LIST(ret, ":"); + APPEND_LIST(ret, line); fi; return ret; end); diff --git a/tst/testinstall/opers/LocationFunc.tst b/tst/testinstall/opers/LocationFunc.tst new file mode 100644 index 0000000000..8cbe53a56f --- /dev/null +++ b/tst/testinstall/opers/LocationFunc.tst @@ -0,0 +1,17 @@ +gap> START_TEST("LocationFunc.tst"); + +# regular GAP function +gap> f:=x->x;; +gap> LocationFunc(f); +"stream:1" + +# GAP function which was compiled to C code by gac +gap> LocationFunc(METHOD_0ARGS); +"GAPROOT/lib/methsel1.g:19" + +# proper kernel function +gap> LocationFunc(APPEND_LIST_INTR); +"src/listfunc.c:APPEND_LIST_INTR" + +# +gap> STOP_TEST("LocationFunc.tst", 1);