|
1 |
| -"""Builder class used to transform a mypy AST to the IR form. |
| 1 | +"""Builder class to transform a mypy AST to the IR form. |
2 | 2 |
|
3 |
| -The IRBuilder class maintains transformation state and provides access |
4 |
| -to various helpers used to implement the transform. |
5 |
| -
|
6 |
| -The top-level transform control logic is in mypyc.irbuild.main. |
7 |
| -
|
8 |
| -mypyc.irbuild.visitor.IRBuilderVisitor is used to dispatch based on mypy |
9 |
| -AST node type to code that actually does the bulk of the work. For |
10 |
| -example, expressions are transformed in mypyc.irbuild.expression and |
11 |
| -functions are transformed in mypyc.irbuild.function. |
| 3 | +See the docstring of class IRBuilder for more information. |
12 | 4 | """
|
13 | 5 |
|
14 | 6 | from __future__ import annotations
|
@@ -154,6 +146,30 @@ class UnsupportedException(Exception):
|
154 | 146 |
|
155 | 147 |
|
156 | 148 | class IRBuilder:
|
| 149 | + """Builder class used to construct mypyc IR from a mypy AST. |
| 150 | +
|
| 151 | + The IRBuilder class maintains IR transformation state and provides access |
| 152 | + to various helpers used to implement the transform. |
| 153 | +
|
| 154 | + mypyc.irbuild.visitor.IRBuilderVisitor is used to dispatch based on mypy |
| 155 | + AST node type to code that actually does the bulk of the work. For |
| 156 | + example, expressions are transformed in mypyc.irbuild.expression and |
| 157 | + functions are transformed in mypyc.irbuild.function. |
| 158 | +
|
| 159 | + Use the "accept()" method to translate individual mypy AST nodes to IR. |
| 160 | + Other methods are used to generate IR for various lower-level operations. |
| 161 | +
|
| 162 | + This class wraps the lower-level LowLevelIRBuilder class, an instance |
| 163 | + of which is available through the "builder" attribute. The low-level |
| 164 | + builder class doesn't have any knowledge of the mypy AST. Wrappers for |
| 165 | + some LowLevelIRBuilder method are provided for convenience, but others |
| 166 | + can also be accessed via the "builder" attribute. |
| 167 | +
|
| 168 | + See also: |
| 169 | + * The mypyc IR is defined in the mypyc.ir package. |
| 170 | + * The top-level IR transform control logic is in mypyc.irbuild.main. |
| 171 | + """ |
| 172 | + |
157 | 173 | def __init__(
|
158 | 174 | self,
|
159 | 175 | current_module: str,
|
|
0 commit comments