mypy
c3534643 - [mypyc] Refactor method IR generation (#9846)

Commit
5 years ago
[mypyc] Refactor method IR generation (#9846) Add new helpers for generating methods that reduces the required boilerplate. Switch several existing use cases to use the new helpers. Summary of the new helpers: 1. Call `builder.enter_method(...)` to begin generating IR for a method. 2. Call `builder.add_argument(..)` for each non-self argument. 3. Generate method body normally. 4. Call `builder.leave_method()`. Previously `enter()` and `leave()` had to be used, along with several additional steps, such as defining `self` explicitly. The new approach is much easier to use and less error-prone. Since not all uses of the old interface have been removed, there is still some duplication. It would be great to eventually always use the higher-level interface to generate methods and functions. Work on mypyc/mypyc#781.
Author
Parents
Loading