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 !msvc { |
5 | - if node.expr is ast.CallExpr { |
6 | - tmp_var := g.new_tmp_var() |
7 | - expr_styp := g.typ(node.expr_type) |
8 | - g.write('({ ${expr_styp} ${tmp_var} = ') |
9 | - g.expr(node.expr) |
10 | - g.write('; ') |
11 | - if sym.info is ast.FnType { |
12 | - g.write('/* as */ (${styp})__as_cast(') |
13 | - } else { |
14 | - g.write('/* as */ *(${styp}*)__as_cast(') |
15 | - } |
16 | - g.write(tmp_var) |
17 | - g.write(dot) |
18 | - g.write('_${sym.cname},') |
19 | - g.write(tmp_var) |
20 | - g.write(dot) |
21 | - sidx := g.type_sidx(unwrapped_node_typ) |
22 | - g.write('_typ, ${sidx}); }) /*expected idx: ${sidx}, name: ${sym.name} */ ') |
23 | - } else { |
24 | - if sym.info is ast.FnType { |
25 | - g.write('/* as */ (${styp})__as_cast(') |
26 | - } else { |
27 | - g.write('/* as */ *(${styp}*)__as_cast(') |
28 | - } |
29 | - g.write('(') |
30 | - g.expr(node.expr) |
31 | - g.write(')') |
32 | - g.write(dot) |
33 | - g.write('_${sym.cname},') |
34 | - g.write('(') |
35 | - g.expr(node.expr) |
36 | - g.write(')') |
37 | - g.write(dot) |
38 | - // g.write('typ, /*expected:*/$node.typ)') |
39 | - sidx := g.type_sidx(unwrapped_node_typ) |
40 | - g.write('_typ, ${sidx}) /*expected idx: ${sidx}, name: ${sym.name} */ ') |
41 | - } |
42 | - } $else { |
43 | - if sym.info is ast.FnType { |
44 | - g.write('/* as */ (${styp})__as_cast(') |
45 | - } else { |
46 | - g.write('/* as */ *(${styp}*)__as_cast(') |
47 | - } |
48 | - g.write('(') |
49 | - g.expr(node.expr) |
50 | - g.write(')') |
51 | - g.write(dot) |
52 | - g.write('_${sym.cname},') |
53 | - g.write('(') |
54 | - g.expr(node.expr) |
55 | - g.write(')') |
56 | - g.write(dot) |
57 | - // g.write('typ, /*expected:*/$node.typ)') |
58 | - sidx := g.type_sidx(unwrapped_node_typ) |
59 | - g.write('_typ, ${sidx}) /*expected idx: ${sidx}, name: ${sym.name} */ ') |
60 | + if sym.info is ast.FnType { |
61 | + g.write('/* as */ (${styp})__as_cast(') |
62 | + } else { |
63 | + g.write('/* as */ *(${styp}*)__as_cast(') |
64 | } |
65 | + g.write('(') |
66 | + g.expr(node.expr) |
67 | + g.write(')') |
68 | + g.write(dot) |
69 | + g.write('_${sym.cname},') |
70 | + g.write('(') |
71 | + g.expr(node.expr) |
72 | + g.write(')') |
73 | + g.write(dot) |
74 | + // g.write('typ, /*expected:*/$node.typ)') |
75 | + sidx := g.type_sidx(unwrapped_node_typ) |
76 | + g.write('_typ, ${sidx}) /*expected idx: ${sidx}, name: ${sym.name} */ ') |
77 | |
78 | // fill as cast name table |
79 | for variant in expr_type_sym.info.variants { |
80 | |