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

Method evalStrata

engine/naivebottomup.go:59–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57}
58
59func (e naiveEngine) evalStrata() {
60 for _, fact := range e.programInfo.InitialFacts {
61 f, _ := functional.EvalAtom(fact, nil)
62 e.store.Add(f)
63 }
64 for i := 0; i < len(e.strata); i++ {
65 stratumEdbPredicates := make(map[ast.PredicateSym]struct{})
66 stratumIdbPredicates := make(map[ast.PredicateSym]struct{})
67 for sym, stratum := range e.predToStratum {
68 if stratum < i {
69 stratumEdbPredicates[sym] = struct{}{}
70 } else if stratum == i {
71 stratumIdbPredicates[sym] = struct{}{}
72 }
73 }
74 var stratumRules []ast.Clause
75 stratumDecls := make(map[ast.PredicateSym]*ast.Decl)
76 for _, clause := range e.programInfo.Rules {
77 sym := clause.Head.Predicate
78 if _, ok := stratumIdbPredicates[sym]; ok {
79 stratumRules = append(stratumRules, clause)
80 stratumDecls[sym] = e.programInfo.Decls[sym]
81 }
82 }
83 naiveEngine{
84 store: e.store,
85 programInfo: analysis.ProgramInfo{stratumEdbPredicates, stratumIdbPredicates, nil, nil, stratumRules, stratumDecls, nil},
86 }.eval()
87 }
88}
89
90// This is very inefficient because it generates the same facts over and over again.
91func (e naiveEngine) eval() {

Callers 1

EvalProgramNaiveFunction · 0.45

Calls 3

EvalAtomFunction · 0.92
AddMethod · 0.65
evalMethod · 0.45

Tested by

no test coverage detected