@@ -243,93 +243,6 @@ def impl_to_scalar(x):
243243 raise TypingError (f"{ x } must be a scalar compatible type." )
244244
245245
246- def enable_slice_literals ():
247- """Enable lowering for ``SliceLiteral``s.
248-
249- TODO: This can be removed once https://github.com/numba/numba/pull/6996 is merged
250- and a release is made.
251- """
252- from numba .core import types
253- from numba .core .datamodel .models import SliceModel
254- from numba .core .datamodel .registry import register_default
255- from numba .core .imputils import lower_cast , lower_constant
256- from numba .core .types .misc import SliceLiteral
257- from numba .cpython .slicing import get_defaults
258-
259- register_default (numba .types .misc .SliceLiteral )(SliceModel )
260-
261- @property
262- def key (self ):
263- return self .name
264-
265- SliceLiteral .key = key
266-
267- def make_slice_from_constant (context , builder , ty , pyval ):
268- sli = context .make_helper (builder , ty )
269- lty = context .get_value_type (types .intp )
270-
271- (
272- default_start_pos ,
273- default_start_neg ,
274- default_stop_pos ,
275- default_stop_neg ,
276- default_step ,
277- ) = (context .get_constant (types .intp , x ) for x in get_defaults (context ))
278-
279- step = pyval .step
280- if step is None :
281- step_is_neg = False
282- step = default_step
283- else :
284- step_is_neg = step < 0
285- step = lty (step )
286-
287- start = pyval .start
288- if start is None :
289- if step_is_neg :
290- start = default_start_neg
291- else :
292- start = default_start_pos
293- else :
294- start = lty (start )
295-
296- stop = pyval .stop
297- if stop is None :
298- if step_is_neg :
299- stop = default_stop_neg
300- else :
301- stop = default_stop_pos
302- else :
303- stop = lty (stop )
304-
305- sli .start = start
306- sli .stop = stop
307- sli .step = step
308-
309- return sli ._getvalue ()
310-
311- @lower_constant (numba .types .SliceType )
312- def constant_slice (context , builder , ty , pyval ):
313- if isinstance (ty , types .Literal ):
314- typ = ty .literal_type
315- else :
316- typ = ty
317-
318- return make_slice_from_constant (context , builder , typ , pyval )
319-
320- @lower_cast (numba .types .misc .SliceLiteral , numba .types .SliceType )
321- def cast_from_literal (context , builder , fromty , toty , val ):
322- return make_slice_from_constant (
323- context ,
324- builder ,
325- toty ,
326- fromty .literal_value ,
327- )
328-
329-
330- enable_slice_literals ()
331-
332-
333246def create_tuple_creator (f , n ):
334247 """Construct a compile-time ``tuple``-comprehension-like loop.
335248
0 commit comments