Updated Go version
This commit is contained in:
parent
d589b02570
commit
88b3f468d1
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module git.akyoto.dev/cli/q
|
module git.akyoto.dev/cli/q
|
||||||
|
|
||||||
go 1.23
|
go 1.24
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.akyoto.dev/go/assert v0.1.3
|
git.akyoto.dev/go/assert v0.1.3
|
||||||
|
@ -16,7 +16,7 @@ func Finalize(a asm.Assembler, dlls dll.List) ([]byte, []byte) {
|
|||||||
|
|
||||||
c := compiler{
|
c := compiler{
|
||||||
code: make([]byte, 0, len(a.Instructions)*8),
|
code: make([]byte, 0, len(a.Instructions)*8),
|
||||||
codeLabels: map[string]Address{},
|
codeLabels: make(map[string]Address, 32),
|
||||||
codeStart: codeOffset(),
|
codeStart: codeOffset(),
|
||||||
data: data,
|
data: data,
|
||||||
dataLabels: dataLabels,
|
dataLabels: dataLabels,
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
func Compile(files <-chan *fs.File, functions <-chan *core.Function, structs <-chan *types.Struct, errs <-chan error) (Result, error) {
|
func Compile(files <-chan *fs.File, functions <-chan *core.Function, structs <-chan *types.Struct, errs <-chan error) (Result, error) {
|
||||||
result := Result{}
|
result := Result{}
|
||||||
allFiles := make([]*fs.File, 0, 8)
|
allFiles := make([]*fs.File, 0, 8)
|
||||||
allFunctions := map[string]*core.Function{}
|
allFunctions := make(map[string]*core.Function, 32)
|
||||||
allStructs := map[string]*types.Struct{}
|
allStructs := make(map[string]*types.Struct, 8)
|
||||||
|
|
||||||
for functions != nil || structs != nil || files != nil || errs != nil {
|
for functions != nil || structs != nil || files != nil || errs != nil {
|
||||||
select {
|
select {
|
||||||
|
@ -4,7 +4,7 @@ import "git.akyoto.dev/cli/q/src/core"
|
|||||||
|
|
||||||
// PrintInstructions prints out the generated instructions.
|
// PrintInstructions prints out the generated instructions.
|
||||||
func (r *Result) PrintInstructions() {
|
func (r *Result) PrintInstructions() {
|
||||||
r.eachFunction(r.Main, map[*core.Function]bool{}, func(f *core.Function) {
|
r.eachFunction(r.Main, make(map[*core.Function]bool, len(r.Functions)), func(f *core.Function) {
|
||||||
f.PrintInstructions()
|
f.PrintInstructions()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ func BenchmarkExpression(b *testing.B) {
|
|||||||
src := []byte("(1+2-3*4)+(5*6-7+8)")
|
src := []byte("(1+2-3*4)+(5*6-7+8)")
|
||||||
tokens := token.Tokenize(src)
|
tokens := token.Tokenize(src)
|
||||||
|
|
||||||
for range b.N {
|
for b.Loop() {
|
||||||
expression.Parse(tokens)
|
expression.Parse(tokens)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ func (s *Scanner) scanImport(file *fs.File, tokens token.List, i int) (int, erro
|
|||||||
packageName := tokens[i].Text(file.Bytes)
|
packageName := tokens[i].Text(file.Bytes)
|
||||||
|
|
||||||
if file.Imports == nil {
|
if file.Imports == nil {
|
||||||
file.Imports = map[string]*fs.Import{}
|
file.Imports = make(map[string]*fs.Import, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
fullPath := filepath.Join(config.Library, packageName)
|
fullPath := filepath.Join(config.Library, packageName)
|
||||||
|
@ -17,7 +17,7 @@ func bench(n int) func(b *testing.B) {
|
|||||||
return func(b *testing.B) {
|
return func(b *testing.B) {
|
||||||
input := bytes.Repeat(line, n)
|
input := bytes.Repeat(line, n)
|
||||||
|
|
||||||
for range b.N {
|
for b.Loop() {
|
||||||
token.Tokenize(input)
|
token.Tokenize(input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func BenchmarkExamples(b *testing.B) {
|
|||||||
b.Run(test.Name, func(b *testing.B) {
|
b.Run(test.Name, func(b *testing.B) {
|
||||||
compiler := build.New(filepath.Join("..", "examples", test.Name))
|
compiler := build.New(filepath.Join("..", "examples", test.Name))
|
||||||
|
|
||||||
for range b.N {
|
for b.Loop() {
|
||||||
_, err := compiler.Run()
|
_, err := compiler.Run()
|
||||||
assert.Nil(b, err)
|
assert.Nil(b, err)
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ func BenchmarkPrograms(b *testing.B) {
|
|||||||
b.Run(test.Name, func(b *testing.B) {
|
b.Run(test.Name, func(b *testing.B) {
|
||||||
compiler := build.New(filepath.Join("programs", test.Name+".q"))
|
compiler := build.New(filepath.Join("programs", test.Name+".q"))
|
||||||
|
|
||||||
for range b.N {
|
for b.Loop() {
|
||||||
_, err := compiler.Run()
|
_, err := compiler.Run()
|
||||||
assert.Nil(b, err)
|
assert.Nil(b, err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user