cgen: array types
parent
7f6b98669e
commit
91269961d0
|
@ -376,8 +376,8 @@ pub struct ForCStmt {
|
||||||
pub:
|
pub:
|
||||||
init Stmt // i := 0;
|
init Stmt // i := 0;
|
||||||
cond Expr // i < 10;
|
cond Expr // i < 10;
|
||||||
//inc Stmt // i++;
|
// inc Stmt // i++;
|
||||||
inc Expr// i++;
|
inc Expr // i++;
|
||||||
stmts []Stmt
|
stmts []Stmt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,27 @@ pub fn (g mut Gen) init() {
|
||||||
g.definitions.writeln('#include <inttypes.h>') // int64_t etc
|
g.definitions.writeln('#include <inttypes.h>') // int64_t etc
|
||||||
g.definitions.writeln(c_builtin_types)
|
g.definitions.writeln(c_builtin_types)
|
||||||
g.definitions.writeln(c_headers)
|
g.definitions.writeln(c_headers)
|
||||||
|
g.write_array_types()
|
||||||
g.write_sorted_types()
|
g.write_sorted_types()
|
||||||
g.write_multi_return_types()
|
g.write_multi_return_types()
|
||||||
g.definitions.writeln('// end of definitions #endif')
|
g.definitions.writeln('// end of definitions #endif')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// V type to C type
|
||||||
|
pub fn (g &Gen) typ(t string) string {
|
||||||
|
return t.replace_each(['.', '__'])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (g mut Gen) write_array_types() {
|
||||||
|
for typ in g.table.types {
|
||||||
|
if typ.kind != .array {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
styp := typ.name.replace('.', '__')
|
||||||
|
g.definitions.writeln('typedef array $styp;')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn (g mut Gen) write_multi_return_types() {
|
pub fn (g mut Gen) write_multi_return_types() {
|
||||||
g.definitions.writeln('// multi return structs')
|
g.definitions.writeln('// multi return structs')
|
||||||
for typ in g.table.types {
|
for typ in g.table.types {
|
||||||
|
|
Loading…
Reference in New Issue