cgen: fix interface struct sorting
parent
51d0ce0222
commit
98cd013908
|
@ -599,11 +599,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
|
||||||
}
|
}
|
||||||
ast.Import {}
|
ast.Import {}
|
||||||
ast.InterfaceDecl {
|
ast.InterfaceDecl {
|
||||||
g.definitions.writeln('//interface')
|
// definitions are sorted and added in write_types
|
||||||
g.definitions.writeln('typedef struct {')
|
|
||||||
g.definitions.writeln('\tvoid* _object;')
|
|
||||||
g.definitions.writeln('\tint _interface_idx;')
|
|
||||||
g.definitions.writeln('} $it.name;')
|
|
||||||
}
|
}
|
||||||
ast.Module {
|
ast.Module {
|
||||||
g.is_builtin_mod = it.name == 'builtin'
|
g.is_builtin_mod = it.name == 'builtin'
|
||||||
|
@ -2271,6 +2267,13 @@ int typ;
|
||||||
g.definitions.writeln('typedef $fixed $styp [$len];')
|
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 {}
|
else {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2287,6 +2290,7 @@ fn (g Gen) sort_structs(typesa []table.TypeSymbol) []table.TypeSymbol {
|
||||||
// loop over types
|
// loop over types
|
||||||
for t in typesa {
|
for t in typesa {
|
||||||
if t.kind == .interface_ {
|
if t.kind == .interface_ {
|
||||||
|
dep_graph.add(t.name, [])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// create list of deps
|
// create list of deps
|
||||||
|
|
|
@ -81,7 +81,7 @@ interface Speaker2 {
|
||||||
|
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
//speaker Speaker
|
speaker Speaker
|
||||||
//speakers []Speaker
|
speakers []Speaker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue