xgo/objects/undefined.go

43 lines
1,014 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package objects
2019-01-11 13:27:28 +03:00
import "github.com/d5/tengo/compiler/token"
2019-01-09 10:17:42 +03:00
// Undefined represents an undefined value.
2019-01-09 10:17:42 +03:00
type Undefined struct{}
// TypeName returns the name of the type.
2019-01-16 04:21:58 +03:00
func (o *Undefined) TypeName() string {
2019-01-09 10:17:42 +03:00
return "undefined"
}
2019-01-16 04:21:58 +03:00
func (o *Undefined) String() string {
2019-01-09 10:17:42 +03:00
return "<undefined>"
}
// BinaryOp returns another object that is the result of
// a given binary operator and a right-hand side object.
2019-01-16 04:21:58 +03:00
func (o *Undefined) BinaryOp(op token.Token, rhs Object) (Object, error) {
2019-01-09 10:17:42 +03:00
return nil, ErrInvalidOperator
}
// Copy returns a copy of the type.
2019-01-16 04:21:58 +03:00
func (o *Undefined) Copy() Object {
return o
2019-01-09 10:17:42 +03:00
}
// IsFalsy returns true if the value of the type is falsy.
2019-01-16 04:21:58 +03:00
func (o *Undefined) IsFalsy() bool {
2019-01-09 10:17:42 +03:00
return true
}
// Equals returns true if the value of the type
// is equal to the value of another object.
2019-01-16 04:21:58 +03:00
func (o *Undefined) Equals(x Object) bool {
return o == x
2019-01-09 10:17:42 +03:00
}
// IndexGet returns an element at a given index.
func (o *Undefined) IndexGet(index Object) (Object, error) {
return UndefinedValue, nil
}