Skip to content

Instantly share code, notes, and snippets.

@mbauman
Created May 6, 2018 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbauman/c914f1ac07a9da9a803231455714c434 to your computer and use it in GitHub Desktop.
Save mbauman/c914f1ac07a9da9a803231455714c434 to your computer and use it in GitHub Desktop.
julia> Meta.@lower function f()
if true
end
r = 1
cb = ()->r
cb()
end
:($(Expr(:thunk, CodeInfo(:(begin
$(Expr(:method, :f))
$(Expr(:thunk, CodeInfo(:(begin
global ##9#10
const ##9#10
$(Expr(:struct_type, Symbol("##9#10"), :((Core.svec)()), :((Core.svec)(:r)), :(Core.Function), :((Core.svec)(Core.Box)), false, 1))
return
end))))
Core.SSAValue(0) = (Core.svec)(##9#10)
Core.SSAValue(1) = (Core.svec)()
Core.SSAValue(2) = (Core.svec)(Core.SSAValue(0), Core.SSAValue(1))
$(Expr(:method, false, Core.SSAValue(2), CodeInfo(:(begin
#= REPL[2]:5 =#
Core.SSAValue(0) = (Core.getfield)(#self#, :r)
Core.SSAValue(1) = (Core.isdefined)(Core.SSAValue(0), :contents)
unless Core.SSAValue(1) goto 6
goto 9
6:
Core.NewvarNode(:(r))
r
9:
Core.SSAValue(2) = (Core.getfield)(Core.SSAValue(0), :contents)
return Core.SSAValue(2)
end))))
Core.SSAValue(3) = (Core.Typeof)(f)
Core.SSAValue(4) = (Core.svec)(Core.SSAValue(3))
Core.SSAValue(5) = (Core.svec)()
Core.SSAValue(6) = (Core.svec)(Core.SSAValue(4), Core.SSAValue(5))
$(Expr(:method, :f, Core.SSAValue(6), CodeInfo(:(begin
#= REPL[2]:2 =#
Core.NewvarNode(:(#9))
r = (Core.Box)()
Core.NewvarNode(:(cb))
unless true goto 7
#= line 3 =#
7:
#= line 4 =#
(Core.setfield!)(r, :contents, 1)
#= line 5 =#
#9 = $(Expr(:new, Symbol("##9#10"), :(r)))
cb = #9
#= line 6 =#
Core.SSAValue(0) = (cb)()
return Core.SSAValue(0)
end))))
return f
end)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment