mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-06 22:53:35 +00:00
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{}
|
interfaces := map[string]*ast.Interface{}
|
||||||
mixins := map[string]*ast.Mixin{}
|
mixins := map[string]*ast.Mixin{}
|
||||||
|
includes := []*ast.Includes{}
|
||||||
for _, d := range in.Declarations {
|
for _, d := range in.Declarations {
|
||||||
switch d := d.(type) {
|
switch d := d.(type) {
|
||||||
case *ast.Interface:
|
case *ast.Interface:
|
||||||
@ -209,27 +210,31 @@ func simplify(in *ast.File) (*ast.File, declarations) {
|
|||||||
mixins[d.Name] = d
|
mixins[d.Name] = d
|
||||||
s.declarations[d.Name] = d
|
s.declarations[d.Name] = d
|
||||||
case *ast.Includes:
|
case *ast.Includes:
|
||||||
// Merge mixin into interface
|
includes = append(includes, d)
|
||||||
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))
|
|
||||||
}
|
|
||||||
m, ok := mixins[d.Source]
|
|
||||||
if !ok {
|
|
||||||
panic(fmt.Errorf("%v includes %v, but %v is not an mixin", d.Name, d.Source, d.Source))
|
|
||||||
}
|
|
||||||
// Merge mixin into the interface
|
|
||||||
for _, member := range m.Members {
|
|
||||||
if member, ok := member.(*ast.Member); ok {
|
|
||||||
i.Members = append(i.Members, member)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
if name := nameOf(d); name != "" {
|
if name := nameOf(d); name != "" {
|
||||||
s.declarations[nameOf(d)] = d
|
s.declarations[nameOf(d)] = d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 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 {
|
||||||
|
if member, ok := member.(*ast.Member); ok {
|
||||||
|
i.Members = append(i.Members, member)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now traverse the declarations in to produce the dependency-ordered
|
// Now traverse the declarations in to produce the dependency-ordered
|
||||||
|
Loading…
x
Reference in New Issue
Block a user