diff options
Diffstat (limited to 'prog')
| -rw-r--r-- | prog/export_test.go | 18 | ||||
| -rw-r--r-- | prog/prog.go | 4 | ||||
| -rw-r--r-- | prog/target.go | 11 |
3 files changed, 15 insertions, 18 deletions
diff --git a/prog/export_test.go b/prog/export_test.go index e6c384c7a..f3fc16997 100644 --- a/prog/export_test.go +++ b/prog/export_test.go @@ -17,25 +17,9 @@ func init() { var ( CalcChecksumsCall = calcChecksumsCall - //AssignSizesCall = assignSizesCall - //DefaultArg = defaultArg - InitTest = initTest + InitTest = initTest ) -/* -func PtrSize() uint64 { - return ptrSize -} - -func DataOffset() uint64 { - return dataOffset -} - -func PageSize() uint64 { - return pageSize -} -*/ - func initTest(t *testing.T) (*Target, rand.Source, int) { t.Parallel() iters := 10000 diff --git a/prog/prog.go b/prog/prog.go index f8335b240..20711266c 100644 --- a/prog/prog.go +++ b/prog/prog.go @@ -343,8 +343,10 @@ func (p *Prog) replaceArg(c *Call, arg, arg1 Arg, calls []*Call) { *a = *arg1.(*PointerArg) case *UnionArg: *a = *arg1.(*UnionArg) + case *DataArg: + *a = *arg1.(*DataArg) default: - panic(fmt.Sprintf("replaceArg: bad arg kind %v", arg)) + panic(fmt.Sprintf("replaceArg: bad arg kind %#v", arg)) } p.Target.SanitizeCall(c) } diff --git a/prog/target.go b/prog/target.go index 45a3e9c3d..4563f107d 100644 --- a/prog/target.go +++ b/prog/target.go @@ -5,6 +5,7 @@ package prog import ( "fmt" + "math/rand" "sort" ) @@ -152,6 +153,10 @@ type Gen struct { s *state } +func (g *Gen) Rand() *rand.Rand { + return g.r.Rand +} + func (g *Gen) NOutOf(n, outOf int) bool { return g.r.nOutOf(n, outOf) } @@ -159,3 +164,9 @@ func (g *Gen) NOutOf(n, outOf int) bool { func (g *Gen) Alloc(ptrType Type, data Arg) (Arg, []*Call) { return g.r.addr(g.s, ptrType, data.Size(), data) } + +func (g *Gen) GenerateArg(typ Type, pcalls *[]*Call) Arg { + arg, calls := g.r.generateArg(g.s, typ) + *pcalls = append(*pcalls, calls...) + return arg +} |
