From be8920b104ac0bfaa02d6193d787c2a0d2fd6d52 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Wed, 6 Jun 2018 13:16:25 +0100 Subject: [PATCH 01/12] Record rank adjustment in METHODS_OPERATION --- lib/oper1.g | 20 ++-- src/c_oper1.c | 180 +++++++++++++++++++++++------------- src/c_type1.c | 4 +- tst/testinstall/varargs.tst | 2 +- 4 files changed, 131 insertions(+), 75 deletions(-) diff --git a/lib/oper1.g b/lib/oper1.g index 5ae4ecd52f..c717fa18c2 100644 --- a/lib/oper1.g +++ b/lib/oper1.g @@ -144,7 +144,7 @@ fi; ## BIND_GLOBAL( "INSTALL_METHOD_FLAGS", function( opr, info, rel, flags, rank, method ) - local methods, narg, i, k, tmp, replace, match, j, lk; + local methods, narg, i, k, tmp, replace, match, j, lk, ranknow; if IsHPCGAP then # TODO: once the GAP compiler supports 'atomic', use that @@ -152,13 +152,18 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", lk := WRITE_LOCK(METHODS_OPERATION_REGION); fi; # add the number of filters required for each argument + if IS_FUNCTION(rank) then + ranknow := rank(); + else + ranknow := rank; + fi; if IS_CONSTRUCTOR(opr) then if 0 < LEN_LIST(flags) then - rank := rank - RankFilter( flags[ 1 ] ); + ranknow := ranknow - RankFilter( flags[ 1 ] ); fi; else for i in flags do - rank := rank + RankFilter( i ); + ranknow := ranknow + RankFilter( i ); od; fi; @@ -182,7 +187,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 + while i < LEN_LIST(methods) and ranknow < methods[i+(narg+3)] do i := i + (narg+BASE_SIZE_METHODS_OPER_ENTRY); od; @@ -191,7 +196,7 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", if REREADING then k := i; while k < LEN_LIST(methods) and - rank = methods[k+narg+3] do + ranknow = methods[k+narg+3] do if info = methods[k+narg+4] then # ForAll not available @@ -256,11 +261,14 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", Error(NAME_FUNC(opr), ": must be a function, `true', or `false'" ); fi; - methods[i+(narg+3)] := rank; + methods[i+(narg+3)] := ranknow; methods[i+(narg+4)] := IMMUTABLE_COPY_OBJ(info); if BASE_SIZE_METHODS_OPER_ENTRY >= 5 then methods[i+(narg+5)] := MakeImmutable([INPUT_FILENAME(), READEVALCOMMAND_LINENUMBER, INPUT_LINENUMBER()]); + if BASE_SIZE_METHODS_OPER_ENTRY >= 6 then + methods[i+(narg+6)] := rank; + fi; fi; # flush the cache diff --git a/src/c_oper1.c b/src/c_oper1.c index 35886bdeb8..370f097448 100644 --- a/src/c_oper1.c +++ b/src/c_oper1.c @@ -1,7 +1,7 @@ #ifndef AVOID_PRECOMPILED /* C file produced by GAC */ #include "compiled.h" -#define FILE_CRC "93694864" +#define FILE_CRC "65425009" /* global variables used in handlers */ static GVar G_REREADING; @@ -613,6 +613,7 @@ static Obj HdlrFunc3 ( Obj l_match = 0; Obj l_j = 0; Obj l_lk = 0; + Obj l_ranknow = 0; Obj t_1 = 0; Obj t_2 = 0; Obj t_3 = 0; @@ -630,6 +631,7 @@ static Obj HdlrFunc3 ( (void)l_match; (void)l_j; (void)l_lk; + (void)l_ranknow; Bag oldFrame; OLD_BRK_CURR_STAT @@ -638,6 +640,31 @@ static Obj HdlrFunc3 ( REM_BRK_CURR_STAT(); SET_BRK_CURR_STAT(0); + /* if IS_FUNCTION( rank ) then */ + t_3 = GF_IS__FUNCTION; + t_2 = CALL_1ARGS( t_3, a_rank ); + CHECK_FUNC_RESULT( t_2 ) + CHECK_BOOL( t_2 ) + t_1 = (Obj)(UInt)(t_2 != False); + if ( t_1 ) { + + /* ranknow := rank( ); */ + CHECK_FUNC( a_rank ) + t_1 = CALL_0ARGS( a_rank ); + CHECK_FUNC_RESULT( t_1 ) + l_ranknow = t_1; + + } + + /* else */ + else { + + /* ranknow := rank; */ + l_ranknow = a_rank; + + } + /* fi */ + /* if IS_CONSTRUCTOR( opr ) then */ t_3 = GF_IS__CONSTRUCTOR; t_2 = CALL_1ARGS( t_3, a_opr ); @@ -653,13 +680,13 @@ static Obj HdlrFunc3 ( t_1 = (Obj)(UInt)(LT( INTOBJ_INT(0), t_2 )); if ( t_1 ) { - /* rank := rank - RankFilter( flags[1] ); */ + /* ranknow := ranknow - RankFilter( flags[1] ); */ t_3 = GF_RankFilter; C_ELM_LIST_FPL( t_4, a_flags, INTOBJ_INT(1) ) t_2 = CALL_1ARGS( t_3, t_4 ); CHECK_FUNC_RESULT( t_2 ) - C_DIFF_FIA( t_1, a_rank, t_2 ) - a_rank = t_1; + C_DIFF_FIA( t_1, l_ranknow, t_2 ) + l_ranknow = t_1; } /* fi */ @@ -692,12 +719,12 @@ static Obj HdlrFunc3 ( } l_i = t_2; - /* rank := rank + RankFilter( i ); */ + /* ranknow := ranknow + RankFilter( i ); */ t_7 = GF_RankFilter; t_6 = CALL_1ARGS( t_7, l_i ); CHECK_FUNC_RESULT( t_6 ) - C_SUM_FIA( t_5, a_rank, t_6 ) - a_rank = t_5; + C_SUM_FIA( t_5, l_ranknow, t_6 ) + l_ranknow = t_5; } /* od */ @@ -764,7 +791,7 @@ static Obj HdlrFunc3 ( /* i := 0; */ l_i = INTOBJ_INT(0); - /* while i < LEN_LIST( methods ) and rank < methods[i + (narg + 3)] od */ + /* while i < LEN_LIST( methods ) and ranknow < methods[i + (narg + 3)] od */ while ( 1 ) { t_4 = GF_LEN__LIST; t_3 = CALL_1ARGS( t_4, l_methods ); @@ -776,13 +803,13 @@ static Obj HdlrFunc3 ( C_SUM_FIA( t_5, l_i, t_6 ) CHECK_INT_POS( t_5 ) C_ELM_LIST_FPL( t_4, l_methods, t_5 ) - t_3 = (Obj)(UInt)(LT( a_rank, t_4 )); + t_3 = (Obj)(UInt)(LT( l_ranknow, t_4 )); t_1 = t_3; } if ( ! t_1 ) break; - /* i := i + (narg + 5); */ - C_SUM_FIA( t_2, l_narg, INTOBJ_INT(5) ) + /* i := i + (narg + 6); */ + C_SUM_FIA( t_2, l_narg, INTOBJ_INT(6) ) C_SUM_FIA( t_1, l_i, t_2 ) l_i = t_1; @@ -803,7 +830,7 @@ static Obj HdlrFunc3 ( /* k := i; */ l_k = l_i; - /* while k < LEN_LIST( methods ) and rank = methods[k + narg + 3] od */ + /* while k < LEN_LIST( methods ) and ranknow = methods[k + narg + 3] od */ while ( 1 ) { t_4 = GF_LEN__LIST; t_3 = CALL_1ARGS( t_4, l_methods ); @@ -815,7 +842,7 @@ static Obj HdlrFunc3 ( C_SUM_FIA( t_5, t_6, INTOBJ_INT(3) ) CHECK_INT_POS( t_5 ) C_ELM_LIST_FPL( t_4, l_methods, t_5 ) - t_3 = (Obj)(UInt)(EQ( a_rank, t_4 )); + t_3 = (Obj)(UInt)(EQ( l_ranknow, t_4 )); t_1 = t_3; } if ( ! t_1 ) break; @@ -890,9 +917,9 @@ static Obj HdlrFunc3 ( } /* fi */ - /* k := k + narg + 5; */ + /* k := k + narg + 6; */ C_SUM_FIA( t_2, l_k, l_narg ) - C_SUM_FIA( t_1, t_2, INTOBJ_INT(5) ) + C_SUM_FIA( t_1, t_2, INTOBJ_INT(6) ) l_k = t_1; } @@ -915,11 +942,11 @@ static Obj HdlrFunc3 ( } if ( t_1 ) { - /* methods{[ narg + 5 + i + 1 .. narg + 5 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; */ - C_SUM_FIA( t_4, l_narg, INTOBJ_INT(5) ) + /* methods{[ narg + 6 + i + 1 .. narg + 6 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; */ + C_SUM_FIA( t_4, l_narg, INTOBJ_INT(6) ) C_SUM_FIA( t_3, t_4, l_i ) C_SUM_FIA( t_2, t_3, INTOBJ_INT(1) ) - C_SUM_FIA( t_4, l_narg, INTOBJ_INT(5) ) + C_SUM_FIA( t_4, l_narg, INTOBJ_INT(6) ) t_6 = GF_LEN__LIST; t_5 = CALL_1ARGS( t_6, l_methods ); CHECK_FUNC_RESULT( t_5 ) @@ -1181,11 +1208,11 @@ static Obj HdlrFunc3 ( } /* fi */ - /* methods[i + (narg + 3)] := rank; */ + /* methods[i + (narg + 3)] := ranknow; */ C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(3) ) C_SUM_FIA( t_1, l_i, t_2 ) CHECK_INT_POS( t_1 ) - C_ASS_LIST_FPL( l_methods, t_1, a_rank ) + C_ASS_LIST_FPL( l_methods, t_1, l_ranknow ) /* methods[i + (narg + 4)] := IMMUTABLE_COPY_OBJ( info ); */ C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(4) ) @@ -1196,8 +1223,8 @@ static Obj HdlrFunc3 ( CHECK_FUNC_RESULT( t_2 ) C_ASS_LIST_FPL( l_methods, t_1, t_2 ) - /* if 5 >= 5 then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(5)) >= ((Int)INTOBJ_INT(5))); + /* if 6 >= 5 then */ + t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(6)) >= ((Int)INTOBJ_INT(5))); if ( t_1 ) { /* methods[i + (narg + 5)] := MakeImmutable( [ INPUT_FILENAME( ), READEVALCOMMAND_LINENUMBER, INPUT_LINENUMBER( ) ] ); */ @@ -1225,6 +1252,19 @@ static Obj HdlrFunc3 ( CHECK_FUNC_RESULT( t_2 ) C_ASS_LIST_FPL( l_methods, t_1, t_2 ) + /* if 6 >= 6 then */ + t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(6)) >= ((Int)INTOBJ_INT(6))); + if ( t_1 ) { + + /* methods[i + (narg + 6)] := rank; */ + C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(6) ) + C_SUM_FIA( t_1, l_i, t_2 ) + CHECK_INT_POS( t_1 ) + C_ASS_LIST_FPL( l_methods, t_1, a_rank ) + + } + /* fi */ + } /* fi */ @@ -2685,8 +2725,8 @@ static Obj HdlrFunc7 ( t_6 = NewFunction( NameFunc[8], 1, 0, HdlrFunc8 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 651); - SET_ENDLINE_BODY(t_7, 669); + SET_STARTLINE_BODY(t_7, 659); + SET_ENDLINE_BODY(t_7, 677); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3289,8 +3329,8 @@ static Obj HdlrFunc11 ( t_1 = NewFunction( NameFunc[12], 1, 0, HdlrFunc12 ); SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); t_2 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_2, 848); - SET_ENDLINE_BODY(t_2, 852); + SET_STARTLINE_BODY(t_2, 856); + SET_ENDLINE_BODY(t_2, 860); SET_FILENAME_BODY(t_2, FileName); SET_BODY_FUNC(t_1, t_2); CHANGED_BAG( STATE(CurrLVars) ); @@ -3369,8 +3409,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[13], 1, 0, HdlrFunc13 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 869); - SET_ENDLINE_BODY(t_7, 869); + SET_STARTLINE_BODY(t_7, 877); + SET_ENDLINE_BODY(t_7, 877); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3432,8 +3472,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[14], 2, 0, HdlrFunc14 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 891); - SET_ENDLINE_BODY(t_7, 914); + SET_STARTLINE_BODY(t_7, 899); + SET_ENDLINE_BODY(t_7, 922); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3481,8 +3521,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[15], 2, 0, HdlrFunc15 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 924); - SET_ENDLINE_BODY(t_7, 932); + SET_STARTLINE_BODY(t_7, 932); + SET_ENDLINE_BODY(t_7, 940); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3543,8 +3583,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[16], 3, 0, HdlrFunc16 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 941); - SET_ENDLINE_BODY(t_7, 954); + SET_STARTLINE_BODY(t_7, 949); + SET_ENDLINE_BODY(t_7, 962); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3917,8 +3957,8 @@ static Obj HdlrFunc17 ( t_4 = NewFunction( NameFunc[18], -1, 0, HdlrFunc18 ); SET_ENVI_FUNC( t_4, STATE(CurrLVars) ); t_5 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_5, 1020); - SET_ENDLINE_BODY(t_5, 1036); + SET_STARTLINE_BODY(t_5, 1028); + SET_ENDLINE_BODY(t_5, 1044); SET_FILENAME_BODY(t_5, FileName); SET_BODY_FUNC(t_4, t_5); CHANGED_BAG( STATE(CurrLVars) ); @@ -4027,15 +4067,20 @@ static Obj HdlrFunc1 ( CALL_2ARGS( t_1, t_2, t_3 ); /* BIND_GLOBAL( "INSTALL_METHOD_FLAGS", function ( opr, info, rel, flags, rank, method ) - local methods, narg, i, k, tmp, replace, match, j, lk; + local methods, narg, i, k, tmp, replace, match, j, lk, ranknow; ; + if IS_FUNCTION( rank ) then + ranknow := rank( ); + else + ranknow := rank; + fi; if IS_CONSTRUCTOR( opr ) then if 0 < LEN_LIST( flags ) then - rank := rank - RankFilter( flags[1] ); + ranknow := ranknow - RankFilter( flags[1] ); fi; else for i in flags do - rank := rank + RankFilter( i ); + ranknow := ranknow + RankFilter( i ); od; fi; narg := LEN_LIST( flags ); @@ -4051,13 +4096,13 @@ static Obj HdlrFunc1 ( CONV_STRING( info ); fi; i := 0; - while i < LEN_LIST( methods ) and rank < methods[i + (narg + 3)] do - i := i + (narg + 5); + while i < LEN_LIST( methods ) and ranknow < methods[i + (narg + 3)] do + i := i + (narg + 6); od; replace := false; if REREADING then k := i; - while k < LEN_LIST( methods ) and rank = methods[k + narg + 3] do + while k < LEN_LIST( methods ) and ranknow = methods[k + narg + 3] do if info = methods[k + narg + 4] then match := false; for j in [ 1 .. narg ] do @@ -4069,11 +4114,11 @@ static Obj HdlrFunc1 ( break; fi; fi; - k := k + narg + 5; + k := k + narg + 6; od; fi; if not REREADING or not replace then - methods{[ narg + 5 + i + 1 .. narg + 5 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; + methods{[ narg + 6 + i + 1 .. narg + 6 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; fi; if rel = true then methods[i + 1] := RETURN_TRUE; @@ -4108,10 +4153,13 @@ static Obj HdlrFunc1 ( else Error( NAME_FUNC( opr ), ": must be a function, `true', or `false'" ); fi; - methods[i + (narg + 3)] := rank; + methods[i + (narg + 3)] := ranknow; methods[i + (narg + 4)] := IMMUTABLE_COPY_OBJ( info ); - if 5 >= 5 then + if 6 >= 5 then methods[i + (narg + 5)] := MakeImmutable( [ INPUT_FILENAME( ), READEVALCOMMAND_LINENUMBER, INPUT_LINENUMBER( ) ] ); + if 6 >= 6 then + methods[i + (narg + 6)] := rank; + fi; fi; CHANGED_METHODS_OPERATION( opr, narg ); return; @@ -4122,7 +4170,7 @@ static Obj HdlrFunc1 ( SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); SET_STARTLINE_BODY(t_4, 146); - SET_ENDLINE_BODY(t_4, 273); + SET_ENDLINE_BODY(t_4, 281); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4137,8 +4185,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[4], -1, 0, HdlrFunc4 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 320); - SET_ENDLINE_BODY(t_4, 322); + SET_STARTLINE_BODY(t_4, 328); + SET_ENDLINE_BODY(t_4, 330); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4153,8 +4201,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[5], -1, 0, HdlrFunc5 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 347); - SET_ENDLINE_BODY(t_4, 349); + SET_STARTLINE_BODY(t_4, 355); + SET_ENDLINE_BODY(t_4, 357); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4323,17 +4371,17 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[6], 2, 0, HdlrFunc6 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 360); - SET_ENDLINE_BODY(t_4, 590); + SET_STARTLINE_BODY(t_4, 368); + SET_ENDLINE_BODY(t_4, 598); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); CALL_2ARGS( t_1, t_2, t_3 ); - /* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (5 + 2); */ + /* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (6 + 2); */ t_2 = GC_LENGTH__SETTER__METHODS__2; CHECK_BOUND( t_2, "LENGTH_SETTER_METHODS_2" ) - C_SUM_INTOBJS( t_3, INTOBJ_INT(5), INTOBJ_INT(2) ) + C_SUM_INTOBJS( t_3, INTOBJ_INT(6), INTOBJ_INT(2) ) C_SUM_FIA( t_1, t_2, t_3 ) AssGVar( G_LENGTH__SETTER__METHODS__2, t_1 ); @@ -4382,8 +4430,8 @@ static Obj HdlrFunc1 ( t_2 = NewFunction( NameFunc[7], 6, 0, HdlrFunc7 ); SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); t_3 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_3, 609); - SET_ENDLINE_BODY(t_3, 673); + SET_STARTLINE_BODY(t_3, 617); + SET_ENDLINE_BODY(t_3, 681); SET_FILENAME_BODY(t_3, FileName); SET_BODY_FUNC(t_2, t_3); CHANGED_BAG( STATE(CurrLVars) ); @@ -4397,8 +4445,8 @@ static Obj HdlrFunc1 ( t_2 = NewFunction( NameFunc[9], 6, 0, HdlrFunc9 ); SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); t_3 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_3, 676); - SET_ENDLINE_BODY(t_3, 682); + SET_STARTLINE_BODY(t_3, 684); + SET_ENDLINE_BODY(t_3, 690); SET_FILENAME_BODY(t_3, FileName); SET_BODY_FUNC(t_2, t_3); CHANGED_BAG( STATE(CurrLVars) ); @@ -4426,8 +4474,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[10], 2, 0, HdlrFunc10 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 695); - SET_ENDLINE_BODY(t_4, 719); + SET_STARTLINE_BODY(t_4, 703); + SET_ENDLINE_BODY(t_4, 727); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4511,8 +4559,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[11], 4, 0, HdlrFunc11 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 844); - SET_ENDLINE_BODY(t_4, 955); + SET_STARTLINE_BODY(t_4, 852); + SET_ENDLINE_BODY(t_4, 963); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4563,8 +4611,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[17], -1, 0, HdlrFunc17 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 990); - SET_ENDLINE_BODY(t_4, 1037); + SET_STARTLINE_BODY(t_4, 998); + SET_ENDLINE_BODY(t_4, 1045); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4871,7 +4919,7 @@ static Int InitLibrary ( StructInitInfo * module ) static StructInitInfo module = { .type = MODULE_STATIC, .name = "GAPROOT/lib/oper1.g", - .crc = 93694864, + .crc = 65425009, .initKernel = InitKernel, .initLibrary = InitLibrary, .postRestore = PostRestore, diff --git a/src/c_type1.c b/src/c_type1.c index 79a54f9985..387f98010a 100644 --- a/src/c_type1.c +++ b/src/c_type1.c @@ -3320,10 +3320,10 @@ static Obj HdlrFunc1 ( CHANGED_BAG( STATE(CurrLVars) ); CALL_1ARGS( t_1, t_2 ); - /* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (5 + 2); */ + /* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (6 + 2); */ t_2 = GC_LENGTH__SETTER__METHODS__2; CHECK_BOUND( t_2, "LENGTH_SETTER_METHODS_2" ) - C_SUM_INTOBJS( t_3, INTOBJ_INT(5), INTOBJ_INT(2) ) + C_SUM_INTOBJS( t_3, INTOBJ_INT(6), INTOBJ_INT(2) ) C_SUM_FIA( t_1, t_2, t_3 ) AssGVar( G_LENGTH__SETTER__METHODS__2, t_1 ); diff --git a/tst/testinstall/varargs.tst b/tst/testinstall/varargs.tst index 1038e5db22..785058583c 100644 --- a/tst/testinstall/varargs.tst +++ b/tst/testinstall/varargs.tst @@ -87,7 +87,7 @@ function ( <>, <>, <>, <>, <>, <> ) end gap> Display(InstallMethod); function ( <>... ) - <> + <> end gap> [1..2]; [ 1, 2 ] From 7812f31f8b2ab0fd087514a185461db0eb4a4574 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Wed, 6 Jun 2018 16:43:31 +0100 Subject: [PATCH 02/12] Add RECALCULATE_ALL_METHOD_RANKS function which does what it says. Adjust MethodsOperation to include base rank --- lib/filter.g | 34 +++++++++- lib/oper.g | 76 ++++++++++++++++++++- lib/oper1.g | 22 +++---- src/c_oper1.c | 76 ++++++++++----------- src/hpc/c_oper1.c | 164 ++++++++++++++++++++++++++++++---------------- src/hpc/c_type1.c | 4 +- src/opers.c | 5 +- 7 files changed, 269 insertions(+), 112 deletions(-) diff --git a/lib/filter.g b/lib/filter.g index a3afa1ea0e..afd23f9aab 100644 --- a/lib/filter.g +++ b/lib/filter.g @@ -214,10 +214,42 @@ end ); ## ## <#/GAPDoc> ## + +# +# Function is defined in oper.g +# +RECALCULATE_ALL_METHOD_RANKS := fail; + +REORDER_METHODS_SUSPENSION_LEVEL := 1; + +BIND_GLOBAL( "SuspendMethodReordering", function() + REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL + 1; +end); + + +BIND_GLOBAL( "ResumeMethodReordering", function() + REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL - 1; + if REORDER_METHODS_SUSPENSION_LEVEL = 0 then + RECALCULATE_ALL_METHOD_RANKS(); + fi; +end); + +BIND_GLOBAL( "ResetMethodReordering", function() + REORDER_METHODS_SUSPENSION_LEVEL := 0; + RECALCULATE_ALL_METHOD_RANKS(); +end); + + + + BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from ) InstallTrueMethodNewFilter( tofilt, from ); - + + if REORDER_METHODS_SUSPENSION_LEVEL = 0 then + RECALCULATE_ALL_METHOD_RANKS(); + fi; + # clear the caches because we do not know if filter is new CLEAR_HIDDEN_IMP_CACHE( from ); CLEAR_IMP_CACHE(); diff --git a/lib/oper.g b/lib/oper.g index b642d809ce..b6c4d6528a 100644 --- a/lib/oper.g +++ b/lib/oper.g @@ -1931,7 +1931,7 @@ end); fi; -if BASE_SIZE_METHODS_OPER_ENTRY <> 5 then +if BASE_SIZE_METHODS_OPER_ENTRY <> 6 then Error("MethodsOperation must be updated for new BASE_SIZE_METHODS_OPER_ENTRY"); fi; @@ -1952,6 +1952,7 @@ BIND_GLOBAL("MethodsOperation", function(oper, nargs) func := meths[i + nargs + 2], rank := meths[i + nargs + 3], info := meths[i + nargs + 4], + rankbase := meths[i + nargs + 6], ); ADD_LIST(result, m); if IsBound(meths[i + nargs + 5]) then @@ -1961,6 +1962,79 @@ BIND_GLOBAL("MethodsOperation", function(oper, nargs) return result; end ); +# +# We had to install a placeholder for this in filter.g +# +Unbind(RECALCULATE_ALL_METHOD_RANKS); + +PRINT_REORDERED_METHODS := false; + +BIND_GLOBAL( "RECALCULATE_ALL_METHOD_RANKS", function() + local oper, n, changed, meths, nmethods, i, base, rank, j, req, + req2, k, l; + + for oper in OPERATIONS do + if IS_CONSTRUCTOR(oper) then + # FIXME do something for constructors + continue; + fi; + + for n in [0..6] do + changed := false; + meths := METHODS_OPERATION(oper, n); + nmethods := LENGTH(meths)/(BASE_SIZE_METHODS_OPER_ENTRY+n); + for i in [1 ..nmethods] do + base := (i-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n); + # data for this method is meths{[base+1..base+BASE_SIZE_METHODS_OPER_ENTRY + n]} + rank := meths[base+6+n]; + if IS_FUNCTION(rank) then + rank := rank(); + fi; + for j in [1..n] do + req := meths[base+1+j]; + rank := rank+RankFilter(WITH_IMPS_FLAGS(req)); + od; + if rank = meths[base+n+3] then + continue; + fi; + meths[base+n+3] := rank; + # compare to rank of preceding method + if i = 1 or rank <= meths[base-BASE_SIZE_METHODS_OPER_ENTRY+3] then + continue; + fi; + + changed := true; + k := i-2; + while k > 1 and meths[(k-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n) + n + 3] < rank do + k := k-1; + od; + k := k+1; + if PRINT_REORDERED_METHODS then + Print(NAME_FUNC(oper), " ", n," args. Moving method ",i," (", + meths[base+n+4]," from ",meths[base+n+5][1],":", meths[base+n+5][2], + ") to position ",k,"\n"); + fi; + l := meths{[base+1..base+n+BASE_SIZE_METHODS_OPER_ENTRY]}; + COPY_LIST_ENTRIES(meths, 1 + (k-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY), 1, + meths, 1 + k*(n+BASE_SIZE_METHODS_OPER_ENTRY), 1, + (i-k)*(n+BASE_SIZE_METHODS_OPER_ENTRY)); + meths{[1 + (k-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY).. + k*(n+BASE_SIZE_METHODS_OPER_ENTRY)]} := l; + od; + od; + if changed then + CHANGED_METHODS_OPERATION(oper,n); + fi; + od; +end ); + + + + + + + + ############################################################################# ## #E diff --git a/lib/oper1.g b/lib/oper1.g index c717fa18c2..b12f04a75c 100644 --- a/lib/oper1.g +++ b/lib/oper1.g @@ -143,8 +143,8 @@ fi; #F INSTALL_METHOD_FLAGS( , , , , , ) . ## BIND_GLOBAL( "INSTALL_METHOD_FLAGS", - function( opr, info, rel, flags, rank, method ) - local methods, narg, i, k, tmp, replace, match, j, lk, ranknow; + function( opr, info, rel, flags, baserank, method ) + local methods, narg, i, k, tmp, replace, match, j, lk, rank; if IsHPCGAP then # TODO: once the GAP compiler supports 'atomic', use that @@ -152,18 +152,18 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", lk := WRITE_LOCK(METHODS_OPERATION_REGION); fi; # add the number of filters required for each argument - if IS_FUNCTION(rank) then - ranknow := rank(); + if IS_FUNCTION(baserank) then + rank := baserank(); else - ranknow := rank; + rank := baserank; fi; if IS_CONSTRUCTOR(opr) then if 0 < LEN_LIST(flags) then - ranknow := ranknow - RankFilter( flags[ 1 ] ); + rank := rank - RankFilter( flags[ 1 ] ); fi; else for i in flags do - ranknow := ranknow + RankFilter( i ); + rank := rank + RankFilter( i ); od; fi; @@ -187,7 +187,7 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", # find the place to put the new method i := 0; - while i < LEN_LIST(methods) and ranknow < methods[i+(narg+3)] do + while i < LEN_LIST(methods) and rank < methods[i+(narg+3)] do i := i + (narg+BASE_SIZE_METHODS_OPER_ENTRY); od; @@ -196,7 +196,7 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", if REREADING then k := i; while k < LEN_LIST(methods) and - ranknow = methods[k+narg+3] do + rank = methods[k+narg+3] do if info = methods[k+narg+4] then # ForAll not available @@ -261,13 +261,13 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", Error(NAME_FUNC(opr), ": must be a function, `true', or `false'" ); fi; - methods[i+(narg+3)] := ranknow; + 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(), READEVALCOMMAND_LINENUMBER, INPUT_LINENUMBER()]); if BASE_SIZE_METHODS_OPER_ENTRY >= 6 then - methods[i+(narg+6)] := rank; + methods[i+(narg+6)] := baserank; fi; fi; diff --git a/src/c_oper1.c b/src/c_oper1.c index 370f097448..bfc5f67a9c 100644 --- a/src/c_oper1.c +++ b/src/c_oper1.c @@ -1,7 +1,7 @@ #ifndef AVOID_PRECOMPILED /* C file produced by GAC */ #include "compiled.h" -#define FILE_CRC "65425009" +#define FILE_CRC "96238222" /* global variables used in handlers */ static GVar G_REREADING; @@ -601,7 +601,7 @@ static Obj HdlrFunc3 ( Obj a_info, Obj a_rel, Obj a_flags, - Obj a_rank, + Obj a_baserank, Obj a_method ) { Obj l_methods = 0; @@ -613,7 +613,7 @@ static Obj HdlrFunc3 ( Obj l_match = 0; Obj l_j = 0; Obj l_lk = 0; - Obj l_ranknow = 0; + Obj l_rank = 0; Obj t_1 = 0; Obj t_2 = 0; Obj t_3 = 0; @@ -631,7 +631,7 @@ static Obj HdlrFunc3 ( (void)l_match; (void)l_j; (void)l_lk; - (void)l_ranknow; + (void)l_rank; Bag oldFrame; OLD_BRK_CURR_STAT @@ -640,27 +640,27 @@ static Obj HdlrFunc3 ( REM_BRK_CURR_STAT(); SET_BRK_CURR_STAT(0); - /* if IS_FUNCTION( rank ) then */ + /* if IS_FUNCTION( baserank ) then */ t_3 = GF_IS__FUNCTION; - t_2 = CALL_1ARGS( t_3, a_rank ); + t_2 = CALL_1ARGS( t_3, a_baserank ); CHECK_FUNC_RESULT( t_2 ) CHECK_BOOL( t_2 ) t_1 = (Obj)(UInt)(t_2 != False); if ( t_1 ) { - /* ranknow := rank( ); */ - CHECK_FUNC( a_rank ) - t_1 = CALL_0ARGS( a_rank ); + /* rank := baserank( ); */ + CHECK_FUNC( a_baserank ) + t_1 = CALL_0ARGS( a_baserank ); CHECK_FUNC_RESULT( t_1 ) - l_ranknow = t_1; + l_rank = t_1; } /* else */ else { - /* ranknow := rank; */ - l_ranknow = a_rank; + /* rank := baserank; */ + l_rank = a_baserank; } /* fi */ @@ -680,13 +680,13 @@ static Obj HdlrFunc3 ( t_1 = (Obj)(UInt)(LT( INTOBJ_INT(0), t_2 )); if ( t_1 ) { - /* ranknow := ranknow - RankFilter( flags[1] ); */ + /* rank := rank - RankFilter( flags[1] ); */ t_3 = GF_RankFilter; C_ELM_LIST_FPL( t_4, a_flags, INTOBJ_INT(1) ) t_2 = CALL_1ARGS( t_3, t_4 ); CHECK_FUNC_RESULT( t_2 ) - C_DIFF_FIA( t_1, l_ranknow, t_2 ) - l_ranknow = t_1; + C_DIFF_FIA( t_1, l_rank, t_2 ) + l_rank = t_1; } /* fi */ @@ -719,12 +719,12 @@ static Obj HdlrFunc3 ( } l_i = t_2; - /* ranknow := ranknow + RankFilter( i ); */ + /* rank := rank + RankFilter( i ); */ t_7 = GF_RankFilter; t_6 = CALL_1ARGS( t_7, l_i ); CHECK_FUNC_RESULT( t_6 ) - C_SUM_FIA( t_5, l_ranknow, t_6 ) - l_ranknow = t_5; + C_SUM_FIA( t_5, l_rank, t_6 ) + l_rank = t_5; } /* od */ @@ -791,7 +791,7 @@ static Obj HdlrFunc3 ( /* i := 0; */ l_i = INTOBJ_INT(0); - /* while i < LEN_LIST( methods ) and ranknow < methods[i + (narg + 3)] od */ + /* while i < LEN_LIST( methods ) and rank < methods[i + (narg + 3)] od */ while ( 1 ) { t_4 = GF_LEN__LIST; t_3 = CALL_1ARGS( t_4, l_methods ); @@ -803,7 +803,7 @@ static Obj HdlrFunc3 ( C_SUM_FIA( t_5, l_i, t_6 ) CHECK_INT_POS( t_5 ) C_ELM_LIST_FPL( t_4, l_methods, t_5 ) - t_3 = (Obj)(UInt)(LT( l_ranknow, t_4 )); + t_3 = (Obj)(UInt)(LT( l_rank, t_4 )); t_1 = t_3; } if ( ! t_1 ) break; @@ -830,7 +830,7 @@ static Obj HdlrFunc3 ( /* k := i; */ l_k = l_i; - /* while k < LEN_LIST( methods ) and ranknow = methods[k + narg + 3] od */ + /* while k < LEN_LIST( methods ) and rank = methods[k + narg + 3] od */ while ( 1 ) { t_4 = GF_LEN__LIST; t_3 = CALL_1ARGS( t_4, l_methods ); @@ -842,7 +842,7 @@ static Obj HdlrFunc3 ( C_SUM_FIA( t_5, t_6, INTOBJ_INT(3) ) CHECK_INT_POS( t_5 ) C_ELM_LIST_FPL( t_4, l_methods, t_5 ) - t_3 = (Obj)(UInt)(EQ( l_ranknow, t_4 )); + t_3 = (Obj)(UInt)(EQ( l_rank, t_4 )); t_1 = t_3; } if ( ! t_1 ) break; @@ -1208,11 +1208,11 @@ static Obj HdlrFunc3 ( } /* fi */ - /* methods[i + (narg + 3)] := ranknow; */ + /* methods[i + (narg + 3)] := rank; */ C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(3) ) C_SUM_FIA( t_1, l_i, t_2 ) CHECK_INT_POS( t_1 ) - C_ASS_LIST_FPL( l_methods, t_1, l_ranknow ) + C_ASS_LIST_FPL( l_methods, t_1, l_rank ) /* methods[i + (narg + 4)] := IMMUTABLE_COPY_OBJ( info ); */ C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(4) ) @@ -1256,11 +1256,11 @@ static Obj HdlrFunc3 ( t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(6)) >= ((Int)INTOBJ_INT(6))); if ( t_1 ) { - /* methods[i + (narg + 6)] := rank; */ + /* methods[i + (narg + 6)] := baserank; */ C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(6) ) C_SUM_FIA( t_1, l_i, t_2 ) CHECK_INT_POS( t_1 ) - C_ASS_LIST_FPL( l_methods, t_1, a_rank ) + C_ASS_LIST_FPL( l_methods, t_1, a_baserank ) } /* fi */ @@ -4066,21 +4066,21 @@ static Obj HdlrFunc1 ( CHANGED_BAG( STATE(CurrLVars) ); CALL_2ARGS( t_1, t_2, t_3 ); - /* BIND_GLOBAL( "INSTALL_METHOD_FLAGS", function ( opr, info, rel, flags, rank, method ) - local methods, narg, i, k, tmp, replace, match, j, lk, ranknow; + /* BIND_GLOBAL( "INSTALL_METHOD_FLAGS", function ( opr, info, rel, flags, baserank, method ) + local methods, narg, i, k, tmp, replace, match, j, lk, rank; ; - if IS_FUNCTION( rank ) then - ranknow := rank( ); + if IS_FUNCTION( baserank ) then + rank := baserank( ); else - ranknow := rank; + rank := baserank; fi; if IS_CONSTRUCTOR( opr ) then if 0 < LEN_LIST( flags ) then - ranknow := ranknow - RankFilter( flags[1] ); + rank := rank - RankFilter( flags[1] ); fi; else for i in flags do - ranknow := ranknow + RankFilter( i ); + rank := rank + RankFilter( i ); od; fi; narg := LEN_LIST( flags ); @@ -4096,13 +4096,13 @@ static Obj HdlrFunc1 ( CONV_STRING( info ); fi; i := 0; - while i < LEN_LIST( methods ) and ranknow < methods[i + (narg + 3)] do + while i < LEN_LIST( methods ) and rank < methods[i + (narg + 3)] do i := i + (narg + 6); od; replace := false; if REREADING then k := i; - while k < LEN_LIST( methods ) and ranknow = methods[k + narg + 3] do + while k < LEN_LIST( methods ) and rank = methods[k + narg + 3] do if info = methods[k + narg + 4] then match := false; for j in [ 1 .. narg ] do @@ -4153,12 +4153,12 @@ static Obj HdlrFunc1 ( else Error( NAME_FUNC( opr ), ": must be a function, `true', or `false'" ); fi; - methods[i + (narg + 3)] := ranknow; + methods[i + (narg + 3)] := rank; methods[i + (narg + 4)] := IMMUTABLE_COPY_OBJ( info ); if 6 >= 5 then methods[i + (narg + 5)] := MakeImmutable( [ INPUT_FILENAME( ), READEVALCOMMAND_LINENUMBER, INPUT_LINENUMBER( ) ] ); if 6 >= 6 then - methods[i + (narg + 6)] := rank; + methods[i + (narg + 6)] := baserank; fi; fi; CHANGED_METHODS_OPERATION( opr, narg ); @@ -4919,7 +4919,7 @@ static Int InitLibrary ( StructInitInfo * module ) static StructInitInfo module = { .type = MODULE_STATIC, .name = "GAPROOT/lib/oper1.g", - .crc = 65425009, + .crc = 96238222, .initKernel = InitKernel, .initLibrary = InitLibrary, .postRestore = PostRestore, diff --git a/src/hpc/c_oper1.c b/src/hpc/c_oper1.c index d9962694e9..c8438b0f90 100644 --- a/src/hpc/c_oper1.c +++ b/src/hpc/c_oper1.c @@ -1,7 +1,7 @@ #ifndef AVOID_PRECOMPILED /* C file produced by GAC */ #include "compiled.h" -#define FILE_CRC "93694864" +#define FILE_CRC "96238222" /* global variables used in handlers */ static GVar G_REREADING; @@ -617,7 +617,7 @@ static Obj HdlrFunc3 ( Obj a_info, Obj a_rel, Obj a_flags, - Obj a_rank, + Obj a_baserank, Obj a_method ) { Obj l_methods = 0; @@ -629,6 +629,7 @@ static Obj HdlrFunc3 ( Obj l_match = 0; Obj l_j = 0; Obj l_lk = 0; + Obj l_rank = 0; Obj t_1 = 0; Obj t_2 = 0; Obj t_3 = 0; @@ -646,6 +647,7 @@ static Obj HdlrFunc3 ( (void)l_match; (void)l_j; (void)l_lk; + (void)l_rank; Bag oldFrame; OLD_BRK_CURR_STAT @@ -662,6 +664,31 @@ static Obj HdlrFunc3 ( CHECK_FUNC_RESULT( t_1 ) l_lk = t_1; + /* if IS_FUNCTION( baserank ) then */ + t_3 = GF_IS__FUNCTION; + t_2 = CALL_1ARGS( t_3, a_baserank ); + CHECK_FUNC_RESULT( t_2 ) + CHECK_BOOL( t_2 ) + t_1 = (Obj)(UInt)(t_2 != False); + if ( t_1 ) { + + /* rank := baserank( ); */ + CHECK_FUNC( a_baserank ) + t_1 = CALL_0ARGS( a_baserank ); + CHECK_FUNC_RESULT( t_1 ) + l_rank = t_1; + + } + + /* else */ + else { + + /* rank := baserank; */ + l_rank = a_baserank; + + } + /* fi */ + /* if IS_CONSTRUCTOR( opr ) then */ t_3 = GF_IS__CONSTRUCTOR; t_2 = CALL_1ARGS( t_3, a_opr ); @@ -682,8 +709,8 @@ static Obj HdlrFunc3 ( C_ELM_LIST_FPL( t_4, a_flags, INTOBJ_INT(1) ) t_2 = CALL_1ARGS( t_3, t_4 ); CHECK_FUNC_RESULT( t_2 ) - C_DIFF_FIA( t_1, a_rank, t_2 ) - a_rank = t_1; + C_DIFF_FIA( t_1, l_rank, t_2 ) + l_rank = t_1; } /* fi */ @@ -720,8 +747,8 @@ static Obj HdlrFunc3 ( t_7 = GF_RankFilter; t_6 = CALL_1ARGS( t_7, l_i ); CHECK_FUNC_RESULT( t_6 ) - C_SUM_FIA( t_5, a_rank, t_6 ) - a_rank = t_5; + C_SUM_FIA( t_5, l_rank, t_6 ) + l_rank = t_5; } /* od */ @@ -808,13 +835,13 @@ static Obj HdlrFunc3 ( C_SUM_FIA( t_5, l_i, t_6 ) CHECK_INT_POS( t_5 ) C_ELM_LIST_FPL( t_4, l_methods, t_5 ) - t_3 = (Obj)(UInt)(LT( a_rank, t_4 )); + t_3 = (Obj)(UInt)(LT( l_rank, t_4 )); t_1 = t_3; } if ( ! t_1 ) break; - /* i := i + (narg + 5); */ - C_SUM_FIA( t_2, l_narg, INTOBJ_INT(5) ) + /* i := i + (narg + 6); */ + C_SUM_FIA( t_2, l_narg, INTOBJ_INT(6) ) C_SUM_FIA( t_1, l_i, t_2 ) l_i = t_1; @@ -847,7 +874,7 @@ static Obj HdlrFunc3 ( C_SUM_FIA( t_5, t_6, INTOBJ_INT(3) ) CHECK_INT_POS( t_5 ) C_ELM_LIST_FPL( t_4, l_methods, t_5 ) - t_3 = (Obj)(UInt)(EQ( a_rank, t_4 )); + t_3 = (Obj)(UInt)(EQ( l_rank, t_4 )); t_1 = t_3; } if ( ! t_1 ) break; @@ -922,9 +949,9 @@ static Obj HdlrFunc3 ( } /* fi */ - /* k := k + narg + 5; */ + /* k := k + narg + 6; */ C_SUM_FIA( t_2, l_k, l_narg ) - C_SUM_FIA( t_1, t_2, INTOBJ_INT(5) ) + C_SUM_FIA( t_1, t_2, INTOBJ_INT(6) ) l_k = t_1; } @@ -947,11 +974,11 @@ static Obj HdlrFunc3 ( } if ( t_1 ) { - /* methods{[ narg + 5 + i + 1 .. narg + 5 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; */ - C_SUM_FIA( t_4, l_narg, INTOBJ_INT(5) ) + /* methods{[ narg + 6 + i + 1 .. narg + 6 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; */ + C_SUM_FIA( t_4, l_narg, INTOBJ_INT(6) ) C_SUM_FIA( t_3, t_4, l_i ) C_SUM_FIA( t_2, t_3, INTOBJ_INT(1) ) - C_SUM_FIA( t_4, l_narg, INTOBJ_INT(5) ) + C_SUM_FIA( t_4, l_narg, INTOBJ_INT(6) ) t_6 = GF_LEN__LIST; t_5 = CALL_1ARGS( t_6, l_methods ); CHECK_FUNC_RESULT( t_5 ) @@ -1217,7 +1244,7 @@ static Obj HdlrFunc3 ( C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(3) ) C_SUM_FIA( t_1, l_i, t_2 ) CHECK_INT_POS( t_1 ) - C_ASS_LIST_FPL( l_methods, t_1, a_rank ) + C_ASS_LIST_FPL( l_methods, t_1, l_rank ) /* methods[i + (narg + 4)] := IMMUTABLE_COPY_OBJ( info ); */ C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(4) ) @@ -1228,8 +1255,8 @@ static Obj HdlrFunc3 ( CHECK_FUNC_RESULT( t_2 ) C_ASS_LIST_FPL( l_methods, t_1, t_2 ) - /* if 5 >= 5 then */ - t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(5)) >= ((Int)INTOBJ_INT(5))); + /* if 6 >= 5 then */ + t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(6)) >= ((Int)INTOBJ_INT(5))); if ( t_1 ) { /* methods[i + (narg + 5)] := MakeImmutable( [ INPUT_FILENAME( ), READEVALCOMMAND_LINENUMBER, INPUT_LINENUMBER( ) ] ); */ @@ -1257,6 +1284,19 @@ static Obj HdlrFunc3 ( CHECK_FUNC_RESULT( t_2 ) C_ASS_LIST_FPL( l_methods, t_1, t_2 ) + /* if 6 >= 6 then */ + t_1 = (Obj)(UInt)(((Int)INTOBJ_INT(6)) >= ((Int)INTOBJ_INT(6))); + if ( t_1 ) { + + /* methods[i + (narg + 6)] := baserank; */ + C_SUM_INTOBJS( t_2, l_narg, INTOBJ_INT(6) ) + C_SUM_FIA( t_1, l_i, t_2 ) + CHECK_INT_POS( t_1 ) + C_ASS_LIST_FPL( l_methods, t_1, a_baserank ) + + } + /* fi */ + } /* fi */ @@ -2748,8 +2788,8 @@ static Obj HdlrFunc7 ( t_6 = NewFunction( NameFunc[8], 1, 0, HdlrFunc8 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 651); - SET_ENDLINE_BODY(t_7, 669); + SET_STARTLINE_BODY(t_7, 659); + SET_ENDLINE_BODY(t_7, 677); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3352,8 +3392,8 @@ static Obj HdlrFunc11 ( t_1 = NewFunction( NameFunc[12], 1, 0, HdlrFunc12 ); SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); t_2 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_2, 848); - SET_ENDLINE_BODY(t_2, 852); + SET_STARTLINE_BODY(t_2, 856); + SET_ENDLINE_BODY(t_2, 860); SET_FILENAME_BODY(t_2, FileName); SET_BODY_FUNC(t_1, t_2); CHANGED_BAG( STATE(CurrLVars) ); @@ -3432,8 +3472,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[13], 1, 0, HdlrFunc13 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 869); - SET_ENDLINE_BODY(t_7, 869); + SET_STARTLINE_BODY(t_7, 877); + SET_ENDLINE_BODY(t_7, 877); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3507,8 +3547,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[14], 2, 0, HdlrFunc14 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 891); - SET_ENDLINE_BODY(t_7, 914); + SET_STARTLINE_BODY(t_7, 899); + SET_ENDLINE_BODY(t_7, 922); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3556,8 +3596,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[15], 2, 0, HdlrFunc15 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 924); - SET_ENDLINE_BODY(t_7, 932); + SET_STARTLINE_BODY(t_7, 932); + SET_ENDLINE_BODY(t_7, 940); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3618,8 +3658,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[16], 3, 0, HdlrFunc16 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 941); - SET_ENDLINE_BODY(t_7, 954); + SET_STARTLINE_BODY(t_7, 949); + SET_ENDLINE_BODY(t_7, 962); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3992,8 +4032,8 @@ static Obj HdlrFunc17 ( t_4 = NewFunction( NameFunc[18], -1, 0, HdlrFunc18 ); SET_ENVI_FUNC( t_4, STATE(CurrLVars) ); t_5 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_5, 1020); - SET_ENDLINE_BODY(t_5, 1036); + SET_STARTLINE_BODY(t_5, 1028); + SET_ENDLINE_BODY(t_5, 1044); SET_FILENAME_BODY(t_5, FileName); SET_BODY_FUNC(t_4, t_5); CHANGED_BAG( STATE(CurrLVars) ); @@ -4110,9 +4150,14 @@ static Obj HdlrFunc1 ( CHECK_FUNC_RESULT( t_3 ) CALL_2ARGS( t_1, t_2, t_3 ); - /* BIND_GLOBAL( "INSTALL_METHOD_FLAGS", function ( opr, info, rel, flags, rank, method ) - local methods, narg, i, k, tmp, replace, match, j, lk; + /* BIND_GLOBAL( "INSTALL_METHOD_FLAGS", function ( opr, info, rel, flags, baserank, method ) + local methods, narg, i, k, tmp, replace, match, j, lk, rank; lk := WRITE_LOCK( METHODS_OPERATION_REGION ); + if IS_FUNCTION( baserank ) then + rank := baserank( ); + else + rank := baserank; + fi; if IS_CONSTRUCTOR( opr ) then if 0 < LEN_LIST( flags ) then rank := rank - RankFilter( flags[1] ); @@ -4136,7 +4181,7 @@ static Obj HdlrFunc1 ( fi; i := 0; while i < LEN_LIST( methods ) and rank < methods[i + (narg + 3)] do - i := i + (narg + 5); + i := i + (narg + 6); od; replace := false; if REREADING then @@ -4153,11 +4198,11 @@ static Obj HdlrFunc1 ( break; fi; fi; - k := k + narg + 5; + k := k + narg + 6; od; fi; if not REREADING or not replace then - methods{[ narg + 5 + i + 1 .. narg + 5 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; + methods{[ narg + 6 + i + 1 .. narg + 6 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; fi; if rel = true then methods[i + 1] := RETURN_TRUE; @@ -4194,8 +4239,11 @@ static Obj HdlrFunc1 ( fi; methods[i + (narg + 3)] := rank; methods[i + (narg + 4)] := IMMUTABLE_COPY_OBJ( info ); - if 5 >= 5 then + if 6 >= 5 then methods[i + (narg + 5)] := MakeImmutable( [ INPUT_FILENAME( ), READEVALCOMMAND_LINENUMBER, INPUT_LINENUMBER( ) ] ); + if 6 >= 6 then + methods[i + (narg + 6)] := baserank; + fi; fi; SET_METHODS_OPERATION( opr, narg, MakeReadOnlySingleObj( methods ) ); UNLOCK( lk ); @@ -4207,7 +4255,7 @@ static Obj HdlrFunc1 ( SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); SET_STARTLINE_BODY(t_4, 146); - SET_ENDLINE_BODY(t_4, 273); + SET_ENDLINE_BODY(t_4, 281); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4222,8 +4270,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[4], -1, 0, HdlrFunc4 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 320); - SET_ENDLINE_BODY(t_4, 322); + SET_STARTLINE_BODY(t_4, 328); + SET_ENDLINE_BODY(t_4, 330); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4238,8 +4286,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[5], -1, 0, HdlrFunc5 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 347); - SET_ENDLINE_BODY(t_4, 349); + SET_STARTLINE_BODY(t_4, 355); + SET_ENDLINE_BODY(t_4, 357); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4408,17 +4456,17 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[6], 2, 0, HdlrFunc6 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 360); - SET_ENDLINE_BODY(t_4, 590); + SET_STARTLINE_BODY(t_4, 368); + SET_ENDLINE_BODY(t_4, 598); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); CALL_2ARGS( t_1, t_2, t_3 ); - /* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (5 + 2); */ + /* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (6 + 2); */ t_2 = GC_LENGTH__SETTER__METHODS__2; CHECK_BOUND( t_2, "LENGTH_SETTER_METHODS_2" ) - C_SUM_INTOBJS( t_3, INTOBJ_INT(5), INTOBJ_INT(2) ) + C_SUM_INTOBJS( t_3, INTOBJ_INT(6), INTOBJ_INT(2) ) C_SUM_FIA( t_1, t_2, t_3 ) AssGVar( G_LENGTH__SETTER__METHODS__2, t_1 ); @@ -4467,8 +4515,8 @@ static Obj HdlrFunc1 ( t_2 = NewFunction( NameFunc[7], 6, 0, HdlrFunc7 ); SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); t_3 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_3, 609); - SET_ENDLINE_BODY(t_3, 673); + SET_STARTLINE_BODY(t_3, 617); + SET_ENDLINE_BODY(t_3, 681); SET_FILENAME_BODY(t_3, FileName); SET_BODY_FUNC(t_2, t_3); CHANGED_BAG( STATE(CurrLVars) ); @@ -4482,8 +4530,8 @@ static Obj HdlrFunc1 ( t_2 = NewFunction( NameFunc[9], 6, 0, HdlrFunc9 ); SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); t_3 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_3, 676); - SET_ENDLINE_BODY(t_3, 682); + SET_STARTLINE_BODY(t_3, 684); + SET_ENDLINE_BODY(t_3, 690); SET_FILENAME_BODY(t_3, FileName); SET_BODY_FUNC(t_2, t_3); CHANGED_BAG( STATE(CurrLVars) ); @@ -4511,8 +4559,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[10], 2, 0, HdlrFunc10 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 695); - SET_ENDLINE_BODY(t_4, 719); + SET_STARTLINE_BODY(t_4, 703); + SET_ENDLINE_BODY(t_4, 727); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4596,8 +4644,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[11], 4, 0, HdlrFunc11 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 844); - SET_ENDLINE_BODY(t_4, 955); + SET_STARTLINE_BODY(t_4, 852); + SET_ENDLINE_BODY(t_4, 963); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4648,8 +4696,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[17], -1, 0, HdlrFunc17 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 990); - SET_ENDLINE_BODY(t_4, 1037); + SET_STARTLINE_BODY(t_4, 998); + SET_ENDLINE_BODY(t_4, 1045); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4972,7 +5020,7 @@ static Int InitLibrary ( StructInitInfo * module ) static StructInitInfo module = { .type = MODULE_STATIC, .name = "GAPROOT/lib/oper1.g", - .crc = 93694864, + .crc = 96238222, .initKernel = InitKernel, .initLibrary = InitLibrary, .postRestore = PostRestore, diff --git a/src/hpc/c_type1.c b/src/hpc/c_type1.c index a8a53ea27f..d184cab36d 100644 --- a/src/hpc/c_type1.c +++ b/src/hpc/c_type1.c @@ -3550,10 +3550,10 @@ static Obj HdlrFunc1 ( CHANGED_BAG( STATE(CurrLVars) ); CALL_1ARGS( t_1, t_2 ); - /* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (5 + 2); */ + /* LENGTH_SETTER_METHODS_2 := LENGTH_SETTER_METHODS_2 + (6 + 2); */ t_2 = GC_LENGTH__SETTER__METHODS__2; CHECK_BOUND( t_2, "LENGTH_SETTER_METHODS_2" ) - C_SUM_INTOBJS( t_3, INTOBJ_INT(5), INTOBJ_INT(2) ) + C_SUM_INTOBJS( t_3, INTOBJ_INT(6), INTOBJ_INT(2) ) C_SUM_FIA( t_1, t_2, t_3 ) AssGVar( G_LENGTH__SETTER__METHODS__2, t_1 ); diff --git a/src/opers.c b/src/opers.c index 2e42d27847..c7837c9179 100644 --- a/src/opers.c +++ b/src/opers.c @@ -1909,7 +1909,7 @@ static Obj NEXT_VMETHOD_PRINT_INFO; // Use of 'ALWAYS_INLINE' is critical for performance, see discussion // earlier in this file. enum { - BASE_SIZE_METHODS_OPER_ENTRY = 5, + BASE_SIZE_METHODS_OPER_ENTRY = 6, }; static ALWAYS_INLINE Obj GetMethodUncached( UInt verbose, UInt constructor, UInt n, Obj methods, Int prec, Obj types[]) @@ -1928,6 +1928,9 @@ static ALWAYS_INLINE Obj GetMethodUncached( // entry n+3 is the rank // entry n+4 is the info text // entry n+5 is, if set, the location where the method was installed + // entry n+6 is, if set, the relative rank that was supplied when + // the method was installed, either as a small integer or a function + // of no arguments // check argument filters against the given types Obj filter; From a3cabba65c728a9ae5a2af1cfd11346e3fee8f34 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Wed, 13 Jun 2018 11:39:17 +0100 Subject: [PATCH 03/12] Increase size of HIDDEN_IMPS_CACHE and WITH_IMPS_CACHE to speed up RECALCULATE_ALL_METHOD_RANKS() --- src/opers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opers.c b/src/opers.c index c7837c9179..5924444c60 100644 --- a/src/opers.c +++ b/src/opers.c @@ -669,7 +669,7 @@ Obj FuncAND_FLAGS ( Obj HIDDEN_IMPS; Obj WITH_HIDDEN_IMPS_FLAGS_CACHE; -enum { HIDDEN_IMPS_CACHE_LENGTH = 2003 }; +enum { HIDDEN_IMPS_CACHE_LENGTH = 20003 }; /* Forward declaration of FuncFLAGS_FILTER */ Obj FuncFLAGS_FILTER(Obj self, Obj oper); @@ -829,7 +829,7 @@ Obj FuncWITH_HIDDEN_IMPS_FLAGS(Obj self, Obj flags) static Obj IMPLICATIONS_SIMPLE; static Obj IMPLICATIONS_COMPOSED; static Obj WITH_IMPS_FLAGS_CACHE; -enum { IMPS_CACHE_LENGTH = 11001 }; +enum { IMPS_CACHE_LENGTH = 21001 }; /**************************************************************************** ** From 953bc86f73b0c3f064781883476acc29a7fede7e Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Wed, 13 Jun 2018 11:40:27 +0100 Subject: [PATCH 04/12] Make sure RANK_FILTERS is always set promptly, then remove the test for it being unset in RankFilter --- lib/filter.g | 4 ---- lib/oper.g | 33 ++++++++++++++------------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/lib/filter.g b/lib/filter.g index afd23f9aab..2568e1199f 100644 --- a/lib/filter.g +++ b/lib/filter.g @@ -456,11 +456,7 @@ BIND_GLOBAL( "RankFilter", function( filter ) 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 - rank := rank + 1; - fi; od; return rank; end ); diff --git a/lib/oper.g b/lib/oper.g index b6c4d6528a..9dfe21ae5b 100644 --- a/lib/oper.g +++ b/lib/oper.g @@ -1096,6 +1096,7 @@ BIND_GLOBAL( "DeclareAttributeKernel", function ( name, filter, getter ) FILTERS[ FLAG2_FILTER( tester ) ] := tester; IMM_FLAGS:= AND_FLAGS( IMM_FLAGS, FLAGS_FILTER( tester ) ); INFO_FILTERS[ FLAG2_FILTER( tester ) ] := 5; + RANK_FILTERS[ FLAG2_FILTER( tester ) ] := 1; od; # clear the cache because is something old @@ -1107,10 +1108,6 @@ BIND_GLOBAL( "DeclareAttributeKernel", function ( name, filter, getter ) # run the attribute functions RUN_ATTR_FUNCS( filter, getter, setter, tester, false ); - # store the ranks - atomic FILTER_REGION do - RANK_FILTERS[ FLAG2_FILTER( tester ) ] := 1; - od; # and make the remaining assignments nname:= "Set"; APPEND_LIST_INTR( nname, name ); @@ -1198,6 +1195,8 @@ BIND_GLOBAL( "OPER_SetupAttribute", function(getter, flags, mutflag, filter, ran # install the default functions FILTERS[ FLAG2_FILTER( tester ) ] := tester; IMM_FLAGS:= AND_FLAGS( IMM_FLAGS, FLAGS_FILTER( tester ) ); + # store the rank + RANK_FILTERS[ FLAG2_FILTER( tester ) ] := rank; # the is newly made, therefore the cache cannot contain a flag # list involving @@ -1209,8 +1208,6 @@ BIND_GLOBAL( "OPER_SetupAttribute", function(getter, flags, mutflag, filter, ran # run the attribute functions RUN_ATTR_FUNCS( filter, getter, setter, tester, mutflag ); - # store the rank - RANK_FILTERS[ FLAG2_FILTER( tester ) ] := rank; return; @@ -1439,6 +1436,10 @@ BIND_GLOBAL( "DeclarePropertyKernel", function ( name, filter, getter ) INFO_FILTERS[ FLAG1_FILTER( getter ) ]:= 7; INFO_FILTERS[ FLAG2_FILTER( getter ) ]:= 8; + # store the ranks + RANK_FILTERS[ FLAG1_FILTER( getter ) ] := 1; + RANK_FILTERS[ FLAG2_FILTER( getter ) ] := 1; + # clear the cache because is something old if not GAPInfo.CommandLineOptions.N then InstallHiddenTrueMethod( tester, getter ); @@ -1450,9 +1451,6 @@ BIND_GLOBAL( "DeclarePropertyKernel", function ( name, filter, getter ) # run the attribute functions RUN_ATTR_FUNCS( filter, getter, setter, tester, false ); - # store the ranks - RANK_FILTERS[ FLAG1_FILTER( getter ) ] := 1; - RANK_FILTERS[ FLAG2_FILTER( getter ) ] := 1; # and make the remaining assignments nname:= "Set"; APPEND_LIST_INTR( nname, name ); @@ -1513,8 +1511,14 @@ BIND_GLOBAL( "NewProperty", function ( arg ) FILTERS[ FLAG2_FILTER( getter ) ] := tester; INFO_FILTERS[ FLAG1_FILTER( getter ) ] := 9; INFO_FILTERS[ FLAG2_FILTER( getter ) ] := 10; + if LEN_LIST( arg ) = 3 and IS_INT( arg[3] ) then + RANK_FILTERS[ FLAG1_FILTER( getter ) ]:= arg[3]; + else + RANK_FILTERS[ FLAG1_FILTER( getter ) ]:= 1; + fi; + RANK_FILTERS[ FLAG2_FILTER( tester ) ]:= 1; od; - + # the and are newly made, therefore the cache cannot # contain a flag list involving or if not GAPInfo.CommandLineOptions.N then @@ -1526,15 +1530,6 @@ BIND_GLOBAL( "NewProperty", function ( arg ) # run the attribute functions RUN_ATTR_FUNCS( filter, getter, setter, tester, false ); - # store the rank - atomic FILTER_REGION do - if LEN_LIST( arg ) = 3 and IS_INT( arg[3] ) then - RANK_FILTERS[ FLAG1_FILTER( getter ) ]:= arg[3]; - else - RANK_FILTERS[ FLAG1_FILTER( getter ) ]:= 1; - fi; - RANK_FILTERS[ FLAG2_FILTER( tester ) ]:= 1; - od; # and return the getter return getter; From 5c4a76c6ddc8fa08769748477ef9f91d9590bbed Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Wed, 13 Jun 2018 12:55:18 +0100 Subject: [PATCH 05/12] Automatically reorder methods after library or package loading, or InstallTrueMethod --- lib/init.g | 5 +++++ lib/package.gi | 19 +++++++++++++++---- tst/testinstall/triviso.tst | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/init.g b/lib/init.g index bb5f570b20..573482e47f 100644 --- a/lib/init.g +++ b/lib/init.g @@ -1018,6 +1018,9 @@ fi; ## ## Read init files, run a shell, and do exit-time processing. ## + +ResumeMethodReordering(); + InstallAndCallPostRestore( function() local i, status; for i in [1..Length(GAPInfo.InitFiles)] do @@ -1037,6 +1040,8 @@ InstallAndCallPostRestore( function() od; end ); + + if IsLIBGAP then # GAP is used as a library, do not start an interactive session elif IsHPCGAP and THREAD_UI() then diff --git a/lib/package.gi b/lib/package.gi index bf78020f41..66e7de917f 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -1420,7 +1420,7 @@ InstallGlobalFunction( LoadPackage, function( arg ) local name, Name, version, banner, loadsuggested, msg, depinfo, path, pair, i, order, paths, cycle, secondrun, pkgname, pos, info, filename, read; - + # Get the arguments. if Length( arg ) = 0 then name:= ""; @@ -1516,7 +1516,14 @@ InstallGlobalFunction( LoadPackage, function( arg ) GAPInfo.LoadPackageLevel:= GAPInfo.LoadPackageLevel - 1; return path; fi; - + + # + # Suspend reordering of methods following InstallTrueMethod + # because it would slow things down too much + # + SuspendMethodReordering(); + + # Compute the order in which the packages are loaded. # For each set of packages with cyclic dependencies, # we will first read all `init.g' files @@ -1631,6 +1638,8 @@ InstallGlobalFunction( LoadPackage, function( arg ) LogPackageLoadingMessage( PACKAGE_DEBUG, "return from LoadPackage", Name ); GAPInfo.LoadPackageLevel:= GAPInfo.LoadPackageLevel - 1; + + ResumeMethodReordering(); return true; end ); @@ -1640,11 +1649,13 @@ InstallGlobalFunction( LoadPackage, function( arg ) #F LoadAllPackages() ## InstallGlobalFunction( LoadAllPackages, function() + SuspendMethodReordering(); if ValueOption( "reversed" ) = true then - List( Reversed( RecNames( GAPInfo.PackagesInfo ) ), LoadPackage ); + List( Reversed( RecNames( GAPInfo.PackagesInfo ) ), LoadPackage ); else - List( RecNames( GAPInfo.PackagesInfo ), LoadPackage ); + List( RecNames( GAPInfo.PackagesInfo ), LoadPackage ); fi; + ResumeMethodReordering(); end ); diff --git a/tst/testinstall/triviso.tst b/tst/testinstall/triviso.tst index 5776ddfa3c..5b7bacb792 100644 --- a/tst/testinstall/triviso.tst +++ b/tst/testinstall/triviso.tst @@ -9,11 +9,11 @@ gap> START_TEST("triviso.tst"); gap> G := Group(()); Group(()) gap> phi := IsomorphismPermGroup(G); -[ ] -> [ ] +IdentityMapping( Group(()) ) gap> HasIsBijective(phi); true gap> inv := InverseGeneralMapping(phi); -[ ] -> [ ] +IdentityMapping( Group(()) ) gap> HasIsMapping(inv); true gap> STOP_TEST( "triviso.tst", 1); From d51f79e1019a8bea8a261a7e2c8f0569fe0bc62b Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Thu, 14 Jun 2018 13:00:07 +0100 Subject: [PATCH 06/12] Add test --- lib/filter.g | 14 ++++++---- lib/oper.g | 6 ++--- tst/testinstall/method-reordering.tst | 37 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 tst/testinstall/method-reordering.tst diff --git a/lib/filter.g b/lib/filter.g index 2568e1199f..f3344691b7 100644 --- a/lib/filter.g +++ b/lib/filter.g @@ -228,8 +228,10 @@ end); BIND_GLOBAL( "ResumeMethodReordering", function() - REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL - 1; - if REORDER_METHODS_SUSPENSION_LEVEL = 0 then + if REORDER_METHODS_SUSPENSION_LEVEL > 0 then + REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL - 1; + fi; + if REORDER_METHODS_SUSPENSION_LEVEL <= 0 then RECALCULATE_ALL_METHOD_RANKS(); fi; end); @@ -246,13 +248,15 @@ BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from ) InstallTrueMethodNewFilter( tofilt, from ); + # clear the caches because we do not know if filter is new + CLEAR_HIDDEN_IMP_CACHE( from ); + CLEAR_IMP_CACHE(); + + # maybe rerank methods to take account of new implication if REORDER_METHODS_SUSPENSION_LEVEL = 0 then RECALCULATE_ALL_METHOD_RANKS(); fi; - # clear the caches because we do not know if filter is new - CLEAR_HIDDEN_IMP_CACHE( from ); - CLEAR_IMP_CACHE(); end ); diff --git a/lib/oper.g b/lib/oper.g index 9dfe21ae5b..b2be4748ea 100644 --- a/lib/oper.g +++ b/lib/oper.g @@ -2016,10 +2016,10 @@ BIND_GLOBAL( "RECALCULATE_ALL_METHOD_RANKS", function() meths{[1 + (k-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY).. k*(n+BASE_SIZE_METHODS_OPER_ENTRY)]} := l; od; + if changed then + CHANGED_METHODS_OPERATION(oper,n); + fi; od; - if changed then - CHANGED_METHODS_OPERATION(oper,n); - fi; od; end ); diff --git a/tst/testinstall/method-reordering.tst b/tst/testinstall/method-reordering.tst new file mode 100644 index 0000000000..eebeccdaa0 --- /dev/null +++ b/tst/testinstall/method-reordering.tst @@ -0,0 +1,37 @@ +gap> START_TEST("method-reordering.tst"); +gap> CheckReorder := function(explicit) +> local f1, f2, f3, myOp, fam, t, o; +> f1 := NewFilter("filter1",100); +> f2 := NewFilter("filter1",10); +> f3 := NewFilter("filter1",1); +> myOp := NewOperation("myOp", [IsObject]); +> InstallMethod(myOp, "meth1", [f2], x ->1); +> InstallMethod(myOp, "meth2", [f3], x ->2); +> fam := NewFamily("myFam"); +> t := NewType(fam, IsComponentObjectRep and f2 and f3); +> o := Objectify(t, rec()); +> if myOp(o) <> 1 then +> Error("Initial method selection wrong"); +> fi; +> InstallTrueMethod(f1,f3); +> if explicit then +> RECALCULATE_ALL_METHOD_RANKS(); +> fi; +> return myOp(o) = 2; +> end;; +gap> CheckReorder(false); +true +gap> SuspendMethodReordering(); +gap> CheckReorder(false); +false +gap> CheckReorder(true); +true +gap> ResumeMethodReordering(); +gap> Unbind(CheckReorder); +gap> STOP_TEST("method-reordering.tst"); + + + + + + From 1d1279d0b8b01e0fe536669397a0e3889690a620 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Fri, 15 Jun 2018 12:06:41 +0100 Subject: [PATCH 07/12] Documentation --- doc/ref/methsel.xml | 1 + lib/filter.g | 91 +++++++++++++++++++++++++++++++-------------- lib/oper.g | 17 +++++++++ 3 files changed, 81 insertions(+), 28 deletions(-) diff --git a/doc/ref/methsel.xml b/doc/ref/methsel.xml index 17543a9549..de75cfd1ac 100644 --- a/doc/ref/methsel.xml +++ b/doc/ref/methsel.xml @@ -252,6 +252,7 @@ one can install also immediate methods. Logical Implications <#Include Label="InstallTrueMethod"> +<#Include Label="MethodReordering"> diff --git a/lib/filter.g b/lib/filter.g index f3344691b7..7416c29be5 100644 --- a/lib/filter.g +++ b/lib/filter.g @@ -171,6 +171,60 @@ BIND_GLOBAL( "InstallTrueMethodNewFilter", function ( tofilt, from ) end ); +############################################################################# +## +#F SuspendMethodReordering() +#F ResumeMethodReordering() +#F ResetMethodReordering() +## +## <#GAPDoc Label="MethodReordering"> +## +## +## +## +## +## These functions control whether the method reordering process +## described in is invoked or not. Since this +## process can be comparatively time-consuming, it is usually suspended when +## a lot of implications are due to be installed, for instance when loading +## the library, or a package. This is done by called SuspendMethodReordering() +## once the installations are done, ResumeMethodReordering() should be called. +## These pairs of calls can be nested. When the outermost pair is complete, method +## reordering takes place and is enabled in InstallTrueMethod thereafter. +## +## ResetMethodReordering() effectively exits all nested suspensions, resuming +## reordering immediately. This function is mainly provided for error recovery and +## similar purposes. +## +## <#/GAPDoc> + +# +# This function will be defined in oper.g +# +RECALCULATE_ALL_METHOD_RANKS := fail; + +REORDER_METHODS_SUSPENSION_LEVEL := 1; + +BIND_GLOBAL( "SuspendMethodReordering", function() + REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL + 1; +end); + + +BIND_GLOBAL( "ResumeMethodReordering", function() + if REORDER_METHODS_SUSPENSION_LEVEL > 0 then + REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL - 1; + fi; + if REORDER_METHODS_SUSPENSION_LEVEL <= 0 then + RECALCULATE_ALL_METHOD_RANKS(); + fi; +end); + +BIND_GLOBAL( "ResetMethodReordering", function() + REORDER_METHODS_SUSPENSION_LEVEL := 0; + RECALCULATE_ALL_METHOD_RANKS(); +end); + + ############################################################################# ## #F InstallTrueMethod( , ) @@ -209,39 +263,20 @@ end ); ## This means that after the above implication has been installed, ## one can rely on the fact that every object in the filter ## IsGroup and IsCyclic will also be in the filter -## . +## .

+## +## Adding logical implications can change the rank of filters +## (see ) and consequently the rank, and so choice of +## methods for operations (see ). +## By default InstallTrueMethod adjusts the method selection data structures +## to take care of this, but this process can be time-consuming, so functions +## and +## are provided to allow control of this process. ## ## ## <#/GAPDoc> ## -# -# Function is defined in oper.g -# -RECALCULATE_ALL_METHOD_RANKS := fail; - -REORDER_METHODS_SUSPENSION_LEVEL := 1; - -BIND_GLOBAL( "SuspendMethodReordering", function() - REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL + 1; -end); - - -BIND_GLOBAL( "ResumeMethodReordering", function() - if REORDER_METHODS_SUSPENSION_LEVEL > 0 then - REORDER_METHODS_SUSPENSION_LEVEL := REORDER_METHODS_SUSPENSION_LEVEL - 1; - fi; - if REORDER_METHODS_SUSPENSION_LEVEL <= 0 then - RECALCULATE_ALL_METHOD_RANKS(); - fi; -end); - -BIND_GLOBAL( "ResetMethodReordering", function() - REORDER_METHODS_SUSPENSION_LEVEL := 0; - RECALCULATE_ALL_METHOD_RANKS(); -end); - - BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from ) diff --git a/lib/oper.g b/lib/oper.g index b2be4748ea..d5d41581f4 100644 --- a/lib/oper.g +++ b/lib/oper.g @@ -1926,6 +1926,7 @@ end); fi; + if BASE_SIZE_METHODS_OPER_ENTRY <> 6 then Error("MethodsOperation must be updated for new BASE_SIZE_METHODS_OPER_ENTRY"); fi; @@ -1957,6 +1958,22 @@ BIND_GLOBAL("MethodsOperation", function(oper, nargs) return result; end ); +############################################################################# +## +#F RECALCULATE_ALL_METHOD_RANKS() . . reorder methods after new implications +## +## Installing new implications (including hidden implications) can change the +## rank of existing filters, and so of existing methods for operations. +## +## This function recalculates all such ranks and adjusts the method ordering +## where needed. If the ordering changes, the relevant caches are flushed. +## +## If PRINT_REORDERED_METHODS is true, it prints some diagnostics (this is a +## bit too low-level for Info). +## +## + + # # We had to install a placeholder for this in filter.g # From 97cecad19376db4c235ae34e2a21c1bf237f56d1 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Fri, 15 Jun 2018 12:07:09 +0100 Subject: [PATCH 08/12] HPCGAP support --- lib/oper.g | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/oper.g b/lib/oper.g index d5d41581f4..be2b6f1644 100644 --- a/lib/oper.g +++ b/lib/oper.g @@ -2014,7 +2014,10 @@ BIND_GLOBAL( "RECALCULATE_ALL_METHOD_RANKS", function() if i = 1 or rank <= meths[base-BASE_SIZE_METHODS_OPER_ENTRY+3] then continue; fi; - + + if IsBound(HPCGAP) and HPCGAP and not changed then + meths := SHALLOW_COPY_OBJ(meths); + fi; changed := true; k := i-2; while k > 1 and meths[(k-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n) + n + 3] < rank do @@ -2034,7 +2037,11 @@ BIND_GLOBAL( "RECALCULATE_ALL_METHOD_RANKS", function() k*(n+BASE_SIZE_METHODS_OPER_ENTRY)]} := l; od; if changed then - CHANGED_METHODS_OPERATION(oper,n); + if IsBound(HPCGAP) and HPCGAP then + SET_METHODS_OPERATION(oper,n,meths); + else + CHANGED_METHODS_OPERATION(oper,n); + fi; fi; od; od; From 533c1b61210e009f9ddf7012ae5aab8d15a46852 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Tue, 19 Jun 2018 11:43:40 +0100 Subject: [PATCH 09/12] Handle Constructors --- lib/oper.g | 140 +++++++++++++++++--------- tst/testinstall/method-reordering.tst | 8 +- 2 files changed, 97 insertions(+), 51 deletions(-) diff --git a/lib/oper.g b/lib/oper.g index be2b6f1644..e45f1e927a 100644 --- a/lib/oper.g +++ b/lib/oper.g @@ -1985,63 +1985,105 @@ BIND_GLOBAL( "RECALCULATE_ALL_METHOD_RANKS", function() local oper, n, changed, meths, nmethods, i, base, rank, j, req, req2, k, l; - for oper in OPERATIONS do - if IS_CONSTRUCTOR(oper) then - # FIXME do something for constructors - continue; - fi; - + for oper in OPERATIONS do for n in [0..6] do changed := false; meths := METHODS_OPERATION(oper, n); nmethods := LENGTH(meths)/(BASE_SIZE_METHODS_OPER_ENTRY+n); - for i in [1 ..nmethods] do - base := (i-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n); - # data for this method is meths{[base+1..base+BASE_SIZE_METHODS_OPER_ENTRY + n]} - rank := meths[base+6+n]; - if IS_FUNCTION(rank) then - rank := rank(); - fi; - for j in [1..n] do - req := meths[base+1+j]; - rank := rank+RankFilter(WITH_IMPS_FLAGS(req)); - od; - if rank = meths[base+n+3] then - continue; - fi; - meths[base+n+3] := rank; - # compare to rank of preceding method - if i = 1 or rank <= meths[base-BASE_SIZE_METHODS_OPER_ENTRY+3] then - continue; - fi; - - if IsBound(HPCGAP) and HPCGAP and not changed then - meths := SHALLOW_COPY_OBJ(meths); - fi; - changed := true; - k := i-2; - while k > 1 and meths[(k-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n) + n + 3] < rank do + if IS_CONSTRUCTOR(oper) and n > 0 then + for i in [nmethods,nmethods-1..1] do + base := (i-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n); + # data for this method is meths{[base+1..base+BASE_SIZE_METHODS_OPER_ENTRY + n]} + rank := meths[base+6+n]; + if IS_FUNCTION(rank) then + rank := rank(); + fi; + rank := rank - RankFilter(WITH_IMPS_FLAGS(meths[base+2])); + if rank <> meths[base+n+3] then + if IsHPCGAP and not changed then + meths := SHALLOW_COPY_OBJ(meths); + fi; + changed := true; + meths[base+n+3] := rank; + fi; + meths[base+n+3] := rank; + # compare to rank of succeding method + if i = nmethods or rank >= meths[base+BASE_SIZE_METHODS_OPER_ENTRY + 2*n + 3] then + continue; + fi; + if IsHPCGAP and not changed then + meths := SHALLOW_COPY_OBJ(meths); + fi; + changed := true; + k := i+2; + while k <= nmethods and meths[(k-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n) + n + 3] < rank do + k := k+1; + od; k := k-1; + if PRINT_REORDERED_METHODS then + Print("Constructor ",NAME_FUNC(oper), " ", n," args. Moving method ",i," (", + meths[base+n+4]," from ",meths[base+n+5][1],":", meths[base+n+5][2], + ") to position ",k,"\n"); + fi; + l := meths{[base+1..base+n+BASE_SIZE_METHODS_OPER_ENTRY]}; + COPY_LIST_ENTRIES(meths, 1 + i*(n+BASE_SIZE_METHODS_OPER_ENTRY), 1, + meths, 1 +(i-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY), 1, + (k-i)*(n+BASE_SIZE_METHODS_OPER_ENTRY)); + meths{[1 + (k-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY).. + k*(n+BASE_SIZE_METHODS_OPER_ENTRY)]} := l; od; - k := k+1; - if PRINT_REORDERED_METHODS then - Print(NAME_FUNC(oper), " ", n," args. Moving method ",i," (", - meths[base+n+4]," from ",meths[base+n+5][1],":", meths[base+n+5][2], - ") to position ",k,"\n"); - fi; - l := meths{[base+1..base+n+BASE_SIZE_METHODS_OPER_ENTRY]}; - COPY_LIST_ENTRIES(meths, 1 + (k-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY), 1, - meths, 1 + k*(n+BASE_SIZE_METHODS_OPER_ENTRY), 1, - (i-k)*(n+BASE_SIZE_METHODS_OPER_ENTRY)); - meths{[1 + (k-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY).. - k*(n+BASE_SIZE_METHODS_OPER_ENTRY)]} := l; - od; + else + for i in [1 ..nmethods] do + base := (i-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n); + # data for this method is meths{[base+1..base+BASE_SIZE_METHODS_OPER_ENTRY + n]} + rank := meths[base+6+n]; + if IS_FUNCTION(rank) then + rank := rank(); + fi; + + + for j in [1..n] do + req := meths[base+1+j]; + rank := rank+RankFilter(WITH_IMPS_FLAGS(req)); + od; + + if rank = meths[base+n+3] then + continue; + fi; + meths[base+n+3] := rank; + # compare to rank of preceding method + if i = 1 or rank <= meths[base-BASE_SIZE_METHODS_OPER_ENTRY+3] then + continue; + fi; + + if IsHPCGAP and not changed then + meths := SHALLOW_COPY_OBJ(meths); + fi; + changed := true; + k := i-2; + while k > 1 and meths[(k-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n) + n + 3] < rank do + k := k-1; + od; + k := k+1; + if PRINT_REORDERED_METHODS then + Print(NAME_FUNC(oper), " ", n," args. Moving method ",i," (", + meths[base+n+4]," from ",meths[base+n+5][1],":", meths[base+n+5][2], + ") to position ",k,"\n"); + fi; + l := meths{[base+1..base+n+BASE_SIZE_METHODS_OPER_ENTRY]}; + COPY_LIST_ENTRIES(meths, 1 + (k-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY), 1, + meths, 1 + k*(n+BASE_SIZE_METHODS_OPER_ENTRY), 1, + (i-k)*(n+BASE_SIZE_METHODS_OPER_ENTRY)); + meths{[1 + (k-1)*(n+BASE_SIZE_METHODS_OPER_ENTRY).. + k*(n+BASE_SIZE_METHODS_OPER_ENTRY)]} := l; + od; + fi; if changed then - if IsBound(HPCGAP) and HPCGAP then - SET_METHODS_OPERATION(oper,n,meths); - else + if IsHPCGAP then + SET_METHODS_OPERATION(oper,n,MakeReadOnlySingleObj(meths)); + else CHANGED_METHODS_OPERATION(oper,n); - fi; + fi; fi; od; od; diff --git a/tst/testinstall/method-reordering.tst b/tst/testinstall/method-reordering.tst index eebeccdaa0..f1175d28c5 100644 --- a/tst/testinstall/method-reordering.tst +++ b/tst/testinstall/method-reordering.tst @@ -5,19 +5,23 @@ gap> CheckReorder := function(explicit) > f2 := NewFilter("filter1",10); > f3 := NewFilter("filter1",1); > myOp := NewOperation("myOp", [IsObject]); +> myC := NewConstructor("myC", [IsObject]); > InstallMethod(myOp, "meth1", [f2], x ->1); > InstallMethod(myOp, "meth2", [f3], x ->2); > fam := NewFamily("myFam"); > t := NewType(fam, IsComponentObjectRep and f2 and f3); > o := Objectify(t, rec()); -> if myOp(o) <> 1 then +> o2 := Objectify(t, rec()); +> InstallMethod(myC, "cons1", [f2], x ->o); +> InstallMethod(myC, "cons2", [f3], x ->o2); +> if myOp(o) <> 1 or not IsIdenticalObj(myC(IsObject),o2) then > Error("Initial method selection wrong"); > fi; > InstallTrueMethod(f1,f3); > if explicit then > RECALCULATE_ALL_METHOD_RANKS(); > fi; -> return myOp(o) = 2; +> return IsIdenticalObj(myC(IsObject),o) and myOp(o) = 2; > end;; gap> CheckReorder(false); true From d03cd97334e4779c176a5a7802197f792073bfa1 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Tue, 19 Jun 2018 12:18:26 +0100 Subject: [PATCH 10/12] Use COPY_LIST_ENTRIES in method installation to avoid making an intermediate list --- lib/oper1.g | 4 +-- src/c_oper1.c | 52 ++++++++++++++++----------- src/hpc/c_oper1.c | 52 ++++++++++++++++----------- tst/testinstall/method-reordering.tst | 2 +- 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/lib/oper1.g b/lib/oper1.g index b12f04a75c..a6b3a218bf 100644 --- a/lib/oper1.g +++ b/lib/oper1.g @@ -215,8 +215,8 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", fi; # push the other functions back if not REREADING or not replace then - methods{[narg+BASE_SIZE_METHODS_OPER_ENTRY+i+1..narg+BASE_SIZE_METHODS_OPER_ENTRY+LEN_LIST(methods)]} - := methods{[i+1..LEN_LIST(methods)]}; + COPY_LIST_ENTRIES(methods, i+1, 1, methods, narg+BASE_SIZE_METHODS_OPER_ENTRY+i+1,1, + LEN_LIST(methods)-i); fi; # install the new method diff --git a/src/c_oper1.c b/src/c_oper1.c index bfc5f67a9c..b491e7510d 100644 --- a/src/c_oper1.c +++ b/src/c_oper1.c @@ -1,7 +1,7 @@ #ifndef AVOID_PRECOMPILED /* C file produced by GAC */ #include "compiled.h" -#define FILE_CRC "96238222" +#define FILE_CRC "72319008" /* global variables used in handlers */ static GVar G_REREADING; @@ -82,6 +82,8 @@ static GVar G_LEN__LIST; static Obj GF_LEN__LIST; static GVar G_APPEND__LIST__INTR; static Obj GF_APPEND__LIST__INTR; +static GVar G_COPY__LIST__ENTRIES; +static Obj GF_COPY__LIST__ENTRIES; static GVar G_CONV__STRING; static Obj GF_CONV__STRING; static GVar G_Print; @@ -942,23 +944,31 @@ static Obj HdlrFunc3 ( } if ( t_1 ) { - /* methods{[ narg + 6 + i + 1 .. narg + 6 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; */ - C_SUM_FIA( t_4, l_narg, INTOBJ_INT(6) ) - C_SUM_FIA( t_3, t_4, l_i ) - C_SUM_FIA( t_2, t_3, INTOBJ_INT(1) ) - C_SUM_FIA( t_4, l_narg, INTOBJ_INT(6) ) - t_6 = GF_LEN__LIST; - t_5 = CALL_1ARGS( t_6, l_methods ); - CHECK_FUNC_RESULT( t_5 ) - C_SUM_FIA( t_3, t_4, t_5 ) - t_1 = Range2Check( t_2, t_3 ); - C_SUM_FIA( t_4, l_i, INTOBJ_INT(1) ) - t_6 = GF_LEN__LIST; - t_5 = CALL_1ARGS( t_6, l_methods ); - CHECK_FUNC_RESULT( t_5 ) - t_3 = Range2Check( t_4, t_5 ); - t_2 = ElmsListCheck( l_methods, t_3 ); - AsssListCheck( l_methods, t_1, t_2 ); + /* COPY_LIST_ENTRIES( methods, i + 1, 1, methods, narg + 6 + i + 1, 1, LEN_LIST( methods ) - i ); */ + t_1 = GF_COPY__LIST__ENTRIES; + t_2 = NEW_PLIST( T_PLIST, 7 ); + SET_LEN_PLIST( t_2, 7 ); + SET_ELM_PLIST( t_2, 1, l_methods ); + CHANGED_BAG( t_2 ); + C_SUM_FIA( t_3, l_i, INTOBJ_INT(1) ) + SET_ELM_PLIST( t_2, 2, t_3 ); + CHANGED_BAG( t_2 ); + SET_ELM_PLIST( t_2, 3, INTOBJ_INT(1) ); + SET_ELM_PLIST( t_2, 4, l_methods ); + CHANGED_BAG( t_2 ); + C_SUM_FIA( t_5, l_narg, INTOBJ_INT(6) ) + C_SUM_FIA( t_4, t_5, l_i ) + C_SUM_FIA( t_3, t_4, INTOBJ_INT(1) ) + SET_ELM_PLIST( t_2, 5, t_3 ); + CHANGED_BAG( t_2 ); + SET_ELM_PLIST( t_2, 6, INTOBJ_INT(1) ); + t_5 = GF_LEN__LIST; + t_4 = CALL_1ARGS( t_5, l_methods ); + CHECK_FUNC_RESULT( t_4 ) + C_DIFF_FIA( t_3, t_4, l_i ) + SET_ELM_PLIST( t_2, 7, t_3 ); + CHANGED_BAG( t_2 ); + CALL_XARGS( t_1, t_2 ); } /* fi */ @@ -4118,7 +4128,7 @@ static Obj HdlrFunc1 ( od; fi; if not REREADING or not replace then - methods{[ narg + 6 + i + 1 .. narg + 6 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; + COPY_LIST_ENTRIES( methods, i + 1, 1, methods, narg + 6 + i + 1, 1, LEN_LIST( methods ) - i ); fi; if rel = true then methods[i + 1] := RETURN_TRUE; @@ -4689,6 +4699,7 @@ static Int PostRestore ( StructInitInfo * module ) G_RETURN__FALSE = GVarName( "RETURN_FALSE" ); G_LEN__LIST = GVarName( "LEN_LIST" ); G_APPEND__LIST__INTR = GVarName( "APPEND_LIST_INTR" ); + G_COPY__LIST__ENTRIES = GVarName( "COPY_LIST_ENTRIES" ); G_CONV__STRING = GVarName( "CONV_STRING" ); G_Print = GVarName( "Print" ); G_ViewObj = GVarName( "ViewObj" ); @@ -4805,6 +4816,7 @@ static Int InitKernel ( StructInitInfo * module ) InitCopyGVar( "RETURN_FALSE", &GC_RETURN__FALSE ); InitFopyGVar( "LEN_LIST", &GF_LEN__LIST ); InitFopyGVar( "APPEND_LIST_INTR", &GF_APPEND__LIST__INTR ); + InitFopyGVar( "COPY_LIST_ENTRIES", &GF_COPY__LIST__ENTRIES ); InitFopyGVar( "CONV_STRING", &GF_CONV__STRING ); InitFopyGVar( "Print", &GF_Print ); InitCopyGVar( "ViewObj", &GC_ViewObj ); @@ -4919,7 +4931,7 @@ static Int InitLibrary ( StructInitInfo * module ) static StructInitInfo module = { .type = MODULE_STATIC, .name = "GAPROOT/lib/oper1.g", - .crc = 96238222, + .crc = 72319008, .initKernel = InitKernel, .initLibrary = InitLibrary, .postRestore = PostRestore, diff --git a/src/hpc/c_oper1.c b/src/hpc/c_oper1.c index c8438b0f90..9a97ece339 100644 --- a/src/hpc/c_oper1.c +++ b/src/hpc/c_oper1.c @@ -1,7 +1,7 @@ #ifndef AVOID_PRECOMPILED /* C file produced by GAC */ #include "compiled.h" -#define FILE_CRC "96238222" +#define FILE_CRC "72319008" /* global variables used in handlers */ static GVar G_REREADING; @@ -82,6 +82,8 @@ static GVar G_LEN__LIST; static Obj GF_LEN__LIST; static GVar G_APPEND__LIST__INTR; static Obj GF_APPEND__LIST__INTR; +static GVar G_COPY__LIST__ENTRIES; +static Obj GF_COPY__LIST__ENTRIES; static GVar G_CONV__STRING; static Obj GF_CONV__STRING; static GVar G_Print; @@ -974,23 +976,31 @@ static Obj HdlrFunc3 ( } if ( t_1 ) { - /* methods{[ narg + 6 + i + 1 .. narg + 6 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; */ - C_SUM_FIA( t_4, l_narg, INTOBJ_INT(6) ) - C_SUM_FIA( t_3, t_4, l_i ) - C_SUM_FIA( t_2, t_3, INTOBJ_INT(1) ) - C_SUM_FIA( t_4, l_narg, INTOBJ_INT(6) ) - t_6 = GF_LEN__LIST; - t_5 = CALL_1ARGS( t_6, l_methods ); - CHECK_FUNC_RESULT( t_5 ) - C_SUM_FIA( t_3, t_4, t_5 ) - t_1 = Range2Check( t_2, t_3 ); - C_SUM_FIA( t_4, l_i, INTOBJ_INT(1) ) - t_6 = GF_LEN__LIST; - t_5 = CALL_1ARGS( t_6, l_methods ); - CHECK_FUNC_RESULT( t_5 ) - t_3 = Range2Check( t_4, t_5 ); - t_2 = ElmsListCheck( l_methods, t_3 ); - AsssListCheck( l_methods, t_1, t_2 ); + /* COPY_LIST_ENTRIES( methods, i + 1, 1, methods, narg + 6 + i + 1, 1, LEN_LIST( methods ) - i ); */ + t_1 = GF_COPY__LIST__ENTRIES; + t_2 = NEW_PLIST( T_PLIST, 7 ); + SET_LEN_PLIST( t_2, 7 ); + SET_ELM_PLIST( t_2, 1, l_methods ); + CHANGED_BAG( t_2 ); + C_SUM_FIA( t_3, l_i, INTOBJ_INT(1) ) + SET_ELM_PLIST( t_2, 2, t_3 ); + CHANGED_BAG( t_2 ); + SET_ELM_PLIST( t_2, 3, INTOBJ_INT(1) ); + SET_ELM_PLIST( t_2, 4, l_methods ); + CHANGED_BAG( t_2 ); + C_SUM_FIA( t_5, l_narg, INTOBJ_INT(6) ) + C_SUM_FIA( t_4, t_5, l_i ) + C_SUM_FIA( t_3, t_4, INTOBJ_INT(1) ) + SET_ELM_PLIST( t_2, 5, t_3 ); + CHANGED_BAG( t_2 ); + SET_ELM_PLIST( t_2, 6, INTOBJ_INT(1) ); + t_5 = GF_LEN__LIST; + t_4 = CALL_1ARGS( t_5, l_methods ); + CHECK_FUNC_RESULT( t_4 ) + C_DIFF_FIA( t_3, t_4, l_i ) + SET_ELM_PLIST( t_2, 7, t_3 ); + CHANGED_BAG( t_2 ); + CALL_XARGS( t_1, t_2 ); } /* fi */ @@ -4202,7 +4212,7 @@ static Obj HdlrFunc1 ( od; fi; if not REREADING or not replace then - methods{[ narg + 6 + i + 1 .. narg + 6 + LEN_LIST( methods ) ]} := methods{[ i + 1 .. LEN_LIST( methods ) ]}; + COPY_LIST_ENTRIES( methods, i + 1, 1, methods, narg + 6 + i + 1, 1, LEN_LIST( methods ) - i ); fi; if rel = true then methods[i + 1] := RETURN_TRUE; @@ -4774,6 +4784,7 @@ static Int PostRestore ( StructInitInfo * module ) G_RETURN__FALSE = GVarName( "RETURN_FALSE" ); G_LEN__LIST = GVarName( "LEN_LIST" ); G_APPEND__LIST__INTR = GVarName( "APPEND_LIST_INTR" ); + G_COPY__LIST__ENTRIES = GVarName( "COPY_LIST_ENTRIES" ); G_CONV__STRING = GVarName( "CONV_STRING" ); G_Print = GVarName( "Print" ); G_ViewObj = GVarName( "ViewObj" ); @@ -4898,6 +4909,7 @@ static Int InitKernel ( StructInitInfo * module ) InitCopyGVar( "RETURN_FALSE", &GC_RETURN__FALSE ); InitFopyGVar( "LEN_LIST", &GF_LEN__LIST ); InitFopyGVar( "APPEND_LIST_INTR", &GF_APPEND__LIST__INTR ); + InitFopyGVar( "COPY_LIST_ENTRIES", &GF_COPY__LIST__ENTRIES ); InitFopyGVar( "CONV_STRING", &GF_CONV__STRING ); InitFopyGVar( "Print", &GF_Print ); InitCopyGVar( "ViewObj", &GC_ViewObj ); @@ -5020,7 +5032,7 @@ static Int InitLibrary ( StructInitInfo * module ) static StructInitInfo module = { .type = MODULE_STATIC, .name = "GAPROOT/lib/oper1.g", - .crc = 96238222, + .crc = 72319008, .initKernel = InitKernel, .initLibrary = InitLibrary, .postRestore = PostRestore, diff --git a/tst/testinstall/method-reordering.tst b/tst/testinstall/method-reordering.tst index f1175d28c5..eb03bccba8 100644 --- a/tst/testinstall/method-reordering.tst +++ b/tst/testinstall/method-reordering.tst @@ -1,6 +1,6 @@ gap> START_TEST("method-reordering.tst"); gap> CheckReorder := function(explicit) -> local f1, f2, f3, myOp, fam, t, o; +> local f1, f2, f3, myOp, fam, t, o, myC; > f1 := NewFilter("filter1",100); > f2 := NewFilter("filter1",10); > f3 := NewFilter("filter1",1); From e29f5b968ee5c2f0f707ad78011346b28249c7fc Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Thu, 28 Jun 2018 15:59:16 +0100 Subject: [PATCH 11/12] Support passing a function of no arguments as the rank adjustment to InstallMethod --- lib/oper.g | 21 ++--- lib/oper1.g | 48 ++++++------ src/c_oper1.c | 107 ++++++++++++++++---------- src/hpc/c_oper1.c | 107 ++++++++++++++++---------- tst/testinstall/method-rankfns.tst | 21 +++++ tst/testinstall/method-reordering.tst | 2 +- tst/testinstall/varargs.tst | 2 +- 7 files changed, 191 insertions(+), 117 deletions(-) create mode 100644 tst/testinstall/method-rankfns.tst diff --git a/lib/oper.g b/lib/oper.g index e45f1e927a..da59588d02 100644 --- a/lib/oper.g +++ b/lib/oper.g @@ -2006,15 +2006,10 @@ BIND_GLOBAL( "RECALCULATE_ALL_METHOD_RANKS", function() changed := true; meths[base+n+3] := rank; fi; - meths[base+n+3] := rank; - # compare to rank of succeding method + # compare to rank of succeding method if i = nmethods or rank >= meths[base+BASE_SIZE_METHODS_OPER_ENTRY + 2*n + 3] then continue; fi; - if IsHPCGAP and not changed then - meths := SHALLOW_COPY_OBJ(meths); - fi; - changed := true; k := i+2; while k <= nmethods and meths[(k-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n) + n + 3] < rank do k := k+1; @@ -2047,19 +2042,19 @@ BIND_GLOBAL( "RECALCULATE_ALL_METHOD_RANKS", function() rank := rank+RankFilter(WITH_IMPS_FLAGS(req)); od; - if rank = meths[base+n+3] then - continue; + if rank <> meths[base+n+3] then + if IsHPCGAP and not changed then + meths := SHALLOW_COPY_OBJ(meths); + fi; + changed := true; + meths[base+n+3] := rank; fi; - meths[base+n+3] := rank; + # compare to rank of preceding method if i = 1 or rank <= meths[base-BASE_SIZE_METHODS_OPER_ENTRY+3] then continue; fi; - if IsHPCGAP and not changed then - meths := SHALLOW_COPY_OBJ(meths); - fi; - changed := true; k := i-2; while k > 1 and meths[(k-1)*(BASE_SIZE_METHODS_OPER_ENTRY+n) + n + 3] < rank do k := k-1; diff --git a/lib/oper1.g b/lib/oper1.g index a6b3a218bf..b36d6f8875 100644 --- a/lib/oper1.g +++ b/lib/oper1.g @@ -69,21 +69,21 @@ BIND_GLOBAL( "RunImmediateMethods", function ( obj, flags ) # `RunImmediateMethods'. if IsBound( IMMEDIATES[j] ) then -#T the `if' statement can disappear when `IMM_FLAGS' is improved ... + #T the `if' statement can disappear when `IMM_FLAGS' is improved ... imm := IMMEDIATES[j]; 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 + 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. meth := IMMEDIATE_METHODS[ imm[i+6] ]; res := meth( obj ); ADD_LIST( tried, imm[i+6] ); RUN_IMMEDIATE_METHODS_CHECKS := - RUN_IMMEDIATE_METHODS_CHECKS+1; + RUN_IMMEDIATE_METHODS_CHECKS+1; if TRACE_IMMEDIATE_METHODS then Print( "#I immediate: ", NAME_FUNC( imm[i+1] )); if imm[i+7] <> false then @@ -99,7 +99,7 @@ BIND_GLOBAL( "RunImmediateMethods", function ( obj, flags ) imm[i+2]( obj, res ); IGNORE_IMMEDIATE_METHODS := false; RUN_IMMEDIATE_METHODS_HITS := - RUN_IMMEDIATE_METHODS_HITS+1; + RUN_IMMEDIATE_METHODS_HITS+1; # If `obj' has noticed the new information, # add the numbers of newly known filters to @@ -107,14 +107,14 @@ BIND_GLOBAL( "RunImmediateMethods", function ( obj, flags ) # methods later. if not IS_IDENTICAL_OBJ( TYPE_OBJ(obj), type ) then - type := TYPE_OBJ(obj); + type := TYPE_OBJ(obj); - newflags := SUB_FLAGS( type![2], IMM_FLAGS ); - newflags := SUB_FLAGS( newflags, flags ); - APPEND_LIST_INTR( flagspos, - TRUES_FLAGS( newflags ) ); + newflags := SUB_FLAGS( type![2], IMM_FLAGS ); + newflags := SUB_FLAGS( newflags, flags ); + APPEND_LIST_INTR( flagspos, + TRUES_FLAGS( newflags ) ); - flags := type![2]; + flags := type![2]; fi; fi; @@ -143,7 +143,7 @@ fi; #F INSTALL_METHOD_FLAGS( , , , , , ) . ## BIND_GLOBAL( "INSTALL_METHOD_FLAGS", - function( opr, info, rel, flags, baserank, method ) + function( opr, info, rel, flags, baserank, method ) local methods, narg, i, k, tmp, replace, match, j, lk, rank; if IsHPCGAP then @@ -215,7 +215,7 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", fi; # push the other functions back if not REREADING or not replace then - COPY_LIST_ENTRIES(methods, i+1, 1, methods, narg+BASE_SIZE_METHODS_OPER_ENTRY+i+1,1, + COPY_LIST_ENTRIES(methods, i+1, 1, methods, narg+BASE_SIZE_METHODS_OPER_ENTRY+i+1,1, LEN_LIST(methods)-i); fi; @@ -252,8 +252,8 @@ BIND_GLOBAL( "INSTALL_METHOD_FLAGS", if CHECK_INSTALL_METHOD and not IS_OPERATION( method ) then tmp := NARG_FUNC(method); if tmp < AINV(narg)-1 or (tmp >= 0 and tmp <> narg) then - Error(NAME_FUNC(opr),": must accept ", - narg, " arguments"); + Error(NAME_FUNC(opr),": must accept ", + narg, " arguments"); fi; fi; methods[i+(narg+2)] := method; @@ -297,9 +297,11 @@ end ); ## if supplied info should be a short but informative string ## that describes for what situation the method is installed, ## famp should be a function to be applied to the families -## of the arguments, -## and val should be an integer that measures the priority -## of the method. +## of the arguments. +## aval should be an integer that measures the priority +## of the method, or a function of no arguments which should return such an +## integer and will be called each time method order is being recalculated, +## (see ). ##

## The default values for info, famp, and val are ## the empty string, @@ -462,9 +464,11 @@ BIND_GLOBAL( "INSTALL_METHOD", # Check the rank. if not IsBound( arglist[ pos ] ) then Error( "the method is missing in " ); - elif IS_INT( arglist[ pos ] ) then - rank:= arglist[ pos ]; - pos:= pos + 1; + elif IS_INT( arglist[ pos ] ) or + (IS_FUNCTION( arglist[ pos ] ) and NARG_FUNC( arglist[ pos ] ) = 0 + and pos < LEN_LIST(arglist)) then + rank := arglist[ pos ]; + pos := pos+1; else rank:= 0; fi; diff --git a/src/c_oper1.c b/src/c_oper1.c index b491e7510d..bbe06074d9 100644 --- a/src/c_oper1.c +++ b/src/c_oper1.c @@ -1,7 +1,7 @@ #ifndef AVOID_PRECOMPILED /* C file produced by GAC */ #include "compiled.h" -#define FILE_CRC "72319008" +#define FILE_CRC "-16477221" /* global variables used in handlers */ static GVar G_REREADING; @@ -1767,14 +1767,41 @@ static Obj HdlrFunc6 ( } - /* elif IS_INT( arglist[pos] ) then */ + /* elif IS_INT( arglist[pos] ) or IS_FUNCTION( arglist[pos] ) and NARG_FUNC( arglist[pos] ) = 0 and pos < LEN_LIST( arglist ) then */ else { - t_3 = GF_IS__INT; - C_ELM_LIST_FPL( t_4, a_arglist, l_pos ) - t_2 = CALL_1ARGS( t_3, t_4 ); - CHECK_FUNC_RESULT( t_2 ) - CHECK_BOOL( t_2 ) - t_1 = (Obj)(UInt)(t_2 != False); + t_4 = GF_IS__INT; + C_ELM_LIST_FPL( t_5, a_arglist, l_pos ) + t_3 = CALL_1ARGS( t_4, t_5 ); + CHECK_FUNC_RESULT( t_3 ) + CHECK_BOOL( t_3 ) + t_2 = (Obj)(UInt)(t_3 != False); + t_1 = t_2; + if ( ! t_1 ) { + t_7 = GF_IS__FUNCTION; + C_ELM_LIST_FPL( t_8, a_arglist, l_pos ) + t_6 = CALL_1ARGS( t_7, t_8 ); + CHECK_FUNC_RESULT( t_6 ) + CHECK_BOOL( t_6 ) + t_5 = (Obj)(UInt)(t_6 != False); + t_4 = t_5; + if ( t_4 ) { + t_8 = GF_NARG__FUNC; + C_ELM_LIST_FPL( t_9, a_arglist, l_pos ) + t_7 = CALL_1ARGS( t_8, t_9 ); + CHECK_FUNC_RESULT( t_7 ) + t_6 = (Obj)(UInt)(EQ( t_7, INTOBJ_INT(0) )); + t_4 = t_6; + } + t_3 = t_4; + if ( t_3 ) { + t_7 = GF_LEN__LIST; + t_6 = CALL_1ARGS( t_7, a_arglist ); + CHECK_FUNC_RESULT( t_6 ) + t_5 = (Obj)(UInt)(LT( l_pos, t_6 )); + t_3 = t_5; + } + t_1 = t_3; + } if ( t_1 ) { /* rank := arglist[pos]; */ @@ -2735,8 +2762,8 @@ static Obj HdlrFunc7 ( t_6 = NewFunction( NameFunc[8], 1, 0, HdlrFunc8 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 659); - SET_ENDLINE_BODY(t_7, 677); + SET_STARTLINE_BODY(t_7, 663); + SET_ENDLINE_BODY(t_7, 681); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3339,8 +3366,8 @@ static Obj HdlrFunc11 ( t_1 = NewFunction( NameFunc[12], 1, 0, HdlrFunc12 ); SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); t_2 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_2, 856); - SET_ENDLINE_BODY(t_2, 860); + SET_STARTLINE_BODY(t_2, 860); + SET_ENDLINE_BODY(t_2, 864); SET_FILENAME_BODY(t_2, FileName); SET_BODY_FUNC(t_1, t_2); CHANGED_BAG( STATE(CurrLVars) ); @@ -3419,8 +3446,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[13], 1, 0, HdlrFunc13 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 877); - SET_ENDLINE_BODY(t_7, 877); + SET_STARTLINE_BODY(t_7, 881); + SET_ENDLINE_BODY(t_7, 881); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3482,8 +3509,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[14], 2, 0, HdlrFunc14 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 899); - SET_ENDLINE_BODY(t_7, 922); + SET_STARTLINE_BODY(t_7, 903); + SET_ENDLINE_BODY(t_7, 926); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3531,8 +3558,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[15], 2, 0, HdlrFunc15 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 932); - SET_ENDLINE_BODY(t_7, 940); + SET_STARTLINE_BODY(t_7, 936); + SET_ENDLINE_BODY(t_7, 944); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3593,8 +3620,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[16], 3, 0, HdlrFunc16 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 949); - SET_ENDLINE_BODY(t_7, 962); + SET_STARTLINE_BODY(t_7, 953); + SET_ENDLINE_BODY(t_7, 966); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3967,8 +3994,8 @@ static Obj HdlrFunc17 ( t_4 = NewFunction( NameFunc[18], -1, 0, HdlrFunc18 ); SET_ENVI_FUNC( t_4, STATE(CurrLVars) ); t_5 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_5, 1028); - SET_ENDLINE_BODY(t_5, 1044); + SET_STARTLINE_BODY(t_5, 1032); + SET_ENDLINE_BODY(t_5, 1048); SET_FILENAME_BODY(t_5, FileName); SET_BODY_FUNC(t_4, t_5); CHANGED_BAG( STATE(CurrLVars) ); @@ -4195,8 +4222,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[4], -1, 0, HdlrFunc4 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 328); - SET_ENDLINE_BODY(t_4, 330); + SET_STARTLINE_BODY(t_4, 330); + SET_ENDLINE_BODY(t_4, 332); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4211,8 +4238,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[5], -1, 0, HdlrFunc5 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 355); - SET_ENDLINE_BODY(t_4, 357); + SET_STARTLINE_BODY(t_4, 357); + SET_ENDLINE_BODY(t_4, 359); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4286,7 +4313,7 @@ static Obj HdlrFunc1 ( od; if not IsBound( arglist[pos] ) then Error( "the method is missing in " ); - elif IS_INT( arglist[pos] ) then + elif IS_INT( arglist[pos] ) or IS_FUNCTION( arglist[pos] ) and NARG_FUNC( arglist[pos] ) = 0 and pos < LEN_LIST( arglist ) then rank := arglist[pos]; pos := pos + 1; else @@ -4381,8 +4408,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[6], 2, 0, HdlrFunc6 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 368); - SET_ENDLINE_BODY(t_4, 598); + SET_STARTLINE_BODY(t_4, 370); + SET_ENDLINE_BODY(t_4, 602); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4440,8 +4467,8 @@ static Obj HdlrFunc1 ( t_2 = NewFunction( NameFunc[7], 6, 0, HdlrFunc7 ); SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); t_3 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_3, 617); - SET_ENDLINE_BODY(t_3, 681); + SET_STARTLINE_BODY(t_3, 621); + SET_ENDLINE_BODY(t_3, 685); SET_FILENAME_BODY(t_3, FileName); SET_BODY_FUNC(t_2, t_3); CHANGED_BAG( STATE(CurrLVars) ); @@ -4455,8 +4482,8 @@ static Obj HdlrFunc1 ( t_2 = NewFunction( NameFunc[9], 6, 0, HdlrFunc9 ); SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); t_3 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_3, 684); - SET_ENDLINE_BODY(t_3, 690); + SET_STARTLINE_BODY(t_3, 688); + SET_ENDLINE_BODY(t_3, 694); SET_FILENAME_BODY(t_3, FileName); SET_BODY_FUNC(t_2, t_3); CHANGED_BAG( STATE(CurrLVars) ); @@ -4484,8 +4511,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[10], 2, 0, HdlrFunc10 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 703); - SET_ENDLINE_BODY(t_4, 727); + SET_STARTLINE_BODY(t_4, 707); + SET_ENDLINE_BODY(t_4, 731); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4569,8 +4596,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[11], 4, 0, HdlrFunc11 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 852); - SET_ENDLINE_BODY(t_4, 963); + SET_STARTLINE_BODY(t_4, 856); + SET_ENDLINE_BODY(t_4, 967); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4621,8 +4648,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[17], -1, 0, HdlrFunc17 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 998); - SET_ENDLINE_BODY(t_4, 1045); + SET_STARTLINE_BODY(t_4, 1002); + SET_ENDLINE_BODY(t_4, 1049); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4931,7 +4958,7 @@ static Int InitLibrary ( StructInitInfo * module ) static StructInitInfo module = { .type = MODULE_STATIC, .name = "GAPROOT/lib/oper1.g", - .crc = 72319008, + .crc = -16477221, .initKernel = InitKernel, .initLibrary = InitLibrary, .postRestore = PostRestore, diff --git a/src/hpc/c_oper1.c b/src/hpc/c_oper1.c index 9a97ece339..964ed69e7b 100644 --- a/src/hpc/c_oper1.c +++ b/src/hpc/c_oper1.c @@ -1,7 +1,7 @@ #ifndef AVOID_PRECOMPILED /* C file produced by GAC */ #include "compiled.h" -#define FILE_CRC "72319008" +#define FILE_CRC "-16477221" /* global variables used in handlers */ static GVar G_REREADING; @@ -1814,14 +1814,41 @@ static Obj HdlrFunc6 ( } - /* elif IS_INT( arglist[pos] ) then */ + /* elif IS_INT( arglist[pos] ) or IS_FUNCTION( arglist[pos] ) and NARG_FUNC( arglist[pos] ) = 0 and pos < LEN_LIST( arglist ) then */ else { - t_3 = GF_IS__INT; - C_ELM_LIST_FPL( t_4, a_arglist, l_pos ) - t_2 = CALL_1ARGS( t_3, t_4 ); - CHECK_FUNC_RESULT( t_2 ) - CHECK_BOOL( t_2 ) - t_1 = (Obj)(UInt)(t_2 != False); + t_4 = GF_IS__INT; + C_ELM_LIST_FPL( t_5, a_arglist, l_pos ) + t_3 = CALL_1ARGS( t_4, t_5 ); + CHECK_FUNC_RESULT( t_3 ) + CHECK_BOOL( t_3 ) + t_2 = (Obj)(UInt)(t_3 != False); + t_1 = t_2; + if ( ! t_1 ) { + t_7 = GF_IS__FUNCTION; + C_ELM_LIST_FPL( t_8, a_arglist, l_pos ) + t_6 = CALL_1ARGS( t_7, t_8 ); + CHECK_FUNC_RESULT( t_6 ) + CHECK_BOOL( t_6 ) + t_5 = (Obj)(UInt)(t_6 != False); + t_4 = t_5; + if ( t_4 ) { + t_8 = GF_NARG__FUNC; + C_ELM_LIST_FPL( t_9, a_arglist, l_pos ) + t_7 = CALL_1ARGS( t_8, t_9 ); + CHECK_FUNC_RESULT( t_7 ) + t_6 = (Obj)(UInt)(EQ( t_7, INTOBJ_INT(0) )); + t_4 = t_6; + } + t_3 = t_4; + if ( t_3 ) { + t_7 = GF_LEN__LIST; + t_6 = CALL_1ARGS( t_7, a_arglist ); + CHECK_FUNC_RESULT( t_6 ) + t_5 = (Obj)(UInt)(LT( l_pos, t_6 )); + t_3 = t_5; + } + t_1 = t_3; + } if ( t_1 ) { /* rank := arglist[pos]; */ @@ -2798,8 +2825,8 @@ static Obj HdlrFunc7 ( t_6 = NewFunction( NameFunc[8], 1, 0, HdlrFunc8 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 659); - SET_ENDLINE_BODY(t_7, 677); + SET_STARTLINE_BODY(t_7, 663); + SET_ENDLINE_BODY(t_7, 681); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3402,8 +3429,8 @@ static Obj HdlrFunc11 ( t_1 = NewFunction( NameFunc[12], 1, 0, HdlrFunc12 ); SET_ENVI_FUNC( t_1, STATE(CurrLVars) ); t_2 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_2, 856); - SET_ENDLINE_BODY(t_2, 860); + SET_STARTLINE_BODY(t_2, 860); + SET_ENDLINE_BODY(t_2, 864); SET_FILENAME_BODY(t_2, FileName); SET_BODY_FUNC(t_1, t_2); CHANGED_BAG( STATE(CurrLVars) ); @@ -3482,8 +3509,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[13], 1, 0, HdlrFunc13 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 877); - SET_ENDLINE_BODY(t_7, 877); + SET_STARTLINE_BODY(t_7, 881); + SET_ENDLINE_BODY(t_7, 881); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3557,8 +3584,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[14], 2, 0, HdlrFunc14 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 899); - SET_ENDLINE_BODY(t_7, 922); + SET_STARTLINE_BODY(t_7, 903); + SET_ENDLINE_BODY(t_7, 926); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3606,8 +3633,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[15], 2, 0, HdlrFunc15 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 932); - SET_ENDLINE_BODY(t_7, 940); + SET_STARTLINE_BODY(t_7, 936); + SET_ENDLINE_BODY(t_7, 944); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -3668,8 +3695,8 @@ static Obj HdlrFunc11 ( t_6 = NewFunction( NameFunc[16], 3, 0, HdlrFunc16 ); SET_ENVI_FUNC( t_6, STATE(CurrLVars) ); t_7 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_7, 949); - SET_ENDLINE_BODY(t_7, 962); + SET_STARTLINE_BODY(t_7, 953); + SET_ENDLINE_BODY(t_7, 966); SET_FILENAME_BODY(t_7, FileName); SET_BODY_FUNC(t_6, t_7); CHANGED_BAG( STATE(CurrLVars) ); @@ -4042,8 +4069,8 @@ static Obj HdlrFunc17 ( t_4 = NewFunction( NameFunc[18], -1, 0, HdlrFunc18 ); SET_ENVI_FUNC( t_4, STATE(CurrLVars) ); t_5 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_5, 1028); - SET_ENDLINE_BODY(t_5, 1044); + SET_STARTLINE_BODY(t_5, 1032); + SET_ENDLINE_BODY(t_5, 1048); SET_FILENAME_BODY(t_5, FileName); SET_BODY_FUNC(t_4, t_5); CHANGED_BAG( STATE(CurrLVars) ); @@ -4280,8 +4307,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[4], -1, 0, HdlrFunc4 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 328); - SET_ENDLINE_BODY(t_4, 330); + SET_STARTLINE_BODY(t_4, 330); + SET_ENDLINE_BODY(t_4, 332); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4296,8 +4323,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[5], -1, 0, HdlrFunc5 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 355); - SET_ENDLINE_BODY(t_4, 357); + SET_STARTLINE_BODY(t_4, 357); + SET_ENDLINE_BODY(t_4, 359); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4371,7 +4398,7 @@ static Obj HdlrFunc1 ( od; if not IsBound( arglist[pos] ) then Error( "the method is missing in " ); - elif IS_INT( arglist[pos] ) then + elif IS_INT( arglist[pos] ) or IS_FUNCTION( arglist[pos] ) and NARG_FUNC( arglist[pos] ) = 0 and pos < LEN_LIST( arglist ) then rank := arglist[pos]; pos := pos + 1; else @@ -4466,8 +4493,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[6], 2, 0, HdlrFunc6 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 368); - SET_ENDLINE_BODY(t_4, 598); + SET_STARTLINE_BODY(t_4, 370); + SET_ENDLINE_BODY(t_4, 602); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4525,8 +4552,8 @@ static Obj HdlrFunc1 ( t_2 = NewFunction( NameFunc[7], 6, 0, HdlrFunc7 ); SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); t_3 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_3, 617); - SET_ENDLINE_BODY(t_3, 681); + SET_STARTLINE_BODY(t_3, 621); + SET_ENDLINE_BODY(t_3, 685); SET_FILENAME_BODY(t_3, FileName); SET_BODY_FUNC(t_2, t_3); CHANGED_BAG( STATE(CurrLVars) ); @@ -4540,8 +4567,8 @@ static Obj HdlrFunc1 ( t_2 = NewFunction( NameFunc[9], 6, 0, HdlrFunc9 ); SET_ENVI_FUNC( t_2, STATE(CurrLVars) ); t_3 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_3, 684); - SET_ENDLINE_BODY(t_3, 690); + SET_STARTLINE_BODY(t_3, 688); + SET_ENDLINE_BODY(t_3, 694); SET_FILENAME_BODY(t_3, FileName); SET_BODY_FUNC(t_2, t_3); CHANGED_BAG( STATE(CurrLVars) ); @@ -4569,8 +4596,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[10], 2, 0, HdlrFunc10 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 703); - SET_ENDLINE_BODY(t_4, 727); + SET_STARTLINE_BODY(t_4, 707); + SET_ENDLINE_BODY(t_4, 731); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4654,8 +4681,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[11], 4, 0, HdlrFunc11 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 852); - SET_ENDLINE_BODY(t_4, 963); + SET_STARTLINE_BODY(t_4, 856); + SET_ENDLINE_BODY(t_4, 967); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -4706,8 +4733,8 @@ static Obj HdlrFunc1 ( t_3 = NewFunction( NameFunc[17], -1, 0, HdlrFunc17 ); SET_ENVI_FUNC( t_3, STATE(CurrLVars) ); t_4 = NewBag( T_BODY, sizeof(BodyHeader) ); - SET_STARTLINE_BODY(t_4, 998); - SET_ENDLINE_BODY(t_4, 1045); + SET_STARTLINE_BODY(t_4, 1002); + SET_ENDLINE_BODY(t_4, 1049); SET_FILENAME_BODY(t_4, FileName); SET_BODY_FUNC(t_3, t_4); CHANGED_BAG( STATE(CurrLVars) ); @@ -5032,7 +5059,7 @@ static Int InitLibrary ( StructInitInfo * module ) static StructInitInfo module = { .type = MODULE_STATIC, .name = "GAPROOT/lib/oper1.g", - .crc = 72319008, + .crc = -16477221, .initKernel = InitKernel, .initLibrary = InitLibrary, .postRestore = PostRestore, diff --git a/tst/testinstall/method-rankfns.tst b/tst/testinstall/method-rankfns.tst new file mode 100644 index 0000000000..93fe2444f3 --- /dev/null +++ b/tst/testinstall/method-rankfns.tst @@ -0,0 +1,21 @@ +gap> START_TEST("method-rankfns.tst"); +gap> myOp := NewOperation("myOp",[IsObject]);; +gap> myC := NewConstructor("myC",[IsObject]);; +gap> xxx := 1;; +gap> InstallMethod(myOp,"method1",[IsObject],x->1); +gap> InstallMethod(myOp,"method2",[IsObject],{}->xxx,x->2); +gap> InstallMethod(myC,"cons1",[IsObject],x->1); +gap> InstallMethod(myC,"cons2",[IsObject],{}->xxx,x->2); +gap> myOp(3); +2 +gap> myC(IsObject); +2 +gap> xxx := -1;; +gap> RECALCULATE_ALL_METHOD_RANKS(); +gap> myOp(3); +1 +gap> myC(IsObject); +1 +gap> Unbind(myOp); +gap> Unbind(myC); +gap> STOP_TEST("method-rankfns.tst"); diff --git a/tst/testinstall/method-reordering.tst b/tst/testinstall/method-reordering.tst index eb03bccba8..73fce4b7b2 100644 --- a/tst/testinstall/method-reordering.tst +++ b/tst/testinstall/method-reordering.tst @@ -1,6 +1,6 @@ gap> START_TEST("method-reordering.tst"); gap> CheckReorder := function(explicit) -> local f1, f2, f3, myOp, fam, t, o, myC; +> local f1, f2, f3, myOp, fam, t, o, o2, myC; > f1 := NewFilter("filter1",100); > f2 := NewFilter("filter1",10); > f3 := NewFilter("filter1",1); diff --git a/tst/testinstall/varargs.tst b/tst/testinstall/varargs.tst index 785058583c..9388937849 100644 --- a/tst/testinstall/varargs.tst +++ b/tst/testinstall/varargs.tst @@ -87,7 +87,7 @@ function ( <>, <>, <>, <>, <>, <> ) end gap> Display(InstallMethod); function ( <>... ) - <> + <> end gap> [1..2]; [ 1, 2 ] From 28d3d3fb219d49e0637f16c2b0c49756a70a7664 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Thu, 28 Jun 2018 16:39:24 +0100 Subject: [PATCH 12/12] Reset reordering status on quit from break loop. --- lib/error.g | 3 +++ lib/filter.g | 16 ++++++++-------- src/opers.c | 4 ++-- tst/testinstall/method-reordering.tst | 6 ------ 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/error.g b/lib/error.g index 74bc769450..ff636977d1 100644 --- a/lib/error.g +++ b/lib/error.g @@ -32,6 +32,9 @@ BIND_GLOBAL( "OnQuit", # care to ensure it always has a definition. - GG until IsEmpty(OptionsStack); Info(InfoWarning,1,"Options stack has been reset"); fi; + if IsBound(ResetMethodReordering) and IsFunction(ResetMethodReordering) then + ResetMethodReordering(); + fi; end); diff --git a/lib/filter.g b/lib/filter.g index 7416c29be5..f80c2b74a6 100644 --- a/lib/filter.g +++ b/lib/filter.g @@ -173,9 +173,9 @@ end ); ############################################################################# ## -#F SuspendMethodReordering() -#F ResumeMethodReordering() -#F ResetMethodReordering() +#F SuspendMethodReordering( ) +#F ResumeMethodReordering( ) +#F ResetMethodReordering( ) ## ## <#GAPDoc Label="MethodReordering"> ## @@ -183,18 +183,20 @@ end ); ## ## ## -## These functions control whether the method reordering process +## +## These functions control whether the method reordering process ## described in is invoked or not. Since this ## process can be comparatively time-consuming, it is usually suspended when ## a lot of implications are due to be installed, for instance when loading -## the library, or a package. This is done by called SuspendMethodReordering() +## the library, or a package. This is done by calling SuspendMethodReordering() ## once the installations are done, ResumeMethodReordering() should be called. ## These pairs of calls can be nested. When the outermost pair is complete, method ## reordering takes place and is enabled in InstallTrueMethod thereafter. ## ## ResetMethodReordering() effectively exits all nested suspensions, resuming ## reordering immediately. This function is mainly provided for error recovery and -## similar purposes. +## similar purposes and is called on quitting from a break loop. +## ## ## <#/GAPDoc> @@ -277,8 +279,6 @@ end); ## <#/GAPDoc> ## - - BIND_GLOBAL( "InstallTrueMethod", function ( tofilt, from ) InstallTrueMethodNewFilter( tofilt, from ); diff --git a/src/opers.c b/src/opers.c index 5924444c60..7a04f32e12 100644 --- a/src/opers.c +++ b/src/opers.c @@ -1929,8 +1929,8 @@ static ALWAYS_INLINE Obj GetMethodUncached( // entry n+4 is the info text // entry n+5 is, if set, the location where the method was installed // entry n+6 is, if set, the relative rank that was supplied when - // the method was installed, either as a small integer or a function - // of no arguments + // the method was installed, either as a small integer + // or a function of no arguments // check argument filters against the given types Obj filter; diff --git a/tst/testinstall/method-reordering.tst b/tst/testinstall/method-reordering.tst index 73fce4b7b2..ff137098c5 100644 --- a/tst/testinstall/method-reordering.tst +++ b/tst/testinstall/method-reordering.tst @@ -33,9 +33,3 @@ true gap> ResumeMethodReordering(); gap> Unbind(CheckReorder); gap> STOP_TEST("method-reordering.tst"); - - - - - -