This commit is contained in:
Chuck Smith
2024-01-19 18:07:54 -05:00
parent 7eba7471c8
commit 44d20ba7a0
3 changed files with 119 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ const (
BOOLEAN_OBJ = "BOOLEAN"
NULL_OBJ = "NULL"
RETURN_VALUE_OBJ = "RETURN_VALUE"
ERROR_OBJ = "ERROR"
)
type Object interface {
@@ -52,10 +53,22 @@ type ReturnValue struct {
Value Object
}
func (rv ReturnValue) Type() ObjectType {
func (rv *ReturnValue) Type() ObjectType {
return RETURN_VALUE_OBJ
}
func (rv ReturnValue) Inspect() string {
func (rv *ReturnValue) Inspect() string {
return rv.Value.Inspect()
}
type Error struct {
Message string
}
func (e *Error) Type() ObjectType {
return ERROR_OBJ
}
func (e *Error) Inspect() string {
return "Error: " + e.Message
}