diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-02-18 13:49:48 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-02-19 21:48:20 +0100 |
| commit | 85d1218f4108e0fe793f63e57e2edadd5da5764f (patch) | |
| tree | 2b8cbd8c476cd0f21d1add6bc74d0ca5bb9dec46 /prog/size.go | |
| parent | 2be2288ee256f3b84a7de15b82894097a08fd939 (diff) | |
prog: rework foreachArg
Make Foreach* callback accept the arg and a context struct
that can contain lots of aux info.
This (1) removes lots of unuser base/parent args,
(2) provides foundation for stopping recursion,
(3) allows to merge foreachSubargOffset.
Diffstat (limited to 'prog/size.go')
| -rw-r--r-- | prog/size.go | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/prog/size.go b/prog/size.go index 67f7ef754..9f2258c82 100644 --- a/prog/size.go +++ b/prog/size.go @@ -94,19 +94,23 @@ func (target *Target) assignSizes(args []Arg, parentsMap map[Arg]Arg) { func (target *Target) assignSizesArray(args []Arg) { parentsMap := make(map[Arg]Arg) - foreachArgArray(&args, nil, func(arg, base Arg, _ *[]Arg) { - if _, ok := arg.Type().(*StructType); ok { - for _, field := range arg.(*GroupArg).Inner { - parentsMap[InnerArg(field)] = arg + for _, arg := range args { + ForeachSubArg(arg, func(arg Arg, _ *ArgCtx) { + if _, ok := arg.Type().(*StructType); ok { + for _, field := range arg.(*GroupArg).Inner { + parentsMap[InnerArg(field)] = arg + } } - } - }) + }) + } target.assignSizes(args, parentsMap) - foreachArgArray(&args, nil, func(arg, base Arg, _ *[]Arg) { - if _, ok := arg.Type().(*StructType); ok { - target.assignSizes(arg.(*GroupArg).Inner, parentsMap) - } - }) + for _, arg := range args { + ForeachSubArg(arg, func(arg Arg, _ *ArgCtx) { + if _, ok := arg.Type().(*StructType); ok { + target.assignSizes(arg.(*GroupArg).Inner, parentsMap) + } + }) + } } func (target *Target) assignSizesCall(c *Call) { |
