25 lines
555 B
Go
25 lines
555 B
Go
|
|
package main
|
||
|
|
|
||
|
|
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"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Sample) SetInputs(state *vm.State) {
|
||
|
|
for i, val := range s.GlobalMemoryInputs {
|
||
|
|
state.GlobalMemory().WriteUnsigned(i, val)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Sample) OutputsMatch(state *vm.State) bool {
|
||
|
|
for i, val := range s.GlobalMemoryOutputs {
|
||
|
|
if state.GlobalMemory().MustReadUnsigned(i) != val {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return true
|
||
|
|
}
|