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,84 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
# pyre-strict
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import ast
|
|
8
|
+
from typing import final, TypeVar
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
FunctionDefNode = TypeVar("FunctionDefNode", ast.FunctionDef, ast.AsyncFunctionDef)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def remove_annotations(node: ast.AST) -> ast.Module:
|
|
15
|
+
return ast.fix_missing_locations(AnnotationRemover().visit(node))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _copy_attrs(src: ast.AST, dest: ast.AST) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Copies line and column info from one node to another.
|
|
21
|
+
"""
|
|
22
|
+
# pyre-fixme[16]: `AST` has no attribute `lineno`.
|
|
23
|
+
dest.lineno = src.lineno
|
|
24
|
+
# pyre-fixme[16]: `AST` has no attribute `end_lineno`.
|
|
25
|
+
dest.end_lineno = src.end_lineno
|
|
26
|
+
# pyre-fixme[16]: `AST` has no attribute `col_offset`.
|
|
27
|
+
dest.col_offset = src.col_offset
|
|
28
|
+
# pyre-fixme[16]: `AST` has no attribute `end_col_offset`.
|
|
29
|
+
dest.end_col_offset = src.end_col_offset
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@final
|
|
33
|
+
class AnnotationRemover(ast.NodeTransformer):
|
|
34
|
+
def visit_single_arg(self, arg: ast.arg) -> ast.arg:
|
|
35
|
+
arg.annotation = None
|
|
36
|
+
return arg
|
|
37
|
+
|
|
38
|
+
def visit_fn_arguments(self, node: ast.arguments) -> ast.arguments:
|
|
39
|
+
if node.posonlyargs:
|
|
40
|
+
node.posonlyargs = [self.visit_single_arg(a) for a in node.posonlyargs]
|
|
41
|
+
if node.args:
|
|
42
|
+
node.args = [self.visit_single_arg(a) for a in node.args]
|
|
43
|
+
if node.kwonlyargs:
|
|
44
|
+
node.kwonlyargs = [self.visit_single_arg(a) for a in node.kwonlyargs]
|
|
45
|
+
vararg = node.vararg
|
|
46
|
+
if vararg:
|
|
47
|
+
node.vararg = self.visit_single_arg(vararg)
|
|
48
|
+
kwarg = node.kwarg
|
|
49
|
+
if kwarg:
|
|
50
|
+
node.kwarg = self.visit_single_arg(kwarg)
|
|
51
|
+
return node
|
|
52
|
+
|
|
53
|
+
def visit_function(self, node: FunctionDefNode) -> FunctionDefNode:
|
|
54
|
+
node.arguments = self.visit_fn_arguments(node.args)
|
|
55
|
+
node.returns = None
|
|
56
|
+
node.decorator_list = [
|
|
57
|
+
self.visit(decorator) for decorator in node.decorator_list
|
|
58
|
+
]
|
|
59
|
+
return node
|
|
60
|
+
|
|
61
|
+
def visit_FunctionDef(self, node: FunctionDefNode) -> FunctionDefNode:
|
|
62
|
+
return self.visit_function(node)
|
|
63
|
+
|
|
64
|
+
def visit_AsyncFunctionDef(self, node: FunctionDefNode) -> FunctionDefNode:
|
|
65
|
+
return self.visit_function(node)
|
|
66
|
+
|
|
67
|
+
def visit_AnnAssign(self, node: ast.AnnAssign) -> ast.Assign:
|
|
68
|
+
# Here, we replace `x: A = a` with just `x = a`. In case there's no value,
|
|
69
|
+
# we set the value to an `...`. E.g: `x: A` changes to `x = ...`.
|
|
70
|
+
#
|
|
71
|
+
# We need to be a little careful about ensuring that newly created nodes
|
|
72
|
+
# get the line and column information copied to them. This helps us avoid
|
|
73
|
+
# an extra pass over the AST with ast.fix_missing_locations()
|
|
74
|
+
value = node.value
|
|
75
|
+
if value is None:
|
|
76
|
+
# pyre-fixme[20]: Argument `value` expected.
|
|
77
|
+
value = ast.Constant(...)
|
|
78
|
+
value.kind = None
|
|
79
|
+
_copy_attrs(node, value)
|
|
80
|
+
|
|
81
|
+
assign = ast.Assign(targets=[node.target], value=value, type_comment=None)
|
|
82
|
+
|
|
83
|
+
_copy_attrs(node, assign)
|
|
84
|
+
return assign
|