Skip to content

Commit c9458f6

Browse files
committed
Inline KernelLocationOfFunction into callers
1 parent b5e99ed commit c9458f6

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

src/calls.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,8 @@ static const Char * CookieOfFunc(Obj func)
815815

816816
static const Char * CookieSuffix(const Char * cookie)
817817
{
818+
if (!cookie)
819+
return NULL;
818820
const Char * pos = strchr(cookie, ':');
819821
return pos ? pos + 1 : NULL;
820822
}
@@ -1013,18 +1015,6 @@ static BOOL FindKernelDefinitionLine(const char * path,
10131015
return found;
10141016
}
10151017

1016-
static Obj KernelLocationOfFunction(Obj func)
1017-
{
1018-
const Char * cookie = CookieOfFunc(func);
1019-
const Char * suffix = cookie ? CookieSuffix(cookie) : NULL;
1020-
1021-
// Only standard GVAR cookies map cleanly to Func<name> definitions.
1022-
if (!IsStandardKernelCookieSuffix(suffix))
1023-
return Fail;
1024-
1025-
return MakeImmString(suffix);
1026-
}
1027-
10281018
static UInt FindKernelFunctionStartLine(Obj func)
10291019
{
10301020
UInt line = 0;
@@ -1034,15 +1024,16 @@ static UInt FindKernelFunctionStartLine(Obj func)
10341024
if (line)
10351025
return line;
10361026

1037-
Obj symbol = KernelLocationOfFunction(func);
1038-
if (symbol == Fail)
1027+
const Char * cookie = CookieOfFunc(func);
1028+
const Char * suffix = CookieSuffix(cookie);
1029+
if (!IsStandardKernelCookieSuffix(suffix))
10391030
return 0;
10401031

1041-
const Char * cookie = CookieOfFunc(func);
10421032
Char path[GAP_PATH_MAX];
10431033
if (!ResolveKernelCookiePath(cookie, path, sizeof(path)))
10441034
return 0;
10451035

1036+
Obj symbol = MakeImmString(suffix);
10461037
if (!FindKernelDefinitionLine(path, symbol, &line))
10471038
return 0;
10481039

@@ -1338,10 +1329,10 @@ void PrintKernelFunction(Obj func)
13381329
Obj body = BODY_FUNC(func);
13391330
Obj filename = body ? GET_FILENAME_BODY(body) : 0;
13401331
if (filename) {
1341-
Obj location = KernelLocationOfFunction(func);
13421332
UInt startline = FindKernelFunctionStartLine(func);
13431333
if (startline) {
1344-
if (location != Fail)
1334+
const Char * cookie = CookieOfFunc(func);
1335+
if (IsStandardKernelCookieSuffix(CookieSuffix(cookie)))
13451336
Pr("<<kernel code>> from %g:%d", (Int)filename, startline);
13461337
else
13471338
Pr("<<compiled GAP code>> from %g:%d", (Int)filename,

0 commit comments

Comments
 (0)