This commit is contained in:
parent
2b703e9af2
commit
70c2da4a4d
40 changed files with 821 additions and 117 deletions
|
@ -1,9 +1,12 @@
|
|||
package scanner
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"git.urbach.dev/cli/q/src/build"
|
||||
"git.urbach.dev/cli/q/src/core"
|
||||
"git.urbach.dev/cli/q/src/fs"
|
||||
"git.urbach.dev/cli/q/src/global"
|
||||
)
|
||||
|
||||
// Scan scans all the files included in the build.
|
||||
|
@ -16,6 +19,7 @@ func Scan(b *build.Build) (*core.Environment, error) {
|
|||
}
|
||||
|
||||
go func() {
|
||||
s.queueDirectory(filepath.Join(global.Library, "core"), "core")
|
||||
s.queue(b.Files...)
|
||||
s.group.Wait()
|
||||
close(s.functions)
|
||||
|
@ -36,6 +40,7 @@ func Scan(b *build.Build) (*core.Environment, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
f.All = all
|
||||
all.Functions[f.UniqueName] = f
|
||||
|
||||
case file, ok := <-s.files:
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package scanner
|
||||
|
||||
import (
|
||||
"git.urbach.dev/cli/q/src/arm"
|
||||
"git.urbach.dev/cli/q/src/build"
|
||||
"git.urbach.dev/cli/q/src/errors"
|
||||
"git.urbach.dev/cli/q/src/fs"
|
||||
"git.urbach.dev/cli/q/src/token"
|
||||
"git.urbach.dev/cli/q/src/x86"
|
||||
)
|
||||
|
||||
// scanFunction scans a function.
|
||||
|
@ -67,6 +70,13 @@ func (s *scanner) scanFunction(file *fs.File, tokens token.List, i int) (int, er
|
|||
return i, errors.New(ExpectedFunctionDefinition, file, tokens[i].Position)
|
||||
}
|
||||
|
||||
switch s.build.Arch {
|
||||
case build.ARM:
|
||||
function.CPU = &arm.CPU
|
||||
case build.X86:
|
||||
function.CPU = &x86.CPU
|
||||
}
|
||||
|
||||
function.Body = tokens[bodyStart:i]
|
||||
s.functions <- function
|
||||
return i, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue