aboutsummaryrefslogtreecommitdiffstats
path: root/prog/resources.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-05-03 11:29:12 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-05-03 12:55:42 +0200
commit58ae5e18624eaaac79cab00e63d6f32c9bd64ee0 (patch)
tree00515dd9b2e461102e898930df00bc80400bf996 /prog/resources.go
parent5457883a514281287bbd81364c4e26e25828563d (diff)
prog: remove StructDesc
Remove StructDesc, KeyedStruct, StructKey and all associated logic/complexity in prog and pkg/compiler. We can now handle recursion more generically with the Ref type, and Dir/FieldName are not a part of the type anymore. This makes StructType/UnionType simpler and more natural. Reduces size of sys/linux/gen/amd64.go from 5201321 to 4180861 (-20%). Update #1580
Diffstat (limited to 'prog/resources.go')
-rw-r--r--prog/resources.go20
1 files changed, 9 insertions, 11 deletions
diff --git a/prog/resources.go b/prog/resources.go
index b7bcecf95..311eb72dd 100644
--- a/prog/resources.go
+++ b/prog/resources.go
@@ -45,16 +45,14 @@ func (target *Target) calcResourceCtors(res *ResourceDesc, precise bool) []*Sysc
func (target *Target) populateResourceCtors() {
// Find resources that are created by each call.
callsResources := make([][]*ResourceDesc, len(target.Syscalls))
- for call, meta := range target.Syscalls {
- foreachType(meta, func(typ Type, ctx typeCtx) {
- switch typ1 := typ.(type) {
- case *ResourceType:
- if ctx.Dir != DirIn {
- callsResources[call] = append(callsResources[call], typ1.Desc)
- }
+ ForeachType(target.Syscalls, func(typ Type, ctx TypeCtx) {
+ switch typ1 := typ.(type) {
+ case *ResourceType:
+ if ctx.Dir != DirIn {
+ callsResources[ctx.Meta.ID] = append(callsResources[ctx.Meta.ID], typ1.Desc)
}
- })
- }
+ }
+ })
// Populate resource ctors accounting for resource compatibility.
for _, res := range target.Resources {
@@ -126,7 +124,7 @@ func isCompatibleResourceImpl(dst, src []string, precise bool) bool {
func (target *Target) getInputResources(c *Syscall) []*ResourceDesc {
var resources []*ResourceDesc
- foreachType(c, func(typ Type, ctx typeCtx) {
+ ForeachCallType(c, func(typ Type, ctx TypeCtx) {
if ctx.Dir == DirOut {
return
}
@@ -146,7 +144,7 @@ func (target *Target) getInputResources(c *Syscall) []*ResourceDesc {
func (target *Target) getOutputResources(c *Syscall) []*ResourceDesc {
var resources []*ResourceDesc
- foreachType(c, func(typ Type, ctx typeCtx) {
+ ForeachCallType(c, func(typ Type, ctx TypeCtx) {
switch typ1 := typ.(type) {
case *ResourceType:
if ctx.Dir != DirIn {