about summary refs log tree commit diff
path: root/pkg/lang/compiler/scope/scope_chain.go
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-07-26 02:37:38 +0200
committerMel <einebeere@gmail.com>2022-07-26 02:37:38 +0200
commit41490ae52e3b1ff20980c5e0837d257043b3ca92 (patch)
tree9d2574dbcdc6f82a9b89cfcf64f7e25634484a5a /pkg/lang/compiler/scope/scope_chain.go
parentb6fa4bc82398b09307f2e6b75e27422d1d1ecb33 (diff)
downloadjinx-41490ae52e3b1ff20980c5e0837d257043b3ca92.tar.zst
jinx-41490ae52e3b1ff20980c5e0837d257043b3ca92.zip
Store functions in locals and remove hoisting
Diffstat (limited to 'pkg/lang/compiler/scope/scope_chain.go')
-rw-r--r--pkg/lang/compiler/scope/scope_chain.go37
1 files changed, 0 insertions, 37 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]
-}