Skip to content

Commit

Permalink
👷 Define integer, boolean objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ChmielewskiKamil committed Sep 7, 2024
1 parent 31e3f5d commit 3007fd6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions object/object.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// object or "value" system used to evaluate the AST nodes.
package object

import (
"fmt"
"math/big"
)

type ObjectType string

const (
INTEGER_OBJ = "INTEGER"
BOOLEAN_OBJ = "BOOLEAN"
)

type Object interface {
Type() ObjectType
Inspect() string
}

type Integer struct {
Value big.Int
}

func (i *Integer) Inspect() string { return i.Value.String() }
func (i *Integer) Type() ObjectType { return INTEGER_OBJ }

type Boolean struct {
Value bool
}

func (b *Boolean) Inspect() string { return fmt.Sprintf("%t", b.Value) }

0 comments on commit 3007fd6

Please sign in to comment.