Improved code generation

This commit is contained in:
2024-07-09 17:00:04 +02:00
parent 1204591cdc
commit 4386392844
23 changed files with 201 additions and 95 deletions

View File

@ -0,0 +1,12 @@
main() {
syscall(60, f(1, 2, 3))
}
f(x, y, z) {
w := g(4, 5, 6)
return x + y + z + w
}
g(x, y, z) {
return x + y + z
}

View File

@ -21,14 +21,15 @@ var programs = []struct {
{"square-sum", "", 25},
{"chained-calls", "", 9},
{"nested-calls", "", 4},
{"overwrite", "", 3},
{"param", "", 3},
{"param-multi", "", 21},
{"reuse", "", 3},
{"return", "", 6},
{"reassign", "", 2},
{"branch", "", 0},
{"branch-and", "", 0},
{"branch-or", "", 0},
{"branch-combined", "", 0},
{"branch-both", "", 0},
}
func TestPrograms(t *testing.T) {
@ -42,7 +43,7 @@ func TestPrograms(t *testing.T) {
func BenchmarkPrograms(b *testing.B) {
for _, test := range programs {
b.Run(test.Name, func(b *testing.B) {
compiler := build.New(filepath.Join("programs", test.Name))
compiler := build.New(filepath.Join("programs", test.Name+".q"))
for i := 0; i < b.N; i++ {
_, err := compiler.Run()