Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discriminating overdub calls for "same" function/args #179

Open
robertfeldt opened this issue Oct 27, 2020 · 1 comment
Open

Discriminating overdub calls for "same" function/args #179

robertfeldt opened this issue Oct 27, 2020 · 1 comment

Comments

@robertfeldt
Copy link

This can probably be done with a specific pass but I wonder if there is a simpler way to "tag" the calls to overdub so I can related them back to the original code of the overdubbed method?

One way to illustrate this is that for a function like:

function f(x, y)
  if x < y           # line 1
    return x + y     # line 2 
  else
    a = x + y        # line 4
    return a
  end
end

I would want a way to discriminate between the Cassette.overdub(ctx, :+, :x, :y) call on "line" 2 and the same call on "line" 4. So essentially something like a Cassette.overdub(context::Context, n::Int, f, args...) where n is unique Int for each unique call site of the overdubbed code.

What I'm trying to achieve here is a simple expression coverage calculation and even though the calls have the same arguments and returns the same result the calls correspond to different "call sites" so for some applications (like mine) we need to keep them apart.

Any ideas how to easily achieve this? Or have you seen anyone implementing a code/expression coverage tool using Cassette? Thanks in advance for any pointers/insight.

@vchuravy
Copy link
Member

vchuravy commented Feb 8, 2021

@robertfeldt did you find an answer to your question? I suspect one could do this with a pass, where you insert before each call a push!(ctx, (f, args...), LineInfo). The question is how do you do "differentiation". If you just need a trace you can do that with prehook/posthook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants