about summary refs log tree commit diff
path: root/pkg/lang/compiler/symbol.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang/compiler/symbol.go')
-rw-r--r--pkg/lang/compiler/symbol.go31
1 files changed, 28 insertions, 3 deletions
diff --git a/pkg/lang/compiler/symbol.go b/pkg/lang/compiler/symbol.go
index 03838da..d22cdc0 100644
--- a/pkg/lang/compiler/symbol.go
+++ b/pkg/lang/compiler/symbol.go
@@ -1,13 +1,38 @@
 package compiler
 
+import "jinx/pkg/lang/vm/code"
+
 type SymbolKind int
 
 const (
 	SymbolKindVariable SymbolKind = iota
+	SymbolKindFunction
 )
 
-type Symbol struct {
-	kind       SymbolKind
-	name       string
+func (s SymbolKind) String() string {
+	switch s {
+	case SymbolKindVariable:
+		return "variable"
+	case SymbolKindFunction:
+		return "function"
+	default:
+		panic("unknown symbol kind")
+	}
+}
+
+type Symbol[D SymbolData] struct {
+	name string
+	data D
+}
+
+type SymbolData interface {
+	SymbolVariable | SymbolFunction
+}
+
+type SymbolVariable struct {
 	localIndex int
 }
+
+type SymbolFunction struct {
+	marker code.Marker
+}