| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package object
- import "fmt"
- // ObjType type of object
- type ObjType string
- const (
- IntegerObj = "INTEGER"
- BooleanObj = "BOOLEAN"
- NullObj = "NULL"
- )
- // Object source code as an Object
- type Object interface {
- Type() ObjType
- Inspect() string
- }
- type Integer struct {
- Value int64
- }
- func (i *Integer) Type() ObjType { return IntegerObj }
- func (i *Integer) Inspect() string { return fmt.Sprintf("%d", i.Value) }
- type Boolean struct {
- Value bool
- }
- func (b *Boolean) Type() ObjType { return BooleanObj }
- func (b *Boolean) Inspect() string { return fmt.Sprintf("%t", b.Value) }
- type Null struct{}
- func (n *Null) Type() ObjType { return NullObj }
- func (n *Null) Inspect() string { return "null" }
|