@@ -18,6 +18,13 @@ pub fn mark_used(mut table ast.Table, pref_ &pref.Preferences, ast_files []&ast.
18
18
// Note: this is temporary, until the native backend supports more features!
19
19
['main.main' ]
20
20
} else {
21
+ byteptr_idx_str := '${ast.byteptr_type_idx} '
22
+ charptr_idx_str := '${ast.charptr_type_idx} '
23
+ u8_idx_str := '${ast.u8_type_idx} '
24
+ string_idx_str := '${ast.string_type_idx} '
25
+ array_idx_str := '${ast.array_type_idx} '
26
+ map_idx_str := '${ast.map_type_idx} '
27
+ ref_array_idx_str := '${int(ast.array_type.ref())} '
21
28
[
22
29
'main.main' ,
23
30
'__new_array' ,
@@ -55,62 +62,62 @@ pub fn mark_used(mut table ast.Table, pref_ &pref.Preferences, ast_files []&ast.
55
62
'compare_strings_reverse' ,
56
63
'builtin_init' ,
57
64
// byteptr and charptr
58
- '3 .vstring' ,
59
- '3 .vstring_with_len' ,
60
- '3 .vstring_literal' ,
61
- '4 .vstring' ,
62
- '4 .vstring_with_len' ,
63
- '4 .vstring_literal' ,
65
+ byteptr_idx_str + ' .vstring' ,
66
+ byteptr_idx_str + ' .vstring_with_len' ,
67
+ byteptr_idx_str + ' .vstring_literal' ,
68
+ charptr_idx_str + ' .vstring' ,
69
+ charptr_idx_str + ' .vstring_with_len' ,
70
+ charptr_idx_str + ' .vstring_literal' ,
64
71
// byte. methods
65
- '11 .str_escaped' ,
72
+ u 8_ idx_str + ' .str_escaped' ,
66
73
// string. methods
67
- '21 .add' ,
68
- '21 .trim_space' ,
69
- '21 .repeat' ,
70
- '21 .replace' ,
71
- '21 .clone' ,
72
- '21 .clone_static' ,
73
- '21 .trim' ,
74
- '21 .substr' ,
75
- '21 .substr_ni' ,
76
- '21 .at' ,
77
- '21 .at_with_check' ,
78
- '21 .index_kmp' ,
74
+ string_idx_str + ' .add' ,
75
+ string_idx_str + ' .trim_space' ,
76
+ string_idx_str + ' .repeat' ,
77
+ string_idx_str + ' .replace' ,
78
+ string_idx_str + ' .clone' ,
79
+ string_idx_str + ' .clone_static' ,
80
+ string_idx_str + ' .trim' ,
81
+ string_idx_str + ' .substr' ,
82
+ string_idx_str + ' .substr_ni' ,
83
+ string_idx_str + ' .at' ,
84
+ string_idx_str + ' .at_with_check' ,
85
+ string_idx_str + ' .index_kmp' ,
79
86
// string. ==, !=, etc...
80
- '21 .eq' ,
81
- '21 .ne' ,
82
- '21 .lt' ,
83
- '21 .gt' ,
84
- '21 .le' ,
85
- '21 .ge' ,
87
+ string_idx_str + ' .eq' ,
88
+ string_idx_str + ' .ne' ,
89
+ string_idx_str + ' .lt' ,
90
+ string_idx_str + ' .gt' ,
91
+ string_idx_str + ' .le' ,
92
+ string_idx_str + ' .ge' ,
86
93
'fast_string_eq' ,
87
94
// other array methods
88
- '23 .get' ,
89
- '23 .set' ,
90
- '23 .get_unsafe' ,
91
- '23 .set_unsafe' ,
92
- '23 .get_with_check' , // used for `x := a[i] or {}`
93
- '23 .clone_static_to_depth' ,
94
- '23 .clone_to_depth' ,
95
- '23 .first' ,
96
- '23 .last' ,
97
- '23 .pointers' , // TODO: handle generic methods calling array primitives more precisely in pool_test.v
98
- '23 .reverse' ,
99
- '23 .repeat_to_depth' ,
100
- '23 .slice' ,
101
- '23 .slice_ni' ,
95
+ array_idx_str + ' .get' ,
96
+ array_idx_str + ' .set' ,
97
+ array_idx_str + ' .get_unsafe' ,
98
+ array_idx_str + ' .set_unsafe' ,
99
+ array_idx_str + ' .get_with_check' , // used for `x := a[i] or {}`
100
+ array_idx_str + ' .clone_static_to_depth' ,
101
+ array_idx_str + ' .clone_to_depth' ,
102
+ array_idx_str + ' .first' ,
103
+ array_idx_str + ' .last' ,
104
+ array_idx_str + ' .pointers' , // TODO: handle generic methods calling array primitives more precisely in pool_test.v
105
+ array_idx_str + ' .reverse' ,
106
+ array_idx_str + ' .repeat_to_depth' ,
107
+ array_idx_str + ' .slice' ,
108
+ array_idx_str + ' .slice_ni' ,
102
109
// map methods
103
- '24 .get' ,
104
- '24 .set' ,
110
+ map_idx_str + ' .get' ,
111
+ map_idx_str + ' .set' ,
105
112
// reference array methods
106
- '65559 .last' ,
107
- '65559 .pop' ,
108
- '65559 .push' ,
109
- '65559 .insert_many' ,
110
- '65559 .prepend_many' ,
111
- '65559 .reverse' ,
112
- '65559 .set' ,
113
- '65559 .set_unsafe' ,
113
+ ref_array_idx_str + ' .last' ,
114
+ ref_array_idx_str + ' .pop' ,
115
+ ref_array_idx_str + ' .push' ,
116
+ ref_array_idx_str + ' .insert_many' ,
117
+ ref_array_idx_str + ' .prepend_many' ,
118
+ ref_array_idx_str + ' .reverse' ,
119
+ ref_array_idx_str + ' .set' ,
120
+ ref_array_idx_str + ' .set_unsafe' ,
114
121
// TODO: process the _vinit const initializations automatically too
115
122
'json.decode_string' ,
116
123
'json.decode_int' ,
0 commit comments