compiler: call string method in C funtion parameter

pull/1953/head
BigBlack 2019-09-13 07:41:51 +08:00 committed by Alexander Medvednikov
parent 2880baa1bc
commit 8fe46d5db5
1 changed files with 5 additions and 1 deletions

View File

@ -2501,7 +2501,11 @@ fn (p mut Parser) string_expr() {
p.fgen('\'$str\'') p.fgen('\'$str\'')
f := format_str(str) f := format_str(str)
// `C.puts('hi')` => `puts("hi");` // `C.puts('hi')` => `puts("hi");`
if p.calling_c || (p.pref.translated && p.mod == 'main') { /*
Calling a C function sometimes requires a call to a string method
C.fun('ssss'.to_wide()) => fun(string_to_wide(tos2((byte*)('ssss'))))
*/
if (p.calling_c && p.peek() != .dot) || (p.pref.translated && p.mod == 'main') {
p.gen('"$f"') p.gen('"$f"')
} }
else if p.is_sql { else if p.is_sql {