aboutsummaryrefslogtreecommitdiffstats
path: root/prog/analysis.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-10-29 23:42:36 +0200
committerDmitry Vyukov <dvyukov@google.com>2016-11-11 14:31:55 -0800
commitb40d502736438fcd899cda22e92fd0a159eecf4f (patch)
tree7c8998ec46220f2e42f34df34d28306c7661bc99 /prog/analysis.go
parent1838728cc121fd6c4c6f52d9c837f1e32e0c86f4 (diff)
prog: remote Type argument from Arg.Size/Value
They are not necessary since we now always have types attached to args. Also remove sys.Type.InnerType as it is not necessary now as well.
Diffstat (limited to 'prog/analysis.go')
-rw-r--r--prog/analysis.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/prog/analysis.go b/prog/analysis.go
index f5219895d..98973d4c7 100644
--- a/prog/analysis.go
+++ b/prog/analysis.go
@@ -160,12 +160,12 @@ func generateSize(arg *Arg, lenType *sys.LenType) *Arg {
return pageSizeArg(lenType, arg.AddrPagesNum, 0)
case *sys.ArrayType:
if lenType.ByteSize {
- return constArg(lenType, arg.Size(arg.Type))
+ return constArg(lenType, arg.Size())
} else {
return constArg(lenType, uintptr(len(arg.Inner)))
}
default:
- return constArg(lenType, arg.Size(arg.Type))
+ return constArg(lenType, arg.Size())
}
}
@@ -174,22 +174,19 @@ func assignSizes(args []*Arg) {
argsMap := make(map[string]*Arg)
var parentSize uintptr
for _, arg := range args {
- parentSize += arg.Size(arg.Type)
+ parentSize += arg.Size()
if sys.IsPad(arg.Type) {
continue
}
- argsMap[arg.Type.Name()] = arg.InnerArg(arg.Type)
+ argsMap[arg.Type.Name()] = arg
}
// Fill in size arguments.
for _, arg := range args {
- if typ, ok := arg.Type.InnerType().(*sys.LenType); ok {
- arg = arg.InnerArg(arg.Type)
- if arg == nil {
- // Pointer to optional len field, no need to fill in value.
- continue
- }
-
+ if arg = arg.InnerArg(); arg == nil {
+ continue // Pointer to optional len field, no need to fill in value.
+ }
+ if typ, ok := arg.Type.(*sys.LenType); ok {
if typ.Buf == "parent" {
arg.Val = parentSize
continue
@@ -201,7 +198,7 @@ func assignSizes(args []*Arg) {
typ.Name(), typ.Buf, argsMap))
}
- *arg = *generateSize(buf, typ)
+ *arg = *generateSize(buf.InnerArg(), typ)
}
}
}