MCPcopy
hub / github.com/google/mangle / collectNames

Function collectNames

analysis/validation.go:410–426  ·  view source on GitHub ↗

We extract name constants from declarations. We build a trie of names that play the role of type expressions. so we can later map name constants to their corresponding, most precise (longest prefix) type expression.

(extraPredicates map[ast.PredicateSym]ast.Decl, decls map[ast.PredicateSym]*ast.Decl)

Source from the content-addressed store, hash-verified

408// that play the role of type expressions. so we can later map name constants to their
409// corresponding, most precise (longest prefix) type expression.
410func collectNames(extraPredicates map[ast.PredicateSym]ast.Decl, decls map[ast.PredicateSym]*ast.Decl) symbols.NameTrie {
411 nameTrie := symbols.NewNameTrie()
412 handleDecl := func(d ast.Decl) {
413 for _, bs := range d.Bounds {
414 for _, typeExpr := range bs.Bounds {
415 nameTrie.Collect(typeExpr)
416 }
417 }
418 }
419 for _, d := range extraPredicates {
420 handleDecl(d)
421 }
422 for _, d := range decls {
423 handleDecl(*d)
424 }
425 return nameTrie
426}
427
428func newBoundsAnalyzer(programInfo *ProgramInfo, nameTrie symbols.NameTrie, initialFacts []ast.Atom, rulesMap map[ast.PredicateSym][]ast.Clause) (*BoundsAnalyzer, error) {
429 var err error

Callers 2

TestCollectNamesFunction · 0.85
AnalyzeMethod · 0.85

Calls 2

CollectMethod · 0.95
NewNameTrieFunction · 0.92

Tested by 1

TestCollectNamesFunction · 0.68