aboutsummaryrefslogtreecommitdiffstats
path: root/prog/rand.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-01 19:24:21 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-08-02 16:57:31 +0200
commitc8643744fe4be55e516f7ba494777016abc1055e (patch)
treec2fe83e2b312132562189b59997b4fbdb1699772 /prog/rand.go
parente002278dfb76b3d01fc860997f08ad71c022d1c7 (diff)
prog: refactor defaultArg/isDefaultArg
Refactor from single-big-switch to type methods. Update #538
Diffstat (limited to 'prog/rand.go')
-rw-r--r--prog/rand.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/prog/rand.go b/prog/rand.go
index 721bbed00..7bded23c6 100644
--- a/prog/rand.go
+++ b/prog/rand.go
@@ -279,7 +279,7 @@ func (r *randGen) createResource(s *state, res *ResourceType) (arg Arg, calls []
metas = append(metas, meta)
}
if len(metas) == 0 {
- return MakeResultArg(res, nil, res.Default()), nil
+ return res.makeDefaultArg(), nil
}
// Now we have a set of candidate calls that can create the necessary resource.
@@ -490,7 +490,7 @@ func (r *randGen) generateArgImpl(s *state, typ Type, ignoreSpecial bool) (arg A
switch typ.(type) {
case *IntType, *FlagsType, *ConstType, *ProcType,
*VmaType, *ResourceType:
- return r.target.defaultArg(typ), nil
+ return typ.makeDefaultArg(), nil
}
}
@@ -499,7 +499,7 @@ func (r *randGen) generateArgImpl(s *state, typ Type, ignoreSpecial bool) (arg A
v := res.Desc.Values[r.Intn(len(res.Desc.Values))]
return MakeResultArg(typ, nil, v), nil
}
- return r.target.defaultArg(typ), nil
+ return typ.makeDefaultArg(), nil
}
// Allow infinite recursion for optional pointers.