You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to move BorrowChecker.jl to use this over Cassette.jl but am having some difficulties figuring out how to do generic overlay passes where I overlay behavior on all functions that get hit.
Here's my current attempt, from studying the code:
using CassetteOverlay
using CassetteOverlay: CassetteOverlayGenerator
using Test
@MethodTable AllMethods
pass =@overlaypass AllMethods
# ^Just to initialize the object_sin(x) =sin(x)
# Now, we attempt to do a generic override of it:@evalfunction (p::typeof(pass))(f, args...)
$(Expr(:meta, :generated, CassetteOverlayGenerator(:pass, :fargs)))
println("Hello from ", f, " with args: ", args)
returnf(args...)
endpass(() ->_sin(0.5));
This prints:
Hello from #2 with args: ()
So it seems this captures the first function (the closure), but the f(args...) does not hit the same overlay pass again.
Another thing I tried was
@overlay AllMethods (f::Function)(args...) =...
but faced similar issues.
How can I do this? I basically want to overload all functions matching a specific signature.
The text was updated successfully, but these errors were encountered:
CassetteOverlay rewrites all function calls (via the mechanism implemented in CassetteBase.jl) but the rewriting mechanism relies on method matching against the overlay table. So it's probably not suitable for what you want to achieve.
It might be possible to implement something similar to what Cassette.jl does with CassetteBase.jl.
@aviatesk
I'm trying to move BorrowChecker.jl to use this over Cassette.jl but am having some difficulties figuring out how to do generic overlay passes where I overlay behavior on all functions that get hit.
Here's my current attempt, from studying the code:
This prints:
So it seems this captures the first function (the closure), but the
f(args...)
does not hit the same overlay pass again.Another thing I tried was
but faced similar issues.
How can I do this? I basically want to overload all functions matching a specific signature.
The text was updated successfully, but these errors were encountered: