Closed oxinabox closed 5 years ago
The last commit is where this diverges from #48 it would be a massive simplication if only it worked.
Unfortunately, it does not as: It is not permitted to use Expr(:locals) in a Cassette pass. Because that gets expanded before/during the creation of the lowered IR (edited) Looks like it gets expend in https://github.com/JuliaLang/julia/blob/553082495c46e851db1d287c917963b408e0db6e/src/julia-syntax.scm#L2433
Expr(:locals)
It is basically expanded into the code that I wanted to replace with it.
julia> function f(x) local y println(Base.@locals()) end f (generic function with 1 method) julia> @code_lowered f(1) CodeInfo( 1 ─ Core.NewvarNode(:(y)) │ %2 = (Core.apply_type)(Base.Dict, Core.Symbol, Core.Any) │ %3 = (%2)() │ %4 = $(Expr(:isdefined, :(y))) └── goto #3 if not %4 2 ─ (Base.setindex!)(%3, y, :y) 3 ┄ %7 = $(Expr(:isdefined, :(x))) └── goto #5 if not %7 4 ─ (Base.setindex!)(%3, x, :x) 5 ┄ %10 = (Main.println)(%3) └── return %10 )
The last commit is where this diverges from #48 it would be a massive simplication
if only it worked.
Unfortunately, it does not as: It is not permitted to use
Expr(:locals)
in a Cassette pass. Because that gets expanded before/during the creation of the lowered IR (edited) Looks like it gets expend in https://github.com/JuliaLang/julia/blob/553082495c46e851db1d287c917963b408e0db6e/src/julia-syntax.scm#L2433It is basically expanded into the code that I wanted to replace with it.