cgen: fixed array fix

pull/3997/head
Alexander Medvednikov 2020-03-12 09:29:52 +01:00
parent 92d6eec09a
commit d2cf6894fe
1 changed files with 10 additions and 7 deletions

View File

@ -477,14 +477,17 @@ fn (g mut Gen) expr(node ast.Expr) {
match node {
ast.ArrayInit {
type_sym := g.table.get_type_symbol(it.typ)
elem_sym := g.table.get_type_symbol(it.elem_type)
g.write('new_array_from_c_array($it.exprs.len, $it.exprs.len, sizeof($type_sym.name), ')
g.writeln('(${elem_sym.name}[]){\t')
for expr in it.exprs {
g.expr(expr)
g.write(', ')
if type_sym.kind != .array_fixed {
elem_sym := g.table.get_type_symbol(it.elem_type)
g.write('new_array_from_c_array($it.exprs.len, $it.exprs.len, sizeof($type_sym.name), ')
g.writeln('(${elem_sym.name}[]){\t')
for expr in it.exprs {
g.expr(expr)
g.write(', ')
}
g.write('\n})')
}
g.write('\n})')
else {}
}
ast.AsCast {
g.write('/* as */')