mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v2: fix C fn calls, save C fns with prefix besides odd cases
This commit is contained in:
parent
236b7b15bb
commit
71b5b0d955
@ -11,7 +11,11 @@ import (
|
|||||||
pub fn (p mut Parser) call_expr(is_c bool, mod string) ast.CallExpr {
|
pub fn (p mut Parser) call_expr(is_c bool, mod string) ast.CallExpr {
|
||||||
tok := p.tok
|
tok := p.tok
|
||||||
name := p.check_name()
|
name := p.check_name()
|
||||||
fn_name := if mod.len > 0 { '${mod}.$name' } else { name }
|
// these fns are are not defined as C functions, but are v fns and have no C prefix
|
||||||
|
// but for some reason are called with the C pefix. for now add exception until fixed
|
||||||
|
v_fns_called_with_c_prefix := ['exit', 'calloc', 'free']
|
||||||
|
fn_name := if is_c && !(name in v_fns_called_with_c_prefix) {'C.$name' }
|
||||||
|
else if mod.len > 0 { '${mod}.$name' } else { name }
|
||||||
p.check(.lpar)
|
p.check(.lpar)
|
||||||
args, muts := p.call_args()
|
args, muts := p.call_args()
|
||||||
node := ast.CallExpr{
|
node := ast.CallExpr{
|
||||||
@ -152,10 +156,9 @@ fn (p mut Parser) fn_decl() ast.FnDecl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: prefix c fuctions with C.
|
if is_c {
|
||||||
// since v1 does not currently it sees
|
name = 'C.$name'
|
||||||
// `fn C.free` and `fn free` as the same
|
} else {
|
||||||
if !is_c {
|
|
||||||
name = p.prepend_mod(name)
|
name = p.prepend_mod(name)
|
||||||
}
|
}
|
||||||
p.table.register_fn(table.Fn{
|
p.table.register_fn(table.Fn{
|
||||||
|
Loading…
Reference in New Issue
Block a user