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
@@ -0,0 +1,151 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ # pyre-strict
4
+
5
+ from __future__ import annotations
6
+
7
+ import linecache
8
+ from contextlib import contextmanager
9
+ from dataclasses import dataclass
10
+ from typing import TYPE_CHECKING
11
+
12
+
13
+ if TYPE_CHECKING:
14
+ from ast import AST
15
+ from typing import Generator
16
+
17
+
18
+ class TypedSyntaxError(SyntaxError):
19
+ pass
20
+
21
+
22
+ class PerfWarning(Warning):
23
+ def __init__(
24
+ self,
25
+ msg: str,
26
+ filename: str,
27
+ lineno: int,
28
+ offset: int,
29
+ text: str | None,
30
+ end_lineno: int | None = None,
31
+ end_offset: int | None = None,
32
+ ) -> None:
33
+ super().__init__(msg, filename, lineno, offset, text)
34
+ self.msg = msg
35
+ self.filename = filename
36
+ self.lineno = lineno
37
+ self.offset = offset
38
+ self.text = text
39
+ self.end_lineno = end_lineno
40
+ self.end_offset = end_offset
41
+
42
+
43
+ @dataclass
44
+ class ErrorLocation:
45
+ filename: str
46
+ node: AST
47
+ lineno: int
48
+ offset: int
49
+ source_line: str | None = None
50
+ end_lineno: int | None = None
51
+ end_offset: int | None = None
52
+
53
+
54
+ def error_location(filename: str, node: AST) -> ErrorLocation:
55
+ # pyre-fixme[16]: `AST` has no attribute `lineno`.
56
+ source_line = linecache.getline(filename, node.lineno)
57
+ # The SyntaxError offset field is 1-indexed:
58
+ # https://docs.python.org/3.10/library/exceptions.html#SyntaxError.offset
59
+ # The AST col_offset field is 0-indexed:
60
+ # https://docs.python.org/3/library/ast.html
61
+ return ErrorLocation(
62
+ filename,
63
+ node,
64
+ node.lineno,
65
+ # pyre-fixme[16]: `AST` has no attribute `col_offset`.
66
+ node.col_offset + 1,
67
+ source_line or None,
68
+ # pyre-fixme[16]: `AST` has no attribute `end_lineno`.
69
+ node.end_lineno + 1 if node.end_lineno is not None else None,
70
+ # pyre-fixme[16]: `AST` has no attribute `end_col_offset`.
71
+ node.end_col_offset + 1 if node.end_col_offset is not None else None,
72
+ )
73
+
74
+
75
+ class ErrorSink:
76
+ throwing = True
77
+
78
+ def __init__(self) -> None:
79
+ self.errors: list[TypedSyntaxError] = []
80
+ self.warnings: list[PerfWarning] = []
81
+
82
+ def error(self, exception: TypedSyntaxError) -> None:
83
+ raise exception
84
+
85
+ def syntax_error(self, msg: str, filename: str, node: AST) -> None:
86
+ errloc = error_location(filename, node)
87
+ self.error(
88
+ TypedSyntaxError(
89
+ msg,
90
+ (
91
+ errloc.filename,
92
+ errloc.lineno,
93
+ errloc.offset,
94
+ errloc.source_line,
95
+ errloc.end_lineno,
96
+ errloc.end_offset,
97
+ ),
98
+ )
99
+ )
100
+
101
+ @property
102
+ def has_errors(self) -> bool:
103
+ return len(self.errors) > 0
104
+
105
+ @contextmanager
106
+ def error_context(self, filename: str, node: AST) -> Generator[None, None, None]:
107
+ """Add error location context to any TypedSyntaxError raised in with block."""
108
+ try:
109
+ yield
110
+ except TypedSyntaxError as exc:
111
+ if exc.filename is None:
112
+ exc.filename = filename
113
+ if (exc.lineno, exc.offset) == (None, None):
114
+ errloc = error_location(filename, node)
115
+ exc.lineno = errloc.lineno
116
+ exc.offset = errloc.offset
117
+ exc.text = errloc.source_line
118
+ exc.end_lineno = errloc.end_lineno
119
+ exc.end_offset = errloc.end_offset
120
+ self.error(exc)
121
+
122
+ def warn(self, warning: PerfWarning) -> None:
123
+ pass
124
+
125
+ def perf_warning(self, msg: str, filename: str, node: AST) -> None:
126
+ errloc = error_location(filename, node)
127
+ self.warn(
128
+ PerfWarning(
129
+ msg,
130
+ filename,
131
+ errloc.lineno,
132
+ errloc.offset,
133
+ errloc.source_line,
134
+ errloc.end_lineno,
135
+ errloc.end_offset,
136
+ )
137
+ )
138
+
139
+ @property
140
+ def has_warnings(self) -> bool:
141
+ return len(self.warnings) > 0
142
+
143
+
144
+ class CollectingErrorSink(ErrorSink):
145
+ throwing = False
146
+
147
+ def error(self, exception: TypedSyntaxError) -> None:
148
+ self.errors.append(exception)
149
+
150
+ def warn(self, warning: PerfWarning) -> None:
151
+ self.warnings.append(warning)