Improved documentation

This commit is contained in:
Eduard Urbach 2024-06-02 15:20:05 +02:00
parent a7afd680da
commit 8974b8b0aa
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
4 changed files with 12 additions and 5 deletions

View File

@ -56,9 +56,15 @@ q build examples/hello --dry
The `Build` type defines all the information needed to start building an executable file.
The name of the executable will be equal to the name of the build directory.
`Run` starts the build which will scan all files in the build directory.
The functions found in the scan will be translated to generic assembler instructions.
All the functions that are required to run the program will be added to final assembler.
`Run` starts the build which will scan all `.q` source files in the build directory.
Every source file is scanned in its own goroutine for performance reasons.
Parallelization here is possible because the order of code in a directory is not significant.
The main function is meanwhile waiting for new function objects to arrive from the scanners.
Once a function has arrived, it will create another goroutine for the function compilation.
The function will then be translated to generic assembler instructions.
All the functions that are required to run the program will be added to the final assembler.
The final assembler resolves label addresses, optimizes the performance and generates the specific x86-64 machine code from the generic instruction set.
The `Run` method is currently not fully implemented.

2
go.mod
View File

@ -1,5 +1,5 @@
module git.akyoto.dev/cli/q
go 1.21
go 1.22
require git.akyoto.dev/go/assert v0.1.3

View File

@ -12,7 +12,7 @@ import (
// Scan scans the directory.
func Scan(path string) (<-chan *Function, <-chan error) {
functions := make(chan *Function, 16)
functions := make(chan *Function)
errors := make(chan error)
go func() {

View File

@ -7,6 +7,7 @@ type InvalidDirectory struct {
Path string
}
// Error implements the text representation.
func (err *InvalidDirectory) Error() string {
if err.Path == "" {
return "Invalid directory"