Skip to content
Merged
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
18 changes: 11 additions & 7 deletions src/RuntimeGeneratedFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ end
```
"""

"$_rgf_docs"
"""
$_rgf_docs
"""
struct RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id, B} <: Function
body::B
function RuntimeGeneratedFunction(cache_tag, context_tag, ex; opaque_closures = true)
Expand Down Expand Up @@ -117,7 +119,9 @@ function RuntimeGeneratedFunction(cache_module::Module, context_module::Module,
opaque_closures = opaque_closures)
end

"$_rgf_docs"
"""
$_rgf_docs
"""
macro RuntimeGeneratedFunction(code)
quote
RuntimeGeneratedFunction(@__MODULE__, @__MODULE__, $(esc(code)))
Expand Down Expand Up @@ -332,11 +336,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
8 changes: 5 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ GC.gc()
@test f_gc(1, -1) == 100001

# Test that drop_expr works
f_drop1, f_drop2 = let
f_drop1,
f_drop2 = let
ex = Base.remove_linenums!(:(x -> x - 1))
# Construct two identical RGFs here to test the cache deduplication code
(drop_expr(@RuntimeGeneratedFunction(ex)),
Expand All @@ -119,8 +120,9 @@ for k in 1:4
t = Threads.@spawn begin
r = Bool[]
for i in 1:100
f = @RuntimeGeneratedFunction(Base.remove_linenums!(:((x, y) -> x + y +
$i * $k)))
f = @RuntimeGeneratedFunction(Base.remove_linenums!(:((
x, y) -> x + y +
$i * $k)))
x = 1
y = 2
push!(r, f(x, y) == x + y + i * k)
Expand Down
Loading