xgo/objects/char.go

39 lines
547 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package objects
import (
"github.com/d5/tengo/token"
)
type Char struct {
Value rune
}
func (o *Char) String() string {
return string(o.Value)
2019-01-09 10:17:42 +03:00
}
func (o *Char) TypeName() string {
return "char"
}
func (o *Char) BinaryOp(op token.Token, rhs Object) (Object, error) {
return nil, ErrInvalidOperator
}
func (o *Char) Copy() Object {
return &Char{Value: o.Value}
}
func (o *Char) IsFalsy() bool {
return o.Value == 0
2019-01-09 10:17:42 +03:00
}
func (o *Char) Equals(x Object) bool {
t, ok := x.(*Char)
if !ok {
return false
}
return o.Value == t.Value
}