package modelse

import "fmt"

type StackStatus uint8

// 定义状态的位图常量
const (
	JattachSuccess StackStatus = 1 << 0
	JattachFailure StackStatus = 0 << 0

	StackUprobesSuccess StackStatus = 1 << 1
	StackUprobesFailure StackStatus = 0 << 1
)

func (s StackStatus) IsJattachSuccess() bool {
	return s&JattachSuccess != 0
}

func (s StackStatus) IsStackUprobesSuccess() bool {
	return s&StackUprobesSuccess != 0
}

func (s *StackStatus) JattachSuccess() {
	*s |= JattachSuccess
}

func (s *StackStatus) JattachFailure() {
	*s &^= JattachSuccess
}

func (s *StackStatus) JattachClose() {
	*s &^= JattachSuccess
}

func (s *StackStatus) StackUprobesSuccess() {
	*s |= StackUprobesSuccess
}

func (s *StackStatus) StackUprobesFailure() {
	*s &^= StackUprobesSuccess
}

func (s *StackStatus) StackUprobesClose() {
	*s &^= StackUprobesSuccess
}

func (s StackStatus) String() string {
	n := 0
	if s.IsJattachSuccess() {
		n = 1
	}
	u := 0
	if s.IsStackUprobesSuccess() {
		u = 1
	}
	return fmt.Sprintf("N=%d U=%d ", n, u)
}
