cinderx 2026.1.16.2__cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. __static__/__init__.py +641 -0
  2. __static__/compiler_flags.py +8 -0
  3. __static__/enum.py +160 -0
  4. __static__/native_utils.py +77 -0
  5. __static__/type_code.py +48 -0
  6. __strict__/__init__.py +39 -0
  7. _cinderx.so +0 -0
  8. cinderx/__init__.py +577 -0
  9. cinderx/__pycache__/__init__.cpython-314.pyc +0 -0
  10. cinderx/_asyncio.py +156 -0
  11. cinderx/compileall.py +710 -0
  12. cinderx/compiler/__init__.py +40 -0
  13. cinderx/compiler/__main__.py +137 -0
  14. cinderx/compiler/config.py +7 -0
  15. cinderx/compiler/consts.py +72 -0
  16. cinderx/compiler/debug.py +70 -0
  17. cinderx/compiler/dis_stable.py +283 -0
  18. cinderx/compiler/errors.py +151 -0
  19. cinderx/compiler/flow_graph_optimizer.py +1287 -0
  20. cinderx/compiler/future.py +91 -0
  21. cinderx/compiler/misc.py +32 -0
  22. cinderx/compiler/opcode_cinder.py +18 -0
  23. cinderx/compiler/opcode_static.py +100 -0
  24. cinderx/compiler/opcodebase.py +158 -0
  25. cinderx/compiler/opcodes.py +991 -0
  26. cinderx/compiler/optimizer.py +547 -0
  27. cinderx/compiler/pyassem.py +3711 -0
  28. cinderx/compiler/pycodegen.py +7660 -0
  29. cinderx/compiler/pysourceloader.py +62 -0
  30. cinderx/compiler/static/__init__.py +1404 -0
  31. cinderx/compiler/static/compiler.py +629 -0
  32. cinderx/compiler/static/declaration_visitor.py +335 -0
  33. cinderx/compiler/static/definite_assignment_checker.py +280 -0
  34. cinderx/compiler/static/effects.py +160 -0
  35. cinderx/compiler/static/module_table.py +666 -0
  36. cinderx/compiler/static/type_binder.py +2176 -0
  37. cinderx/compiler/static/types.py +10580 -0
  38. cinderx/compiler/static/util.py +81 -0
  39. cinderx/compiler/static/visitor.py +91 -0
  40. cinderx/compiler/strict/__init__.py +69 -0
  41. cinderx/compiler/strict/class_conflict_checker.py +249 -0
  42. cinderx/compiler/strict/code_gen_base.py +409 -0
  43. cinderx/compiler/strict/common.py +507 -0
  44. cinderx/compiler/strict/compiler.py +352 -0
  45. cinderx/compiler/strict/feature_extractor.py +130 -0
  46. cinderx/compiler/strict/flag_extractor.py +97 -0
  47. cinderx/compiler/strict/loader.py +827 -0
  48. cinderx/compiler/strict/preprocessor.py +11 -0
  49. cinderx/compiler/strict/rewriter/__init__.py +5 -0
  50. cinderx/compiler/strict/rewriter/remove_annotations.py +84 -0
  51. cinderx/compiler/strict/rewriter/rewriter.py +975 -0
  52. cinderx/compiler/strict/runtime.py +77 -0
  53. cinderx/compiler/symbols.py +1754 -0
  54. cinderx/compiler/unparse.py +414 -0
  55. cinderx/compiler/visitor.py +194 -0
  56. cinderx/jit.py +230 -0
  57. cinderx/opcode.py +202 -0
  58. cinderx/static.py +113 -0
  59. cinderx/strictmodule.py +6 -0
  60. cinderx/test_support.py +341 -0
  61. cinderx-2026.1.16.2.dist-info/METADATA +15 -0
  62. cinderx-2026.1.16.2.dist-info/RECORD +68 -0
  63. cinderx-2026.1.16.2.dist-info/WHEEL +6 -0
  64. cinderx-2026.1.16.2.dist-info/licenses/LICENSE +21 -0
  65. cinderx-2026.1.16.2.dist-info/top_level.txt +5 -0
  66. opcodes/__init__.py +0 -0
  67. opcodes/assign_opcode_numbers.py +272 -0
  68. opcodes/cinderx_opcodes.py +121 -0
__static__/enum.py ADDED
@@ -0,0 +1,160 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # pyre-strict
3
+
4
+ from __future__ import annotations
5
+
6
+ import inspect
7
+ from typing import Iterable, Mapping, Sequence, SupportsIndex, Type
8
+
9
+
10
+ def eq_method(self: Enum, other: Enum) -> bool:
11
+ return self.value == other or (
12
+ getattr(other, "value", None) is not None and self.value == other.value
13
+ )
14
+
15
+
16
+ def hash_method(self: Enum) -> int:
17
+ return hash(self.value)
18
+
19
+
20
+ TYPE_NEW: object = type.__new__
21
+ SENTINEL = object()
22
+
23
+
24
+ class EnumMeta(type):
25
+ @staticmethod
26
+ def is_hashable(obj: object) -> bool:
27
+ try:
28
+ hash(obj)
29
+ return True
30
+ except TypeError:
31
+ return False
32
+
33
+ def __new__(
34
+ metacls,
35
+ classname: str,
36
+ parents: tuple[Type[object], ...],
37
+ dct: Mapping[str, object],
38
+ ) -> type[Enum]:
39
+ attributes = {}
40
+ members = {}
41
+
42
+ for name, value in dct.items():
43
+ if (
44
+ name.startswith("_")
45
+ or inspect.isroutine(value)
46
+ or inspect.isdatadescriptor(value)
47
+ ):
48
+ attributes[name] = value
49
+ else:
50
+ members[name] = value
51
+
52
+ attributes.update({"__members__": {}, "__reversed_map__": {}})
53
+ if len(members) != len(
54
+ {members[k] for k in members if EnumMeta.is_hashable(members[k])}
55
+ ):
56
+ attributes["__eq__"] = eq_method
57
+ attributes["__hash__"] = hash_method
58
+
59
+ klass = super().__new__(metacls, classname, parents, attributes)
60
+
61
+ for name, value in members.items():
62
+ option = klass(name=name, value=value)
63
+ # pyre-ignore[16]: __members__ is dynamically defined
64
+ klass.__members__[name] = option
65
+ if EnumMeta.is_hashable(option):
66
+ # pyre-ignore[16]: __reversed_map__ is dynamically defined
67
+ klass.__reversed_map__[option] = option
68
+ if EnumMeta.is_hashable(value):
69
+ klass.__reversed_map__[value] = option
70
+ setattr(klass, name, option)
71
+ return klass
72
+
73
+ def __len__(cls) -> int:
74
+ # pyre-ignore[16]: __members__ is dynamically defined
75
+ return len(cls.__members__)
76
+
77
+ def __getitem__(cls, attribute: str) -> Enum:
78
+ # pyre-ignore[16]: __members__ is dynamically defined
79
+ return cls.__members__[attribute]
80
+
81
+ def __iter__(cls) -> Iterable[Enum]:
82
+ # pyre-ignore[16]: __members__ is dynamically defined
83
+ return iter(cls.__members__.values())
84
+
85
+ def __call__(cls, *args: object, **kwargs: object) -> Enum:
86
+ if len(args) == 1:
87
+ attribute = args[0]
88
+ # pyre-ignore[6]: expected str, got object
89
+ return cls._get_by_value(attribute)
90
+
91
+ name = kwargs["name"]
92
+ value = kwargs["value"]
93
+ # pyre-ignore[20]: __new__ expects dct
94
+ # pyre-ignore[9]:declared to have type Enum but is used as Type[Enum]
95
+ instance: Enum = cls.__new__(cls, value)
96
+ instance.name = name
97
+ instance.value = value
98
+ return instance
99
+
100
+ def _get_by_value(cls, value: str) -> Enum:
101
+ # pyre-ignore[16]: __reversed_map__ is dynamically defined
102
+ res = cls.__reversed_map__.get(value, SENTINEL)
103
+ if res is not SENTINEL:
104
+ return res
105
+
106
+ raise ValueError(
107
+ f"Enum type {cls.__name__} has no attribute with value {value!r}"
108
+ )
109
+
110
+
111
+ class Enum(metaclass=EnumMeta):
112
+ def __init__(self, value: object) -> None:
113
+ self.value = value
114
+ self.name: object = None
115
+
116
+ def __dir__(self) -> Sequence[str]:
117
+ return ["name", "value"]
118
+
119
+ def __str__(self) -> str:
120
+ return f"{type(self).__name__}.{self.name}"
121
+
122
+ def __repr__(self) -> str:
123
+ return f"<{type(self).__name__}.{self.name}: {self.value}>"
124
+
125
+ def __reduce_ex__(self, proto: SupportsIndex) -> tuple[type[object], tuple[object]]:
126
+ return self.__class__, (self.value,)
127
+
128
+
129
+ class IntEnum(Enum, int):
130
+ pass
131
+
132
+
133
+ class StringEnumMeta(EnumMeta):
134
+ """Like the regular EnumMeta, but parses string/binary inputs to __call__
135
+ as text (to match text literals used in StringEnum)."""
136
+
137
+ def _get_by_value(cls, value: str | bytes) -> StringEnum:
138
+ # pyre-ignore[7]: Expected StringEnum, got Enum
139
+ return super()._get_by_value(
140
+ value.decode("utf-8") if isinstance(value, bytes) else value
141
+ )
142
+
143
+
144
+ class StringEnum(Enum, str, metaclass=StringEnumMeta):
145
+ def __str__(self) -> str:
146
+ return f"{self.value}"
147
+
148
+
149
+ def unique(enumeration: type[Enum]) -> type[Enum]:
150
+ """
151
+ Class decorator for enumerations ensuring unique member values
152
+ """
153
+ duplicates = []
154
+ # pyre-ignore[16]: __members__ is dynamically defined
155
+ for name, member in enumeration.__members__.items():
156
+ if name != member.name:
157
+ duplicates.append((name, member.name))
158
+ if duplicates:
159
+ raise ValueError(f"duplicate values found in {enumeration!r}")
160
+ return enumeration
@@ -0,0 +1,77 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # pyre-strict
3
+
4
+ from __future__ import annotations
5
+
6
+ import ctypes
7
+
8
+ from cinderx.static import (
9
+ resolve_primitive_descr,
10
+ TYPED_BOOL,
11
+ TYPED_CHAR,
12
+ TYPED_INT16,
13
+ TYPED_INT32,
14
+ TYPED_INT64,
15
+ TYPED_INT8,
16
+ TYPED_UINT16,
17
+ TYPED_UINT32,
18
+ TYPED_UINT64,
19
+ TYPED_UINT8,
20
+ )
21
+
22
+ _static_to_ctype: dict[int, object] = {
23
+ TYPED_BOOL: ctypes.c_bool,
24
+ TYPED_CHAR: ctypes.c_char,
25
+ # TASK(T130985738): Add support for doubles
26
+ # TYPED_DOUBLE: ctypes.c_double,
27
+ TYPED_INT8: ctypes.c_int8,
28
+ TYPED_INT16: ctypes.c_int16,
29
+ TYPED_INT32: ctypes.c_int32,
30
+ TYPED_INT64: ctypes.c_int64,
31
+ TYPED_UINT8: ctypes.c_uint8,
32
+ TYPED_UINT16: ctypes.c_uint16,
33
+ TYPED_UINT32: ctypes.c_uint32,
34
+ TYPED_UINT64: ctypes.c_uint64,
35
+ }
36
+
37
+
38
+ def _create_args(
39
+ signature: tuple[tuple[str, ...], ...], args: tuple[object]
40
+ ) -> list[object]:
41
+ arg_descrs = signature[:-1]
42
+
43
+ n = len(arg_descrs)
44
+ if n != len(args):
45
+ raise RuntimeError(f"invoke_native: {n} args required, got {len(args)}")
46
+
47
+ call_args = []
48
+ for i in range(n):
49
+ descr = arg_descrs[i]
50
+ arg = args[i]
51
+ primitive_type = resolve_primitive_descr(descr)
52
+ try:
53
+ ctypes_type = _static_to_ctype[primitive_type]
54
+ except KeyError as e:
55
+ raise RuntimeError(f"Unsupported primitive type: {descr}") from e
56
+ else:
57
+ # pyre-ignore[29]: object is not callable
58
+ call_args.append(ctypes_type(arg))
59
+ return call_args
60
+
61
+
62
+ def invoke_native(
63
+ libname: str,
64
+ symbol: str,
65
+ signature: tuple[tuple[str, ...], ...],
66
+ args: tuple[object],
67
+ ) -> int:
68
+ # This is basically just a `dlopen()` under the hood
69
+ lib = ctypes.CDLL(libname)
70
+
71
+ # Python wrapper over `dlsym`
72
+ fn = getattr(lib, symbol)
73
+
74
+ call_args = _create_args(signature, args)
75
+
76
+ res = fn(*call_args)
77
+ return res
@@ -0,0 +1,48 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # pyre-strict
3
+
4
+ TYPED_INT8 = 0
5
+ TYPED_INT16 = 0
6
+ TYPED_INT32 = 0
7
+ TYPED_INT64 = 0
8
+ TYPED_UINT8 = 0
9
+ TYPED_UINT16 = 0
10
+ TYPED_UINT32 = 0
11
+ TYPED_UINT64 = 0
12
+ TYPED_INT_64BIT = 0
13
+ TYPED_DOUBLE = 0
14
+ TYPED_SINGLE = 0
15
+ TYPED_BOOL = 0
16
+ TYPED_CHAR = 0
17
+ TYPED_OBJECT = 0
18
+
19
+ try:
20
+ from cinderx.static import ( # noqa: F401
21
+ set_type_code,
22
+ TYPED_BOOL,
23
+ TYPED_CHAR,
24
+ TYPED_DOUBLE,
25
+ TYPED_INT16,
26
+ TYPED_INT32,
27
+ TYPED_INT64,
28
+ TYPED_INT8,
29
+ TYPED_INT_64BIT,
30
+ TYPED_OBJECT,
31
+ TYPED_SINGLE,
32
+ TYPED_UINT16,
33
+ TYPED_UINT32,
34
+ TYPED_UINT64,
35
+ TYPED_UINT8,
36
+ )
37
+ except ImportError:
38
+
39
+ def set_type_code(func: object, code: object) -> None:
40
+ pass
41
+
42
+
43
+ def type_code(code: int) -> object:
44
+ def inner(func: object) -> object:
45
+ set_type_code(func, code)
46
+ return func
47
+
48
+ return inner
__strict__/__init__.py ADDED
@@ -0,0 +1,39 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ # pyre-strict
4
+
5
+ try:
6
+ from cinderx.compiler.strict.runtime import (
7
+ _mark_cached_property,
8
+ extra_slot,
9
+ freeze_type,
10
+ loose_slots,
11
+ mutable,
12
+ set_freeze_enabled,
13
+ strict_slots,
14
+ )
15
+ except ImportError:
16
+
17
+ def _mark_cached_property(o: object) -> object:
18
+ return o
19
+
20
+ def extra_slot(cls: object, o: object) -> object:
21
+ return cls
22
+
23
+ def freeze_type(o: object) -> object:
24
+ return o
25
+
26
+ def loose_slots(o: object) -> object:
27
+ return o
28
+
29
+ def mutable(o: object) -> object:
30
+ return o
31
+
32
+ def set_freeze_enabled(o: object) -> object:
33
+ return o
34
+
35
+ def strict_slots(o: object) -> object:
36
+ return o
37
+
38
+
39
+ allow_side_effects = object()
_cinderx.so ADDED
Binary file