Start of code growth
This commit is contained in:
7
grow/add_one.yaml
Normal file
7
grow/add_one.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
global_memory_size: 1
|
||||||
|
function_memory_size: 1
|
||||||
|
samples:
|
||||||
|
- global_memory_inputs:
|
||||||
|
0: 0
|
||||||
|
global_memory_outputs:
|
||||||
|
0: 1
|
||||||
30
grow/definition.go
Normal file
30
grow/definition.go
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
import "gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
type Definition struct {
|
||||||
|
GlobalMemorySize uint64 `yaml:"global_memory_size"`
|
||||||
|
FunctionMemorySize uint64 `yaml:"function_memory_size"`
|
||||||
|
Samples []*Sample `yaml:"samples"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Sample struct {
|
||||||
|
GlobalMemoryInputs map[uint64]uint64 `yaml:"global_memory_inputs"`
|
||||||
|
GlobalMemoryOutputs map[uint64]uint64 `yaml:"global_memory_outputs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadDefinition(r io.Reader) (*Definition, error) {
|
||||||
|
dec := yaml.NewDecoder(r)
|
||||||
|
dec.SetStrict(true)
|
||||||
|
|
||||||
|
def := &Definition{}
|
||||||
|
|
||||||
|
err := dec.Decode(def)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return def, nil
|
||||||
|
}
|
||||||
26
grow/main.go
Normal file
26
grow/main.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "flag"
|
||||||
|
import "log"
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
defPath := flag.String("def-path", "", "path to definition YAML file")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if *defPath == "" {
|
||||||
|
log.Fatal("Please specify --def-path")
|
||||||
|
}
|
||||||
|
|
||||||
|
defFile, err := os.Open(*defPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
def, err := loadDefinition(defFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("%+v", def)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user