diff options
| author | Bobby <[email protected]> | 2024-04-04 14:29:40 +0000 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-04-04 14:29:40 +0000 |
| commit | 98b3baa1d9d05551948b6657b4130cf05c11934d (patch) | |
| tree | c9ff7cc56f26e6481f0ca0cd74bae4f64abe53b0 /object | |
| parent | 2f28a8de055029c4501a8cfb796e7f4a1af8b719 (diff) | |
| download | mana-98b3baa1d9d05551948b6657b4130cf05c11934d.tar.xz mana-98b3baa1d9d05551948b6657b4130cf05c11934d.zip | |
built in functions
Diffstat (limited to 'object')
| -rw-r--r-- | object/object.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/object/object.go b/object/object.go index 731be0b..24de9be 100644 --- a/object/object.go +++ b/object/object.go @@ -17,6 +17,7 @@ const ( FUNCTION_OBJ = "FUNCTION" STRING_OBJ = "STRING" ERROR_OBJ = "ERROR" + BUILTIN_OBJ = "BUILTIN" ) type Object interface { @@ -52,6 +53,12 @@ type String struct { Value string } +type BuiltinFunction func(args ...Object) Object + +type Builtin struct { + Fn BuiltinFunction +} + func (i *Integer) Type() ObjectType { return INTEGER_OBJ } @@ -112,3 +119,6 @@ func (e *Error) Inspect() string { return "ERROR:" + e.Message } func (s *String) Type() ObjectType { return STRING_OBJ } func (s *String) Inspect() string { return s.Value } + +func (b *Builtin) Type() ObjectType { return BUILTIN_OBJ } +func (b *Builtin) Inspect() string { return "builtin function" } |
