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

Method unify

unionfind/unionfind.go:95–116  ·  view source on GitHub ↗

Returns true if v can be unified with t, updates unionfind sets.

(v ast.Variable, t ast.BaseTerm)

Source from the content-addressed store, hash-verified

93
94// Returns true if v can be unified with t, updates unionfind sets.
95func (uf UnionFind) unify(v ast.Variable, t ast.BaseTerm) bool {
96 vroot := uf.find(v)
97 if vroot == nil {
98 vroot = v
99 }
100 troot := uf.find(t)
101 if troot == nil {
102 troot = t
103 }
104 if vroot.Equals(troot) {
105 return true
106 }
107 _, vconst := vroot.(ast.Constant)
108 _, tconst := troot.(ast.Constant)
109 if vconst && tconst {
110 return false
111 }
112 uf.parent[v] = vroot
113 uf.parent[t] = troot
114 uf.union(vroot, troot)
115 return true
116}
117
118// Get implements the Subst interface so UnionFind can be used as substituion.
119func (uf UnionFind) Get(v ast.Variable) ast.BaseTerm {

Callers

nothing calls this directly

Calls 3

findMethod · 0.95
unionMethod · 0.95
EqualsMethod · 0.65

Tested by

no test coverage detected