-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 Define integer, boolean objects
- Loading branch information
1 parent
31e3f5d
commit 3007fd6
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } |