prog: add MaxArgs const

Move the const from the compiler.
In preparation for future changes.
This commit is contained in:
Dmitry Vyukov 2020-03-31 13:29:37 +02:00
parent 22968402ee
commit 8950ec3f51
2 changed files with 6 additions and 3 deletions

View File

@ -146,7 +146,6 @@ func (comp *compiler) checkNames() {
} }
func (comp *compiler) checkFields() { func (comp *compiler) checkFields() {
const maxArgs = 9 // executor does not support more
for _, decl := range comp.desc.Nodes { for _, decl := range comp.desc.Nodes {
switch n := decl.(type) { switch n := decl.(type) {
case *ast.Struct: case *ast.Struct:
@ -160,9 +159,9 @@ func (comp *compiler) checkFields() {
case *ast.Call: case *ast.Call:
name := n.Name.Name name := n.Name.Name
comp.checkFieldGroup(n.Args, "argument", "syscall "+name) comp.checkFieldGroup(n.Args, "argument", "syscall "+name)
if len(n.Args) > maxArgs { if len(n.Args) > prog.MaxArgs {
comp.error(n.Pos, "syscall %v has %v arguments, allowed maximum is %v", comp.error(n.Pos, "syscall %v has %v arguments, allowed maximum is %v",
name, len(n.Args), maxArgs) name, len(n.Args), prog.MaxArgs)
} }
} }
} }

View File

@ -21,6 +21,10 @@ type Syscall struct {
outputResources []*ResourceDesc outputResources []*ResourceDesc
} }
// MaxArgs is maximum number of syscall arguments.
// Executor also knows about this value.
const MaxArgs = 9
type Dir int type Dir int
const ( const (