func sortStructs(b *builder, m map[string]*pkgStruct) []*pkgStruct { s := toposort.NewSorter("struct") for name, ps := range m { s.AddNode(name, ps.name, ps.deps) } order := s.Sort(b) ret := make([]*pkgStruct, 0, len(order)) for _, name := range order { ret = append(ret, m[name]) } return ret }
func sortPkgConsts(b *builder, consts []*pkgConst) []*pkgConst { m := make(map[string]*pkgConst) s := toposort.NewSorter("const") for _, c := range consts { name := c.sym.Name() m[name] = c s.AddNode(name, c.tok, c.deps) } order := s.Sort(b) var ret []*pkgConst for _, name := range order { ret = append(ret, m[name]) } return ret }