Improved instruction parser
This commit is contained in:
parent
a4ecaf0622
commit
78cde0d0bd
7 changed files with 114 additions and 54 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue