// Stack returns the callstack formatted the same way that go does
// in runtime/debug.Stack()
964961
func (err *Error) Stack() []byte {
	buf := bytes.Buffer{}

	for _, frame := range err.StackFrames() {
		buf.WriteString(frame.String())
	}

	return buf.Bytes()
}
614812
func (a *Ancestor) Stack(n int) ([]Stackframe, error) {
	if a.Unreadable != nil {
		return nil, a.Unreadable
	}
	pcsVar := a.pcsVar.clone()
	pcsVar.loadValue(LoadConfig{MaxArrayValues: n})
	if pcsVar.Unreadable != nil {
		return nil, pcsVar.Unreadable
	}
	r := make([]Stackframe, len(pcsVar.Children))
	for i := range pcsVar.Children {
		if pcsVar.Children[i].Unreadable != nil {
			r[i] = Stackframe{Err: pcsVar.Children[i].Unreadable}
			continue
		}
		if pcsVar.Children[i].Kind != reflect.Uint {
			return nil, fmt.Errorf("wrong type for pcs item %d: %v", i, pcsVar.Children[i].Kind)
		}
		pc, _ := constant.Int64Val(pcsVar.Children[i].Value)
		fn := a.pcsVar.bi.PCToFunc(uint64(pc))
		if fn == nil {
			loc := Location{PC: uint64(pc)}
			r[i] = Stackframe{Current: loc, Call: loc}
			continue
		}
		pc2 := uint64(pc)
		if pc2-1 >= fn.Entry {
			pc2--
		}
		f, ln := fn.cu.lineInfo.PCToLine(fn.Entry, pc2)
		loc := Location{PC: uint64(pc), File: f, Line: ln, Fn: fn}
		r[i] = Stackframe{Current: loc, Call: loc}
	}
	r[len(r)-1].Bottom = pcsVar.Len == int64(len(pcsVar.Children))
	return r, nil
}
1288313
func Wrap(err error) error {
	return wrapStackError{stack: string(debug.Stack(2)), err: err}
}
601697
func (s *stack) Push(vs ...interface{}) {
	s.values = append(s.values, vs...)
}
32511
func Stack() (c *StackController) {
	return &StackController{
		List:     stackList,
		New:      stackNew,
		Create:   stackCreate,
		Detail:   stackDetail,
		Edit:     stackEdit,
		Update:   stackUpdate,
		Deploy:   stackDeploy,
		Shutdown: stackShutdown,
		Delete:   stackDelete,
	}
}
1329354
func Stack(err error) []error {
	if eb, ok := err.(*errorBox); ok {
		return append([]error{eb}, Stack(eb.err)...)
	}
	return []error{err}
}
1048453
func (stack *ErrorStack) Pop() error {
	if len(stack.errors) == 0 {
		return nil
	}
	err := stack.errors[len(stack.errors)-1]
	stack.errors = stack.errors[:len(stack.errors)-1]
	return err
}
1222789
func (c *Debugger) GetStackTrace(stackTraceId *RuntimeStackTraceId) (*RuntimeStackTrace, error) {
	var v DebuggerGetStackTraceParams
	v.StackTraceId = stackTraceId
	return c.GetStackTraceWithParams(&v)
}
1262393
func (m *Mux) SetStack(stack []plugin.Plugin) {
	m.Middleware.SetStack(stack)
}
203346
func (e Error) StackTraceString() string {
	buf := new(bytes.Buffer)
	for _, v := range e.Stack {
		fmt.Fprintf(buf, "%s: %s\n\t%s\n", v.File, v.Number, v.Method)
	}
	return string(buf.Bytes())
}
651559
func stacktrace() []string {
	ret := make([]string, 0, 2)

	for skip := 2; skip < maxStackFrames; skip++ {
		_, file, line, ok := runtime.Caller(skip)
		if !ok {
			break
		}

		ret = append(ret, fmt.Sprintf("at %s:%d", stripDirectories(file, 1), line))
	}

	return ret
}
1155377
func NewStack(size int) *Stack {
	if size < 0 {
		panic(IllegalArgumentError{"size must >= 0"})
	}
	stack := &Stack{}
	stack.values = list.New()
	return stack
}
631017
func (s *Stack) Pop() string {
	if len(*s) == 0 {
		return ""
	}
	top := s.Peek()
	*s = (*s)[0 : len(*s)-1]
	return top
}
758532
func (s *exprStack) push(expr Expression) {
	s.stack = append(s.stack, expr)
}
1286797
func (s *Factory) Stacks(allNamespaces bool) (StackClient, error) {
	version, err := kubernetes.GetStackAPIVersion(s.clientSet.Discovery(), s.experimental)
	if err != nil {
		return nil, err
	}
	namespace := s.namespace
	if allNamespaces {
		namespace = metav1.NamespaceAll
	}

	switch version {
	case kubernetes.StackAPIV1Beta1:
		return newStackV1Beta1(s.config, namespace)
	case kubernetes.StackAPIV1Beta2:
		return newStackV1Beta2(s.config, namespace)
	case kubernetes.StackAPIV1Alpha3:
		return newStackV1Alpha3(s.config, namespace)
	default:
		return nil, errors.Errorf("unsupported stack API version: %q", version)
	}
}
646541
func Stack(calldepth int) []byte {
	var (
		e             = make([]byte, 1<<16) // 64k
		nbytes        = runtime.Stack(e, false)
		ignorelinenum = 2*calldepth + 1
		count         = 0
		startIndex    = 0
	)
	for i := range e {
		if e[i] == '\n' {
			count++
			if count == ignorelinenum {
				startIndex = i + 1
			}
		}
	}
	return e[startIndex:nbytes]
}
802268
func StackTrace(err error) (errors.StackTrace, bool) {
	st, ok := getStackTracer(err)
	if ok {
		return st.StackTrace(), true
	}

	return nil, false
}