Return statements

This commit is contained in:
Chuck Smith
2024-01-19 17:50:02 -05:00
parent e6d5567681
commit 7eba7471c8
3 changed files with 70 additions and 7 deletions

View File

@@ -5,9 +5,10 @@ import "fmt"
type ObjectType string
const (
INTEGER_OBJ = "INTEGER"
BOOLEAN_OBJ = "BOOLEAN"
NULL_OBJ = "NULL"
INTEGER_OBJ = "INTEGER"
BOOLEAN_OBJ = "BOOLEAN"
NULL_OBJ = "NULL"
RETURN_VALUE_OBJ = "RETURN_VALUE"
)
type Object interface {
@@ -46,3 +47,15 @@ func (n *Null) Type() ObjectType {
func (n *Null) Inspect() string {
return "null"
}
type ReturnValue struct {
Value Object
}
func (rv ReturnValue) Type() ObjectType {
return RETURN_VALUE_OBJ
}
func (rv ReturnValue) Inspect() string {
return rv.Value.Inspect()
}