This commit is contained in:
Chuck Smith
2024-01-20 13:20:13 -05:00
parent 10821fc88a
commit 13c9062fed
9 changed files with 140 additions and 23 deletions

View File

@@ -16,6 +16,7 @@ const (
RETURN_VALUE_OBJ = "RETURN_VALUE"
ERROR_OBJ = "ERROR"
FUNCTION_OBJ = "FUNCTION"
STRING_OBJ = "STRING"
)
type Object interface {
@@ -85,11 +86,11 @@ type Function struct {
Env *Environment
}
func (f Function) Type() ObjectType {
func (f *Function) Type() ObjectType {
return FUNCTION_OBJ
}
func (f Function) Inspect() string {
func (f *Function) Inspect() string {
var out bytes.Buffer
params := []string{}
@@ -106,3 +107,15 @@ func (f Function) Inspect() string {
return out.String()
}
type String struct {
Value string
}
func (s *String) Type() ObjectType {
return STRING_OBJ
}
func (s *String) Inspect() string {
return s.Value
}