Files
monkey/internal/object/builtin.go
Chuck Smith 07fd82b261
Some checks failed
Build / build (push) Successful in 10m29s
Publish Image / publish (push) Failing after 31s
Test / build (push) Failing after 6m34s
optimizations
2024-04-02 14:08:08 -04:00

38 lines
535 B
Go

package object
import "fmt"
type Builtin struct {
Name string
Fn BuiltinFunction
}
func (b Builtin) Bool() bool {
return true
}
func (b Builtin) Type() Type {
return BuiltinType
}
func (b Builtin) Inspect() string {
return fmt.Sprintf("<built-in function %s>", b.Name)
}
func (b Builtin) Compare(other Object) int {
if obj, ok := other.(Builtin); ok {
if b.Name > obj.Name {
return 1
}
if b.Name == obj.Name {
return 0
}
return -1
}
return -1
}
func (b Builtin) String() string {
return b.Inspect()
}