// See: http://duktape.org/api.html#duk_check_stack_top
14036
func (d *Context) CheckStackTop(top int) bool {
	return int(C.duk_check_stack_top(d.duk_context, C.duk_idx_t(top))) == 1
}
1194437
func DefaultStacktracePred(status int) bool {
	return (status < http.StatusOK || status >= http.StatusInternalServerError) && status != http.StatusSwitchingProtocols
}
364565
func (d *Context) CheckType(index int, typ int) bool {
	return int(C.duk_check_type(d.duk_context, C.duk_idx_t(index), C.duk_int_t(typ))) == 1
}
305326
func (c Context) Stack() Context {
	c.l = c.l.Hook(sh)
	return c
}
303985
func (d *Context) CheckTypeMask(index int, mask uint) bool {
	return int(C.duk_check_type_mask(d.duk_context, C.duk_idx_t(index), C.duk_uint_t(mask))) == 1
}
475669
func (stack ErrorStack) Top() error {
	if len(stack.errors) == 0 {
		return nil
	}
	return stack.errors[len(stack.errors)-1]
}
137029
func (v *Validator) CheckHooks() (errs error) {
	logrus.Debugf("check hooks")

	if v.platform != "linux" && v.platform != "solaris" {
		errs = multierror.Append(errs, fmt.Errorf("For %q platform, the configuration structure does not support hooks", v.platform))
		return
	}

	if v.spec.Hooks != nil {
		errs = multierror.Append(errs, v.checkEventHooks("prestart", v.spec.Hooks.Prestart, v.HostSpecific))
		errs = multierror.Append(errs, v.checkEventHooks("poststart", v.spec.Hooks.Poststart, v.HostSpecific))
		errs = multierror.Append(errs, v.checkEventHooks("poststop", v.spec.Hooks.Poststop, v.HostSpecific))
	}

	return
}
1291421
func Stack(e error) []uintptr {
	stack, _ := Value(e, stack).([]uintptr)
	return stack
}
288184
func GetOrNewStacktrace(err error, skip int, context int, appPackagePrefixes []string) *Stacktrace {
	type stackTracer interface {
		StackTrace() []runtime.Frame
	}
	stacktrace, ok := err.(stackTracer)
	if !ok {
		return NewStacktrace(skip+1, context, appPackagePrefixes)
	}
	var frames []*StacktraceFrame
	for f := range stacktrace.StackTrace() {
		pc := uintptr(f) - 1
		fn := runtime.FuncForPC(pc)
		var fName string
		var file string
		var line int
		if fn != nil {
			file, line = fn.FileLine(pc)
			fName = fn.Name()
		} else {
			file = "unknown"
			fName = "unknown"
		}
		frame := NewStacktraceFrame(pc, fName, file, line, context, appPackagePrefixes)
		if frame != nil {
			frames = append([]*StacktraceFrame{frame}, frames...)
		}
	}
	return &Stacktrace{Frames: frames}
}
1068600
func (c *Client) StackInfo(stackIdentity string) (*Stack, error) {
	var stack Stack
	return &stack, c.Get(&stack, "/stacks/"+stackIdentity)
}
391466
func (client *Client) GetStack(guid string) (Stack, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.GetStackRequest,
		URIParams:   Params{"stack_guid": guid},
	})
	if err != nil {
		return Stack{}, nil, err
	}

	var stack Stack
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &stack,
	}

	err = client.connection.Make(request, &response)
	return stack, response.Warnings, err
}
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,
	}
}
965275
func (L *State) CheckStack(extra int) bool {
	return C.lua_checkstack(L.s, C.int(extra)) != 0
}
909488
func Stacktrace(e error) string {
	s := Stack(e)
	if len(s) > 0 {
		buf := bytes.Buffer{}
		frames := runtime.CallersFrames(s)
		for {
			frame, more := frames.Next()
			buf.WriteString(frame.Function)
			buf.WriteString(fmt.Sprintf("\n\t%s:%d\n", frame.File, frame.Line))
			if !more {
				break
			}

		}
		return buf.String()
	}
	return ""
}
716262
func (c *configuration) stackValue(i int) head {
	size := c.stackSize()
	if i >= size || i < 0 {
		return DOES_NOT_EXIST
	}
	return c.stack[size-1-i]
}
1352066
func (s *callStack) tailCallTrimStack() {
	for i := len(s.stack) - 1; i >= 0; i-- {
		if s.stack[i].isCall {
			if !s.stack[i].trimmable {
				return
			}
			// Remove this stack frame and everything above it
			s.stack = s.stack[:i]
			s.calls--
			return
		}
	}
}
1115144
func stacktrace(skip int) (lines []Line) {
	for i := skip; ; i++ {
		pc, file, line, ok := runtime.Caller(i)
		if !ok {
			break
		}

		item := Line{string(function(pc)), string(file), line}

		// ignore panic method
		if item.Function != "panic" {
			lines = append(lines, item)
		}
	}
	return
}