Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit 1585ad6

Browse files
committed
feat: add compiled function type
1 parent 0b447f0 commit 1585ad6

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

models/object/function.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package object
22

3-
import "github.com/looplanguage/loop/models/ast"
3+
import (
4+
"fmt"
5+
"github.com/looplanguage/loop/models/ast"
6+
)
47

58
type Function struct {
69
Parameters []*ast.Identifier
@@ -10,3 +13,10 @@ type Function struct {
1013

1114
func (f *Function) Type() string { return FUNCTION }
1215
func (f *Function) Inspect() string { return "function" }
16+
17+
type CompiledFunction struct {
18+
Instructions []byte
19+
}
20+
21+
func (cf *CompiledFunction) Type() string { return COMPILED_FUNCTION }
22+
func (cf *CompiledFunction) Inspect() string { return fmt.Sprintf("CompiledFunction[%p]", cf) }

models/object/object.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ package object
33
import "fmt"
44

55
const (
6-
INTEGER = "INTEGER"
7-
ERROR = "ERROR"
8-
FUNCTION = "FUNCTION"
9-
BOOLEAN = "BOOLEAN"
10-
ARRAY = "ARRAY"
11-
RETURN = "RETURN"
12-
BUILTIN = "BUILTIN"
13-
STRING = "STRING"
14-
NONE = "NONE"
15-
HASHMAP = "HASHMAP"
16-
EXPORT = "EXPORT"
17-
IMPORT = "IMPORT"
6+
INTEGER = "INTEGER"
7+
ERROR = "ERROR"
8+
FUNCTION = "FUNCTION"
9+
BOOLEAN = "BOOLEAN"
10+
ARRAY = "ARRAY"
11+
RETURN = "RETURN"
12+
BUILTIN = "BUILTIN"
13+
STRING = "STRING"
14+
NONE = "NONE"
15+
HASHMAP = "HASHMAP"
16+
EXPORT = "EXPORT"
17+
IMPORT = "IMPORT"
18+
COMPILED_FUNCTION = "COMPILED_FUNCTION"
1819
)
1920

2021
type Object interface {

0 commit comments

Comments
 (0)