Improved variable lifetime tracking
This commit is contained in:
parent
1510f88165
commit
b8c011d742
17 changed files with 114 additions and 31 deletions
|
@ -1,6 +1,8 @@
|
|||
package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/config"
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
"git.akyoto.dev/cli/q/src/build/fs"
|
||||
|
@ -44,6 +46,10 @@ func (f *Function) CompileTokens(body token.List) error {
|
|||
instruction := body[start:i]
|
||||
|
||||
if config.Verbose {
|
||||
f.Logf("compiling: %s", instruction)
|
||||
}
|
||||
|
||||
if config.Assembler {
|
||||
f.debug = append(f.debug, debug{
|
||||
position: len(f.assembler.Instructions),
|
||||
source: instruction,
|
||||
|
@ -108,6 +114,11 @@ func (f *Function) CompileInstruction(line token.List) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Logf formats a message for verbose output.
|
||||
func (f *Function) Logf(format string, data ...any) {
|
||||
fmt.Printf("[%s @ %d] %s\n", f, len(f.assembler.Instructions), fmt.Sprintf(format, data...))
|
||||
}
|
||||
|
||||
// String returns the function name.
|
||||
func (f *Function) String() string {
|
||||
return f.Name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue