refactor: move ConstructPatterns into compiler package

ConstructPatterns was never used except during compilation, so it
makes sense to have it closer where it is used. We could consider
making it even private function, as the pattern table construction
is quite specific to how compiler compiles and probably not that
reusable elsewhere.
This commit is contained in:
5684185+vsariola@users.noreply.github.com 2023-10-19 12:38:18 +03:00
parent e010b2da9d
commit e28891abd5
3 changed files with 7 additions and 7 deletions

View File

@ -91,7 +91,7 @@ func (com *Compiler) Song(song *sointu.Song) (map[string]string, error) {
if err != nil {
return nil, fmt.Errorf(`could not encode patch: %v`, err)
}
patterns, sequences, err := vm.ConstructPatterns(song)
patterns, sequences, err := ConstructPatterns(song)
if err != nil {
return nil, fmt.Errorf(`could not encode song: %v`, err)
}

View File

@ -1,4 +1,4 @@
package vm
package compiler
import (
"errors"

View File

@ -1,11 +1,11 @@
package vm_test
package compiler_test
import (
"reflect"
"testing"
"github.com/vsariola/sointu"
"github.com/vsariola/sointu/vm"
"github.com/vsariola/sointu/vm/compiler"
)
func TestPatternReusing(t *testing.T) {
@ -22,7 +22,7 @@ func TestPatternReusing(t *testing.T) {
}},
},
}
patterns, sequences, err := vm.ConstructPatterns(&song)
patterns, sequences, err := compiler.ConstructPatterns(&song)
if err != nil {
t.Fatalf("erorr constructing patterns: %v", err)
}
@ -49,7 +49,7 @@ func TestUnnecessaryHolds(t *testing.T) {
Order: []int{0, 1},
}}},
}
patterns, sequences, err := vm.ConstructPatterns(&song)
patterns, sequences, err := compiler.ConstructPatterns(&song)
if err != nil {
t.Fatalf("erorr constructing patterns: %v", err)
}
@ -77,7 +77,7 @@ func TestDontCares(t *testing.T) {
}},
},
}
patterns, sequences, err := vm.ConstructPatterns(&song)
patterns, sequences, err := compiler.ConstructPatterns(&song)
if err != nil {
t.Fatalf("erorr constructing patterns: %v", err)
}