Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,9 @@ From a constructed RuntimeGeneratedFunction, you can retrieve the expressions us
`RuntimeGeneratedFunctions.get_expression` command. For example:

```julia
julia> RuntimeGeneratedFunctions.get_expression(rgf)
ex = :((x) -> x^2)
rgf = @RuntimeGeneratedFunction(ex)
julia> RuntimeGeneratedFunctions.get_expression(rgf)
#=
quote
#= c:\Users\accou\OneDrive\Computer\Desktop\test.jl:39 =#
x ^ 2
end
=#
```

This can be used to get the expression even if `drop_expr` has been performed.
Expand Down
7 changes: 1 addition & 6 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,9 @@ From a constructed RuntimeGeneratedFunction, you can retrieve the expressions us
`RuntimeGeneratedFunctions.get_expression` command. For example:

```julia
julia> RuntimeGeneratedFunctions.get_expression(rgf)
ex = :((x) -> x^2)
rgf = @RuntimeGeneratedFunction(ex)
julia> RuntimeGeneratedFunctions.get_expression(rgf)
:((x,)->begin
#= REPL[14]:1 =#
x ^ 2
end)
```

This can be used to get the expression even if `drop_expr` has been performed.
Expand Down Expand Up @@ -198,7 +194,6 @@ julia> RuntimeGeneratedFunctions.get_expression(prob.f.f.f_oop)
end)
```


## Reproducibility

```@raw html
Expand Down
13 changes: 7 additions & 6 deletions src/RuntimeGeneratedFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ function closures_to_opaque(ex::Expr, return_type = nothing)
fdef[:body] = body
name = get(fdef, :name, nothing)
name !== nothing && delete!(fdef, :name)
opaque = Expr(:., Expr(:., :Base, QuoteNode(:Experimental)), QuoteNode(Symbol("@opaque")))
opaque = Expr(
:., Expr(:., :Base, QuoteNode(:Experimental)), QuoteNode(Symbol("@opaque")))
_ex = Expr(:macrocall, opaque, LineNumberNode(0), combinedef(fdef))
# TODO: emit named opaque closure for better stacktraces
# (ref https://github.com/JuliaLang/julia/pull/40242)
Expand Down Expand Up @@ -332,11 +333,11 @@ end

function get_expression(rgf::RuntimeGeneratedFunction{argnames, cache_tag,
context_tag, id, B}) where {
argnames,
cache_tag,
context_tag,
id,
B
argnames,
cache_tag,
context_tag,
id,
B
}
func_expr = Expr(:->, Expr(:tuple, argnames...), _lookup_body(cache_tag, id))
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ deserialized_f, deserialized_g = deserialize(buf)
@test deserialized_g.body isa Nothing

# deepcopy
ff = @RuntimeGeneratedFunction(:(x -> [x, x+1]))
ff = @RuntimeGeneratedFunction(:(x -> [x, x + 1]))
@test deepcopy(ff) == ff
@test deepcopy(ff) === ff
Loading