1 | mut expr_type_sym := g.table.sym(g.unwrap_generic(node.expr_type)) |
2 | if mut expr_type_sym.info is ast.SumType { |
3 | dot := if node.expr_type.is_ptr() { '->' } else { '.' } |
4 | - if sym.info is ast.FnType { |
5 | - g.write('/* as */ (${styp})__as_cast(') |
6 | + if node.expr is ast.CallExpr && !g.is_cc_msvc { |
7 | + tmp_var := g.new_tmp_var() |
8 | + expr_styp := g.typ(node.expr_type) |
9 | + g.write('({ ${expr_styp} ${tmp_var} = ') |
10 | + g.expr(node.expr) |
11 | + g.write('; ') |
12 | + if sym.info is ast.FnType { |
13 | + g.write('/* as */ (${styp})__as_cast(') |
14 | + } else { |
15 | + g.write('/* as */ *(${styp}*)__as_cast(') |
16 | + } |
17 | + g.write(tmp_var) |
18 | + g.write(dot) |
19 | + g.write('_${sym.cname},') |
20 | + g.write(tmp_var) |
21 | + g.write(dot) |
22 | + sidx := g.type_sidx(unwrapped_node_typ) |
23 | + g.write('_typ, ${sidx}); }) /*expected idx: ${sidx}, name: ${sym.name} */ ') |
24 | } else { |
25 | - g.write('/* as */ *(${styp}*)__as_cast(') |
26 | + if sym.info is ast.FnType { |
27 | + g.write('/* as */ (${styp})__as_cast(') |
28 | + } else { |
29 | + g.write('/* as */ *(${styp}*)__as_cast(') |
30 | + } |
31 | + g.write('(') |
32 | + g.expr(node.expr) |
33 | + g.write(')') |
34 | + g.write(dot) |
35 | + g.write('_${sym.cname},') |
36 | + g.write('(') |
37 | + g.expr(node.expr) |
38 | + g.write(')') |
39 | + g.write(dot) |
40 | + // g.write('typ, /*expected:*/$node.typ)') |
41 | + sidx := g.type_sidx(unwrapped_node_typ) |
42 | + g.write('_typ, ${sidx}) /*expected idx: ${sidx}, name: ${sym.name} */ ') |
43 | } |
44 | - g.write('(') |
45 | - g.expr(node.expr) |
46 | - g.write(')') |
47 | - g.write(dot) |
48 | - g.write('_${sym.cname},') |
49 | - g.write('(') |
50 | - g.expr(node.expr) |
51 | - g.write(')') |
52 | - g.write(dot) |
53 | - // g.write('typ, /*expected:*/$node.typ)') |
54 | - sidx := g.type_sidx(unwrapped_node_typ) |
55 | - g.write('_typ, ${sidx}) /*expected idx: ${sidx}, name: ${sym.name} */ ') |
56 | |
57 | // fill as cast name table |
58 | for variant in expr_type_sym.info.variants { |
59 | |