Skip to content

Commit 2883d8e

Browse files
frank-emrichmeta-codesync[bot]
authored andcommitted
label graph with reasons and expansion strategies
Summary: This diff adds labels to the edges and nodes in our graph. - Edges are labeled with a *reason*, describing why a particular node was created from another node (i.e., which heuristic was used). - Nodes are labeled with a *strategy*, determining how successors of this node should be created. Concretely, nodes in our graph now consist of a symbol (as before) and a strategy. The *strategy* of a node is derived from the *reasons* on the incoming edges. The motivation is the following: For some heuristics I'm planning to implement, it's not enough to just know that we want to determine the successor nodes of, say, a particular class `C`. Instead, we need to know why we are interested in `C` in the first place to decide what successors to construct for `C`. A concrete example for this is implemented in the next diff in this stack, where a class can then be in our graph because it contains the definition of a root method *or* because it contains the definition of a type constant we care about. It would be possible to do all of this with just *reason* values. We could enforce that each node only has incoming edges labeled with the same *reason* and use that to determine how to build successors. But for most reasons, there isn't actually a difference. Therefore, *strategies* effectively act as an equivalence relation on *reasons*, where having equivalent reasons implies having the same successor nodes in the graph. Eventually, `reasons` will also be used for provenance tracking, and I want to be able to dump the graph (including reasons) to create .exp tests. But that's coming in the future. Implementation note: I went back and forth between several designs for how to type the reasons and strategies. It would be nice to have some additional static guarantees (e.g., a node for a `Method` symbol can only have a `method` reason), but this ended up being pretty unwieldy. I a Reviewed By: madgen Differential Revision: D90081785 fbshipit-source-id: 3d9c8f8c5d8ee8316378d91607dc6ef3e905ba99
1 parent c323851 commit 2883d8e

File tree

1 file changed

+467
-158
lines changed

1 file changed

+467
-158
lines changed

0 commit comments

Comments
 (0)