dawn_node: Allow Include and Mixins to come out of order in idlgen
Bug: dawn:1123 Change-Id: I120e6234e194f46954e3c7e75a3a8cc667df9611 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/75900 Auto-Submit: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
454c64429b
commit
4fe5d65446
|
@ -193,6 +193,7 @@ func simplify(in *ast.File) (*ast.File, declarations) {
|
|||
{
|
||||
interfaces := map[string]*ast.Interface{}
|
||||
mixins := map[string]*ast.Mixin{}
|
||||
includes := []*ast.Includes{}
|
||||
for _, d := range in.Declarations {
|
||||
switch d := d.(type) {
|
||||
case *ast.Interface:
|
||||
|
@ -209,14 +210,23 @@ func simplify(in *ast.File) (*ast.File, declarations) {
|
|||
mixins[d.Name] = d
|
||||
s.declarations[d.Name] = d
|
||||
case *ast.Includes:
|
||||
// Merge mixin into interface
|
||||
i, ok := interfaces[d.Name]
|
||||
if !ok {
|
||||
panic(fmt.Errorf("%v includes %v, but %v is not an interface", d.Name, d.Source, d.Name))
|
||||
includes = append(includes, d)
|
||||
default:
|
||||
if name := nameOf(d); name != "" {
|
||||
s.declarations[nameOf(d)] = d
|
||||
}
|
||||
m, ok := mixins[d.Source]
|
||||
}
|
||||
}
|
||||
|
||||
// Merge mixin into interface
|
||||
for _, include := range includes {
|
||||
i, ok := interfaces[include.Name]
|
||||
if !ok {
|
||||
panic(fmt.Errorf("%v includes %v, but %v is not an mixin", d.Name, d.Source, d.Source))
|
||||
panic(fmt.Errorf("%v includes %v, but %v is not an interface", include.Name, include.Source, include.Name))
|
||||
}
|
||||
m, ok := mixins[include.Source]
|
||||
if !ok {
|
||||
panic(fmt.Errorf("%v includes %v, but %v is not an mixin", include.Name, include.Source, include.Source))
|
||||
}
|
||||
// Merge mixin into the interface
|
||||
for _, member := range m.Members {
|
||||
|
@ -224,11 +234,6 @@ func simplify(in *ast.File) (*ast.File, declarations) {
|
|||
i.Members = append(i.Members, member)
|
||||
}
|
||||
}
|
||||
default:
|
||||
if name := nameOf(d); name != "" {
|
||||
s.declarations[nameOf(d)] = d
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue