Add support for simple structs and var inits
This commit is contained in:
parent
14529c3fe1
commit
4d17ba3d65
10 changed files with 210 additions and 22 deletions
8
tests/generators/nim/test_struct_init.c
Normal file
8
tests/generators/nim/test_struct_init.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
int main() {
|
||||
struct account account = {
|
||||
123,
|
||||
"Pan",
|
||||
"Jan",
|
||||
33.433
|
||||
};
|
||||
}
|
||||
2
tests/generators/nim/test_struct_init.nim
Normal file
2
tests/generators/nim/test_struct_init.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
proc main(): cint =
|
||||
var account = account @ {123, "Pan", "Jan", 33.433}
|
||||
6
tests/generators/nim/test_struct_simple_def.c
Normal file
6
tests/generators/nim/test_struct_simple_def.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
struct account {
|
||||
int account_number;
|
||||
char *first_name;
|
||||
char *last_name;
|
||||
float balance;
|
||||
};
|
||||
6
tests/generators/nim/test_struct_simple_def.nim
Normal file
6
tests/generators/nim/test_struct_simple_def.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
type
|
||||
account = object
|
||||
account_number: cint
|
||||
first_name: cstring
|
||||
last_name: cstring
|
||||
balance: cfloat
|
||||
6
tests/generators/nim/test_struct_simple_def_alias.c
Normal file
6
tests/generators/nim/test_struct_simple_def_alias.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
struct account {
|
||||
int account_number;
|
||||
char *first_name;
|
||||
char *last_name;
|
||||
float balance;
|
||||
} alias_name;
|
||||
6
tests/generators/nim/test_struct_simple_def_alias.nim
Normal file
6
tests/generators/nim/test_struct_simple_def_alias.nim
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
type
|
||||
alias_name = object
|
||||
account_number: cint
|
||||
first_name: cstring
|
||||
last_name: cstring
|
||||
balance: cfloat
|
||||
4
tests/generators/nim/test_var_init_func.c
Normal file
4
tests/generators/nim/test_var_init_func.c
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
int main() {
|
||||
int x = some_func();
|
||||
x = some_func();
|
||||
}
|
||||
3
tests/generators/nim/test_var_init_func.nim
Normal file
3
tests/generators/nim/test_var_init_func.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
proc main(): cint =
|
||||
var x: cint = some_func()
|
||||
x = some_func()
|
||||
Loading…
Add table
Add a link
Reference in a new issue