Exemplo n.º 1
0
func getFuncs(prog *ssa.Program, pkg *ssa.Package) []*ssa.Function {
	funcs := make([]*ssa.Function, 0, len(pkg.Members))
	for _, mem := range pkg.Members {
		fn, ok := mem.(*ssa.Function)
		if ok {
			if iu := unicode.IsUpper(rune(fn.Name()[0])); iu || *nonExp {
				funcs = append(funcs, fn)
			}
		}
		typ, ok := mem.(*ssa.Type)
		if ok {
			mset := prog.MethodSets.MethodSet(typ.Type())
			for i, n := 0, mset.Len(); i < n; i++ {
				if mf := prog.MethodValue(mset.At(i)); mf != nil {
					if mfn := mf.Name(); len(mfn) > 0 {
						if iu := unicode.IsUpper(rune(mfn[0])); iu || *nonExp {
							funcs = append(funcs, mf)
							//fmt.Printf("DEBUG method %v %v\n", mfn, mf)
						}
					}
				}
			}
		}
	}
	return funcs
}