Skip to content

JS: Allow MaD flow through properties #8670

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Apr 5, 2022

Adds the possibility of stepping through a property read obj -> obj.foo using a summary CSV row where:

  • The input part is the empty string, and
  • The output part is Member[foo].

@RasmusWL what do you think?

@asgerf asgerf added JS no-change-note-required This PR does not need a change note labels Apr 5, 2022
@github-actions github-actions bot added the Ruby label Apr 5, 2022
Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks good to me 👍

I assume that using Member[foo,bar], adding flow from obj to obj.foo and obj.bar, would also work?

@asgerf
Copy link
Contributor Author

asgerf commented Apr 6, 2022

I assume that using Member[foo,bar], adding flow from obj to obj.foo and obj.bar, would also work?

Yes, that should work as well.

But you can't do Member[foo].Member[bar] because the simple approach I took here won't work when the .foo and .bar operations occur in different functions. For that to work we'd have to interpret the initial .foo as a call to a function with an output spec of ReturnValue.Member[bar].

@asgerf
Copy link
Contributor Author

asgerf commented Apr 8, 2022

After ruminating on this some more, I think the more general solution is to add something like AccessorCall[x] which models an access to the x attribute as a call (even if it's not considered a call in the language IR).

Then a step like foo -> foo.bar could be modelled as

package;type;Member[foo].AccessorCall[bar];Argument[self];ReturnValue

This avoids the somewhat awkward special case where the output must consist of a single token.

To be clear, with the solution currently in this PR it would look like this:

package;type;Member[foo];;Member[bar]

@aschackmull do you have any thoughts on this? The context is that we want to be able to model flow through things that aren't calls, but in principle could be modelled as a calls. It looks like the two approaches are:

  • Add a special rule for specifying a step through a member accesses. This can be implemented a step, without a flow summary.
  • Model member access as a call, even though it's not a call in the language IR. I'm still not familiar enough with the flow summary code to foresee what problems this will incur. (JS and Python don't have flow summaries at the moment, and the question is moot for Ruby since everything is a method call there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS no-change-note-required This PR does not need a change note Ruby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants