From 8974b8b0aac9d5c1a4b7f914c22af391c7e38ab8 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 2 Jun 2024 15:20:05 +0200 Subject: [PATCH] Improved documentation --- README.md | 12 +++++++++--- go.mod | 2 +- src/compiler/Scan.go | 2 +- src/errors/InvalidDirectory.go | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 72a1f8b..2b6cfb4 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/go.mod b/go.mod index e78e48b..b286207 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/src/compiler/Scan.go b/src/compiler/Scan.go index 1c52ba4..deef107 100644 --- a/src/compiler/Scan.go +++ b/src/compiler/Scan.go @@ -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() { diff --git a/src/errors/InvalidDirectory.go b/src/errors/InvalidDirectory.go index 161cdf0..90beadd 100644 --- a/src/errors/InvalidDirectory.go +++ b/src/errors/InvalidDirectory.go @@ -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"