from typing import overload
from .ir_value import RuntimeInt
class range:
@overload
def __init__(self, stop: int, /):
...
@overload
def __init__(self, start: int, stop: int, /):
...
@overload
def __init__(self, start: int, stop: int, step: int, /):
...
def __init__(self, *args):
if len(args) < 1 or len(args) > 3:
raise ValueError(f"range expects from 1 to 3 arguments, got {len(args)}")
self.start: RuntimeInt = 0
self.stop: RuntimeInt = 0
self.step: RuntimeInt = 1
if len(args) == 1:
self.stop = args[0]
elif len(args) >= 2:
self.start = args[0]
self.stop = args[1]
if len(args) == 3:
self.step = args[2]
def __iter__(self):
return self
def __next__(self) -> int:
raise NotImplementedError("This function must not be called")
class static_range:
@overload
def __init__(self, stop: int, /):
...
@overload
def __init__(self, start: int, stop: int, /):
...
@overload
def __init__(self, start: int, stop: int, step: int, /):
...
def __init__(self, *args):
if len(args) < 1 or len(args) > 3:
raise ValueError(f"range expects from 1 to 3 arguments, got {len(args)}")
self.start: int = 0
self.stop: int = 0
self.step: int = 1
if len(args) == 1:
self.stop = args[0]
elif len(args) >= 2:
self.start = args[0]
self.stop = args[1]
if len(args) == 3:
self.step = args[2]
def __iter__(self):
return self
def __next__(self) -> int:
raise NotImplementedError("This function must not be called")