From bcaf72eccbea6520f0c2fdaf2246f315b662c866 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 5 Mar 2020 01:36:44 +0100 Subject: [PATCH] cgen: update the test --- vlib/v/gen/cgen.v | 2 ++ vlib/v/gen/tests/1.c | 4 ++-- vlib/v/gen/tests/4.c | 12 ++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 167de0ec1e..d13c86d4ca 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -186,8 +186,10 @@ fn (g mut Gen) stmt(node ast.Stmt) { sym := g.table.get_type_symbol(it.receiver.typ) styp := sym.name.replace('.', '__') g.write('$styp $it.receiver.name') + g.definitions.write('$styp $it.receiver.name') if it.args.len > 0 { g.write(', ') + g.definitions.write(', ') } } // diff --git a/vlib/v/gen/tests/1.c b/vlib/v/gen/tests/1.c index 503e5a6cb3..9c7b3905fe 100644 --- a/vlib/v/gen/tests/1.c +++ b/vlib/v/gen/tests/1.c @@ -1,5 +1,5 @@ void foo(int a); -void User_inc_age(int n); +void User_inc_age(User u, int n); int get_int(string a); bool get_bool(); int get_int2(); @@ -75,7 +75,7 @@ i < 10; i++) { int f = TODO_first(nums); } -void User_inc_age(int n) { +void User_inc_age(User u, int n) { u.age += n; } diff --git a/vlib/v/gen/tests/4.c b/vlib/v/gen/tests/4.c index 9b6335bedf..6373b5b056 100644 --- a/vlib/v/gen/tests/4.c +++ b/vlib/v/gen/tests/4.c @@ -2,9 +2,9 @@ multi_return_int_string mr_test(); int testa(); string testb(int a); int testc(int a); -int Foo_testa(); -int Foo_testb(); -int Bar_testa(); +int Foo_testa(Foo f); +int Foo_testb(Foo f); +int Bar_testa(Bar b); int main() { Bar b = (Bar){ @@ -55,17 +55,17 @@ int testc(int a) { return a; } -int Foo_testa() { +int Foo_testa(Foo f) { int a = TODO_testb(f); a = 1; return 4; } -int Foo_testb() { +int Foo_testb(Foo f) { return 4; } -int Bar_testa() { +int Bar_testa(Bar b) { return 4; }