1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix interface struct sorting

This commit is contained in:
joe-conigliaro 2020-04-29 21:08:39 +10:00
parent 51d0ce0222
commit 98cd013908
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
2 changed files with 11 additions and 7 deletions

View File

@ -599,11 +599,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
}
ast.Import {}
ast.InterfaceDecl {
g.definitions.writeln('//interface')
g.definitions.writeln('typedef struct {')
g.definitions.writeln('\tvoid* _object;')
g.definitions.writeln('\tint _interface_idx;')
g.definitions.writeln('} $it.name;')
// definitions are sorted and added in write_types
}
ast.Module {
g.is_builtin_mod = it.name == 'builtin'
@ -2271,6 +2267,13 @@ int typ;
g.definitions.writeln('typedef $fixed $styp [$len];')
// }
}
table.Interface {
g.definitions.writeln('//interface')
g.definitions.writeln('typedef struct {')
g.definitions.writeln('\tvoid* _object;')
g.definitions.writeln('\tint _interface_idx;')
g.definitions.writeln('} $typ.name;')
}
else {}
}
}
@ -2287,6 +2290,7 @@ fn (g Gen) sort_structs(typesa []table.TypeSymbol) []table.TypeSymbol {
// loop over types
for t in typesa {
if t.kind == .interface_ {
dep_graph.add(t.name, [])
continue
}
// create list of deps

View File

@ -81,7 +81,7 @@ interface Speaker2 {
struct Foo {
//speaker Speaker
//speakers []Speaker
speaker Speaker
speakers []Speaker
}