Skip to content

Commit cbc5329

Browse files
committed
Refactor code related to block construction
Code generation relies on CgContext for storing information about the currently available variables, imports, statements, etc. The context also stores info about code block currently being generated (currentBlock). It is possible to collect statements into some list and then update the currentBlock with them, but it is discouraged, because this way it is very easy to occacionally lose some of the statements. That's because some statements will go to the currentBlock, but then will be overriden on update from the new list of statements. Hence, it is recommended to always work with the statements using currentBlock and DSL methods that also use it. Such methods can be found in CgStatementConstructor.kt, see method `ifStatement` for example. This PR makes more use of currentBlock instead of using separate lists. That is done in order to prevent possible future bugs.
1 parent a2883ee commit cbc5329

File tree

2 files changed

+73
-105
lines changed

2 files changed

+73
-105
lines changed

0 commit comments

Comments
 (0)