Improved instruction parser

This commit is contained in:
Eduard Urbach 2024-06-15 14:46:44 +02:00
parent a4ecaf0622
commit 78cde0d0bd
Signed by: eduard
GPG key ID: 49226B848C78F6C8
7 changed files with 114 additions and 54 deletions

View file

@ -6,7 +6,6 @@ import (
// Compile compiles all the functions.
func Compile(functions <-chan *Function, errors <-chan error) (map[string]*Function, error) {
wg := sync.WaitGroup{}
allFunctions := map[string]*Function{}
for functions != nil || errors != nil {
@ -25,17 +24,28 @@ func Compile(functions <-chan *Function, errors <-chan error) (map[string]*Funct
continue
}
wg.Add(1)
go func() {
defer wg.Done()
function.Compile()
}()
allFunctions[function.Name] = function
}
}
wg := sync.WaitGroup{}
for _, function := range allFunctions {
wg.Add(1)
go func() {
defer wg.Done()
function.Compile()
}()
}
wg.Wait()
for _, function := range allFunctions {
if function.Error != nil {
return nil, function.Error
}
}
return allFunctions, nil
}