@@ -85,6 +85,21 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
8585 core_fns << '__new_array_with_array_default_noscan'
8686 core_fns << 'new_array_from_c_array'
8787 }
88+ if table.used_features.index || pref_.is_shared {
89+ include_panic_deps = true
90+ core_fns << string_idx_str + '.at_with_check'
91+ core_fns << string_idx_str + '.clone'
92+ core_fns << string_idx_str + '.clone_static'
93+ core_fns << string_idx_str + '.at'
94+ core_fns << array_idx_str + '.set'
95+ core_fns << array_idx_str + '.get_with_check' // used for `x := a[i] or {}`
96+ core_fns << ref_array_idx_str + '.set'
97+ core_fns << map_idx_str + '.get'
98+ core_fns << map_idx_str + '.set'
99+ core_fns << '__new_array_noscan'
100+ core_fns << ref_array_idx_str + '.push_noscan'
101+ core_fns << ref_array_idx_str + '.push_many_noscan'
102+ }
88103 if table.used_features.range_index || pref_.is_shared {
89104 core_fns << string_idx_str + '.substr_with_check'
90105 core_fns << string_idx_str + '.substr_ni'
@@ -94,6 +109,10 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
94109 core_fns << array_idx_str + '.clone_static_to_depth'
95110 core_fns << array_idx_str + '.clone_to_depth'
96111 }
112+ if table.used_features.auto_str || table.used_features.dump {
113+ core_fns << string_idx_str + '.repeat'
114+ core_fns << 'tos3'
115+ }
97116 if table.used_features.arr_prepend {
98117 core_fns << ref_array_idx_str + '.prepend_many'
99118 }
@@ -102,7 +121,6 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
102121 }
103122 if table.used_features.arr_pop {
104123 core_fns << ref_array_idx_str + '.pop'
105- core_fns << ref_array_idx_str + '.pop_noscan'
106124 }
107125 if table.used_features.arr_first {
108126 core_fns << array_idx_str + '.first'
@@ -112,7 +130,15 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
112130 }
113131 if table.used_features.arr_insert {
114132 core_fns << ref_array_idx_str + '.insert_many'
115- core_fns << ref_array_idx_str + '.insert_noscan'
133+ }
134+ if table.used_features.dump {
135+ include_panic_deps = true
136+ builderptr_idx := int (table.find_type ('strings.Builder' ).ref ()).str ()
137+ core_fns << [
138+ builderptr_idx + '.str' ,
139+ builderptr_idx + '.free' ,
140+ builderptr_idx + '.write_rune' ,
141+ ]
116142 }
117143 if table.used_features.print_options {
118144 include_panic_deps = true
@@ -259,6 +285,26 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
259285 handle_vweb (mut table, mut all_fn_root_names, 'vweb.Result' , 'vweb.filter' , 'vweb.Context' )
260286 handle_vweb (mut table, mut all_fn_root_names, 'x.vweb.Result' , 'x.vweb.filter' , 'x.vweb.Context' )
261287
288+ // handle ORM drivers:
289+ orm_connection_implementations := table.iface_types['orm.Connection' ] or { []ast.Type{} }
290+ if orm_connection_implementations.len > 0 {
291+ for k, _ in all_fns {
292+ if k.starts_with ('orm.' ) {
293+ all_fn_root_names << k
294+ }
295+ }
296+ for orm_type in orm_connection_implementations {
297+ typ := int (orm_type).str ()
298+ all_fn_root_names << typ + '.select'
299+ all_fn_root_names << typ + '.insert'
300+ all_fn_root_names << typ + '.update'
301+ all_fn_root_names << typ + '.delete'
302+ all_fn_root_names << typ + '.create'
303+ all_fn_root_names << typ + '.drop'
304+ all_fn_root_names << typ + '.last_id'
305+ }
306+ }
307+
262308 if 'debug_used_features' in pref_.compile_defines {
263309 eprintln ('> debug_used_features: ${table .used_features }' )
264310 }
0 commit comments