From 9f03ac8152a4c80ea601f88db236cc9103c78ef9 Mon Sep 17 00:00:00 2001 From: Mohamed Barakat Date: Fri, 2 Sep 2022 13:18:40 +0200 Subject: [PATCH] CapJitAddTypeSignature( "LazyArray", [ IsInt, IsFunction ], ... ) --- CompilerForCAP/gap/HoistExpressions.gi | 2 +- CompilerForCAP/gap/InferDataTypes.gi | 58 +++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/CompilerForCAP/gap/HoistExpressions.gi b/CompilerForCAP/gap/HoistExpressions.gi index f14e9f4747..93d0d1635f 100644 --- a/CompilerForCAP/gap/HoistExpressions.gi +++ b/CompilerForCAP/gap/HoistExpressions.gi @@ -276,7 +276,7 @@ InstallGlobalFunction( CapJitExtractedExpensiveOperationsFromLoops, function ( t fi; - elif ForAny( tree.args, a -> a.type = "EXPR_DECLARATIVE_FUNC" ) and not tree.funcref.gvar in [ "ListN", "Iterated", "CapFixpoint", "LazyHList" ] then + elif ForAny( tree.args, a -> a.type = "EXPR_DECLARATIVE_FUNC" ) and not tree.funcref.gvar in [ "ListN", "Iterated", "CapFixpoint", "LazyHList", "LazyArray" ] then # COVERAGE_IGNORE_NEXT_LINE Print( "WARNING: Could not detect domain of function in call of ", tree.funcref.gvar, ". Please write a bug report including this message.\n" ); diff --git a/CompilerForCAP/gap/InferDataTypes.gi b/CompilerForCAP/gap/InferDataTypes.gi index eb6db693f0..486965a87a 100644 --- a/CompilerForCAP/gap/InferDataTypes.gi +++ b/CompilerForCAP/gap/InferDataTypes.gi @@ -965,10 +965,17 @@ CapJitAddTypeSignature( "ListWithIdenticalEntries", [ IsInt, IsObject ], functio end ); CapJitAddTypeSignature( "Concatenation", [ IsList ], function ( input_types ) + local filter; - Assert( 0, input_types[1].element_type.filter = IsList ); + if input_types[1].element_type.filter = IsList then + filter := IsList; + elif input_types[1].element_type.filter = IsLazyArray then + filter := IsLazyArray; + else + Error( input_types[1].element_type.filter, " is not in [ IsList, IsLazyArray ]\n" ); + fi; - return rec( filter := IsList, element_type := input_types[1].element_type.element_type ); + return rec( filter := filter, element_type := input_types[1].element_type.element_type ); end ); @@ -1176,6 +1183,53 @@ CapJitAddTypeSignature( "[,]", [ IsList, IsInt, IsInt ], function ( input_types end ); +CapJitAddTypeSignature( "LazyArray", [ IsInt, IsFunction ], function ( args, func_stack ) + + args := ShallowCopy( args ); + + args.2 := CAP_JIT_INTERNAL_INFERRED_DATA_TYPES_OF_FUNCTION_BY_ARGUMENTS_TYPES( args.2, [ args.1.data_type ], func_stack ); + + if args.2 = fail then + + #Error( "could not determine output type" ); + return fail; + + fi; + + return rec( args := args, output_type := rec( filter := IsLazyArray, element_type := args.2.data_type.signature[2] ) ); + +end ); + +CapJitAddTypeSignature( "LazyStandardInterval", [ IsInt ], function ( input_types ) + + return rec( filter := IsLazyArray, element_type := rec( filter := IsInt ) ); + +end ); + +CapJitAddTypeSignature( "LazyInterval", [ IsInt, IsInt ], function ( input_types ) + + return rec( filter := IsLazyInterval, element_type := rec( filter := IsInt ) ); + +end ); + +CapJitAddTypeSignature( "LazyConstantArray", [ IsInt, IsInt ], function ( input_types ) + + return rec( filter := IsLazyConstantArray, element_type := rec( filter := IsInt ) ); + +end ); + +CapJitAddTypeSignature( "LazyArrayFromList", [ IsList ], function ( input_types ) + + return rec( filter := IsLazyArrayFromList, element_type := rec( filter := IsInt ) ); + +end ); + +CapJitAddTypeSignature( "ListOfValues", [ IsLazyArray ], function ( input_types ) + + return rec( filter := IsList, element_type := rec( filter := IsInt ) ); + +end ); + CapJitAddTypeSignature( "LazyHList", [ IsList, IsFunction ], function ( args, func_stack ) args := ShallowCopy( args );