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.
- __static__/__init__.py +641 -0
- __static__/compiler_flags.py +8 -0
- __static__/enum.py +160 -0
- __static__/native_utils.py +77 -0
- __static__/type_code.py +48 -0
- __strict__/__init__.py +39 -0
- _cinderx.so +0 -0
- cinderx/__init__.py +577 -0
- cinderx/__pycache__/__init__.cpython-314.pyc +0 -0
- cinderx/_asyncio.py +156 -0
- cinderx/compileall.py +710 -0
- cinderx/compiler/__init__.py +40 -0
- cinderx/compiler/__main__.py +137 -0
- cinderx/compiler/config.py +7 -0
- cinderx/compiler/consts.py +72 -0
- cinderx/compiler/debug.py +70 -0
- cinderx/compiler/dis_stable.py +283 -0
- cinderx/compiler/errors.py +151 -0
- cinderx/compiler/flow_graph_optimizer.py +1287 -0
- cinderx/compiler/future.py +91 -0
- cinderx/compiler/misc.py +32 -0
- cinderx/compiler/opcode_cinder.py +18 -0
- cinderx/compiler/opcode_static.py +100 -0
- cinderx/compiler/opcodebase.py +158 -0
- cinderx/compiler/opcodes.py +991 -0
- cinderx/compiler/optimizer.py +547 -0
- cinderx/compiler/pyassem.py +3711 -0
- cinderx/compiler/pycodegen.py +7660 -0
- cinderx/compiler/pysourceloader.py +62 -0
- cinderx/compiler/static/__init__.py +1404 -0
- cinderx/compiler/static/compiler.py +629 -0
- cinderx/compiler/static/declaration_visitor.py +335 -0
- cinderx/compiler/static/definite_assignment_checker.py +280 -0
- cinderx/compiler/static/effects.py +160 -0
- cinderx/compiler/static/module_table.py +666 -0
- cinderx/compiler/static/type_binder.py +2176 -0
- cinderx/compiler/static/types.py +10580 -0
- cinderx/compiler/static/util.py +81 -0
- cinderx/compiler/static/visitor.py +91 -0
- cinderx/compiler/strict/__init__.py +69 -0
- cinderx/compiler/strict/class_conflict_checker.py +249 -0
- cinderx/compiler/strict/code_gen_base.py +409 -0
- cinderx/compiler/strict/common.py +507 -0
- cinderx/compiler/strict/compiler.py +352 -0
- cinderx/compiler/strict/feature_extractor.py +130 -0
- cinderx/compiler/strict/flag_extractor.py +97 -0
- cinderx/compiler/strict/loader.py +827 -0
- cinderx/compiler/strict/preprocessor.py +11 -0
- cinderx/compiler/strict/rewriter/__init__.py +5 -0
- cinderx/compiler/strict/rewriter/remove_annotations.py +84 -0
- cinderx/compiler/strict/rewriter/rewriter.py +975 -0
- cinderx/compiler/strict/runtime.py +77 -0
- cinderx/compiler/symbols.py +1754 -0
- cinderx/compiler/unparse.py +414 -0
- cinderx/compiler/visitor.py +194 -0
- cinderx/jit.py +230 -0
- cinderx/opcode.py +202 -0
- cinderx/static.py +113 -0
- cinderx/strictmodule.py +6 -0
- cinderx/test_support.py +341 -0
- cinderx-2026.1.16.2.dist-info/METADATA +15 -0
- cinderx-2026.1.16.2.dist-info/RECORD +68 -0
- cinderx-2026.1.16.2.dist-info/WHEEL +6 -0
- cinderx-2026.1.16.2.dist-info/licenses/LICENSE +21 -0
- cinderx-2026.1.16.2.dist-info/top_level.txt +5 -0
- opcodes/__init__.py +0 -0
- opcodes/assign_opcode_numbers.py +272 -0
- opcodes/cinderx_opcodes.py +121 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
# pyre-strict
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import ast
|
|
8
|
+
from collections.abc import Sequence
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from .types import Value
|
|
13
|
+
|
|
14
|
+
RefinedFields = dict[str, tuple[Value, int, set[ast.AST]]]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# A refined field consists of a refined type in addition to the node that
|
|
18
|
+
# refined the field. The node information is used to hoist reads during codegen.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TypeState:
|
|
22
|
+
def __init__(self) -> None:
|
|
23
|
+
self.local_types: dict[str, Value] = {}
|
|
24
|
+
self.refined_fields: dict[str, RefinedFields] = {}
|
|
25
|
+
|
|
26
|
+
def copy(self) -> TypeState:
|
|
27
|
+
type_state = TypeState()
|
|
28
|
+
type_state.local_types = dict(self.local_types)
|
|
29
|
+
type_state.refined_fields = dict(self.refined_fields)
|
|
30
|
+
return type_state
|
|
31
|
+
|
|
32
|
+
def __repr__(self) -> str:
|
|
33
|
+
return f"TypeState({self.local_types}, {self.refined_fields})"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class NarrowingEffect:
|
|
37
|
+
"""captures type narrowing effects on variables"""
|
|
38
|
+
|
|
39
|
+
def and_(self, other: NarrowingEffect) -> NarrowingEffect:
|
|
40
|
+
if other is NO_EFFECT:
|
|
41
|
+
return self
|
|
42
|
+
|
|
43
|
+
return AndEffect(self, other)
|
|
44
|
+
|
|
45
|
+
def or_(self, other: NarrowingEffect) -> NarrowingEffect:
|
|
46
|
+
if other is NO_EFFECT:
|
|
47
|
+
return self
|
|
48
|
+
|
|
49
|
+
return OrEffect(self, other)
|
|
50
|
+
|
|
51
|
+
def not_(self) -> NarrowingEffect:
|
|
52
|
+
return NegationEffect(self)
|
|
53
|
+
|
|
54
|
+
def apply(
|
|
55
|
+
self,
|
|
56
|
+
type_state: TypeState,
|
|
57
|
+
type_state_nodes: dict[str, ast.AST] | None = None,
|
|
58
|
+
) -> None:
|
|
59
|
+
"""applies the given effect in the target scope. if `type_state_nodes` is passed, populates
|
|
60
|
+
it with the underlying name or attribute nodes"""
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
def undo(self, type_state: TypeState) -> None:
|
|
64
|
+
"""restores the type to its original value"""
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
def reverse(
|
|
68
|
+
self,
|
|
69
|
+
type_state: TypeState,
|
|
70
|
+
type_state_nodes: dict[str, ast.AST] | None = None,
|
|
71
|
+
) -> None:
|
|
72
|
+
"""applies the reverse of the scope or reverts it if
|
|
73
|
+
there is no reverse"""
|
|
74
|
+
self.undo(type_state)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class AndEffect(NarrowingEffect):
|
|
78
|
+
def __init__(self, *effects: NarrowingEffect) -> None:
|
|
79
|
+
self.effects: Sequence[NarrowingEffect] = effects
|
|
80
|
+
|
|
81
|
+
def and_(self, other: NarrowingEffect) -> NarrowingEffect:
|
|
82
|
+
if other is NO_EFFECT:
|
|
83
|
+
return self
|
|
84
|
+
elif isinstance(other, AndEffect):
|
|
85
|
+
return AndEffect(*self.effects, *other.effects)
|
|
86
|
+
|
|
87
|
+
return AndEffect(*self.effects, other)
|
|
88
|
+
|
|
89
|
+
def apply(
|
|
90
|
+
self,
|
|
91
|
+
type_state: TypeState,
|
|
92
|
+
type_state_nodes: dict[str, ast.AST] | None = None,
|
|
93
|
+
) -> None:
|
|
94
|
+
for effect in self.effects:
|
|
95
|
+
effect.apply(type_state, type_state_nodes)
|
|
96
|
+
|
|
97
|
+
def undo(self, type_state: TypeState) -> None:
|
|
98
|
+
"""restores the type to its original value"""
|
|
99
|
+
for effect in self.effects:
|
|
100
|
+
effect.undo(type_state)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class OrEffect(NarrowingEffect):
|
|
104
|
+
def __init__(self, *effects: NarrowingEffect) -> None:
|
|
105
|
+
self.effects: Sequence[NarrowingEffect] = effects
|
|
106
|
+
|
|
107
|
+
def and_(self, other: NarrowingEffect) -> NarrowingEffect:
|
|
108
|
+
if other is NO_EFFECT:
|
|
109
|
+
return self
|
|
110
|
+
elif isinstance(other, OrEffect):
|
|
111
|
+
return OrEffect(*self.effects, *other.effects)
|
|
112
|
+
|
|
113
|
+
return OrEffect(*self.effects, other)
|
|
114
|
+
|
|
115
|
+
def reverse(
|
|
116
|
+
self,
|
|
117
|
+
type_state: TypeState,
|
|
118
|
+
type_state_nodes: dict[str, ast.AST] | None = None,
|
|
119
|
+
) -> None:
|
|
120
|
+
for effect in self.effects:
|
|
121
|
+
effect.reverse(type_state, type_state_nodes)
|
|
122
|
+
|
|
123
|
+
def undo(self, type_state: TypeState) -> None:
|
|
124
|
+
"""restores the type to its original value"""
|
|
125
|
+
for effect in self.effects:
|
|
126
|
+
effect.undo(type_state)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class NoEffect(NarrowingEffect):
|
|
130
|
+
def union(self, other: NarrowingEffect) -> NarrowingEffect:
|
|
131
|
+
return other
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# Singleton instance for no effects
|
|
135
|
+
NO_EFFECT = NoEffect()
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class NegationEffect(NarrowingEffect):
|
|
139
|
+
def __init__(self, negated: NarrowingEffect) -> None:
|
|
140
|
+
self.negated = negated
|
|
141
|
+
|
|
142
|
+
def not_(self) -> NarrowingEffect:
|
|
143
|
+
return self.negated
|
|
144
|
+
|
|
145
|
+
def apply(
|
|
146
|
+
self,
|
|
147
|
+
type_state: TypeState,
|
|
148
|
+
type_state_nodes: dict[str, ast.AST] | None = None,
|
|
149
|
+
) -> None:
|
|
150
|
+
self.negated.reverse(type_state, type_state_nodes)
|
|
151
|
+
|
|
152
|
+
def undo(self, type_state: TypeState) -> None:
|
|
153
|
+
self.negated.undo(type_state)
|
|
154
|
+
|
|
155
|
+
def reverse(
|
|
156
|
+
self,
|
|
157
|
+
type_state: TypeState,
|
|
158
|
+
type_state_nodes: dict[str, ast.AST] | None = None,
|
|
159
|
+
) -> None:
|
|
160
|
+
self.negated.apply(type_state, type_state_nodes)
|