v.gen.c: fix compiling `go f(x)` for `x` of the same struct in different .v files with parallel cgen
parent
0d53705776
commit
e53682320c
|
@ -118,7 +118,7 @@ mut:
|
||||||
defer_profile_code string
|
defer_profile_code string
|
||||||
str_types []StrType // types that need automatic str() generation
|
str_types []StrType // types that need automatic str() generation
|
||||||
generated_str_fns []StrType // types that already have a str() function
|
generated_str_fns []StrType // types that already have a str() function
|
||||||
threaded_fns []string // for generating unique wrapper types and fns for `go xxx()`
|
threaded_fns shared []string // for generating unique wrapper types and fns for `go xxx()`
|
||||||
waiter_fns []string // functions that wait for `go xxx()` to finish
|
waiter_fns []string // functions that wait for `go xxx()` to finish
|
||||||
auto_fn_definitions []string // auto generated functions defination list
|
auto_fn_definitions []string // auto generated functions defination list
|
||||||
sumtype_casting_fns []SumtypeCastingFn
|
sumtype_casting_fns []SumtypeCastingFn
|
||||||
|
@ -298,6 +298,7 @@ pub fn gen(files []&ast.File, table &ast.Table, pref &pref.Preferences) string {
|
||||||
inner_loop: &ast.EmptyStmt{}
|
inner_loop: &ast.EmptyStmt{}
|
||||||
field_data_type: ast.Type(global_g.table.find_type_idx('FieldData'))
|
field_data_type: ast.Type(global_g.table.find_type_idx('FieldData'))
|
||||||
array_sort_fn: global_g.array_sort_fn
|
array_sort_fn: global_g.array_sort_fn
|
||||||
|
threaded_fns: global_g.threaded_fns
|
||||||
done_optionals: global_g.done_optionals
|
done_optionals: global_g.done_optionals
|
||||||
is_autofree: global_g.pref.autofree
|
is_autofree: global_g.pref.autofree
|
||||||
}
|
}
|
||||||
|
@ -370,7 +371,6 @@ pub fn gen(files []&ast.File, table &ast.Table, pref &pref.Preferences) string {
|
||||||
global_g.nr_closures += g.nr_closures
|
global_g.nr_closures += g.nr_closures
|
||||||
global_g.has_main = global_g.has_main || g.has_main
|
global_g.has_main = global_g.has_main || g.has_main
|
||||||
|
|
||||||
global_g.threaded_fns << g.threaded_fns
|
|
||||||
global_g.waiter_fns << g.waiter_fns
|
global_g.waiter_fns << g.waiter_fns
|
||||||
global_g.auto_fn_definitions << g.auto_fn_definitions
|
global_g.auto_fn_definitions << g.auto_fn_definitions
|
||||||
global_g.anon_fn_definitions << g.anon_fn_definitions
|
global_g.anon_fn_definitions << g.anon_fn_definitions
|
||||||
|
@ -6668,7 +6668,14 @@ fn (mut g Gen) go_expr(node ast.GoExpr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Register the wrapper type and function
|
// Register the wrapper type and function
|
||||||
|
mut should_register := false
|
||||||
|
lock g.threaded_fns {
|
||||||
if name !in g.threaded_fns {
|
if name !in g.threaded_fns {
|
||||||
|
g.threaded_fns << name
|
||||||
|
should_register = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if should_register {
|
||||||
g.type_definitions.writeln('\ntypedef struct $wrapper_struct_name {')
|
g.type_definitions.writeln('\ntypedef struct $wrapper_struct_name {')
|
||||||
if expr.is_method {
|
if expr.is_method {
|
||||||
styp := g.typ(expr.receiver_type)
|
styp := g.typ(expr.receiver_type)
|
||||||
|
@ -6762,7 +6769,6 @@ fn (mut g Gen) go_expr(node ast.GoExpr) {
|
||||||
g.gowrappers.writeln('\treturn 0;')
|
g.gowrappers.writeln('\treturn 0;')
|
||||||
}
|
}
|
||||||
g.gowrappers.writeln('}')
|
g.gowrappers.writeln('}')
|
||||||
g.threaded_fns << name
|
|
||||||
}
|
}
|
||||||
if node.is_expr {
|
if node.is_expr {
|
||||||
g.empty_line = false
|
g.empty_line = false
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
fn f1() {
|
||||||
|
x := Abc{111}
|
||||||
|
go f(x)
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
fn f2() {
|
||||||
|
x := Abc{222}
|
||||||
|
go f(x)
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
struct Abc {
|
||||||
|
x int
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f(x Abc) {
|
||||||
|
println(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
f1()
|
||||||
|
f2()
|
||||||
|
time.sleep(1 * time.second)
|
||||||
|
println('OK')
|
||||||
|
}
|
|
@ -24,13 +24,13 @@ fn test_v_profile_works() ? {
|
||||||
for folder_path in folder_paths {
|
for folder_path in folder_paths {
|
||||||
local_path := folder_path.replace(vroot + os.path_separator, '').replace('\\',
|
local_path := folder_path.replace(vroot + os.path_separator, '').replace('\\',
|
||||||
'/')
|
'/')
|
||||||
println('..... $local_path/')
|
println('..... v run $local_path/')
|
||||||
res := os.execute('"$vexe" run $folder_path')
|
res := os.execute('"$vexe" run $folder_path')
|
||||||
// eprintln('res: $res')
|
// eprintln('res: $res')
|
||||||
assert res.exit_code == 0
|
assert res.exit_code == 0
|
||||||
assert res.output.len > 0
|
assert res.output.len > 0
|
||||||
assert res.output.contains('OK')
|
assert res.output.contains('OK')
|
||||||
term.clear_previous_line()
|
term.clear_previous_line()
|
||||||
println('${term.bold('OK')} $local_path/')
|
println('${term.bold('OK')} v run $local_path/')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue