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

cgen: more minor fixes

This commit is contained in:
Alexander Medvednikov 2020-03-18 19:56:59 +01:00
parent ca0bae0fcd
commit c3d7c57096

View File

@ -65,7 +65,7 @@ pub fn (g mut Gen) typ(t table.Type) string {
if styp.starts_with('C__') { if styp.starts_with('C__') {
styp = styp[3..] styp = styp[3..]
} }
if styp in ['stat', 'dirent*', 'tm'] { if styp in ['stat', 'dirent*', 'tm', 'tm*'] {
// TODO perf and other C structs // TODO perf and other C structs
styp = 'struct $styp' styp = 'struct $styp'
} }
@ -244,7 +244,8 @@ fn (g mut Gen) stmt(node ast.Stmt) {
} }
ast.ExprStmt { ast.ExprStmt {
g.expr(it.expr) g.expr(it.expr)
match it.expr { expr := it.expr
match expr {
// no ; after an if expression // no ; after an if expression
ast.IfExpr {} ast.IfExpr {}
else { else {
@ -1453,6 +1454,10 @@ fn (g mut Gen) write_types(types []table.TypeSymbol) {
g.definitions.writeln('};\n') g.definitions.writeln('};\n')
g.typedefs.writeln('#define _type_idx_$name $i') g.typedefs.writeln('#define _type_idx_$name $i')
} }
// table.Alias, table.SumType { TODO
table.Alias {
g.typedefs.writeln('#define _type_idx_$name $i')
}
table.Enum { table.Enum {
g.definitions.writeln('typedef enum {') g.definitions.writeln('typedef enum {')
for j, val in it.vals { for j, val in it.vals {
@ -1461,6 +1466,7 @@ fn (g mut Gen) write_types(types []table.TypeSymbol) {
g.definitions.writeln('} $name;\n') g.definitions.writeln('} $name;\n')
} }
table.SumType { table.SumType {
g.typedefs.writeln('#define _type_idx_$name $i')
g.definitions.writeln('// Sum type') g.definitions.writeln('// Sum type')
g.definitions.writeln(' g.definitions.writeln('
typedef struct { typedef struct {