Skip to content
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
303 changes: 196 additions & 107 deletions hpcgap/src/c_oper1.c

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions hpcgap/src/c_type1.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef AVOID_PRECOMPILED
/* C file produced by GAC */
#include <src/compiled.h>
#define FILE_CRC "127455113"
#define FILE_CRC "-95946497"

/* global variables used in handlers */
static GVar G_NAME__FUNC;
Expand Down Expand Up @@ -3575,10 +3575,11 @@ static Obj HdlrFunc1 (
CHANGED_BAG( STATE(CurrLVars) );
CALL_1ARGS( t_1, t_2 );

/* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + 6; */
/* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (5 + 2); */
t_2 = GC_LENGTH__SETTER__METHODS__2;
CHECK_BOUND( t_2, "LENGTH_SETTER_METHODS_2" )
C_SUM_FIA( t_1, t_2, INTOBJ_INT(6) )
C_SUM_INTOBJS( t_3, INTOBJ_INT(5), INTOBJ_INT(2) )
C_SUM_FIA( t_1, t_2, t_3 )
AssGVar( G_LENGTH__SETTER__METHODS__2, t_1 );

/* InstallAttributeFunction( function ( name, filter, getter, setter, tester, mutflag )
Expand Down Expand Up @@ -4770,7 +4771,7 @@ static Int InitLibrary ( StructInitInfo * module )
static StructInitInfo module = {
.type = MODULE_STATIC,
.name = "GAPROOT/lib/type1.g",
.crc = 127455113,
.crc = -95946497,
.initKernel = InitKernel,
.initLibrary = InitLibrary,
.postRestore = PostRestore,
Expand Down
23 changes: 14 additions & 9 deletions lib/methsel.g
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,20 @@
#F AttributeValueNotSet( <attr>, <obj> )
##
AttributeValueNotSet := function(attr,obj)
local type,fam,methods,i,flag,erg;
local type,fam,methods,i,j,flag,erg;
type:=TypeObj(obj);
fam:=FamilyObj(obj);
methods:=METHODS_OPERATION(attr,1);
for i in [1..LEN_LIST(methods)/5] do
for i in [1..LEN_LIST(methods)/(1+BASE_SIZE_METHODS_OPER_ENTRY)] do
# nam:=methods[5*(i-1)+5]; # name
j:=(1+BASE_SIZE_METHODS_OPER_ENTRY)*(i-1);
flag:=true;
flag:=flag and IS_SUBSET_FLAGS(type![2],methods[5*(i-1)+2]);
flag:=flag and IS_SUBSET_FLAGS(type![2],methods[j+2]);
if flag then
flag:=flag and methods[5*(i-1)+1](fam);
flag:=flag and methods[j+1](fam);
fi;
if flag then
attr:=methods[5*(i-1)+3];
attr:=methods[j+3];
erg:=attr(obj);
if not IS_IDENTICAL_OBJ(erg,TRY_NEXT_METHOD) then
return erg;
Expand All @@ -55,9 +56,11 @@ end;
##
VMETHOD_PRINT_INFO := function ( methods, i, arity)
local offset;
offset := (arity+4)*(i-1)+arity;
offset := (arity+BASE_SIZE_METHODS_OPER_ENTRY)*(i-1)+arity;
Print("#I ", methods[offset+4]);
if FILENAME_FUNC(methods[offset+2]) <> fail then
if BASE_SIZE_METHODS_OPER_ENTRY >= 5 then
Print(" at ", methods[offset+5][1], ":", methods[offset+5][2]);
elif FILENAME_FUNC(methods[offset+2]) <> fail then
Print(" at ",
FILENAME_FUNC(methods[offset+2]), ":",
STARTLINE_FUNC(methods[offset+2]));
Expand All @@ -71,9 +74,11 @@ end;
##
NEXT_VMETHOD_PRINT_INFO := function ( methods, i, arity)
local offset;
offset := (arity+4)*(i-1)+arity;
offset := (arity+BASE_SIZE_METHODS_OPER_ENTRY)*(i-1)+arity;
Print("#I Trying next: ", methods[offset+4]);
if FILENAME_FUNC(methods[offset+2]) <> fail then
if BASE_SIZE_METHODS_OPER_ENTRY >= 5 then
Print(" at ", methods[offset+5][1], ":", methods[offset+5][2]);
elif FILENAME_FUNC(methods[offset+2]) <> fail then
Print(" at ",
FILENAME_FUNC(methods[offset+2]), ":",
STARTLINE_FUNC(methods[offset+2]));
Expand Down
43 changes: 24 additions & 19 deletions lib/methwhy.g
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ end);
## <#/GAPDoc>
##
BIND_GLOBAL("ApplicableMethodTypes",function(arg)
local oper,l,obj,skip,verbos,fams,flags,i,j,methods,flag,flag2,
lent,nam,val,erg,has,need,isconstructor;
local oper,narg,args,skip,verbos,fams,flags,i,j,methods,flag,flag2,
lent,offset,nam,val,erg,has,need,isconstructor;
if Length(arg)<2 or not IsList(arg[2]) or not IsFunction(arg[1]) then
Error("usage: ApplicableMethodTypes(<opr>,<arglist>[,<verbosity>[,<nr>]])");
fi;
oper:=arg[1];
isconstructor:=IS_CONSTRUCTOR(oper);
obj:=arg[2];
args:=arg[2];
if Length(arg)>2 then
verbos:=arg[3];
else
Expand All @@ -142,12 +142,12 @@ local oper,l,obj,skip,verbos,fams,flags,i,j,methods,flag,flag2,
else
skip:=0;
fi;
l:=Length(obj);
narg:=Length(args);

# get families and filters
flags:=[];
fams:=[];
for i in obj do
for i in args do
if IsFilter(i) then
Add(flags,FLAGS_FILTER(i));
Add(fams,fail);
Expand All @@ -164,22 +164,25 @@ local oper,l,obj,skip,verbos,fams,flags,i,j,methods,flag,flag2,
Info(InfoWarning,1,"Family predicate cannot be tested");
fi;

methods:=METHODS_OPERATION(oper,l);
methods:=METHODS_OPERATION(oper,narg);
if verbos > 0 then
Print("#I Searching Method for ",NameFunction(oper)," with ",l,
Print("#I Searching Method for ",NameFunction(oper)," with ",narg,
" arguments:\n");
fi;
lent:=4+l; #length of one entry
lent:=BASE_SIZE_METHODS_OPER_ENTRY+narg; #length of one entry
if verbos > 0 then
Print("#I Total: ", Length(methods)/lent," entries\n");
fi;
for i in [1..Length(methods)/lent] do
nam:=methods[lent*(i-1)+l+4];
val:=methods[lent*(i-1)+l+3];
oper:=methods[lent*(i-1)+l+2];
offset:=lent*(i-1);
nam:=methods[offset+narg+4];
val:=methods[offset+narg+3];
oper:=methods[offset+narg+2];
if verbos>1 then
Print("#I Method ",i,": ``",nam,"''");
if LocationFunc(oper) <> "" then
if BASE_SIZE_METHODS_OPER_ENTRY >= 5 then
Print(" at ", methods[offset+narg+5][1], ":", methods[offset+narg+5][2]);
elif LocationFunc(oper) <> "" then
Print(" at ",LocationFunc(oper));
fi;
Print(", value: ");
Expand All @@ -188,15 +191,15 @@ local oper,l,obj,skip,verbos,fams,flags,i,j,methods,flag,flag2,
fi;
flag:=true;
j:=1;
while j<=l and (flag or verbos>3) do
while j<=narg and (flag or verbos>3) do
if j=1 and isconstructor then
flag2:=IS_SUBSET_FLAGS(methods[lent*(i-1)+1+j],flags[j]);
flag2:=IS_SUBSET_FLAGS(methods[offset+1+j],flags[j]);
else
flag2:=IS_SUBSET_FLAGS(flags[j],methods[lent*(i-1)+1+j]);
flag2:=IS_SUBSET_FLAGS(flags[j],methods[offset+1+j]);
fi;
flag:=flag and flag2;
if flag2=false and verbos>2 then
need:=NamesFilter(methods[lent*(i-1)+1+j]);
need:=NamesFilter(methods[offset+1+j]);
if j=1 and isconstructor then
Print("#I - ",Ordinal(j)," argument must be ",
need,"\n");
Expand All @@ -209,11 +212,13 @@ local oper,l,obj,skip,verbos,fams,flags,i,j,methods,flag,flag2,
j:=j+1;
od;
if flag then
if fams=fail or CallFuncList(methods[lent*(i-1)+1],fams) then
oper:=methods[lent*(i-1)+j+1];
if fams=fail or CallFuncList(methods[offset+1],fams) then
oper:=methods[offset+j+1];
if verbos=1 then
Print("#I Method ",i,": ``",nam,"''");
if LocationFunc(oper) <> "" then
if BASE_SIZE_METHODS_OPER_ENTRY >= 5 then
Print(" at ", methods[offset+narg+5][1], ":", methods[offset+narg+5][2]);
elif LocationFunc(oper) <> "" then
Print(" at ",LocationFunc(oper));
fi;
Print(" , value: ");
Expand Down
46 changes: 25 additions & 21 deletions lib/oper.g
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ IGNORE_IMMEDIATE_METHODS := false;
## </Description>
## </ManSection>
##
BIND_CONSTANT("SIZE_IMMEDIATE_METHOD_ENTRY", 8);
BIND_GLOBAL( "INSTALL_IMMEDIATE_METHOD",
function( oper, info, filter, rank, method )

Expand Down Expand Up @@ -361,44 +362,43 @@ BIND_GLOBAL( "INSTALL_IMMEDIATE_METHOD",
#T (This would make an if statement in `RunImmediateMethods' unnecessary!)

# Find the place to put the new method.
if not IsBound( IMMEDIATES[j] ) then
if IsHPCGAP then
IMMEDIATES[j]:= MakeImmutable([]);
if not IsHPCGAP then
if IsBound( IMMEDIATES[j] ) then
imm := IMMEDIATES[j];
else
IMMEDIATES[j]:= [];
imm := [];
IMMEDIATES[j] := imm;
fi;
else
if IsBound( IMMEDIATES[j] ) then
imm := SHALLOW_COPY_OBJ(IMMEDIATES[j]);
else
imm := [];
fi;
fi;
i := 0;
while i < LEN_LIST(IMMEDIATES[j]) and rank < IMMEDIATES[j][i+5] do
i := i + 7;
while i < LEN_LIST(imm) and rank < imm[i+5] do
i := i + SIZE_IMMEDIATE_METHOD_ENTRY;
od;

# Now is a good time to see if the method is already there
if REREADING then
replace := false;
k := i;
while k < LEN_LIST(IMMEDIATES[j]) and
rank = IMMEDIATES[j][k+5] do
if info = IMMEDIATES[j][k+7] and
oper = IMMEDIATES[j][k+1] and
FLAGS_FILTER( filter ) = IMMEDIATES[j][k+4] then
while k < LEN_LIST(imm) and rank = imm[k+5] do
if info = imm[k+7] and oper = imm[k+1] and
FLAGS_FILTER( filter ) = imm[k+4] then
replace := true;
i := k;
break;
fi;
k := k+7;
k := k+SIZE_IMMEDIATE_METHOD_ENTRY;
od;
fi;

# push the other functions back
imm:=IMMEDIATES[j];
if IsHPCGAP then
# ShallowCopy is not bound yet, so we take a sublist
imm:=imm{[1..LEN_LIST(IMMEDIATES[j])]};
fi;

if not REREADING or not replace then
imm{[i+8..7+LEN_LIST(imm)]} := imm{[i+1..LEN_LIST(imm)]};
imm{[SIZE_IMMEDIATE_METHOD_ENTRY+i+1..SIZE_IMMEDIATE_METHOD_ENTRY+LEN_LIST(imm)]} := imm{[i+1..LEN_LIST(imm)]};
fi;

# install the new method
Expand All @@ -409,6 +409,9 @@ BIND_GLOBAL( "INSTALL_IMMEDIATE_METHOD",
imm[i+5] := rank;
imm[i+6] := pos;
imm[i+7] := IMMUTABLE_COPY_OBJ(info);
if SIZE_IMMEDIATE_METHOD_ENTRY >= 8 then
imm[i+8] := MakeImmutable([INPUT_FILENAME(), INPUT_LINENUMBER()]);
fi;

if IsHPCGAP then
IMMEDIATES[j]:=MakeImmutable(imm);
Expand Down Expand Up @@ -554,9 +557,10 @@ end );
## <Ref Func="UntraceImmediateMethods"/>, or <Ref Func="TraceImmediateMethods"/>
## with <A>flag</A> equal <K>false</K> turns tracing off.
## (There is no facility to trace <E>specific</E> immediate methods.)
## <Example><![CDATA[
## <Log><![CDATA[
## gap> TraceImmediateMethods( );
## gap> g:= Group( (1,2,3), (1,2) );;
## #I RunImmediateMethods
## #I immediate: Size
## #I immediate: IsCyclic
## #I immediate: IsCommutative
Expand All @@ -574,7 +578,7 @@ end );
## 6
## gap> UntraceImmediateMethods( );
## gap> UntraceMethods( [ Size ] );
## ]]></Example>
## ]]></Log>
## <P/>
## This example gives an explanation for the two calls of the
## <Q>system getter</Q> for <Ref Func="Size"/>.
Expand Down
32 changes: 22 additions & 10 deletions lib/oper1.g
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
## have been discovered recently.
## So possible consequences of other filters are not checked.
##
RUN_IMMEDIATE_METHODS_RUNS := 0;
RUN_IMMEDIATE_METHODS_CHECKS := 0;
RUN_IMMEDIATE_METHODS_HITS := 0;

Expand All @@ -31,7 +32,9 @@ BIND_GLOBAL( "RunImmediateMethods", function ( obj, flags )
j, # loop over `flagspos'
imm, # immediate methods for filter `j'
i, # loop over `imm'
meth,
res, # result of an immediate method
loc,
newflags; # newly found filters

# Avoid recursive calls from inside a setter,
Expand All @@ -49,6 +52,11 @@ BIND_GLOBAL( "RunImmediateMethods", function ( obj, flags )
type := TYPE_OBJ( obj );
flags := type![2];

RUN_IMMEDIATE_METHODS_RUNS := RUN_IMMEDIATE_METHODS_RUNS + 1;
if TRACE_IMMEDIATE_METHODS then
Print( "#I RunImmediateMethods\n");
fi;

# Check the immediate methods for all in `flagspos'.
# (Note that new information is handled via appending to that list.)
for j in flagspos do
Expand All @@ -63,24 +71,25 @@ BIND_GLOBAL( "RunImmediateMethods", function ( obj, flags )
if IsBound( IMMEDIATES[j] ) then
#T the `if' statement can disappear when `IMM_FLAGS' is improved ...
imm := IMMEDIATES[j];
for i in [ 0, 7 .. LEN_LIST(imm)-7 ] do
for i in [ 0, SIZE_IMMEDIATE_METHOD_ENTRY .. LEN_LIST(imm)-SIZE_IMMEDIATE_METHOD_ENTRY ] do

if IS_SUBSET_FLAGS( flags, imm[i+4] )
and not IS_SUBSET_FLAGS( flags, imm[i+3] )
and not imm[i+6] in tried
then

# Call the method, and store that it was used.
res := IMMEDIATE_METHODS[ imm[i+6] ]( obj );
meth := IMMEDIATE_METHODS[ imm[i+6] ];
res := meth( obj );
ADD_LIST( tried, imm[i+6] );
RUN_IMMEDIATE_METHODS_CHECKS :=
RUN_IMMEDIATE_METHODS_CHECKS+1;
if TRACE_IMMEDIATE_METHODS then
if imm[i+7] = false then
Print( "#I immediate: ", NAME_FUNC( imm[i+1] ), "\n");
else
Print( "#I immediate: ", NAME_FUNC( imm[i+1] ), ": ", imm[i+7], "\n" );
Print( "#I immediate: ", NAME_FUNC( imm[i+1] ));
if imm[i+7] <> false then
Print( ": ", imm[i+7] );
fi;
Print(" at ", imm[i+8][1], ":", imm[i+8][2], "\n");
fi;

if res <> TRY_NEXT_METHOD then
Expand Down Expand Up @@ -174,7 +183,7 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS",
# find the place to put the new method
i := 0;
while i < LEN_LIST(methods) and rank < methods[i+(narg+3)] do
i := i + (narg+4);
i := i + (narg+BASE_SIZE_METHODS_OPER_ENTRY);
od;

# Now is a good time to see if the method is already there
Expand All @@ -196,12 +205,12 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS",
break;
fi;
fi;
k := k+narg+4;
k := k+narg+BASE_SIZE_METHODS_OPER_ENTRY;
od;
fi;
# push the other functions back
if not REREADING or not replace then
methods{[narg+4+i+1..narg+4+LEN_LIST(methods)]}
methods{[narg+BASE_SIZE_METHODS_OPER_ENTRY+i+1..narg+BASE_SIZE_METHODS_OPER_ENTRY+LEN_LIST(methods)]}
:= methods{[i+1..LEN_LIST(methods)]};
fi;

Expand Down Expand Up @@ -250,6 +259,9 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS",
methods[i+(narg+3)] := rank;

methods[i+(narg+4)] := IMMUTABLE_COPY_OBJ(info);
if BASE_SIZE_METHODS_OPER_ENTRY >= 5 then
methods[i+(narg+5)] := MakeImmutable([INPUT_FILENAME(), INPUT_LINENUMBER()]);
fi;

# flush the cache
if IsHPCGAP then
Expand Down Expand Up @@ -572,7 +584,7 @@ end );
##
## The default setter method does nothing.
##
LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + 6; # one method
LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (BASE_SIZE_METHODS_OPER_ENTRY+2); # one method

InstallAttributeFunction(
function ( name, filter, getter, setter, tester, mutflag )
Expand Down
Loading