@@ -1185,6 +1185,9 @@ pub fn (mut g Gen) write_typeof_functions() {
11851185 if inter_info.is_generic {
11861186 continue
11871187 }
1188+ if g.pref.skip_unused && sym.idx ! in g.table.used_features.used_syms {
1189+ continue
1190+ }
11881191 g.definitions.writeln ('${g .static_non_parallel }char * v_typeof_interface_${sym .cname }(int sidx);' )
11891192 if g.pref.parallel_cc {
11901193 g.extern_out.writeln ('extern char * v_typeof_interface_${sym .cname }(int sidx);' )
@@ -1620,6 +1623,13 @@ fn (mut g Gen) write_chan_pop_option_fns() {
16201623 if opt_el_type in done {
16211624 continue
16221625 }
1626+ if g.pref.skip_unused {
1627+ if sym := g.table.find_sym (opt_el_type) {
1628+ if sym.idx ! in g.table.used_features.used_syms {
1629+ continue
1630+ }
1631+ }
1632+ }
16231633 done << opt_el_type
16241634 g.channel_definitions.writeln ('
16251635static inline ${opt_el_type } __Option_${styp }_popval(${styp } ch) {
@@ -1642,6 +1652,13 @@ fn (mut g Gen) write_chan_push_option_fns() {
16421652 if styp in done {
16431653 continue
16441654 }
1655+ if g.pref.skip_unused {
1656+ if sym := g.table.find_sym (el_type) {
1657+ if sym.idx ! in g.table.used_features.used_syms {
1658+ continue
1659+ }
1660+ }
1661+ }
16451662 done << styp
16461663 g.register_option (ast.void_type.set_flag (.option))
16471664 g.channel_definitions.writeln ('
@@ -1744,10 +1761,14 @@ pub fn (mut g Gen) write_typedef_types() {
17441761 }
17451762 .chan {
17461763 if sym.name != 'chan' {
1747- g.type_definitions.writeln ('typedef chan ${sym .cname };' )
17481764 chan_inf := sym.chan_info ()
17491765 chan_elem_type := chan_inf.elem_type
1750- is_fixed_arr := g.table.sym (chan_elem_type).kind == .array_fixed
1766+ esym := g.table.sym (chan_elem_type)
1767+ if g.pref.skip_unused && esym.idx ! in g.table.used_features.used_syms {
1768+ continue
1769+ }
1770+ g.type_definitions.writeln ('typedef chan ${sym .cname };' )
1771+ is_fixed_arr := esym.kind == .array_fixed
17511772 if ! chan_elem_type.has_flag (.generic) {
17521773 el_stype := if is_fixed_arr { '_v_' } else { '' } + g.styp (chan_elem_type)
17531774 val_arg_pop := if is_fixed_arr { '&val.ret_arr' } else { '&val' }
@@ -1798,6 +1819,9 @@ static inline void __${sym.cname}_pushval(${sym.cname} ch, ${push_arg} val) {
17981819 }
17991820 }
18001821 for sym in interface_non_generic_syms {
1822+ if g.pref.skip_unused && sym.idx ! in g.table.used_features.used_syms {
1823+ continue
1824+ }
18011825 g.write_interface_typesymbol_declaration (sym)
18021826 }
18031827}
@@ -6444,7 +6468,8 @@ fn (mut g Gen) write_debug_calls_typeof_functions() {
64446468 continue
64456469 }
64466470 inter_info := sym.info as ast.Interface
6447- if inter_info.is_generic {
6471+ if inter_info.is_generic
6472+ || (g.pref.skip_unused && sym.idx ! in g.table.used_features.used_syms) {
64486473 continue
64496474 }
64506475 g.writeln ('\t v_typeof_interface_${sym .cname }(0);' )
@@ -6646,6 +6671,9 @@ fn (mut g Gen) write_builtin_types() {
66466671 // everything except builtin will get sorted
66476672 for builtin_name in ast.builtins {
66486673 sym := g.table.sym_by_idx (g.table.type_idxs[builtin_name])
6674+ if g.pref.skip_unused && sym.idx ! in g.table.used_features.used_syms {
6675+ continue
6676+ }
66496677 if sym.info is ast.Interface {
66506678 g.write_interface_typedef (sym)
66516679 if ! sym.info.is_generic {
@@ -7802,6 +7830,9 @@ fn (mut g Gen) interface_table() string {
78027830 if inter_info.is_generic {
78037831 continue
78047832 }
7833+ if g.pref.skip_unused && isym.idx ! in g.table.used_features.used_syms {
7834+ continue
7835+ }
78057836 // interface_name is for example Speaker
78067837 interface_name := isym.cname
78077838 // generate a struct that references interface methods
0 commit comments