Simplified compiler package
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
package compiler
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/core"
|
||||
"git.akyoto.dev/cli/q/src/errors"
|
||||
"git.akyoto.dev/cli/q/src/fs"
|
||||
@ -16,7 +14,7 @@ func Compile(files <-chan *fs.File, functions <-chan *core.Function, structs <-c
|
||||
allFunctions := map[string]*core.Function{}
|
||||
allStructs := map[string]*types.Struct{}
|
||||
|
||||
for functions != nil || files != nil || errs != nil {
|
||||
for functions != nil || structs != nil || files != nil || errs != nil {
|
||||
select {
|
||||
case function, ok := <-functions:
|
||||
if !ok {
|
||||
@ -102,23 +100,3 @@ func Compile(files <-chan *fs.File, functions <-chan *core.Function, structs <-c
|
||||
result.finalize()
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CompileFunctions starts a goroutine for each function compilation and waits for completion.
|
||||
func CompileFunctions(functions map[string]*core.Function) {
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
for _, function := range functions {
|
||||
if function.IsExtern() {
|
||||
continue
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
function.Compile()
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
Reference in New Issue
Block a user