func (self *Node) Cap() (int, error) {
    if err := self.checkRaw(); err != nil {
        return 0, err
    }
    if self.t == types.V_ARRAY || self.t == types.V_OBJECT || self.t == _V_ARRAY_LAZY || self.t == _V_OBJECT_LAZY {
        return int(self.v >> _CAP_BITS), nil
    } else {
        return 0, ErrUnsupportType
    }
}
Cap returns malloc capacity of a array|object node for children
package ast
import (
	`encoding/json`
	`unsafe`
	`github.com/bytedance/sonic/decoder`
	`github.com/bytedance/sonic/internal/native/types`
	`github.com/bytedance/sonic/internal/rt`
	`github.com/bytedance/sonic/unquote`
)
const (
    _CAP_BITS          = 32
    _LEN_MASK          = 1 << _CAP_BITS - 1
    _NODE_SIZE = unsafe.Sizeof(Node{})
    _PAIR_SIZE = unsafe.Sizeof(Pair{})
)
const (
    _V_NONE         types.ValueType = 0
    _V_NODE_BASE    types.ValueType = 1<<5
    _V_LAZY         types.ValueType = 1 << 7
    _V_RAW          types.ValueType = 1 << 8
    _V_NUMBER                       = _V_NODE_BASE + 1
    _V_ARRAY_LAZY                   = _V_LAZY | types.V_ARRAY
    _V_OBJECT_LAZY                  = _V_LAZY | types.V_OBJECT
    _MASK_LAZY                      = _V_LAZY - 1
    _MASK_RAW                       = _V_RAW - 1
)
const (
    V_NONE   = 0
    V_ERROR  = 1
    V_NULL   = 2
    V_TRUE   = 3
    V_FALSE  = 4
    V_ARRAY  = 5
    V_OBJECT = 6
    V_STRING = 7
    V_NUMBER = int(_V_NUMBER)
)
type Node struct {
    v int64
    t types.ValueType
    p unsafe.Pointer
}
func (self Node) Type() int {
    return int(self.t & _MASK_LAZY & _MASK_RAW)
}
func (self Node) itype() types.ValueType {
    return self.t & _MASK_LAZY & _MASK_RAW
}
func (self *Node) Exists() bool {
    return self != nil && self.t != _V_NONE
}
func (self *Node) Valid() bool {
    if self == nil {
        return false
    }
    it := self.Type()
    return it >= V_NULL && it <= V_STRING || it == V_NUMBER
}
func (self *Node)  Check() error {
    if self == nil || self.t == V_NONE {
        return ErrNotExist
    } else if self.t != V_ERROR {
        return nil
    } else {
        return self
    }
}
func (self Node) Error() string {
    if self.t == V_NONE {
        return "unsupported type"
    } else if self.t != V_ERROR {
        return ""
    } else {
        return *(*string)(self.p)
    } 
}
func (self Node) IsRaw() bool {
    return self.t&_V_RAW != 0
}
func (self Node) isLazy() bool {
    return self.t&_V_LAZY != 0
}
func (self *Node) Raw() (string, error) {
    if !self.IsRaw() {
        return "", ErrUnsupportType
    }
    return addr2str(self.p, self.v), nil
}
func (self *Node) checkRaw() error {
    if self.IsRaw() {
        self.parseRaw(false)
    }
    if err := self.Check(); err != nil {
        return err
    }
    return nil
}
func (self *Node) Bool() (bool, error) {
    if err := self.checkRaw(); err != nil {
        return false, err
    }
    switch self.t {
        case types.V_TRUE  : return true , nil
        case types.V_FALSE : return false, nil
        default            : return false, ErrUnsupportType
    }
}
func (self *Node) Int64() (int64, error) {
    if err := self.checkRaw(); err != nil {
        return 0, err
    }
    switch self.t {
        case _V_NUMBER        : return numberToInt64(self)
        case types.V_TRUE     : return 1, nil
        case types.V_FALSE    : return 0, nil
        default               : return 0, ErrUnsupportType
    }
}
func (self *Node) Number() (json.Number, error) {
    if err := self.checkRaw(); err != nil {
        return json.Number(""), err
    }
    switch self.t {
        case _V_NUMBER        : return toNumber(self)  , nil
        case types.V_TRUE     : return json.Number("1"), nil
        case types.V_FALSE    : return json.Number("0"), nil
        default               : return json.Number(""), ErrUnsupportType
    }
}
func (self *Node) String() (string, error) {
    if err := self.checkRaw(); err != nil {
        return "", err
    }
    switch self.t {
        case _V_NUMBER       : return toNumber(self).String(), nil
        case types.V_NULL    : return "null" , nil
        case types.V_TRUE    : return "true" , nil
        case types.V_FALSE   : return "false", nil
        case types.V_STRING  : return addr2str(self.p, self.v), nil
        default              : return ""     , ErrUnsupportType
    }
}
func (self *Node) Float64() (float64, error) {
    if err := self.checkRaw(); err != nil {
        return 0.0, err
    }
    switch self.t {
        case _V_NUMBER       : return numberToFloat64(self)
        case types.V_TRUE    : return 1.0, nil
        case types.V_FALSE   : return 0.0, nil
        default              : return 0.0, ErrUnsupportType
    }
}
func (self *Node) Len() (int, error) {
    if err := self.checkRaw(); err != nil {
        return 0, err
    }
    if self.t == types.V_ARRAY || self.t == types.V_OBJECT || self.t == _V_ARRAY_LAZY || self.t == _V_OBJECT_LAZY {
        return int(self.v & _LEN_MASK), nil
    } else if self.t == types.V_STRING {
        return int(self.v), nil
    } else {
        return 0, ErrUnsupportType
    }
}
func (self Node) len() int {
    return int(self.v & _LEN_MASK)
}