@@ -346,6 +346,10 @@ fn (mut g FlatGen) libc_compat_call_name(name string) ?string {
346346 g.libc_compat_fns['gettid' ] = true
347347 return 'v3_gettid'
348348 }
349+ if name in ['C.v_filelock_lock' , 'C.v_filelock_unlock' , 'v_filelock_lock' , 'v_filelock_unlock' ] {
350+ g.libc_compat_fns['filelock' ] = true
351+ return c_name (name)
352+ }
349353 return none
350354}
351355
@@ -1540,10 +1544,7 @@ fn (mut g FlatGen) gen_call(id flat.NodeId, node flat.Node) {
15401544 base_id := g.a.child (fn_node, 0 )
15411545 base_type := g.tc.resolve_type (base_id)
15421546 if base_type is types.Channel {
1543- g.write ('sync__Channel__close(' )
1544- g.gen_expr (base_id)
1545- g.write (', array_new(sizeof(IError), 0, 0))' )
1546- return
1547+ panic ('channel close should be lowered by v3 transform' )
15471548 }
15481549 }
15491550 match fn_name {
@@ -1689,31 +1690,14 @@ fn (mut g FlatGen) gen_call(id flat.NodeId, node flat.Node) {
16891690 g.write (', ${len_expr })' )
16901691 return
16911692 }
1692- if clean_type is types.Map {
1693- if fn_node.value == 'delete' {
1694- g.gen_map_delete (node, fn_node, clean_type, base_type)
1695- return
1696- } else if fn_node.value == 'clone' {
1697- g.write ('map__clone(' )
1698- g.gen_map_ref_arg (g.a.child (fn_node, 0 ), base_type)
1699- g.write (')' )
1700- return
1701- } else if fn_node.value == 'clear' {
1702- g.write ('map__clear(' )
1703- g.gen_map_ref_arg (g.a.child (fn_node, 0 ), base_type)
1704- g.write (')' )
1705- return
1706- } else if fn_node.value == 'free' {
1707- g.write ('map__free(' )
1708- if base_type is types.Pointer {
1709- g.gen_expr (g.a.child (fn_node, 0 ))
1710- } else {
1711- g.write ('&' )
1712- g.gen_expr (g.a.child (fn_node, 0 ))
1713- }
1714- g.write (')' )
1715- return
1716- }
1693+ if clean_type is types.Map && fn_node.value == 'clone' {
1694+ g.write ('map__clone(' )
1695+ g.gen_map_ref_arg (g.a.child (fn_node, 0 ), base_type)
1696+ g.write (')' )
1697+ return
1698+ }
1699+ if clean_type is types.Map && fn_node.value in ['delete' , 'clear' , 'free' ] {
1700+ panic ('map method `${fn_node .value }` should be lowered by v3 transform' )
17171701 }
17181702 if clean_type is types.String {
17191703 method_name = 'string.${fn_node .value }'
@@ -1844,31 +1828,14 @@ fn (mut g FlatGen) gen_call(id flat.NodeId, node flat.Node) {
18441828 g.write (', ${len_expr })' )
18451829 return
18461830 }
1847- if clean_type is types.Map {
1848- if fn_node.value == 'delete' {
1849- g.gen_map_delete (node, fn_node, clean_type, base_type)
1850- return
1851- } else if fn_node.value == 'clone' {
1852- g.write ('map__clone(' )
1853- g.gen_map_ref_arg (g.a.child (fn_node, 0 ), base_type)
1854- g.write (')' )
1855- return
1856- } else if fn_node.value == 'clear' {
1857- g.write ('map__clear(' )
1858- g.gen_map_ref_arg (g.a.child (fn_node, 0 ), base_type)
1859- g.write (')' )
1860- return
1861- } else if fn_node.value == 'free' {
1862- g.write ('map__free(' )
1863- if base_type is types.Pointer {
1864- g.gen_expr (g.a.child (fn_node, 0 ))
1865- } else {
1866- g.write ('&' )
1867- g.gen_expr (g.a.child (fn_node, 0 ))
1868- }
1869- g.write (')' )
1870- return
1871- }
1831+ if clean_type is types.Map && fn_node.value == 'clone' {
1832+ g.write ('map__clone(' )
1833+ g.gen_map_ref_arg (g.a.child (fn_node, 0 ), base_type)
1834+ g.write (')' )
1835+ return
1836+ }
1837+ if clean_type is types.Map && fn_node.value in ['delete' , 'clear' , 'free' ] {
1838+ panic ('map method `${fn_node .value }` should be lowered by v3 transform' )
18721839 }
18731840 if clean_type is types.String {
18741841 method_name = 'string.${fn_node .value }'
@@ -3803,6 +3770,9 @@ fn (mut g FlatGen) forward_decls() {
38033770 }
38043771 } else if kind_id == 76
38053772 && (node.value.starts_with ('C.v_filelock_' ) || node.value.starts_with ('v_filelock_' )) {
3773+ if g.libc_compat_fns['filelock' ] {
3774+ continue
3775+ }
38063776 g.tc.cur_file = cur_file
38073777 g.tc.cur_module = cur_module
38083778 ret_type := g.tc.parse_type (node.typ)
0 commit comments