Skip to content

Commit

Permalink
Introduce -N switch to not use hidden implications
Browse files Browse the repository at this point in the history
If GAP is normally called then this patch only causes
 - that the kernel list HIDDEN_IMPS is visible from GAP level
 - that two debugging functions are available
     - WriteFilterRanks(filename);
     - WriteMethodOverview(filename);

Furthermore a command line switch -N is introduced. When gap is called with
this -N then:
  - no hidden implications are installed anymore
  - RankFilter only uses proper implications
  - InstallMethod uses only proper implication during its check if
    the installation fits to one declaration. When it does not find
    an appropriate declaration then it does not run into an error but only
    prints a line of useful information. (This allows to systematically
    either add explicit filter implications or change the filters in some
    method installations until these messages disappear.)

This patch should be safe to be merged into master. Actual changes in
filter implications will be provided in separate patches.
  • Loading branch information
frankluebeck committed Mar 6, 2018
1 parent f5c015f commit f7d12b1
Show file tree
Hide file tree
Showing 8 changed files with 372 additions and 78 deletions.
13 changes: 10 additions & 3 deletions lib/filter.g
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ BIND_GLOBAL( "InstallTrueMethodNewFilter", function ( tofilt, from )
fi;
fi;
od;
InstallHiddenTrueMethod( tofilt, from );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( tofilt, from );
fi;
end );


Expand Down Expand Up @@ -408,15 +410,20 @@ BIND_GLOBAL( "CANONICAL_BASIS_FLAGS", QUO_INT(SUM_FLAGS,5) );
## Compute the rank including the hidden implications.
##
BIND_GLOBAL( "RankFilter", function( filter )
local rank, flags, i;
local rank, flags, all, i;

rank := 0;
if IS_FUNCTION(filter) then
flags := FLAGS_FILTER(filter);
else
flags := filter;
fi;
for i in TRUES_FLAGS(WITH_HIDDEN_IMPS_FLAGS(flags)) do
if not GAPInfo.CommandLineOptions.N then
all := WITH_HIDDEN_IMPS_FLAGS(flags);
else
all := WITH_IMPS_FLAGS(flags);
fi;
for i in TRUES_FLAGS(all) do
if IsBound(RANK_FILTERS[i]) then
rank := rank + RANK_FILTERS[i];
else
Expand Down
24 changes: 16 additions & 8 deletions lib/oper.g
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,9 @@ BIND_GLOBAL( "DeclareAttributeKernel", function ( name, filter, getter )
od;

# clear the cache because <filter> is something old
InstallHiddenTrueMethod( filter, tester );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( filter, tester );
fi;
CLEAR_HIDDEN_IMP_CACHE( tester );

# run the attribute functions
Expand Down Expand Up @@ -1167,7 +1169,9 @@ BIND_GLOBAL( "OPER_SetupAttribute", function(getter, flags, mutflag, filter, ran

# the <tester> is newly made, therefore the cache cannot contain a flag
# list involving <tester>
InstallHiddenTrueMethod( filter, tester );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( filter, tester );
fi;
# CLEAR_HIDDEN_IMP_CACHE();

# run the attribute functions
Expand Down Expand Up @@ -1404,10 +1408,12 @@ BIND_GLOBAL( "DeclarePropertyKernel", function ( name, filter, getter )
INFO_FILTERS[ FLAG2_FILTER( getter ) ]:= 8;

# clear the cache because <filter> is something old
InstallHiddenTrueMethod( tester, getter );
CLEAR_HIDDEN_IMP_CACHE( getter );
InstallHiddenTrueMethod( filter, tester );
CLEAR_HIDDEN_IMP_CACHE( tester );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( tester, getter );
CLEAR_HIDDEN_IMP_CACHE( getter );
InstallHiddenTrueMethod( filter, tester );
CLEAR_HIDDEN_IMP_CACHE( tester );
fi;

# run the attribute functions
RUN_ATTR_FUNCS( filter, getter, setter, tester, false );
Expand Down Expand Up @@ -1479,8 +1485,10 @@ BIND_GLOBAL( "NewProperty", function ( arg )

# the <tester> and <getter> are newly made, therefore the cache cannot
# contain a flag list involving <tester> or <getter>
InstallHiddenTrueMethod( tester, getter );
InstallHiddenTrueMethod( filter, tester );
if not GAPInfo.CommandLineOptions.N then
InstallHiddenTrueMethod( tester, getter );
InstallHiddenTrueMethod( filter, tester );
fi;
# CLEAR_HIDDEN_IMP_CACHE();

# run the attribute functions
Expand Down
31 changes: 25 additions & 6 deletions lib/oper1.g
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,11 @@ BIND_GLOBAL( "INSTALL_METHOD",
# do check with implications
imp := [];
for i in flags do
ADD_LIST( imp, WITH_HIDDEN_IMPS_FLAGS( i ) );
if not GAPInfo.CommandLineOptions.N then
ADD_LIST( imp, WITH_HIDDEN_IMPS_FLAGS( i ) );
else
ADD_LIST( imp, WITH_IMPS_FLAGS( i ) );
fi;
od;

# Check that the requirements of the method match
Expand Down Expand Up @@ -515,12 +519,27 @@ BIND_GLOBAL( "INSTALL_METHOD",
# If the requirements do not match any of the declarations
# then something is wrong or `InstallOtherMethod' should be used.
if notmatch=0 then
Error("the number of arguments does not match a declaration of ",
NAME_FUNC(opr) );
if not GAPInfo.CommandLineOptions.N then
Error("the number of arguments does not match a declaration of ",
NAME_FUNC(opr) );
else
Print("IM: the number of arguments does not ",
"match a declaration of ", NAME_FUNC(opr), "\n" );
fi;
else
Error("required filters ", NamesFilter(imp[notmatch]),"\nfor ",
Ordinal(notmatch)," argument do not match a declaration of ",
NAME_FUNC(opr) );
if not GAPInfo.CommandLineOptions.N then
Error("required filters ", NamesFilter(imp[notmatch]),"\nfor ",
Ordinal(notmatch)," argument do not match a declaration of ",
NAME_FUNC(opr) );
else
Print("IM: ", NAME_FUNC(opr), "(\c",INPUT_FILENAME(),"\c +",
INPUT_LINENUMBER(),") \c","required filters \c");
for j in NamesFilter(imp[notmatch]) do
Print(j,"/\c");
od;
Print(" for ",Ordinal(notmatch)," argument do not match \ca ",
"declaration\n");
fi;
fi;

else
Expand Down
69 changes: 69 additions & 0 deletions lib/operdebug.g
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
##############################################################################
## operdebug.g Frank Lübeck
##
## Non-documented utilities to write out infos about all methods of all
## operations with location and rank, and to write out all filters by name
## and their rank. These can be useful to debug larger changes that influence
## the ranking of filters and methods.
##
BIND_GLOBAL("WriteMethodOverview", function(fname)
local name, sline, f;
name := function(f)
local path, ls, s;
path := FilenameFunc(f);
if path=fail then
return NameFunction(f);
fi;
for s in GAPInfo.RootPaths do
ls := Length(s);
if Length(path) >= ls and path{[1..ls]}=s then
return path{[ls+1..Length(path)]};
fi;
od;
return path;
end;
sline := function(f)
local n;
n := StartlineFunc(f);
if n=fail then
return "\c";
fi;
return Concatenation(":",String(n),"\c");
end;
f := function()
local nam, m, s, op, i, j;
for op in OPERATIONS do
nam := NameFunction(op);
for i in [0..6] do
m := METHODS_OPERATION(op, i);
s := 4+i;
for j in [1..Length(m)/s] do
Print(nam,";\c",i,";",
name(m[j*s-2]),
sline(m[j*s-2]),";\c",
m[j*s-1],"\n");
od;
od;
od;
end;
PrintTo1(fname, f);
end);

BIND_GLOBAL("WriteFilterRanks", function(fname)
local f;
f := function()
local nams, rks, n, i;
nams := List(FILTERS, NameFunction);
rks := List(FILTERS, RankFilter);
SortParallel(nams, rks);
for i in [1..Length(nams)] do
n := SubstitutionSublist(nams[i],"CategoryCollections","CC");
if Length(n) > 75 then
n := Concatenation(n{[1..30]},"...",n{[Length(n)-29..Length(n)]});
fi;
Print(n,";",rks[i],"\n");
od;
end;
PrintTo1(fname, f);
end);

6 changes: 6 additions & 0 deletions lib/read8.g
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ ReadLib( "compiler.g" );
ReadLib( "teaching.g" );
ReadLib( "teachm2.g" );

#############################################################################
##
#X Debugging method and filter ranks
##
ReadLib( "operdebug.g" );

2 changes: 1 addition & 1 deletion lib/system.g
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ BIND_GLOBAL( "GAPInfo", rec(
rec( short:= "B", default := "", arg := "<name>", help := [ "current architecture"] ),
rec( short:= "D", default := false, help := ["enable/disable debugging the loading of files"] ),
rec( short:= "M", default := false, help := ["disable/enable loading of compiled modules"] ),
rec( short:= "N", default := false, help := ["unused, for backward compatibility only"] ),
rec( short:= "N", default := false, help := ["do not use hidden implications"] ),
rec( short:= "O", default := false, help := ["disable/enable loading of obsolete files"] ),
rec( short:= "T", default := false, help := ["disable/enable break loop"] ),
rec( long := "quitonbreak", default := false, help := ["quit GAP with non-zero return value instead of entering break loop"]),
Expand Down
Loading

0 comments on commit f7d12b1

Please sign in to comment.