Refactor inlining logic into try_inline function

This commit extracts the logic for inlining function calls into a new
private
method, `try_inline`. This improves code organization and reduces
duplication in the `Optimizer`'s `visit_node` method.

The extracted method handles the preparation of substitutions and the
recursive visiting of the inlined node. It also ensures that the
substitution map state is correctly synchronized back to the calling
context.
This commit is contained in:
Michael Schimmel
2026-03-07 21:10:48 +01:00
parent f88992da61
commit d08fab4f73
3 changed files with 72 additions and 33 deletions
+4 -2
View File
@@ -5,6 +5,8 @@
(macro printx [s] `(fn [x] (print ~s x)))
(pipe [(.close src)] (printx "close="))
(pipe [(pipe [(.close src)] (SMA 20))] (printx "sma="))
(pipe src print)
(pipe [(pipe [(.close src)] (SMA 20))] (printx "sma20="))
(pipe [(pipe [(.close src)] (SMA 5))] (printx "sma5="))
(pipe [(pipe [(.close src)] (SMA 100))] (printx "sma100="))
)