// w is the destination; left and right are the delimiters; @ and $ are both
// reasonable choices.
//
// c is used to make a function for every naming system, to which you can pass
// a type and get the corresponding name.
11127
func NewSnippetWriter(w io.Writer, c *Context, left, right string) *SnippetWriter {
	sw := &SnippetWriter{
		w:       w,
		context: c,
		left:    left,
		right:   right,
		funcMap: template.FuncMap{},
	}
	for name, namer := range c.Namers {
		sw.funcMap[name] = namer.Name
	}
	return sw
}
305267
func function(pc uintptr) []byte {
	fn := runtime.FuncForPC(pc)
	if fn == nil {
		return dunno
	}
	name := []byte(fn.Name())
	// The name includes the path name to the package, which is unnecessary
	// since the file name is already included.  Plus, it has center dots.
	// That is, we see
	//  runtime/debug.*T·ptrmethod
	// and want
	//  *T.ptrmethod
	if period := bytes.Index(name, dot); period >= 0 {
		name = name[period+1:]
	}
	name = bytes.Replace(name, centerDot, dot, -1)
	return name
}
911260
func WKT(input string) interface{} {
	parts := strings.SplitN(input, " ", 2)
	name := parts[0]
	predicate := parseWKTPredicate(parts[1])

	switch name {
	case "POINT":
		if coords, ok := predicate.([]float64); ok {
			return NewPoint(coords)
		}
		return NewPoint(nil)
	case "POLYGON":
		if coords, ok := predicate.([][][]float64); ok {
			return NewPolygon(coords)
		}
		return NewPolygon(nil)
	case "LINESTRING":
		if coords, ok := predicate.([][]float64); ok {
			return NewLineString(coords)
		}
		return NewLineString(nil)
	case "MULTIPOINT":
		switch mpp := predicate.(type) {
		case [][]float64:
			return NewMultiPoint(mpp)
		default:
			fmt.Printf("%T\n", mpp)
			return NewMultiPoint(nil)
		}
	}
	return nil
}
855419
func main() {
	if len(os.Args) != 4 {
		fmt.Fprintf(os.Stderr, "expected 3 arguments, got %d\n", len(os.Args)-1)
		exit.Exit(1)
	}

	// No error checking here, it's a contrived example after all.
	a, _ := strconv.Atoi(os.Args[2])
	b, _ := strconv.Atoi(os.Args[3])

	var op func(int, int) int
	switch os.Args[1] {
	case "add":
		op = add
	case "sub":
		op = sub
	default:
		fmt.Fprintf(os.Stderr, "unknown operation: %s\n", os.Args[1])
		exit.Exit(1)
	}

	fmt.Println(op(a, b))
}
570299
func Name(i interface{}) string {
	val := reflect.ValueOf(i)
	if !val.IsValid() {
		return ""
	}
	t := val.Type()
	switch t.Kind() {
	case reflect.Func:
		return runtime.FuncForPC(val.Pointer()).Name()
	default:
		return nameof(t)
	}
}
911146
func (w WriteOptions) String() string {
	f := []string{}
	for _, on := range optNames {
		if w&on.opt != 0 {
			f = append(f, on.name)
			w &= ^on.opt
		}
	}
	if len(f) == 0 || w != 0 {
		f = append(f, fmt.Sprintf("0x%x", int(w)))
	}
	return strings.Join(f, "|")
}
441780
func variablesStr(vs []*Variable) string {
	result := ""
	ks := make([]string, 0, len(vs))
	m := make(map[string]*Variable)
	for _, v := range vs {
		ks = append(ks, v.Name)
		m[v.Name] = v
	}
	sort.Strings(ks)

	for _, k := range ks {
		v := m[k]

		required := ""
		if v.Required() {
			required = " (required)"
		}

		declaredType := ""
		if v.DeclaredType != "" {
			declaredType = fmt.Sprintf(" (%s)", v.DeclaredType)
		}

		if v.Default == nil || v.Default == "" {
			v.Default = "<>"
		}
		if v.Description == "" {
			v.Description = "<>"
		}

		result += fmt.Sprintf(
			"%s%s%s\n  %v\n  %s\n",
			k,
			required,
			declaredType,
			v.Default,
			v.Description)
	}

	return strings.TrimSpace(result)
}
1119590
func (a *stmtCompiler) defineVar(ident *ast.Ident, t Type) *Variable {
	v, prev := a.block.DefineVar(ident.Name, ident.Pos(), t)
	if prev != nil {
		if prev.Pos().IsValid() {
			a.diagAt(ident.Pos(), "variable %s redeclared in this block\n\tprevious declaration at %s", ident.Name, a.fset.Position(prev.Pos()))
		} else {
			a.diagAt(ident.Pos(), "variable %s redeclared in this block", ident.Name)
		}
		return nil
	}

	// Initialize the variable
	index := v.Index
	if v.Index >= 0 {
		a.push(func(v *Thread) { v.f.Vars[index] = t.Zero() })
	}
	return v
}
1257691
func (d DestinationKeyspaceIDs) String() string {
	var buffer bytes.Buffer
	buffer.WriteString("DestinationKeyspaceIDs(")
	for i, ksid := range d {
		if i > 0 {
			buffer.WriteByte(',')
		}
		buffer.WriteString(hex.EncodeToString(ksid))
	}
	buffer.WriteByte(')')
	return buffer.String()
}
320672
func (i EqualsExpr) String() string {
	return fmt.Sprintf("equals(%v, %v)", i.Left, i.Right)
}
778360
func DumpFunction(fun ZlispFunction, pc int) {
	blank := "      "
	extra := blank
	for i, instr := range fun {
		if i == pc {
			extra = " PC-> "
		} else {
			extra = blank
		}
		fmt.Printf("%s %d: %s\n", extra, i, instr.InstrString())
	}
	if pc == len(fun) {
		fmt.Printf(" PC just past end at %d -----\n\n", pc)
	}
}
845086
func go_resolve_variables(ctxt unsafe.Pointer, name, ns *C.char) (ret C.xmlXPathObjectPtr) {
	variable := C.GoString(name)
	namespace := C.GoString(ns)

	context := (*VariableScope)(ctxt)
	if context != nil {
		val := (*context).ResolveVariable(variable, namespace)
		ret = ValueToXPathObject(val)
	}
	return
}
1361099
func (v *TypeReference) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [3]string
	i := 0
	fields[i] = fmt.Sprintf("Name: %v", v.Name)
	i++
	fields[i] = fmt.Sprintf("ImportPath: %v", v.ImportPath)
	i++
	if v.Annotations != nil {
		fields[i] = fmt.Sprintf("Annotations: %v", v.Annotations)
		i++
	}

	return fmt.Sprintf("TypeReference{%v}", strings.Join(fields[:i], ", "))
}
721844
func (g *G) Go() Location {
	pc := g.GoPC
	if fn := g.variable.bi.PCToFunc(pc); fn != nil {
		// Backup to CALL instruction.
		// Mimics runtime/traceback.go:677.
		if g.GoPC > fn.Entry {
			pc--
		}
	}
	f, l, fn := g.variable.bi.PCToLine(pc)
	return Location{PC: g.GoPC, File: f, Line: l, Fn: fn}
}
1214672
func typeOf(i interface{}) string {
	if i == nil {
		return ""
	}
	return reflect.TypeOf(i).Elem().Name()
}
541416
func (c Coord) String() string {
	return fmt.Sprintf("%f %f", c.X, c.Y)
}
1092875
func (t *UseNode) String() string {
	if l := len(t.Aliases); l > 0 {
		keys := make([]string, l)
		i := 0
		for orig := range t.Aliases {
			keys[i] = orig
			i++
		}
		sort.Strings(keys)
		res := make([]string, l)
		for i, orig := range keys {
			res[i] = orig + ": " + t.Aliases[orig]
		}
		return fmt.Sprintf("Use(%s with %s)", t.Tpl, strings.Join(res, ", "))
	}
	return fmt.Sprintf("Use(%s)", t.Tpl)
}