/// <summary> /// Creates nodes in the trie to capture all the don't care (unbound) locations in the pattern. /// </summary> private ShapeNode CreateDontCareNodes() { int i; bool isExpanded; ShapeNode n; ShapeNode[] children; return(Pattern.Compute <ShapeNode>( (x, s) => x.Groundness == Groundness.Variable ? x.Args : null, (x, ch, s) => { if (x.Symbol.Arity == 0) { if (Executer.IsUnboundPatternVariable(x)) { return new ShapeNode(true); } else { return null; } } Contract.Assert(x.Symbol.IsDataConstructor); isExpanded = false; foreach (var m in ch) { if (m != null) { isExpanded = true; break; } } if (!isExpanded) { return null; } children = new ShapeNode[x.Symbol.Arity]; i = 0; foreach (var m in ch) { children[i++] = m; } n = new ShapeNode(); n.AddRefinement((UserSymbol)x.Symbol, children); return n; })); }