// ConvertToLtree returns ltree form of given UUID
193301
func ConvertToLtree(id uuid.UUID) string {
	converted := strings.Replace(id.String(), "-", "_", -1)
	return converted
}
875257
func (n *NodePlanDeposedResourceInstanceObject) EvalTree() EvalNode {
	addr := n.ResourceInstanceAddr()

	var provider providers.Interface
	var providerSchema *ProviderSchema
	var state *states.ResourceInstanceObject

	seq := &EvalSequence{Nodes: make([]EvalNode, 0, 5)}

	// During the refresh walk we will ensure that our record of the deposed
	// object is up-to-date. If it was already deleted outside of Terraform
	// then this will remove it from state and thus avoid us planning a
	// destroy for it during the subsequent plan walk.
	seq.Nodes = append(seq.Nodes, &EvalOpFilter{
		Ops: []walkOperation{walkRefresh},
		Node: &EvalSequence{
			Nodes: []EvalNode{
				&EvalGetProvider{
					Addr:   n.ResolvedProvider,
					Output: &provider,
					Schema: &providerSchema,
				},
				&EvalReadStateDeposed{
					Addr:           addr.Resource,
					Provider:       &provider,
					ProviderSchema: &providerSchema,
					Key:            n.DeposedKey,
					Output:         &state,
				},
				&EvalRefresh{
					Addr:           addr.Resource,
					ProviderAddr:   n.ResolvedProvider,
					Provider:       &provider,
					ProviderSchema: &providerSchema,
					State:          &state,
					Output:         &state,
				},
				&EvalWriteStateDeposed{
					Addr:           addr.Resource,
					Key:            n.DeposedKey,
					ProviderAddr:   n.ResolvedProvider,
					ProviderSchema: &providerSchema,
					State:          &state,
				},
			},
		},
	})

	// During the plan walk we always produce a planned destroy change, because
	// destroying is the only supported action for deposed objects.
	var change *plans.ResourceInstanceChange
	seq.Nodes = append(seq.Nodes, &EvalOpFilter{
		Ops: []walkOperation{walkPlan, walkPlanDestroy},
		Node: &EvalSequence{
			Nodes: []EvalNode{
				&EvalGetProvider{
					Addr:   n.ResolvedProvider,
					Output: &provider,
					Schema: &providerSchema,
				},
				&EvalReadStateDeposed{
					Addr:           addr.Resource,
					Output:         &state,
					Key:            n.DeposedKey,
					Provider:       &provider,
					ProviderSchema: &providerSchema,
				},
				&EvalDiffDestroy{
					Addr:         addr.Resource,
					ProviderAddr: n.ResolvedProvider,
					DeposedKey:   n.DeposedKey,
					State:        &state,
					Output:       &change,
				},
				&EvalWriteDiff{
					Addr:           addr.Resource,
					DeposedKey:     n.DeposedKey,
					ProviderSchema: &providerSchema,
					Change:         &change,
				},
				// Since deposed objects cannot be referenced by expressions
				// elsewhere, we don't need to also record the planned new
				// state in this case.
			},
		},
	})

	return seq
}
427477
func parseTreeData(tree *Tree, data []byte) ([]*TreeEntry, error) {
	entries := make([]*TreeEntry, 0, 10)
	l := len(data)
	pos := 0
	for pos < l {
		entry := new(TreeEntry)
		entry.ptree = tree
		step := 6
		switch string(data[pos : pos+step]) {
		case "100644", "100664":
			entry.mode = ENTRY_MODE_BLOB
			entry.Type = OBJECT_BLOB
		case "100755":
			entry.mode = ENTRY_MODE_EXEC
			entry.Type = OBJECT_BLOB
		case "120000":
			entry.mode = ENTRY_MODE_SYMLINK
			entry.Type = OBJECT_BLOB
		case "160000":
			entry.mode = ENTRY_MODE_COMMIT
			entry.Type = OBJECT_COMMIT

			step = 8
		case "040000":
			entry.mode = ENTRY_MODE_TREE
			entry.Type = OBJECT_TREE
		default:
			return nil, fmt.Errorf("unknown type: %v", string(data[pos:pos+step]))
		}
		pos += step + 6 // Skip string type of entry type.

		step = 40
		id, err := NewIDFromString(string(data[pos : pos+step]))
		if err != nil {
			return nil, err
		}
		entry.ID = id
		pos += step + 1 // Skip half of sha1.

		step = bytes.IndexByte(data[pos:], '\n')

		// In case entry name is surrounded by double quotes(it happens only in git-shell).
		if data[pos] == '"' {
			entry.name = string(UnescapeChars(data[pos+1 : pos+step-1]))
		} else {
			entry.name = string(data[pos : pos+step])
		}

		pos += step + 1
		entries = append(entries, entry)
	}
	return entries, nil
}
792531
func linesInTree(db *gitobj.ObjectDatabase, t *gitobj.Tree) ([]*Line, string, error) {
	var at int = -1
	for i, e := range t.Entries {
		if e.Name == ".gitattributes" {
			at = i
			break
		}
	}

	if at < 0 {
		return nil, "", nil
	}

	blob, err := db.Blob(t.Entries[at].Oid)
	if err != nil {
		return nil, "", err
	}
	defer blob.Close()

	return ParseLines(blob.Contents)
}
19928
func (n *NodeValidatableResource) EvalTree() EvalNode {
	addr := n.ResourceAddr()
	config := n.Config

	// Declare the variables will be used are used to pass values along
	// the evaluation sequence below. These are written to via pointers
	// passed to the EvalNodes.
	var provider providers.Interface
	var providerSchema *ProviderSchema
	var configVal cty.Value

	seq := &EvalSequence{
		Nodes: []EvalNode{
			&EvalGetProvider{
				Addr:   n.ResolvedProvider,
				Output: &provider,
				Schema: &providerSchema,
			},
			&EvalValidateResource{
				Addr:           addr.Resource,
				Provider:       &provider,
				ProviderSchema: &providerSchema,
				Config:         config,
				ConfigVal:      &configVal,
			},
		},
	}

	if managed := n.Config.Managed; managed != nil {
		hasCount := n.Config.Count != nil

		// Validate all the provisioners
		for _, p := range managed.Provisioners {
			var provisioner provisioners.Interface
			var provisionerSchema *configschema.Block

			if p.Connection == nil {
				p.Connection = config.Managed.Connection
			} else if config.Managed.Connection != nil {
				p.Connection.Config = configs.MergeBodies(config.Managed.Connection.Config, p.Connection.Config)
			}

			seq.Nodes = append(
				seq.Nodes,
				&EvalGetProvisioner{
					Name:   p.Type,
					Output: &provisioner,
					Schema: &provisionerSchema,
				},
				&EvalValidateProvisioner{
					ResourceAddr:     addr.Resource,
					Provisioner:      &provisioner,
					Schema:           &provisionerSchema,
					Config:           p,
					ResourceHasCount: hasCount,
				},
			)
		}
	}

	return seq
}
326636
func NewTreeVertex(id string, data interface{}, descendants ...*TreeVertex) *TreeVertex {
	return &TreeVertex{
		Id:          id,
		Data:        data,
		Descendants: descendants,
	}
}
214203
func newTree(segmentSize, depth int, hashfunc func() hash.Hash) *tree {
	n := newNode(0, nil, hashfunc())
	prevlevel := []*node{n}
	// iterate over levels and creates 2^(depth-level) nodes
	// the 0 level is on double segment sections so we start at depth - 2 since
	count := 2
	for level := depth - 2; level >= 0; level-- {
		nodes := make([]*node, count)
		for i := 0; i < count; i++ {
			parent := prevlevel[i/2]
			var hasher hash.Hash
			if level == 0 {
				hasher = hashfunc()
			}
			nodes[i] = newNode(i, parent, hasher)
		}
		prevlevel = nodes
		count *= 2
	}
	// the datanode level is the nodes on the last level
	return &tree{
		leaves:  prevlevel,
		result:  make(chan []byte),
		section: make([]byte, 2*segmentSize),
	}
}
1150964
func NewTree(cs []Content) (*MerkleTree, error) {
	root, leafs, err := buildWithContent(cs)
	if err != nil {
		return nil, err
	}
	t := &MerkleTree{
		Root:       root,
		merkleRoot: root.Hash,
		Leafs:      leafs,
	}
	return t, nil
}
623039
func (s *Application) Tree(args ...*echo.Echo) (r map[string]map[string]map[string]map[string]string) {
	core := s.Core
	if len(args) > 0 {
		core = args[0]
	}
	nrs := core.NamedRoutes()
	rs := core.Routes()
	r = map[string]map[string]map[string]map[string]string{}
	for name, indexes := range nrs {
		p := strings.LastIndex(name, `/`)
		s := strings.Split(name[p+1:], `.`)
		var appName, ctlName, actName string
		switch len(s) {
		case 3:
			if !strings.HasSuffix(s[2], `-fm`) {
				continue
			}
			actName = strings.TrimSuffix(s[2], `-fm`)
			ctlName = strings.TrimPrefix(s[1], `(`)
			ctlName = strings.TrimPrefix(ctlName, `*`)
			ctlName = strings.TrimSuffix(ctlName, `)`)
			p2 := strings.LastIndex(name[0:p], `/`)
			appName = name[p2+1 : p]
		default:
			continue
		}
		if _, ok := r[appName]; !ok {
			r[appName] = map[string]map[string]map[string]string{}
		}
		if _, ok := r[appName][ctlName]; !ok {
			r[appName][ctlName] = map[string]map[string]string{}
		}
		if _, ok := r[appName][ctlName][actName]; !ok {
			r[appName][ctlName][actName] = map[string]string{}
			for _, index := range indexes {
				route := rs[index]
				if _, ok := r[appName][ctlName][actName][route.Method]; !ok {
					r[appName][ctlName][actName][route.Method] = route.Method
				}
			}
		}
	}
	return
}
1363915
func (nz *normalizer) convertSQLVal(node *SQLVal) {
	bval := nz.sqlToBindvar(node)
	if bval == nil {
		return
	}

	bvname := nz.newName()
	nz.bindVars[bvname] = bval

	node.Type = ValArg
	node.Val = append([]byte(":"), bvname...)
}
521274
func (n *NodeDestroyableDataResourceInstance) EvalTree() EvalNode {
	addr := n.ResourceInstanceAddr()

	var providerSchema *ProviderSchema
	// We don't need the provider, but we're calling EvalGetProvider to load the
	// schema.
	var provider providers.Interface

	// Just destroy it.
	var state *states.ResourceInstanceObject
	return &EvalSequence{
		Nodes: []EvalNode{
			&EvalGetProvider{
				Addr:   n.ResolvedProvider,
				Output: &provider,
				Schema: &providerSchema,
			},
			&EvalWriteState{
				Addr:           addr.Resource,
				State:          &state,
				ProviderAddr:   n.ResolvedProvider,
				ProviderSchema: &providerSchema,
			},
		},
	}
}
1096308
func NewTreeRootNode(t *Tree) noder.Noder {
	if t == nil {
		return &treeNoder{}
	}

	return &treeNoder{
		parent: t,
		name:   "",
		mode:   filemode.Dir,
		hash:   t.Hash,
	}
}
130320
func (e *Encoder) nextTree() *Tree {
	return newTreeWithPosition(Position{Line: e.line, Col: 1})
}
141671
func (imf *ImmutableForest) newTree(prefix []byte) *RWTree {
	p := string(prefix)
	tree := NewRWTree(NewPrefixDB(imf.treeDB, p), imf.cacheSize)
	imf.treeCache.Add(p, tree)
	return tree
}
658614
func TreeToFiles(r *git.Repository, t *object.Tree,
	repoURL string, repoCache *RepoCache) (map[fileKey]BlobLocation, map[string]plumbing.Hash, error) {
	rw := newRepoWalker(r, repoURL, repoCache)

	if err := rw.parseModuleMap(t); err != nil {
		return nil, nil, err
	}

	tw := object.NewTreeWalker(t, true, make(map[plumbing.Hash]bool))
	defer tw.Close()
	for {
		name, entry, err := tw.Next()
		if err == io.EOF {
			break
		}
		if err := rw.handleEntry(name, &entry); err != nil {
			return nil, nil, err
		}
	}
	return rw.tree, rw.subRepoVersions, nil
}
62722
func (n *graphNodeImportStateSub) EvalTree() EvalNode {
	// If the Ephemeral type isn't set, then it is an error
	if n.State.TypeName == "" {
		err := fmt.Errorf("import of %s didn't set type", n.TargetAddr.String())
		return &EvalReturnError{Error: &err}
	}

	state := n.State.AsInstanceObject()

	var provider providers.Interface
	var providerSchema *ProviderSchema
	return &EvalSequence{
		Nodes: []EvalNode{
			&EvalGetProvider{
				Addr:   n.ResolvedProvider,
				Output: &provider,
				Schema: &providerSchema,
			},
			&EvalRefresh{
				Addr:           n.TargetAddr.Resource,
				ProviderAddr:   n.ResolvedProvider,
				Provider:       &provider,
				ProviderSchema: &providerSchema,
				State:          &state,
				Output:         &state,
			},
			&EvalImportStateVerify{
				Addr:  n.TargetAddr.Resource,
				State: &state,
			},
			&EvalWriteState{
				Addr:           n.TargetAddr.Resource,
				ProviderAddr:   n.ResolvedProvider,
				ProviderSchema: &providerSchema,
				State:          &state,
			},
		},
	}
}
1091631
func DocToTree(doc string) (*Node, error) {
	// xml.Decoder doesn't properly handle whitespace in some doc
	// see songTextString.xml test case ...
	reg, _ := regexp.Compile("[ \t\n\r]*<")
	doc = reg.ReplaceAllString(doc, "<")

	b := bytes.NewBufferString(doc)
	p := xml.NewDecoder(b)
	p.CharsetReader = X2jCharsetReader
	n, berr := xmlToTree("", nil, p)
	if berr != nil {
		return nil, berr
	}

	return n, nil
}