File: methsel.g

package info (click to toggle)
gap 4r10p0-7
  • links: PTS
  • area: main
  • in suites: buster
  • size: 47,392 kB
  • sloc: ansic: 118,475; xml: 54,089; sh: 4,112; perl: 1,654; makefile: 274
file content (93 lines) | stat: -rw-r--r-- 3,176 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#############################################################################
##
#W  methsel.g                   GAP library                      Frank Celler
#W                                                           Martin Schönert
##
##
#Y  Copyright (C)  1996,  Lehrstuhl D für Mathematik,  RWTH Aachen,  Germany
#Y  (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y  Copyright (C) 2002 The GAP Group
##
##  This file defines the less frequently used functions to select
##  methods. More frequently used functions used to be in methsel1.g,
##  which was compiled in the default setup; this code has now been
##  replaced by hand written C code in the kernel.
##


#############################################################################
##
#F  # # # # # # # # # # # # #  method selection # # # # # # # # # # # # # # #
##


#############################################################################
##
#F  AttributeValueNotSet( <attr>, <obj> )
##
AttributeValueNotSet := function(attr,obj)
local type,fam,methods,i,j,flag,erg;
  type:=TypeObj(obj);
  fam:=FamilyObj(obj);
  methods:=METHODS_OPERATION(attr,1);
  for i in [1..LEN_LIST(methods)/(1+BASE_SIZE_METHODS_OPER_ENTRY)] do
#    nam:=methods[5*(i-1)+5]; # name
    j:=(1+BASE_SIZE_METHODS_OPER_ENTRY)*(i-1);
    flag:=true;
    flag:=flag and IS_SUBSET_FLAGS(type![2],methods[j+2]);
    if flag then
      flag:=flag and methods[j+1](fam);
    fi;
    if flag then
      attr:=methods[j+3];
      erg:=attr(obj);
      if not IS_IDENTICAL_OBJ(erg,TRY_NEXT_METHOD) then
        return erg;
      fi;
    fi;
  od;
  Error("No applicable method found for attribute");
end;


#############################################################################
##
#F  # # # # # # # # # # #  verbose method selection # # # # # # # # # # # # #
##
VMETHOD_PRINT_INFO := function ( methods, i, arity)
    local offset;
    offset := (arity+BASE_SIZE_METHODS_OPER_ENTRY)*(i-1)+arity;
    Print("#I  ", methods[offset+4]);
    if BASE_SIZE_METHODS_OPER_ENTRY >= 5 then
        Print(" at ", methods[offset+5][1], ":", methods[offset+5][2]);
    elif FILENAME_FUNC(methods[offset+2]) <> fail then
        Print(" at ",
              FILENAME_FUNC(methods[offset+2]), ":",
              STARTLINE_FUNC(methods[offset+2]));
    fi;
    Print("\n");
end;

#############################################################################
##
#F  # # # # # # # # # # #  verbose try next method  # # # # # # # # # # # # #
##
NEXT_VMETHOD_PRINT_INFO := function ( methods, i, arity)
    local offset;
    offset := (arity+BASE_SIZE_METHODS_OPER_ENTRY)*(i-1)+arity;
    Print("#I Trying next: ", methods[offset+4]);
    if BASE_SIZE_METHODS_OPER_ENTRY >= 5 then
        Print(" at ", methods[offset+5][1], ":", methods[offset+5][2]);
    elif FILENAME_FUNC(methods[offset+2]) <> fail then
        Print(" at ",
              FILENAME_FUNC(methods[offset+2]), ":",
              STARTLINE_FUNC(methods[offset+2]));
    fi;
    Print("\n");
end;


#############################################################################
##
#E  methsel.g . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here
##