From c0c2cb967d8d038d3ee92b21502fb746c2503f67 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Wed, 17 Jul 2024 16:30:31 +0200 Subject: [PATCH] Distinguish between small and big integers --- CAP/gap/InstallAdds.gi | 2 +- CAP/gap/ToolsForCategories.gi | 2 +- CompilerForCAP/gap/CompilerForCAP.gi | 3 +++ CompilerForCAP/gap/InferDataTypes.gi | 20 +++++++++++++++++-- FreydCategoriesForCAP/gap/AdditiveClosure.gi | 4 ++-- FreydCategoriesForCAP/gap/CategoryOfRows.gi | 6 +++--- ...fRows_as_AdditiveClosure_RingAsCategory.gi | 2 +- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CAP/gap/InstallAdds.gi b/CAP/gap/InstallAdds.gi index 02019a2694..599dfbe9a8 100644 --- a/CAP/gap/InstallAdds.gi +++ b/CAP/gap/InstallAdds.gi @@ -127,7 +127,7 @@ InstallGlobalFunction( CapInternalInstallAdd, fi; - InstallMethod( CAP_operation, replaced_filter_list{[ 2 .. Length( replaced_filter_list ) ]}, get_convenience_function( CAP_operation ) ); + InstallOtherMethod( CAP_operation, replaced_filter_list{[ 2 .. Length( replaced_filter_list ) ]}, get_convenience_function( CAP_operation ) ); fi; diff --git a/CAP/gap/ToolsForCategories.gi b/CAP/gap/ToolsForCategories.gi index 061461a772..2125df334b 100644 --- a/CAP/gap/ToolsForCategories.gi +++ b/CAP/gap/ToolsForCategories.gi @@ -106,7 +106,7 @@ InstallGlobalFunction( "CAP_INTERNAL_GET_DATA_TYPE_FROM_STRING", function ( stri elif string = "integer" then - return rec( filter := IsInt ); + return rec( filter := IsSmallIntRep ); elif string = "nonneg_integer_or_infinity" then diff --git a/CompilerForCAP/gap/CompilerForCAP.gi b/CompilerForCAP/gap/CompilerForCAP.gi index b3dc6dd79c..72423ee67c 100644 --- a/CompilerForCAP/gap/CompilerForCAP.gi +++ b/CompilerForCAP/gap/CompilerForCAP.gi @@ -260,6 +260,7 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_COMPILED_ENHANCED_SYNTAX_TREE, function # resolving phase resolving_phase_functions := [ + CapJitInferredDataTypes, CapJitResolvedOperations, CapJitInlinedArguments, CapJitDroppedUnusedBindings, @@ -380,6 +381,8 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_COMPILED_ENHANCED_SYNTAX_TREE, function fi; + #Display(ENHANCED_SYNTAX_TREE_CODE( tree ) ); + tree := f( tree ); if CAP_JIT_INTERNAL_DEBUG_LEVEL >= 2 then diff --git a/CompilerForCAP/gap/InferDataTypes.gi b/CompilerForCAP/gap/InferDataTypes.gi index c94fd69731..95eb7219ef 100644 --- a/CompilerForCAP/gap/InferDataTypes.gi +++ b/CompilerForCAP/gap/InferDataTypes.gi @@ -152,7 +152,7 @@ InstallGlobalFunction( "CAP_JIT_INTERNAL_GET_OUTPUT_TYPE_OF_GLOBAL_FUNCTION_BY_I if Length( type_signatures ) = 0 then - DisplayWithCurrentlyCompiledFunctionLocation( Concatenation( "WARNING: Could not find matching declaration of ", gvar, " for input ", String( input_filters ) ) ); + ErrorWithCurrentlyCompiledFunctionLocation( Concatenation( "WARNING: Could not find matching declaration of ", gvar, " for input ", String( input_filters ) ) ); return fail; elif Length( type_signatures ) > 1 then @@ -428,7 +428,7 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_INFERRED_DATA_TYPES, function ( tree, in if tree.type = "EXPR_INT" then - data_type := rec( filter := IsInt ); + data_type := rec( filter := IsSmallIntRep ); elif tree.type = "EXPR_STRING" then @@ -519,6 +519,7 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_INFERRED_DATA_TYPES, function ( tree, in elif tree.type = "EXPR_RANGE" then + # TODO data_type := CapJitDataTypeOfListOf( IsInt ); elif tree.type = "EXPR_LIST" then @@ -888,9 +889,17 @@ CapJitAddTypeSignature( "RETURN_TRUE", [ IsObject, IsObject ], IsBool ); CapJitAddTypeSignature( "Length", [ IsList ], IsInt ); CapJitAddTypeSignature( "IsEmpty", [ IsList ], IsBool ); CapJitAddTypeSignature( "+", [ IsInt, IsInt ], IsInt ); +CapJitAddTypeSignature( "+", [ IsInt, IsSmallIntRep ], IsInt ); +CapJitAddTypeSignature( "+", [ IsSmallIntRep, IsSmallIntRep ], IsSmallIntRep ); +CapJitAddTypeSignature( "+", [ IsSmallIntRep, IsInt ], IsInt ); CapJitAddTypeSignature( "AdditiveInverseSameMutability", [ IsInt ], IsInt ); CapJitAddTypeSignature( "-", [ IsInt, IsInt ], IsInt ); +CapJitAddTypeSignature( "-", [ IsInt, IsSmallIntRep ], IsInt ); +CapJitAddTypeSignature( "-", [ IsSmallIntRep, IsSmallIntRep ], IsSmallIntRep ); CapJitAddTypeSignature( "*", [ IsInt, IsInt ], IsInt ); +CapJitAddTypeSignature( "*", [ IsInt, IsSmallIntRep ], IsInt ); +CapJitAddTypeSignature( "*", [ IsSmallIntRep, IsInt ], IsInt ); +CapJitAddTypeSignature( "*", [ IsSmallIntRep, IsSmallIntRep ], IsInt ); CapJitAddTypeSignature( "^", [ IsInt, IsInt ], IsInt ); CapJitAddTypeSignature( "REM_INT", [ IsInt, IsInt ], IsInt ); CapJitAddTypeSignature( "QUO_INT", [ IsInt, IsInt ], IsInt ); @@ -900,6 +909,7 @@ CapJitAddTypeSignature( "^", [ IsPerm, IsInt ], IsPerm ); CapJitAddTypeSignature( "PermList", [ IsList ], IsPerm ); CapJitAddTypeSignature( "PermutationMat", [ IsPerm, IsInt ], CapJitDataTypeOfListOf( CapJitDataTypeOfListOf( IsInt ) ) ); CapJitAddTypeSignature( "BigInt", [ IsInt ], IsBigInt ); +CapJitAddTypeSignature( "BigInt", [ IsSmallIntRep ], IsInt ); CapJitAddTypeSignature( "IS_IDENTICAL_OBJ", [ IsObject, IsObject ], function ( input_types ) @@ -1019,6 +1029,12 @@ CapJitAddTypeSignature( "[]", [ IsList, IsInt ], function ( input_types ) end ); +CapJitAddTypeSignature( "[]", [ IsList, IsSmallIntRep ], function ( input_types ) + + return input_types[1].element_type; + +end ); + CapJitAddTypeSignature( "{}", [ IsList, IsList ], function ( input_types ) return input_types[1]; diff --git a/FreydCategoriesForCAP/gap/AdditiveClosure.gi b/FreydCategoriesForCAP/gap/AdditiveClosure.gi index f8ca220146..360f77e70c 100644 --- a/FreydCategoriesForCAP/gap/AdditiveClosure.gi +++ b/FreydCategoriesForCAP/gap/AdditiveClosure.gi @@ -910,7 +910,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_ADDITIVE_CLOSURE, function( cat, diagram, test_object, morphisms, direct_sum ) local listlist; - listlist := UnionOfColumnsListList( Length( ObjectList( test_object ) ), List( morphisms, tau -> MorphismMatrix( tau ) ) ); + listlist := UnionOfColumnsListList( BigInt( Length( ObjectList( test_object ) ) ), List( morphisms, tau -> MorphismMatrix( tau ) ) ); return AdditiveClosureMorphism( cat, test_object, listlist, @@ -923,7 +923,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_ADDITIVE_CLOSURE, function( cat, diagram, test_object, morphisms, direct_sum ) local listlist; - listlist := UnionOfRowsListList( Length( ObjectList( test_object ) ), List( morphisms, tau -> MorphismMatrix( tau ) ) ); + listlist := UnionOfRowsListList( BigInt( Length( ObjectList( test_object ) ) ), List( morphisms, tau -> MorphismMatrix( tau ) ) ); return AdditiveClosureMorphism( cat, direct_sum, listlist, diff --git a/FreydCategoriesForCAP/gap/CategoryOfRows.gi b/FreydCategoriesForCAP/gap/CategoryOfRows.gi index e4d74ca112..837e09e0cd 100644 --- a/FreydCategoriesForCAP/gap/CategoryOfRows.gi +++ b/FreydCategoriesForCAP/gap/CategoryOfRows.gi @@ -379,7 +379,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CATEGORY_OF_ROWS, AddAdditiveGenerators( category, function( cat ) - return [ CategoryOfRowsObject( cat, 1 ) ]; + return [ CategoryOfRowsObject( cat, BigInt( 1 ) ) ]; end ); @@ -1013,7 +1013,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CATEGORY_OF_ROWS, AddTensorUnit( category, function( cat ) - return CategoryOfRowsObject( cat, 1 ); + return CategoryOfRowsObject( cat, BigInt( 1 ) ); end ); @@ -1364,7 +1364,7 @@ AddFinalDerivationBundle( "Using BasisOfExternalHom and CoefficientsOfMorphism t [ ], function ( cat ) - return CategoryOfRowsObject( RangeCategoryOfHomomorphismStructure( cat ), 1 ); + return CategoryOfRowsObject( RangeCategoryOfHomomorphismStructure( cat ), BigInt( 1 ) ); end ], diff --git a/FreydCategoriesForCAP/gap/CategoryOfRows_as_AdditiveClosure_RingAsCategory.gi b/FreydCategoriesForCAP/gap/CategoryOfRows_as_AdditiveClosure_RingAsCategory.gi index 6ea5c3c37f..caabbd31f3 100644 --- a/FreydCategoriesForCAP/gap/CategoryOfRows_as_AdditiveClosure_RingAsCategory.gi +++ b/FreydCategoriesForCAP/gap/CategoryOfRows_as_AdditiveClosure_RingAsCategory.gi @@ -88,7 +88,7 @@ InstallMethod( CategoryOfRows_as_AdditiveClosure_RingAsCategory, modeling_tower_object_datum := function ( cat, object ) - return Length( ObjectList( object ) ); + return BigInt( Length( ObjectList( object ) ) ); end;