diff --git a/gap/gaptypes.g b/gap/gaptypes.g index e024660a1ff1f6d0bde2f200cf7fe8c6cbb889b6..36e01db11cf0008f974af0cfde6b7cd4559dc92b 100644 --- a/gap/gaptypes.g +++ b/gap/gaptypes.g @@ -1,24 +1,46 @@ # Load into GAP using Read("gaptypes.g"); and export using # GAPTypesToJson("gap_types.json"); +# Operations +# Families (not necessary) +# Types of Installed Methods ( with filters ) + LoadPackage("json"); LoadPackage("io"); +FindOperationId := function( oper ) + local i; -GAPFilterToFilterType := function(fid) - if INFO_FILTERS[fid] in FNUM_CATS then - return "GAP_Category"; - elif INFO_FILTERS[fid] in FNUM_REPS then - return "GAP_Representation"; - elif INFO_FILTERS[fid] in FNUM_ATTS then - return "GAP_Attribute"; - elif INFO_FILTERS[fid] in FNUM_PROS then - return "GAP_Property"; - elif INFO_FILTERS[fid] in FNUM_TPRS then - return "GAP_TrueProperty"; + if IsOperation(oper) then + for i in [1..Length(OPERATIONS)/2] do + if OPERATIONS[2*i - 1] = oper then + return 2*i - 1; + fi; + od; + return fail; else - return "GAP_Filter"; + Error("not an operation"); fi; + return fail; +end; + +FiltersForOperation := function( oper ) + local res, res2, filts, opid, fset, flags; + + res := []; + opid := FindOperationId(oper); + + filts := OPERATIONS[opid + 1]; + + for fset in filts do + res2 := []; + for flags in fset do + Add(res2, List(TRUES_FLAGS(flags), x -> FILTERS[x])); + od; + Add(res, res2); + od; + + return res; end; GAPAndFilterUnpack := function(t) @@ -28,7 +50,7 @@ GAPAndFilterUnpack := function(t) if IsOperation(t) then if (IsInt(FLAG1_FILTER(t)) and IsInt(FLAG2_FILTER(t))) - then + then Add(res, NAME_FUNC(t)); else Append(res, GAPAndFilterUnpack(FLAG1_FILTER(t))); @@ -38,6 +60,21 @@ GAPAndFilterUnpack := function(t) return res; end; +GAPFilterToFilterType := function(fid) + if INFO_FILTERS[fid] in FNUM_CATS then + return "GAP_Category"; + elif INFO_FILTERS[fid] in FNUM_REPS then + return "GAP_Representation"; + elif INFO_FILTERS[fid] in FNUM_ATTS then + return "GAP_Attribute"; + elif INFO_FILTERS[fid] in FNUM_PROS then + return "GAP_Property"; + elif INFO_FILTERS[fid] in FNUM_TPRS then + return "GAP_TrueProperty"; + else + return "GAP_Filter"; + fi; +end; # Make GAP Type graph as a record GAPTypesInfo := function() @@ -83,9 +120,18 @@ GAPTypesInfo := function() lres.name := ATTRIBUTES[i][1]; Add(res, lres); od; + for i in [1..Length(OPERATIONS)/2] do + lres := rec(); + lres.type := "GAP_Operation"; + lres.name := NAME_FUNC(OPERATIONS[2*i - 1]); + lres.filters := FiltersForOperation(OPERATIONS[2*i - 1]); + lres.filters := List(lres.filters, x->List(x,y -> List(y,NAME_FUNC))); + Add(res, lres); + od; return res; end; + # Write the graph of type info to JSon file GAPTypesToJson := function(file) local fd, n;