Simplified compiler package

This commit is contained in:
2025-02-12 19:05:40 +01:00
parent b7b4dad1a5
commit 0dffb79364
11 changed files with 234 additions and 201 deletions

@ -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()
}