monna/object/object.go
tijani 886a16e706 Spelling corrections
Interpreter can now evaluate Booleans

git-svn-id: https://svn.tlawal.org/svn/monkey@45 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-08-07 14:58:35 +00:00

54 lines
723 B
Go

package object
import "fmt"
type ObjectType string
const (
INTEGER_OBJECT = "INTEGER"
BOOLEAN_OBJECT = "BOOLEAN"
NULL_OBJECT = "NULL"
)
type Object interface {
Type() ObjectType
Inspect() string
}
// Integer
type Integer struct {
Value int64
}
func (i *Integer) Type() ObjectType {
return INTEGER_OBJECT
}
func (i *Integer) Inspect() string {
return fmt.Sprintf("%d", i.Value)
}
// Booleans
type Boolean struct {
Value bool
}
func (b *Boolean) Type() ObjectType {
return BOOLEAN_OBJECT
}
func (b *Boolean) Inspect() string {
return fmt.Sprintf("%t", b.Value)
}
// Null
type Null struct{}
func (n *Null) Type() ObjectType {
return NULL_OBJECT
}
func (n *Null) Inspect() string {
return "null"
}