xgo/objects/builtin_function.go

38 lines
692 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package objects
import (
2019-01-11 13:27:28 +03:00
"github.com/d5/tengo/compiler/token"
2019-01-09 10:17:42 +03:00
)
2019-01-10 06:07:03 +03:00
type BuiltinFunction struct {
Value BuiltinFunc
}
2019-01-09 10:17:42 +03:00
2019-01-10 06:07:03 +03:00
func (o *BuiltinFunction) TypeName() string {
2019-01-09 10:17:42 +03:00
return "builtin-function"
}
2019-01-10 06:07:03 +03:00
func (o *BuiltinFunction) String() string {
2019-01-09 10:17:42 +03:00
return "<builtin-function>"
}
2019-01-10 06:07:03 +03:00
func (o *BuiltinFunction) BinaryOp(op token.Token, rhs Object) (Object, error) {
2019-01-09 10:17:42 +03:00
return nil, ErrInvalidOperator
}
2019-01-10 06:07:03 +03:00
func (o *BuiltinFunction) Copy() Object {
return &BuiltinFunction{Value: o.Value}
2019-01-09 10:17:42 +03:00
}
2019-01-10 06:07:03 +03:00
func (o *BuiltinFunction) IsFalsy() bool {
2019-01-09 10:17:42 +03:00
return false
}
2019-01-10 06:07:03 +03:00
func (o *BuiltinFunction) Equals(x Object) bool {
2019-01-09 10:17:42 +03:00
return false
}
2019-01-10 06:07:03 +03:00
func (o *BuiltinFunction) Call(args ...Object) (Object, error) {
return o.Value(args...)
}