mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
f91fbf6f8c
* rename method Clone to Copy * added Cloneable interface * added Value to Cloneable interface * implemented Cloneable intefrace by array * implemented Cloneable interface by Object * unit tests for Object.Clone * move core.IsCloneable to value.go * change Clone function * move IsClonable to package values
43 lines
578 B
Go
43 lines
578 B
Go
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
|
|
}
|
|
|
|
func (t *none) Hash() uint64 {
|
|
return 0
|
|
}
|
|
|
|
func (t *none) Copy() core.Value {
|
|
return None
|
|
}
|