//	If the WalkHandlers.TSampleType function is not nil (ie. was set by outside code), calls it with this TSampleType instance as the single argument. Then calls the Walk() method on 6/7 embed(s) and 0/0 field(s) belonging to this TSampleType instance.
544248
func (me *TSampleType) Walk() (err error) {
	if fn := WalkHandlers.TSampleType; me != nil {
		if fn != nil {
			if err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
				return
			}
		}
		if err = me.XsdGoPkgHasElem_SampleLINKSsequenceSampleTypeschema_SampleLinks_TxsdSampleTypeSequenceSampleLinks_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_SampleATTRIBUTESsequenceSampleTypeschema_SampleAttributes_TxsdSampleTypeSequenceSampleAttributes_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_IDENTIFIERSsequenceSampleTypeschema_Identifiers_TIdentifierType_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_TITLEsequenceSampleTypeschema_Title_XsdtString_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_SampleNAMEsequenceSampleTypeschema_SampleName_TxsdSampleTypeSequenceSampleName_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_DESCRIPTIONsequenceSampleTypeschema_Description_XsdtString_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if fn != nil {
			if err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
				return
			}
		}
	}
	return
}
557033
func WalkExprs(x interface{}, f func(*Expr) bool) {
	vis := &GenericVisitor{func(x interface{}) bool {
		if r, ok := x.(*Expr); ok {
			return f(r)
		}
		return false
	}}
	Walk(vis, x)
}
796846
func (m *rewrite) walkNode(cur expr.Node) (expr.Node, error) {
	//u.Debugf("WalkNode: %#v", cur)
	switch curNode := cur.(type) {
	case *expr.NumberNode, *expr.StringNode:
		return curNode, nil
	case *expr.BinaryNode:
		return m.walkFilterBinary(curNode)
	case *expr.TriNode: // Between
		return m.walkFilterTri(curNode)
	case *expr.UnaryNode:
		//return m.walkUnary(curNode)
		u.Warnf("not implemented: %#v", curNode)
		return nil, fmt.Errorf("Not implemented urnary function: %v", curNode.String())
	case *expr.FuncNode:
		return m.walkFilterFunc(curNode)
	case *expr.IdentityNode:
		u.Warnf("we are trying to project?   %v", curNode.String())
		return curNode, nil
	case *expr.ArrayNode:
		return m.walkArrayNode(curNode)
	default:
		u.Debugf("unrecognized T:%T  %v", cur, cur)
	}

	return cur, nil
}
1027198
func (a *ArgType) TemplateLoader(name string) ([]byte, error) {
	// no template path specified
	if a.TemplatePath == "" {
		return templates.Asset(name)
	}

	return ioutil.ReadFile(path.Join(a.TemplatePath, name))
}
905793
func runCallbacks(xu *xgbutil.XUtil, event interface{}, evtype int,
	win xproto.Window) {

	// The callback slice for a particular (event type, window) tuple uses
	// copy on write. So just take a pointer to whatever is there and use that.
	// We can be sure that the slice won't change from underneathe us.
	xu.CallbacksLck.RLock()
	cbs := xu.Callbacks[evtype][win]
	xu.CallbacksLck.RUnlock()

	for _, cb := range cbs {
		cb.Run(xu, event)
	}
}
1006171
func Walk(x Syntax, before, after func(Syntax)) {
	seen := map[Syntax]bool{
		nil:           true,
		(*Decl)(nil):  true,
		(*Init)(nil):  true,
		(*Type)(nil):  true,
		(*Expr)(nil):  true,
		(*Stmt)(nil):  true,
		(*Label)(nil): true,
	}
	walk(x, before, after, seen)
}
436599
func (me *TRunType) Walk() (err error) {
	if fn := WalkHandlers.TRunType; me != nil {
		if fn != nil {
			if err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
				return
			}
		}
		if err = me.XsdGoPkgHasElem_PROCESSINGsequenceRunTypeschema_Processing_TProcessingType_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_SpotDESCRIPTORsequenceRunTypeschema_SpotDescriptor_TSpotDescriptorType_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_TITLEsequenceRunTypeschema_Title_XsdtString_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_ExperimentREFsequenceRunTypeschema_ExperimentRef_TxsdRunTypeSequenceExperimentRef_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_PLATFORMsequenceRunTypeschema_Platform_TPlatformType_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_RunLINKSsequenceRunTypeschema_RunLinks_TxsdRunTypeSequenceRunLinks_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_RunATTRIBUTESsequenceRunTypeschema_RunAttributes_TxsdRunTypeSequenceRunAttributes_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElems_DataBLOCKsequencesequenceRunTypeschema_DataBlock_TxsdRunTypeSequenceSequenceDataBlock_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if err = me.XsdGoPkgHasElem_IDENTIFIERSsequenceRunTypeschema_Identifiers_TIdentifierType_.Walk(); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
			return
		}
		if fn != nil {
			if err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {
				return
			}
		}
	}
	return
}
494135
func walkNames(exp Expr) []string {
	switch expr := exp.(type) {
	case *VarRef:
		return []string{expr.Val}
	case *Call:
		var a []string
		for _, expr := range expr.Args {
			if ref, ok := expr.(*VarRef); ok {
				a = append(a, ref.Val)
			}
		}
		return a
	case *BinaryExpr:
		var ret []string
		ret = append(ret, walkNames(expr.LHS)...)
		ret = append(ret, walkNames(expr.RHS)...)
		return ret
	case *ParenExpr:
		return walkNames(expr.Expr)
	}

	return nil
}
888225
func walkRefs(exp Expr) []VarRef {
	refs := make(map[VarRef]struct{})
	var walk func(exp Expr)
	walk = func(exp Expr) {
		switch expr := exp.(type) {
		case *VarRef:
			refs[*expr] = struct{}{}
		case *Call:
			for _, expr := range expr.Args {
				if ref, ok := expr.(*VarRef); ok {
					refs[*ref] = struct{}{}
				}
			}
		case *BinaryExpr:
			walk(expr.LHS)
			walk(expr.RHS)
		case *ParenExpr:
			walk(expr.Expr)
		}
	}
	walk(exp)

	// Turn the map into a slice.
	a := make([]VarRef, 0, len(refs))
	for ref := range refs {
		a = append(a, ref)
	}
	return a
}
1197264
func type_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
	if len(kwargs) > 0 {
		return nil, fmt.Errorf("type does not accept keyword arguments")
	}
	if len(args) != 1 {
		return nil, fmt.Errorf("type: got %d arguments, want exactly 1", len(args))
	}
	return String(args[0].Type()), nil
}
628516
func (s *Shape) GoCodeStringers() string {
	w := bytes.Buffer{}
	if err := goCodeStringerTmpl.Execute(&w, s); err != nil {
		panic(fmt.Sprintln("Unexpected error executing GoCodeStringers template", err))
	}

	return w.String()
}
931566
func WalkRefs(x interface{}, f func(Ref) bool) {
	vis := &GenericVisitor{func(x interface{}) bool {
		if r, ok := x.(Ref); ok {
			return f(r)
		}
		return false
	}}
	Walk(vis, x)
}
1290644
func (env *Zlisp) FunctionCallNameTypeCheck(f *SexpFunction, nargs *int) error {
	if f.inputTypes != nil {
		Q("FunctionCallNameTypeCheck sees inputTypes: '%v'", f.inputTypes.SexpString(nil))
	} else {
		return nil // no type checking requested
	}
	if f.varargs {
		return nil // name/type checking for vargarg not currently implemented.
	}

	// our call arguments prepared -- will be pushed to the datastack
	finalArgs := make([]Sexp, f.inputTypes.NumKeys)

	// pop everything off the stack, will push finalArgs later
	exprs, err := env.datastack.PopExpressions(*nargs)
	if err != nil {
		return err
	}

	// map the named submitted args, for fast lookup by name
	submittedByName := make(map[string]Sexp)

	// prep submittedByName
	for i := 0; i < *nargs; i++ {
		switch sym := exprs[i].(type) {
		case *SexpSymbol:
			if sym.colonTail {
				Q("in env.CallFunction, have symbol.colonTail: exprs[%v]='%#v'", i, sym)
				typ, err := f.inputTypes.HashGet(env, sym)
				if err != nil {
					return fmt.Errorf("%s takes no argument '%s'", f.name, sym.name)
				}
				if i == (*nargs)-1 {
					return fmt.Errorf("named parameter '%s' not followed by value", sym.name)
				}
				val := exprs[i+1]
				i++
				_, already := submittedByName[sym.name]
				if already {
					return fmt.Errorf("duplicate named parameter '%s'", sym.name)
				}

				submittedByName[sym.name] = val
				valtyp := val.Type()
				if typ != nil && typ != valtyp {
					return fmt.Errorf("type mismatch for parameter '%s': expected '%s', got '%s'",
						sym.name, typ.SexpString(nil), valtyp.SexpString(nil))
				}
			} else {
				Q("in env.CallFunction, exprs[%v]='%v'/type=%T", i, exprs[i].SexpString(nil), exprs[i])
			}
		default:
			Q("in env.CallFunction, exprs[%v]='%v'/type=%T", i, exprs[i].SexpString(nil), exprs[i])
		}
	}

	// simplify name matching for now with this rule: all by name, or none.
	haveByName := len(submittedByName)
	if haveByName > 0 {
		if haveByName != f.inputTypes.NumKeys {
			return fmt.Errorf("named arguments count %v != expected %v", haveByName, f.inputTypes.NumKeys)
		}

		// prep finalArgs in the order dictated
		for i, key := range f.inputTypes.KeyOrder {
			switch sy := key.(type) {
			case *SexpSymbol:
				// search for sy.name in our submittedByName args
				a, found := submittedByName[sy.name]
				if found {
					Q("%s call: matching %v-th argument named '%s': passing value '%s'",
						f.name, i, sy.name, a.SexpString(nil))
					finalArgs[i] = a
				}
			default:
				return fmt.Errorf("unsupported argument-name type %T", key)
			}

		}
	} else {
		// not using named parameters, restore the arguments to the stack as they were.
		finalArgs = exprs
	}
	*nargs = len(finalArgs)
	return env.datastack.PushExpressions(finalArgs)
}
1220513
func Caller(skip int) Call {
	// As of Go 1.9 we need room for up to three PC entries.
	//
	// 0. An entry for the stack frame prior to the target to check for
	//    special handling needed if that prior entry is runtime.sigpanic.
	// 1. A possible second entry to hold metadata about skipped inlined
	//    functions. If inline functions were not skipped the target frame
	//    PC will be here.
	// 2. A third entry for the target frame PC when the second entry
	//    is used for skipped inline functions.
	var pcs [3]uintptr
	n := runtime.Callers(skip+1, pcs[:])
	frames := runtime.CallersFrames(pcs[:n])
	frame, _ := frames.Next()
	frame, _ = frames.Next()

	return Call{
		frame: frame,
	}
}
1321111
func (n *Parameter) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

	if n.VariableType != nil {
		v.EnterChildNode("VariableType", n)
		n.VariableType.Walk(v)
		v.LeaveChildNode("VariableType", n)
	}

	if n.Variable != nil {
		v.EnterChildNode("Variable", n)
		n.Variable.Walk(v)
		v.LeaveChildNode("Variable", n)
	}

	if n.DefaultValue != nil {
		v.EnterChildNode("DefaultValue", n)
		n.DefaultValue.Walk(v)
		v.LeaveChildNode("DefaultValue", n)
	}

	v.LeaveNode(n)
}
44735
func Walk(n Node, f func(Node)) {
	f(n)
	switch n := n.(type) {
	case *BinaryNode:
		Walk(n.Args[0], f)
		Walk(n.Args[1], f)
	case *AskNode:
		// Ignore.
	case *UnaryNode:
		Walk(n.Arg, f)
	default:
		panic(fmt.Errorf("other type: %T", n))
	}
}
703543
func (m *rewrite) walkSelectList() error {

	m.result.Columns = m.sel.Columns

	for i := len(m.result.Columns) - 1; i >= 0; i-- {
		col := m.result.Columns[i]
		//u.Debugf("i=%d of %d  %v %#v ", i, len(m.sel.Columns), col.Key(), col)
		if col.Expr != nil {
			switch curNode := col.Expr.(type) {
			// case *expr.NumberNode:
			// 	return nil, value.NewNumberValue(curNode.Float64), nil
			// case *expr.BinaryNode:
			// 	return m.walkBinary(curNode)
			// case *expr.TriNode: // Between
			// 	return m.walkTri(curNode)
			// case *expr.UnaryNode:
			// 	return m.walkUnary(curNode)
			case *expr.FuncNode:
				// All Func Nodes are Aggregates?
				newNode, err := m.selectFunc(curNode)
				if err == nil {
					col.Expr = newNode
				} else if err != nil {
					u.Error(err)
					return err
				}
				//u.Debugf("esm: %v:%v", col.As, esm)
				//u.Debugf(curNode.String())
			// case *expr.ArrayNode:
			// 	return m.walkArrayNode(curNode)
			// case *expr.IdentityNode:
			// 	return nil, value.NewStringValue(curNode.Text), nil
			// case *expr.StringNode:
			// 	return nil, value.NewStringValue(curNode.Text), nil
			case *expr.IdentityNode:
				//u.Debugf("likely a projection, not agg T:%T  %v", curNode, curNode)
			default:
				u.Warnf("unrecognized not agg T:%T  %v", curNode, curNode)
				//panic("Unrecognized node type")
			}
		}

	}
	return nil
}