Skip to content

Commit 9f03ac8

Browse files
CapJitAddTypeSignature( "LazyArray", [ IsInt, IsFunction ], ... )
1 parent 274ba63 commit 9f03ac8

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

CompilerForCAP/gap/HoistExpressions.gi

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ InstallGlobalFunction( CapJitExtractedExpensiveOperationsFromLoops, function ( t
276276

277277
fi;
278278

279-
elif ForAny( tree.args, a -> a.type = "EXPR_DECLARATIVE_FUNC" ) and not tree.funcref.gvar in [ "ListN", "Iterated", "CapFixpoint", "LazyHList" ] then
279+
elif ForAny( tree.args, a -> a.type = "EXPR_DECLARATIVE_FUNC" ) and not tree.funcref.gvar in [ "ListN", "Iterated", "CapFixpoint", "LazyHList", "LazyArray" ] then
280280

281281
# COVERAGE_IGNORE_NEXT_LINE
282282
Print( "WARNING: Could not detect domain of function in call of ", tree.funcref.gvar, ". Please write a bug report including this message.\n" );

CompilerForCAP/gap/InferDataTypes.gi

+56-2
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,17 @@ CapJitAddTypeSignature( "ListWithIdenticalEntries", [ IsInt, IsObject ], functio
965965
end );
966966

967967
CapJitAddTypeSignature( "Concatenation", [ IsList ], function ( input_types )
968+
local filter;
968969

969-
Assert( 0, input_types[1].element_type.filter = IsList );
970+
if input_types[1].element_type.filter = IsList then
971+
filter := IsList;
972+
elif input_types[1].element_type.filter = IsLazyArray then
973+
filter := IsLazyArray;
974+
else
975+
Error( input_types[1].element_type.filter, " is not in [ IsList, IsLazyArray ]\n" );
976+
fi;
970977

971-
return rec( filter := IsList, element_type := input_types[1].element_type.element_type );
978+
return rec( filter := filter, element_type := input_types[1].element_type.element_type );
972979

973980
end );
974981

@@ -1176,6 +1183,53 @@ CapJitAddTypeSignature( "[,]", [ IsList, IsInt, IsInt ], function ( input_types
11761183

11771184
end );
11781185

1186+
CapJitAddTypeSignature( "LazyArray", [ IsInt, IsFunction ], function ( args, func_stack )
1187+
1188+
args := ShallowCopy( args );
1189+
1190+
args.2 := CAP_JIT_INTERNAL_INFERRED_DATA_TYPES_OF_FUNCTION_BY_ARGUMENTS_TYPES( args.2, [ args.1.data_type ], func_stack );
1191+
1192+
if args.2 = fail then
1193+
1194+
#Error( "could not determine output type" );
1195+
return fail;
1196+
1197+
fi;
1198+
1199+
return rec( args := args, output_type := rec( filter := IsLazyArray, element_type := args.2.data_type.signature[2] ) );
1200+
1201+
end );
1202+
1203+
CapJitAddTypeSignature( "LazyStandardInterval", [ IsInt ], function ( input_types )
1204+
1205+
return rec( filter := IsLazyArray, element_type := rec( filter := IsInt ) );
1206+
1207+
end );
1208+
1209+
CapJitAddTypeSignature( "LazyInterval", [ IsInt, IsInt ], function ( input_types )
1210+
1211+
return rec( filter := IsLazyInterval, element_type := rec( filter := IsInt ) );
1212+
1213+
end );
1214+
1215+
CapJitAddTypeSignature( "LazyConstantArray", [ IsInt, IsInt ], function ( input_types )
1216+
1217+
return rec( filter := IsLazyConstantArray, element_type := rec( filter := IsInt ) );
1218+
1219+
end );
1220+
1221+
CapJitAddTypeSignature( "LazyArrayFromList", [ IsList ], function ( input_types )
1222+
1223+
return rec( filter := IsLazyArrayFromList, element_type := rec( filter := IsInt ) );
1224+
1225+
end );
1226+
1227+
CapJitAddTypeSignature( "ListOfValues", [ IsLazyArray ], function ( input_types )
1228+
1229+
return rec( filter := IsList, element_type := rec( filter := IsInt ) );
1230+
1231+
end );
1232+
11791233
CapJitAddTypeSignature( "LazyHList", [ IsList, IsFunction ], function ( args, func_stack )
11801234

11811235
args := ShallowCopy( args );

0 commit comments

Comments
 (0)