Compact definition formats
This commit is contained in:
@@ -2,15 +2,11 @@ global_memory_size: 1
|
|||||||
function_memory_size: 1
|
function_memory_size: 1
|
||||||
instruction_limit: 2
|
instruction_limit: 2
|
||||||
samples:
|
samples:
|
||||||
- global_memory_inputs:
|
- in: [0]
|
||||||
0: 0
|
out: [1]
|
||||||
global_memory_outputs:
|
|
||||||
0: 1
|
- in: [1]
|
||||||
- global_memory_inputs:
|
out: [2]
|
||||||
0: 1
|
|
||||||
global_memory_outputs:
|
- in: [100]
|
||||||
0: 2
|
out: [101]
|
||||||
- global_memory_inputs:
|
|
||||||
0: 100
|
|
||||||
global_memory_outputs:
|
|
||||||
0: 101
|
|
||||||
|
|||||||
@@ -2,19 +2,14 @@ global_memory_size: 1
|
|||||||
function_memory_size: 1
|
function_memory_size: 1
|
||||||
instruction_limit: 2
|
instruction_limit: 2
|
||||||
samples:
|
samples:
|
||||||
- global_memory_inputs:
|
- in: [0]
|
||||||
0: 0
|
out: [0]
|
||||||
global_memory_outputs:
|
|
||||||
0: 0
|
- in: [1]
|
||||||
- global_memory_inputs:
|
out: [5]
|
||||||
0: 1
|
|
||||||
global_memory_outputs:
|
- in: [2]
|
||||||
0: 5
|
out: [10]
|
||||||
- global_memory_inputs:
|
|
||||||
0: 2
|
- in: [100]
|
||||||
global_memory_outputs:
|
out: [500]
|
||||||
0: 10
|
|
||||||
- global_memory_inputs:
|
|
||||||
0: 100
|
|
||||||
global_memory_outputs:
|
|
||||||
0: 500
|
|
||||||
|
|||||||
@@ -2,19 +2,14 @@ global_memory_size: 1
|
|||||||
function_memory_size: 1
|
function_memory_size: 1
|
||||||
instruction_limit: 2
|
instruction_limit: 2
|
||||||
samples:
|
samples:
|
||||||
- global_memory_inputs:
|
- in: [0]
|
||||||
0: 0
|
out: [0]
|
||||||
global_memory_outputs:
|
|
||||||
0: 0
|
- in: [1]
|
||||||
- global_memory_inputs:
|
out: [4]
|
||||||
0: 1
|
|
||||||
global_memory_outputs:
|
- in: [2]
|
||||||
0: 4
|
out: [8]
|
||||||
- global_memory_inputs:
|
|
||||||
0: 2
|
- in: [100]
|
||||||
global_memory_outputs:
|
out: [400]
|
||||||
0: 8
|
|
||||||
- global_memory_inputs:
|
|
||||||
0: 100
|
|
||||||
global_memory_outputs:
|
|
||||||
0: 400
|
|
||||||
|
|||||||
@@ -2,19 +2,14 @@ global_memory_size: 1
|
|||||||
function_memory_size: 1
|
function_memory_size: 1
|
||||||
instruction_limit: 2
|
instruction_limit: 2
|
||||||
samples:
|
samples:
|
||||||
- global_memory_inputs:
|
- in: [0]
|
||||||
0: 0
|
out: [0]
|
||||||
global_memory_outputs:
|
|
||||||
0: 0
|
- in: [1]
|
||||||
- global_memory_inputs:
|
out: [2]
|
||||||
0: 1
|
|
||||||
global_memory_outputs:
|
- in: [2]
|
||||||
0: 2
|
out: [4]
|
||||||
- global_memory_inputs:
|
|
||||||
0: 2
|
- in: [100]
|
||||||
global_memory_outputs:
|
out: [200]
|
||||||
0: 4
|
|
||||||
- global_memory_inputs:
|
|
||||||
0: 100
|
|
||||||
global_memory_outputs:
|
|
||||||
0: 200
|
|
||||||
|
|||||||
@@ -3,19 +3,19 @@ package grow
|
|||||||
import "github.com/firestuff/subcoding/vm"
|
import "github.com/firestuff/subcoding/vm"
|
||||||
|
|
||||||
type Sample struct {
|
type Sample struct {
|
||||||
GlobalMemoryInputs map[uint64]uint64 `yaml:"global_memory_inputs"`
|
In []uint64 `yaml:"in,flow"`
|
||||||
GlobalMemoryOutputs map[uint64]uint64 `yaml:"global_memory_outputs"`
|
Out []uint64 `yaml:"out,flow"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sample) SetInputs(state *vm.State) {
|
func (s *Sample) SetInputs(state *vm.State) {
|
||||||
for i, val := range s.GlobalMemoryInputs {
|
for i, val := range s.In {
|
||||||
state.GlobalMemory().WriteUnsigned(i, val)
|
state.GlobalMemory().WriteUnsigned(uint64(i), val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sample) OutputsMatch(state *vm.State) bool {
|
func (s *Sample) OutputsMatch(state *vm.State) bool {
|
||||||
for i, val := range s.GlobalMemoryOutputs {
|
for i, val := range s.Out {
|
||||||
if state.GlobalMemory().MustReadUnsigned(i) != val {
|
if state.GlobalMemory().MustReadUnsigned(uint64(i)) != val {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user