MCPcopy Index your code
hub / github.com/google/mangle / FreshVariable

Function FreshVariable

ast/ast.go:1338–1350  ·  view source on GitHub ↗

FreshVariable returns a variable different from the ones in used.

(used map[Variable]bool)

Source from the content-addressed store, hash-verified

1336
1337// FreshVariable returns a variable different from the ones in used.
1338func FreshVariable(used map[Variable]bool) Variable {
1339 makeFresh := func(n int) Variable { return Variable{fmt.Sprintf("X%d", n)} }
1340 i := 0
1341 for {
1342 v := makeFresh(i)
1343 if used[v] {
1344 i++
1345 continue
1346 }
1347 used[v] = true
1348 return v
1349 }
1350}
1351
1352// ReplaceWildcards returns a new term where each wildcard is replaced
1353// with a fresh variables. The used-variables map is modified to keep track

Callers 4

RectifyAtomFunction · 0.92
feasibleAlternativesMethod · 0.92
ReplaceWildcardsFunction · 0.85
NewSyntheticDeclFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected