cgen: handle c2v fn casts

pull/12507/head
Alexander Medvednikov 2021-11-18 11:57:57 +03:00
parent 1edb3e559e
commit 5bf28c5287
1 changed files with 18 additions and 0 deletions

View File

@ -5061,6 +5061,15 @@ fn (mut g Gen) ident(node ast.Ident) {
} }
} }
} else if node_info is ast.IdentFn { } else if node_info is ast.IdentFn {
if g.pref.translated {
// `p_mobjthinker` => `P_MobjThinker`
if f := g.table.find_fn(node.name) {
// TODO PERF fn lookup for each fn call in translated mode
if f.attrs.contains('c') {
name = f.attrs[0].arg
}
}
}
if g.pref.obfuscate && g.cur_mod.name == 'main' && name.starts_with('main__') { if g.pref.obfuscate && g.cur_mod.name == 'main' && name.starts_with('main__') {
key := node.name key := node.name
g.write('/* obf identfn: $key */') g.write('/* obf identfn: $key */')
@ -5114,6 +5123,15 @@ fn (mut g Gen) cast_expr(node ast.CastExpr) {
g.expr(node.expr) g.expr(node.expr)
} else { } else {
styp := g.typ(node.typ) styp := g.typ(node.typ)
if g.pref.translated && sym.kind == .function {
// TODO handle the type in fn casts, not just exprs
/*
info := sym.info as ast.FnType
if info.func.attrs.contains('c') {
// name = f.attrs[0].arg
}
*/
}
mut cast_label := '' mut cast_label := ''
// `ast.string_type` is done for MSVC's bug // `ast.string_type` is done for MSVC's bug
if sym.kind != .alias if sym.kind != .alias