MCPcopy Create free account
hub / github.com/decomp/decomp / FindSeq

Function FindSeq

cfa/seq.go:63–80  ·  view source on GitHub ↗

FindSeq returns the first occurrence of a sequence of two statements in g, and a boolean indicating if such a primitive was found.

(g graph.Directed, dom cfg.DominatorTree)

Source from the content-addressed store, hash-verified

61// FindSeq returns the first occurrence of a sequence of two statements in g,
62// and a boolean indicating if such a primitive was found.
63func FindSeq(g graph.Directed, dom cfg.DominatorTree) (prim Seq, ok bool) {
64 // Range through entry node candidates.
65 for _, entry := range g.Nodes() {
66 // Verify that entry has one successor (exit).
67 entrySuccs := g.From(entry)
68 if len(entrySuccs) != 1 {
69 continue
70 }
71 prim.Entry = entry
72
73 // Select exit node candidate.
74 prim.Exit = entrySuccs[0]
75 if prim.IsValid(g, dom) {
76 return prim, true
77 }
78 }
79 return Seq{}, false
80}
81
82// IsValid reports whether the entry and exit node candidates of prim form a
83// valid sequence of two statements in g.

Callers 1

FindPrimFunction · 0.85

Calls 1

IsValidMethod · 0.45

Tested by

no test coverage detected