Skip to content

Commit

Permalink
Generate dual derivations automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
zickgraf committed Sep 26, 2023
1 parent 95f09b4 commit c8f27fb
Show file tree
Hide file tree
Showing 20 changed files with 2,288 additions and 1,578 deletions.
2 changes: 1 addition & 1 deletion CAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "CAP",
Subtitle := "Categories, Algorithms, Programming",
Version := "2023.09-09",
Version := "2023.09-10",
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
License := "GPL-2.0-or-later",

Expand Down
11 changes: 10 additions & 1 deletion CAP/gap/CAP.gi
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,16 @@ InstallGlobalFunction( "CreateCapCategoryWithDataTypes",

obj!.is_computable := CAP_INTERNAL_RETURN_OPTION_OR_DEFAULT( "is_computable", true );

obj!.derivations_weight_list := MakeOperationWeightList( obj, CAP_INTERNAL_DERIVATION_GRAPH );
if ValueOption( "disable_derivations" ) = true then

# use an empty derivation graph
obj!.derivations_weight_list := MakeOperationWeightList( obj, MakeDerivationGraph( Operations( CAP_INTERNAL_DERIVATION_GRAPH ) ) );

else

obj!.derivations_weight_list := MakeOperationWeightList( obj, CAP_INTERNAL_DERIVATION_GRAPH );

fi;

obj!.caches := rec( );

Expand Down
15 changes: 13 additions & 2 deletions CAP/gap/Derivations.gi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ InstallMethod( MakeDerivation,
[ IsString, IsFunction, IsDenseList, IsPosInt, IsFunction, IsFunction ],

function( name, target_op, used_op_names_with_multiples_and_category_getters, weight, func, category_filter )
local wrapped_category_filter;
local wrapped_category_filter, derivation;

#= comment for Julia
if PositionSublist( String( category_filter ), "CanCompute" ) <> fail then
Expand Down Expand Up @@ -70,7 +70,7 @@ function( name, target_op, used_op_names_with_multiples_and_category_getters, we

fi;

return ObjectifyWithAttributes(
derivation := ObjectifyWithAttributes(
rec( ), TheTypeOfDerivedMethods,
DerivationName, name,
DerivationWeight, weight,
Expand All @@ -80,6 +80,17 @@ function( name, target_op, used_op_names_with_multiples_and_category_getters, we
UsedOperationsWithMultiplesAndCategoryGetters, used_op_names_with_multiples_and_category_getters
);

derivation!.is_with_given_derivation := CAP_INTERNAL_RETURN_OPTION_OR_DEFAULT( "is_with_given_derivation", false );
derivation!.is_autogenerated_by_CompilerForCAP := CAP_INTERNAL_RETURN_OPTION_OR_DEFAULT( "is_autogenerated_by_CompilerForCAP", false );

if derivation!.is_with_given_derivation and derivation!.is_autogenerated_by_CompilerForCAP then

Error( "WithGiven derivations should not be marked as being autogenerated by CompilerForCAP" );

Check warning on line 88 in CAP/gap/Derivations.gi

View check run for this annotation

Codecov / codecov/patch

CAP/gap/Derivations.gi#L88

Added line #L88 was not covered by tests

fi;

return derivation;

end );

InstallMethod( String,
Expand Down
1,596 changes: 1,596 additions & 0 deletions CAP/gap/DerivedMethods.autogen.gi

Large diffs are not rendered by default.

Loading

0 comments on commit c8f27fb

Please sign in to comment.