Compact definition formats

This commit is contained in:
Ian Gulliver
2021-11-20 20:14:35 -10:00
parent 68ae25192e
commit 24db692859
5 changed files with 47 additions and 66 deletions

View File

@@ -3,19 +3,19 @@ package grow
import "github.com/firestuff/subcoding/vm"
type Sample struct {
GlobalMemoryInputs map[uint64]uint64 `yaml:"global_memory_inputs"`
GlobalMemoryOutputs map[uint64]uint64 `yaml:"global_memory_outputs"`
In []uint64 `yaml:"in,flow"`
Out []uint64 `yaml:"out,flow"`
}
func (s *Sample) SetInputs(state *vm.State) {
for i, val := range s.GlobalMemoryInputs {
state.GlobalMemory().WriteUnsigned(i, val)
for i, val := range s.In {
state.GlobalMemory().WriteUnsigned(uint64(i), val)
}
}
func (s *Sample) OutputsMatch(state *vm.State) bool {
for i, val := range s.GlobalMemoryOutputs {
if state.GlobalMemory().MustReadUnsigned(i) != val {
for i, val := range s.Out {
if state.GlobalMemory().MustReadUnsigned(uint64(i)) != val {
return false
}
}