about summary refs log tree commit diff
path: root/pkg/lang/compiler/scope
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang/compiler/scope')
-rw-r--r--pkg/lang/compiler/scope/scope_chain.go37
-rw-r--r--pkg/lang/compiler/scope/scopes.go2
-rw-r--r--pkg/lang/compiler/scope/symbol.go21
3 files changed, 2 insertions, 58 deletions
diff --git a/pkg/lang/compiler/scope/scope_chain.go b/pkg/lang/compiler/scope/scope_chain.go
index d0108ee..f4b9f46 100644
--- a/pkg/lang/compiler/scope/scope_chain.go
+++ b/pkg/lang/compiler/scope/scope_chain.go
@@ -137,35 +137,6 @@ func (sc *ScopeChain) Declare(name string) (int, bool) {
 	return indexInScope, true
 }
 
-func (sc *ScopeChain) DeclareFunction(name string, args uint) (code.Marker, bool) {
-	if _, ok := sc.nameToSymbol[name]; ok {
-		return "", false
-	}
-
-	current := sc.Current()
-	index := len(current.functionSymbols)
-
-	symbolID := SymbolID{
-		symbolKind:   SymbolKindFunction,
-		scopeID:      sc.CurrentScopeID(),
-		indexInScope: index,
-	}
-
-	unitName := sc.CreateFunctionSubUnit(name)
-
-	current.functionSymbols = append(current.functionSymbols, Symbol[SymbolFunction]{
-		name: name,
-		data: SymbolFunction{
-			marker: unitName,
-			args:   args,
-		},
-	})
-
-	sc.nameToSymbol[name] = symbolID
-
-	return unitName, true
-}
-
 func (sc *ScopeChain) DeclareAnonymous() int {
 	current := sc.Current()
 	index := len(current.variableSymbols)
@@ -221,11 +192,3 @@ func (sc *ScopeChain) GetVariable(id SymbolID) Symbol[SymbolVariable] {
 
 	return sc.symbolScopes[id.scopeID].variableSymbols[id.indexInScope]
 }
-
-func (sc *ScopeChain) GetFunction(id SymbolID) Symbol[SymbolFunction] {
-	if id.symbolKind != SymbolKindFunction {
-		panic("incorrect symbol id kind given")
-	}
-
-	return sc.symbolScopes[id.scopeID].functionSymbols[id.indexInScope]
-}
diff --git a/pkg/lang/compiler/scope/scopes.go b/pkg/lang/compiler/scope/scopes.go
index 5cfcd5d..e34b45a 100644
--- a/pkg/lang/compiler/scope/scopes.go
+++ b/pkg/lang/compiler/scope/scopes.go
@@ -14,13 +14,11 @@ const (
 
 type SymbolScope struct {
 	variableSymbols []Symbol[SymbolVariable]
-	functionSymbols []Symbol[SymbolFunction]
 }
 
 func NewSymbolScope() SymbolScope {
 	return SymbolScope{
 		variableSymbols: make([]Symbol[SymbolVariable], 0),
-		functionSymbols: make([]Symbol[SymbolFunction], 0),
 	}
 }
 
diff --git a/pkg/lang/compiler/scope/symbol.go b/pkg/lang/compiler/scope/symbol.go
index df91899..3b50108 100644
--- a/pkg/lang/compiler/scope/symbol.go
+++ b/pkg/lang/compiler/scope/symbol.go
@@ -1,7 +1,5 @@
 package scope
 
-import "jinx/pkg/lang/vm/code"
-
 type SymbolID struct {
 	symbolKind   SymbolKind
 	scopeID      ScopeID
@@ -15,16 +13,14 @@ func (id SymbolID) SymbolKind() SymbolKind {
 type SymbolKind int
 
 const (
+	// A variable symbol is bound to a local on the stack.
 	SymbolKindVariable SymbolKind = iota
-	SymbolKindFunction
 )
 
 func (s SymbolKind) String() string {
 	switch s {
 	case SymbolKindVariable:
 		return "variable"
-	case SymbolKindFunction:
-		return "function"
 	default:
 		panic("unknown symbol kind")
 	}
@@ -40,7 +36,7 @@ func (s Symbol[D]) Data() D {
 }
 
 type SymbolData interface {
-	SymbolVariable | SymbolFunction
+	SymbolVariable
 }
 
 type SymbolVariable struct {
@@ -50,16 +46,3 @@ type SymbolVariable struct {
 func (sv SymbolVariable) LocalIndex() int {
 	return sv.localIndex
 }
-
-type SymbolFunction struct {
-	marker code.Marker
-	args   uint
-}
-
-func (sf SymbolFunction) Marker() code.Marker {
-	return sf.marker
-}
-
-func (sf SymbolFunction) Args() uint {
-	return sf.args
-}