Make memory sizes parameters
This commit is contained in:
14
asm/parse.go
14
asm/parse.go
@@ -1,9 +1,13 @@
|
||||
package asm
|
||||
|
||||
import "fmt"
|
||||
|
||||
import "gopkg.in/yaml.v2"
|
||||
|
||||
type program struct {
|
||||
Functions []function `yaml:"functions"`
|
||||
GlobalMemorySize uint64 `yaml:"global_memory_size"`
|
||||
FunctionMemorySize uint64 `yaml:"function_memory_size"`
|
||||
Functions []function `yaml:"functions"`
|
||||
}
|
||||
|
||||
type function []instruction
|
||||
@@ -18,5 +22,13 @@ func parse(src []byte) (*program, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if prog.GlobalMemorySize == 0 {
|
||||
return nil, fmt.Errorf("global_memory_size must be set and non-zero")
|
||||
}
|
||||
|
||||
if prog.FunctionMemorySize == 0 {
|
||||
return nil, fmt.Errorf("function_memory_size must be set and non-zero")
|
||||
}
|
||||
|
||||
return prog, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user