mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
95f57e9206
commit
8666ef43fd
@ -5297,6 +5297,43 @@ fn (mut g Gen) sort_structs(typesa []&ast.TypeSymbol) []&ast.TypeSymbol {
|
||||
}
|
||||
}
|
||||
}
|
||||
ast.SumType {
|
||||
for variant in sym.info.variants {
|
||||
vsym := g.table.sym(variant)
|
||||
if vsym.info !is ast.Struct {
|
||||
continue
|
||||
}
|
||||
fields := g.table.struct_fields(vsym)
|
||||
for field in fields {
|
||||
if field.typ.is_ptr() {
|
||||
continue
|
||||
}
|
||||
fsym := g.table.sym(field.typ)
|
||||
if fsym.info is ast.Alias {
|
||||
xsym := g.table.sym(fsym.info.parent_type)
|
||||
if xsym.info !is ast.ArrayFixed {
|
||||
continue
|
||||
}
|
||||
xdep := xsym.name
|
||||
// skip if not in types list or already in deps
|
||||
if xdep !in type_names || xdep in field_deps {
|
||||
continue
|
||||
}
|
||||
field_deps << xdep
|
||||
continue
|
||||
}
|
||||
if fsym.info !is ast.ArrayFixed {
|
||||
continue
|
||||
}
|
||||
dep := fsym.name
|
||||
// skip if not in types list or already in deps
|
||||
if dep !in type_names || dep in field_deps {
|
||||
continue
|
||||
}
|
||||
field_deps << dep
|
||||
}
|
||||
}
|
||||
}
|
||||
// ast.Interface {}
|
||||
else {}
|
||||
}
|
||||
|
0
vlib/v/gen/c/testdata/sumtype_struct_depend_order.out
vendored
Normal file
0
vlib/v/gen/c/testdata/sumtype_struct_depend_order.out
vendored
Normal file
20
vlib/v/gen/c/testdata/sumtype_struct_depend_order.vv
vendored
Normal file
20
vlib/v/gen/c/testdata/sumtype_struct_depend_order.vv
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
type OneOrTwo = One | Two
|
||||
|
||||
struct One {
|
||||
sig u32
|
||||
num u32
|
||||
items [16]Three
|
||||
}
|
||||
|
||||
struct Two {
|
||||
sig u32
|
||||
num u64
|
||||
items [16]Three
|
||||
}
|
||||
|
||||
struct Three {
|
||||
}
|
||||
|
||||
pub fn (obj OneOrTwo) get_sig() u32 {
|
||||
return obj.sig
|
||||
}
|
Loading…
Reference in New Issue
Block a user