2023-01-08 14:24:10 -05:00
|
|
|
# Copyright (C) 2022-2023 Exaloop Inc. <https://exaloop.io>
|
2022-09-15 15:40:00 -04:00
|
|
|
|
2021-10-02 18:56:18 -04:00
|
|
|
# Core library
|
2024-03-04 09:02:48 -08:00
|
|
|
# from internal.core import * # done automatically by compiler
|
2021-10-02 18:56:18 -04:00
|
|
|
from internal.attributes import *
|
2023-03-18 14:16:38 -07:00
|
|
|
from internal.static import static_print as __static_print__
|
2021-10-02 18:56:18 -04:00
|
|
|
from internal.types.ptr import *
|
|
|
|
from internal.types.str import *
|
|
|
|
from internal.types.int import *
|
|
|
|
from internal.types.bool import *
|
|
|
|
from internal.types.array import *
|
|
|
|
from internal.types.error import *
|
|
|
|
from internal.types.intn import *
|
|
|
|
from internal.types.float import *
|
|
|
|
from internal.types.byte import *
|
|
|
|
from internal.types.generator import *
|
|
|
|
from internal.types.optional import *
|
2023-12-09 18:13:07 -08:00
|
|
|
from internal.internal import *
|
2021-10-02 18:56:18 -04:00
|
|
|
|
2024-03-04 09:02:48 -08:00
|
|
|
class Num[N_: Static[int]]:
|
|
|
|
def __init__(self):
|
|
|
|
pass
|
|
|
|
def foo[N: Static[int]]():
|
|
|
|
__static_print__(N)
|
|
|
|
a = Num[N*2]()
|
|
|
|
__static_print__(a)
|
|
|
|
b = N
|
|
|
|
__static_print__(b)
|
|
|
|
foo(3)
|
|
|
|
|
|
|
|
class XX[N_: Static[int]]:
|
|
|
|
a: Num[N_*2]
|
|
|
|
def __init__(self):
|
|
|
|
self.a = Num()
|
|
|
|
y = XX[5]()
|
|
|
|
__static_print__(y)
|
|
|
|
# y.a, y.__class__.__name__, y.a.__class__.__name__ #: [10] XX[5] Num[10]
|
|
|
|
|
|
|
|
# @tuple
|
|
|
|
# class FooBar[N: Static[int]]:
|
|
|
|
# x: Int[N]
|
|
|
|
# z = FooBar(i32(5))
|
|
|
|
# z, z.__class__.__name__, z.x.__class__.__name__ #: (x: Int[32](5)) FooBar[32] Int[32]
|
|
|
|
|
|
|
|
# @tuple
|
|
|
|
# class Foo[N: Static[int]]:
|
|
|
|
# x: Int[2*N]
|
|
|
|
# def __new__(x: Int[2*N]) -> Foo[N]:
|
|
|
|
# return (x,)
|
|
|
|
# foo = Foo[10](Int[20](0))
|
|
|
|
# foo.__class__.__name__, foo.x.__class__.__name__ #: Foo[10] Int[20]
|
|
|
|
|
|
|
|
|
|
|
|
#############################################
|
|
|
|
# from internal.types.slice import *
|
|
|
|
# from internal.types.range import *
|
|
|
|
# from internal.types.complex import *
|
|
|
|
|
|
|
|
# __argv__ = Array[str](0)
|
2022-07-26 13:06:00 -07:00
|
|
|
|
2024-03-04 09:02:48 -08:00
|
|
|
# from internal.types.strbuf import strbuf as _strbuf
|
|
|
|
# from internal.types.collections.list import *
|
|
|
|
# from internal.types.collections.set import *
|
|
|
|
# from internal.types.collections.dict import *
|
|
|
|
# from internal.types.collections.tuple import *
|
2021-10-02 18:56:18 -04:00
|
|
|
|
2024-03-04 09:02:48 -08:00
|
|
|
# # Extended core library
|
2021-10-02 18:56:18 -04:00
|
|
|
|
2024-03-04 09:02:48 -08:00
|
|
|
# import internal.c_stubs as _C
|
|
|
|
# from internal.format import *
|
|
|
|
# from internal.builtin import *
|
2023-06-25 00:17:52 +02:00
|
|
|
|
2024-03-04 09:02:48 -08:00
|
|
|
# from internal.builtin import _jit_display
|
|
|
|
# from internal.str import *
|
2021-10-02 18:56:18 -04:00
|
|
|
|
2024-03-04 09:02:48 -08:00
|
|
|
# from internal.sort import sorted
|
2021-10-02 18:56:18 -04:00
|
|
|
|
2024-03-04 09:02:48 -08:00
|
|
|
# # from openmp import Ident as __OMPIdent, for_par
|
|
|
|
# # from gpu import _gpu_loop_outline_template
|
|
|
|
# from internal.file import File, gzFile, open, gzopen
|
|
|
|
# from pickle import pickle, unpickle
|
|
|
|
# from internal.dlopen import dlsym as _dlsym
|
|
|
|
# import internal.python
|
|
|
|
# from internal.python import PyError
|
2022-09-15 15:40:00 -04:00
|
|
|
|
2024-03-04 09:02:48 -08:00
|
|
|
# # if __py_numerics__:
|
|
|
|
# # import internal.pynumerics
|
|
|
|
# # if __py_extension__:
|
|
|
|
# # internal.python.ensure_initialized()
|