about summary refs log tree commit diff
path: root/pkg/lang/compiler/symbol.go
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-07-11 00:35:59 +0200
committerMel <einebeere@gmail.com>2022-07-11 00:35:59 +0200
commit1b6ef1e43e1ec1107ce29a6438b399352d09fbc2 (patch)
tree20b8cc80564f0c76c9e68e9fb6df6163b06b24f2 /pkg/lang/compiler/symbol.go
parentb16b70fd40ffc72ff861afe0517cba0e37ba1145 (diff)
downloadjinx-1b6ef1e43e1ec1107ce29a6438b399352d09fbc2.tar.zst
jinx-1b6ef1e43e1ec1107ce29a6438b399352d09fbc2.zip
Rebuild compiler and code builder with markers
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
+}