2018-09-18 22:42:38 +02:00
|
|
|
package values
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
|
|
)
|
|
|
|
|
|
|
|
type none struct{}
|
|
|
|
|
|
|
|
var None = &none{}
|
|
|
|
|
|
|
|
func (t *none) MarshalJSON() ([]byte, error) {
|
|
|
|
return []byte("null"), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *none) Type() core.Type {
|
|
|
|
return core.NoneType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *none) String() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *none) Compare(other core.Value) int {
|
|
|
|
switch other.Type() {
|
|
|
|
case core.NoneType:
|
|
|
|
return 0
|
|
|
|
default:
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *none) Unwrap() interface{} {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-10-05 21:17:22 +02:00
|
|
|
func (t *none) Hash() uint64 {
|
2018-09-18 22:42:38 +02:00
|
|
|
return 0
|
|
|
|
}
|
2018-09-27 17:53:26 +02:00
|
|
|
|
2018-10-12 17:58:08 +02:00
|
|
|
func (t *none) Copy() core.Value {
|
2018-09-27 17:53:26 +02:00
|
|
|
return None
|
|
|
|
}
|