Skip to content

Commit

Permalink
Add function LocationOfDeclaration
Browse files Browse the repository at this point in the history
This function returns the location of the declaration of the passed
object if it is known.
  • Loading branch information
markuspf committed Apr 12, 2017
1 parent 1757a43 commit e39b3d4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/type.gd
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,21 @@ DeclareGlobalFunction( "IsCategory" );
## </ManSection>
## <#/GAPDoc>
DeclareGlobalFunction( "CategoryByName" );


#############################################################################
##
#F LocationOfDeclaration( <object> )
##
## Find the location of the declaration of <object>.
##
## <#GAPDoc Label="LocationOfDeclaration">
## <ManSection>
## <Func Name="LocationofDeclaration" Arg='object'/>
##
## <Description>
## returns the location of the declaration of <A>object</A> if it is known.
## </Description>
## </ManSection>
## <#/GAPDoc>
DeclareGlobalFunction( "LocationOfDeclaration" );
18 changes: 18 additions & 0 deletions lib/type.gi
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,21 @@ function(name)
return fail;
end);

InstallGlobalFunction( LocationOfDeclaration,
function(object)
local fid;
if IsFilter(object) then
fid := IdOfFilter(object);
if fid <> fail then
if IsBound(FILTERS_LOCATIONS[fid]) then
return FILTERS_LOCATIONS[fid];
fi;
fi;
elif IsOperation(object) then
fid := Position(OPERATIONS, object);
if IsBound(OPERATIONS_LOCATIONS[fid + 1]) then
return OPERATIONS_LOCATIONS[fid + 1];
fi;
fi;
return fail;
end);

0 comments on commit e39b3d4

Please sign in to comment.