asar coverage - build #161


src/asar/
File: src/asar/assembleblock.cpp
Date: 2024-01-27 02:12:20
Lines:
1360/1626
83.6%
Functions:
38/41
92.7%
Branches:
2044/3774
54.2%

Line Branch Exec Source
1 #include "addr2line.h"
2 #include "asar.h"
3 #include "libstr.h"
4 #include "libsmw.h"
5 #include "assocarr.h"
6 #include "autoarray.h"
7 #include "warnings.h"
8 #include "assembleblock.h"
9 #include "asar_math.h"
10 #include "macro.h"
11 #include "platform/file-helpers.h"
12 #include <cinttypes>
13
14 #include "interface-shared.h"
15 #include "arch-shared.h"
16
17 int arch=arch_65816;
18
19 int snespos;
20 int realsnespos;
21 int startpos;
22 int realstartpos;
23
24 bool emulatexkas;
25 bool mapper_set = false;
26 bool warn_endwhile = true;
27 static bool specifiedasarver = false;
28
29 static int old_snespos;
30 static int old_startpos;
31 static int old_optimizeforbank;
32 static int struct_base;
33 static string struct_name;
34 static string struct_parent;
35 static bool in_struct = false;
36 static bool in_sub_struct = false;
37 static bool static_struct = false;
38 static bool in_spcblock = false;
39
40 assocarr<snes_struct> structs;
41
42 static bool movinglabelspossible = false;
43
44 static bool disable_bank_cross_errors = false;
45 static bool check_half_banks_crossed = false;
46
47 int bytes;
48
49 static enum {
50 ratsmeta_ban,
51 ratsmeta_allow,
52 ratsmeta_used,
53 } ratsmetastate=ratsmeta_ban;
54
55 enum spcblock_type{
56 spcblock_nspc,
57 spcblock_custom
58 };
59
60 struct spcblock_data{
61 unsigned int destination;
62 spcblock_type type;
63 string macro_name;
64
65 unsigned int execute_address; // Can be removed in Asar 2.0
66 unsigned int size_address;
67 mapper_t old_mapper;
68 }spcblock;
69
70 282 int snestopc_pick(int addr)
71 {
72 492 return snestopc(addr);
73 }
74
75 239012 inline void verifysnespos()
76 {
77
3/4
✓ Branch 0 taken 238988 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 238988 times.
239012 if (snespos<0 || realsnespos<0)
78 {
79 24 asar_throw_warning(0, warning_id_missing_org);
80 24 snespos=0x008000;
81 24 realsnespos=0x008000;
82 24 startpos=0x008000;
83 24 realstartpos=0x008000;
84 }
85 239012 }
86
87 960 static int fixsnespos(int inaddr, int step)
88 {
89 // randomdude999: turns out it wasn't very reliable at all.
90 /* // RPG Hacker: No idea how reliable this is.
91 // Might not work with some of the more exotic mappers.
92 return pctosnes(snestopc(inaddr) + step); */
93
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 588 times.
960 if (mapper == lorom) {
94
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 348 times.
372 if ((inaddr&0xFFFF)+step > 0xFFFF) {
95 // bank crossed
96 24 return inaddr+step+0x8000;
97 }
98 348 return inaddr+step;
99
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == hirom) {
100 if ((inaddr&0x400000) == 0) {
101 // system pages, need to account for low pages and stuff
102 if ((inaddr&0xFFFF)+step > 0xFFFF) {
103 return inaddr+step+0x8000;
104 }
105 }
106 return inaddr+step;
107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == exlorom) {
108 // exlorom has no mirroring so this should work fine
109 return pctosnes(snestopc(inaddr)+step);
110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == exhirom) {
111 // apparently exhirom is pretty similar to hirom after all
112 if ((inaddr&0x400000) == 0) {
113 // system pages, need to account for low pages and stuff
114 if ((inaddr&0xFFFF)+step > 0xFFFF) {
115 return inaddr+step+0x8000;
116 }
117 }
118 return inaddr+step;
119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == sa1rom) {
120 if((inaddr&0x400000) == 0) {
121 // lorom area
122 if ((inaddr&0xFFFF)+step > 0xFFFF) {
123 return inaddr+step+0x8000;
124 }
125 return inaddr+step;
126 } else {
127 // hirom area
128 return inaddr+step;
129 }
130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == sfxrom) {
131 if ((inaddr&0x400000) == 0) {
132 // lorom area
133 if ((inaddr&0xFFFF)+step > 0xFFFF) {
134 return inaddr+step+0x8000;
135 }
136 } else {
137 // hirom area
138 return inaddr+step;
139 }
140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 } else if (mapper == bigsa1rom) {
141 // no mirrors here, so this should work
142 return pctosnes(snestopc(inaddr)+step);
143
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 } else if (mapper == norom) {
144 588 return inaddr+step;
145 }
146 return -1;
147 }
148
149 238304 inline void step(int num)
150 {
151
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 237824 times.
238304 if (disable_bank_cross_errors)
152 {
153 480 snespos = fixsnespos(snespos, num);
154 480 realsnespos = fixsnespos(realsnespos, num);
155
156 // RPG Hacker: Not adjusting startpos here will eventually throw
157 // an error in checkbankcross() if we set warn bankcross on again.
158 // As far as I can tell, those are pretty much just used for
159 // checking bank crossing, anyways, so it's hopefully save to just
160 // adjust them here.
161 480 startpos = snespos;
162 480 realstartpos = realsnespos;
163 }
164 else
165 {
166 237824 snespos += num;
167 237824 realsnespos += num;
168 }
169 238304 bytes+=num;
170 238304 }
171
172 238100 inline void write1_65816(unsigned int num)
173 {
174 238100 verifysnespos();
175
2/2
✓ Branch 0 taken 79356 times.
✓ Branch 1 taken 158744 times.
238100 if (pass==2)
176 {
177 79356 int pcpos=snestopc(realsnespos&0xFFFFFF);
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79356 times.
79356 if (pcpos<0)
179 {
180 movinglabelspossible=true;
181 asar_throw_error(2, error_type_block, error_id_snes_address_doesnt_map_to_rom, hex6((unsigned int)realsnespos).data());
182 }
183 79356 writeromdata_byte(pcpos, (unsigned char)num);
184
2/2
✓ Branch 0 taken 8246 times.
✓ Branch 1 taken 71110 times.
79356 if (pcpos>=romlen) {
185
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 8172 times.
8246 if(pcpos - romlen > 0) writeromdata_bytes(romlen, default_freespacebyte, pcpos - romlen, false);
186 8246 romlen=pcpos+1;
187 }
188 }
189 238100 step(1);
190 238100 ratsmetastate=ratsmeta_ban;
191 238100 }
192
193 int recent_opcode_num = 0;
194
195 126747 void write1_pick(unsigned int num)
196 {
197
10/20
✓ Branch 0 taken 106876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 27 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 27 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 27 times.
✗ Branch 19 not taken.
233866 write1_65816(num);
198 226718 }
199
200 228050 static bool asblock_pick(char** word, int numwords)
201 {
202 228050 recent_opcode_num = 1;
203
204
4/4
✓ Branch 0 taken 225716 times.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 225686 times.
228050 if (arch==arch_spc700 || in_spcblock) return asblock_spc700(word, numwords);
205
2/2
✓ Branch 0 taken 222020 times.
✓ Branch 1 taken 3666 times.
225686 if (arch==arch_65816) return asblock_65816(word, numwords);
206
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3654 times.
3666 if (arch==arch_spc700_inline) return asblock_spc700(word, numwords);
207
1/2
✓ Branch 0 taken 3654 times.
✗ Branch 1 not taken.
3654 if (arch==arch_superfx) return asblock_superfx(word, numwords);
208 return true;
209 }
210
211 #define write1 write1_pick
212 #define snestopc snestopc_pick
213
214 1508 const char * safedequote(char * str)
215 {
216 1508 const char * tmp=dequote(str);
217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1508 times.
1508 if (!tmp) asar_throw_error(0, error_type_block, error_id_garbage_near_quoted_string);
218 1508 return tmp;
219 }
220
221 extern char romtitle[30];
222 extern bool stdlib;
223
224 1774 void write2(unsigned int num)
225 {
226 887 write1(num);
227 1774 write1(num/256);
228 1774 }
229
230 1154 void write3(unsigned int num)
231 {
232 577 write1(num);
233 1154 write1(num/256);
234 1154 write1(num/65536);
235 1154 }
236
237 90 void write4(unsigned int num)
238 {
239 45 write1(num);
240 90 write1(num/256);
241 90 write1(num/65536);
242 90 write1(num/16777216);
243 90 }
244
245 //these are NOT used by the math parser - see math.cpp for that
246 int read1(int insnespos)
247 {
248 int addr=snestopc(insnespos);
249 if (addr<0 || addr+1>romlen_r) return -1;
250 return
251 romdata_r[addr ] ;
252 }
253
254 48 int read2(int insnespos)
255 {
256 24 int addr=snestopc(insnespos);
257
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 23 times.
48 if (addr<0 || addr+2>romlen_r) return -1;
258 return
259 46 romdata_r[addr ] |
260 46 (romdata_r[addr+1]<< 8);
261 }
262
263 114 int read3(int insnespos)
264 {
265 57 int addr=snestopc(insnespos);
266
3/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 57 times.
114 if (addr<0 || addr+3>romlen_r) return -1;
267 return
268 114 romdata_r[addr ] |
269 114 (romdata_r[addr+1]<< 8)|
270 114 (romdata_r[addr+2]<<16);
271 }
272
273 1416 int getlenfromchar(char c)
274 {
275 1416 c=(char)to_lower(c);
276
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 708 times.
1416 if (c=='b') return 1;
277
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 378 times.
756 if (c=='w') return 2;
278
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if (c=='l') return 3;
279 if (c=='d')
280 {
281 asar_throw_warning(1, warning_id_feature_deprecated, ".d opcode suffix", "this doesn't even make sense");
282 return 4;
283 }
284 asar_throw_error(0, error_type_block, error_id_invalid_opcode_length);
285 return -1;
286 }
287
288 assocarr<snes_label> labels;
289 static autoarray<int> poslabels;
290 static autoarray<int> neglabels;
291
292 autoarray<int>* macroposlabels;
293 autoarray<int>* macroneglabels;
294
295 autoarray<string> sublabels;
296 autoarray<string>* macrosublabels;
297
298 // randomdude999: ns is still the string to prefix to all labels, it's calculated whenever namespace_list is changed
299 string ns;
300 string ns_backup;
301 autoarray<string> namespace_list;
302
303 //bool fastrom=false;
304
305 autoarray<string> includeonce;
306
307 914 bool confirmname(const char * name)
308 {
309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 914 times.
914 if (!name[0]) return false;
310
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 764 times.
914 if (is_digit(name[0])) return false;
311
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 758 times.
6230 for (int i=0;name[i];i++)
312 {
313
6/6
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5196 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 2733 times.
5472 if (!is_alnum(name[i]) && name[i]!='_') return false;
314 }
315 379 return true;
316 }
317
318 2282922 string posneglabelname(const char ** input, bool define)
319 {
320 2282922 const char* label = *input;
321
322 1141461 string output;
323
324 1141461 int depth = 0;
325 1141461 bool ismacro = false;
326
327
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2282872 times.
2282922 if (label[0] == '?')
328 {
329 25 ismacro = true;
330 50 label++;
331 }
332
4/4
✓ Branch 0 taken 1141461 times.
✓ Branch 1 taken 1141461 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 2282624 times.
2282922 if (label[0] == '-' || label[0] == '+')
333 {
334 149 char first = label[0];
335
4/4
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 86 times.
596 for (depth = 0; label[0] && label[0] == first; depth++) label++;
336
337
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 20 times.
298 if (!ismacro)
338 {
339
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 72 times.
278 if (first == '+')
340 {
341 206 *input = label;
342
8/16
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 103 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 103 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 103 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 103 times.
✗ Branch 15 not taken.
309 output = STR":pos_" + dec(depth) + "_" + dec(poslabels[depth]);
343
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
257 if (define) poslabels[depth]++;
344 }
345 else
346 {
347 72 *input = label;
348
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
75 if (define) neglabels[depth]++;
349
8/16
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 36 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 36 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 36 times.
✗ Branch 15 not taken.
108 output = STR":neg_" + dec(depth) + "_" + dec(neglabels[depth]);
350 }
351 }
352 else
353 {
354
3/6
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
20 if (macrorecursion == 0 || macroposlabels == nullptr || macroneglabels == nullptr)
355 {
356 if (!macrorecursion) asar_throw_error(0, error_type_block, error_id_macro_label_outside_of_macro);
357 }
358 else
359 {
360
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
20 if (first == '+')
361 {
362 10 *input = label;
363
12/24
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 5 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
20 output = STR":macro_" + dec(calledmacros) + STR"_pos_" + dec(depth) + "_" + dec((*macroposlabels)[depth]);
364
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
10 if (define) (*macroposlabels)[depth]++;
365 }
366 else
367 {
368 10 *input = label;
369
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
13 if (define) (*macroneglabels)[depth]++;
370
12/24
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 5 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
20 output = STR":macro_" + dec(calledmacros) + STR"_neg_" + dec(depth) + "_" + dec((*macroneglabels)[depth]);
371 }
372 }
373 }
374 }
375
376 2282922 return output;
377 }
378
379 2662 static string labelname(const char ** rawname, bool define=false)
380 {
381 #define deref_rawname (*rawname)
382 2662 bool ismacro = (deref_rawname[0] == '?');
383
384
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2638 times.
2662 if (ismacro)
385 {
386 24 deref_rawname++;
387 }
388
389 1331 bool issublabel = false;
390
391 1331 string name;
392 1331 int i=-1;
393
394 1331 autoarray<string>* sublabellist = &sublabels;
395
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2638 times.
2662 if (ismacro)
396 {
397 24 sublabellist = macrosublabels;
398 }
399
400
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2662 if (is_digit(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
401
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 2566 times.
2662 if (*deref_rawname ==':')
402 {
403 96 deref_rawname++;
404
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 name=":";
405 }
406
4/4
✓ Branch 0 taken 1283 times.
✓ Branch 1 taken 1283 times.
✓ Branch 2 taken 1193 times.
✓ Branch 3 taken 1193 times.
2566 else if (!in_struct && !in_sub_struct)
407 {
408
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 2362 times.
2430 for (i=0;(*deref_rawname =='.');i++) deref_rawname++;
409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2362 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2362 if (!is_ualnum(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
410
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2346 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2362 if (emulatexkas && i>1) asar_throw_warning(1, warning_id_convert_to_asar);
411
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2300 times.
2362 if (i)
412 {
413
6/12
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 31 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
62 if (!sublabellist || !(*sublabellist)[i - 1]) asar_throw_error(1, error_type_block, error_id_label_missing_parent);
414
4/8
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
93 name+=STR(*sublabellist)[i-1]+"_";
415 31 issublabel = true;
416 }
417 }
418
419
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2643 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 5 times.
2662 if (ismacro && !issublabel)
420 {
421 // RPG Hacker: Don't add the prefix for sublabels, because they already inherit it from
422 // their parents' names.
423
2/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14 if (!macrorecursion || macrosublabels == nullptr) asar_throw_error(1, error_type_block, error_id_macro_label_outside_of_macro);
424
6/12
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
21 name = STR":macro_" + dec(calledmacros) + "_" + name;
425 }
426
427
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2638 times.
2662 if(in_sub_struct)
428 {
429
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 name += struct_parent + ".";
430 }
431
432
4/4
✓ Branch 0 taken 2482 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 2458 times.
2662 if (in_struct || in_sub_struct)
433 {
434
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
204 name += struct_name;
435
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
204 name += '.';
436
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
204 if(*deref_rawname != '.') asar_throw_error(1, error_type_block, error_id_invalid_label_name); //probably should be a better error. TODO!!!
437 204 deref_rawname++;
438 }
439
440
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2662 if (!is_ualnum(*deref_rawname)) asar_throw_error(1, error_type_block, error_id_invalid_label_name);
441
442
8/8
✓ Branch 0 taken 11945 times.
✓ Branch 1 taken 11945 times.
✓ Branch 2 taken 1530 times.
✓ Branch 3 taken 1530 times.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 2662 times.
✓ Branch 6 taken 10614 times.
✓ Branch 7 taken 1331 times.
23890 while (is_ualnum(*deref_rawname) || *deref_rawname == '.' || *deref_rawname == '[')
443 {
444
6/6
✓ Branch 0 taken 20022 times.
✓ Branch 1 taken 1206 times.
✓ Branch 2 taken 19950 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 19872 times.
21228 if(!in_struct && !in_sub_struct && *deref_rawname == '[')
445 {
446 39 bool invalid = true;
447
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 while (isprint(*deref_rawname))
448 {
449
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 117 times.
234 if (*(deref_rawname++) == ']')
450 {
451 39 invalid = false;
452 39 break;
453 }
454 }
455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (invalid)
456 {
457 asar_throw_error(1, error_type_block, error_id_invalid_label_missing_closer);
458 }
459 39 }
460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21150 times.
21150 else if (*deref_rawname == '{')
461 {
462 asar_throw_error(1, error_type_block, error_id_array_invalid_inside_structs);
463 }
464
465
1/2
✓ Branch 0 taken 10614 times.
✗ Branch 1 not taken.
21228 name+=*(deref_rawname++);
466 }
467
4/4
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1990 times.
✓ Branch 2 taken 285 times.
✓ Branch 3 taken 102 times.
2662 if (define && i>=0)
468 {
469
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
570 (*sublabellist).reset(i);
470
2/4
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 285 times.
✗ Branch 3 not taken.
285 (*sublabellist)[i]=name;
471 }
472 2662 return name;
473 #undef deref_rawname
474 }
475
476 1864 inline bool labelvalcore(const char ** rawname, snes_label * rval, bool define, bool shouldthrow)
477 {
478
1/2
✓ Branch 0 taken 932 times.
✗ Branch 1 not taken.
1864 string name=labelname(rawname, define);
479 932 snes_label rval_;
480
24/36
✓ Branch 0 taken 977 times.
✓ Branch 1 taken 887 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 1774 times.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 887 times.
✓ Branch 6 taken 74 times.
✓ Branch 7 taken 903 times.
✓ Branch 8 taken 45 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 29 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 45 times.
✓ Branch 13 taken 887 times.
✓ Branch 14 taken 45 times.
✓ Branch 15 taken 887 times.
✓ Branch 16 taken 45 times.
✓ Branch 17 taken 887 times.
✓ Branch 18 taken 45 times.
✓ Branch 19 taken 887 times.
✓ Branch 20 taken 29 times.
✓ Branch 21 taken 903 times.
✓ Branch 22 taken 29 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 29 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 29 times.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
1938 if (ns && labels.exists(STR ns+name)) {rval_ = labels.find(STR ns+name);}
481
5/6
✓ Branch 0 taken 1736 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 833 times.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 833 times.
✗ Branch 5 not taken.
1806 else if (labels.exists(name)) {rval_ = labels.find(name);}
482 else
483 {
484
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
140 if (shouldthrow && pass)
485 {
486 asar_throw_error(2, error_type_block, error_id_label_not_found, name.data());
487 }
488
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if (rval) { rval->pos = (unsigned int)-1; rval->is_static = false; }
489 140 return false;
490 }
491
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
1724 if (rval)
492 {
493 1724 *rval=rval_;
494 //if (fastrom && (rval_&0x700000)!=0x700000) *rval|=0x800000;
495 }
496 862 return true;
497 1864 }
498
499 1160 snes_label labelval(const char ** rawname, bool define)
500 {
501 580 snes_label rval;
502
1/2
✓ Branch 0 taken 580 times.
✗ Branch 1 not taken.
1160 labelvalcore(rawname, &rval, define, true);
503 1160 return rval;
504 }
505
506 snes_label labelval(char ** rawname, bool define)
507 {
508 snes_label rval;
509 labelvalcore(const_cast<const char**>(rawname), &rval, define, true);
510 return rval;
511 }
512
513 56 snes_label labelval(string name, bool define)
514 {
515 56 const char * rawname=name;
516 28 snes_label rval;
517
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
56 labelvalcore(&rawname, &rval, define, true);
518 84 return rval;
519 }
520
521 592 bool labelval(const char ** rawname, snes_label * rval, bool define)
522 {
523 592 return labelvalcore(rawname, rval, define, false);
524 }
525
526 bool labelval(char ** rawname, snes_label * rval, bool define)
527 {
528 return labelvalcore(const_cast<const char**>(rawname), rval, define, false);
529 }
530
531 56 bool labelval(string name, snes_label * rval, bool define)
532 {
533 56 const char * str=name;
534
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
84 return labelvalcore(&str, rval, define, false);
535 }
536
537 1082 static void setlabel(string name, int loc=-1, bool is_static=false)
538 {
539
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 170 times.
1082 if (loc==-1)
540 {
541
1/2
✓ Branch 0 taken 456 times.
✗ Branch 1 not taken.
912 verifysnespos();
542 912 loc=snespos;
543 }
544
545 541 snes_label label_data;
546 1082 label_data.pos = (unsigned int)loc;
547 1082 label_data.is_static = is_static;
548
549 unsigned int labelpos;
550
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 720 times.
1082 if (pass==0)
551 {
552
4/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 180 times.
362 if (labels.exists(name))
553 {
554 2 movinglabelspossible=true;
555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
2 asar_throw_error(0, error_type_block, error_id_label_redefined, name.data());
556 }
557
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
360 labels.create(name) = label_data;
558 }
559
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 360 times.
720 else if (pass==1)
560 {
561
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
360 labels.create(name) = label_data;
562 }
563
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 else if (pass==2)
564 {
565 //all label locations are known at this point, add a sanity check
566
3/6
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
360 if (!labels.exists(name)) asar_throw_error(2, error_type_block, error_id_label_on_third_pass);
567
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
360 labelpos = labels.find(name).pos;
568
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 360 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
360 if ((int)labelpos != loc && !movinglabelspossible)
569 {
570 if((unsigned int)loc < labelpos && (unsigned int)loc>>16 != labelpos>>16) asar_throw_error(2, error_type_block, error_id_label_ambiguous, name.raw());
571 else if((unsigned int)loc < labelpos && labelpos == (dp_base + 0xFFu)) asar_throw_error(2, error_type_block, error_id_label_ambiguous, name.raw());
572 else if(errored) return;
573 else asar_throw_error(2, error_type_block, error_id_label_moving);
574 }
575 }
576 }
577
578
579 chartabledata table;
580 static autoarray<chartabledata> tablestack;
581
582 static int freespacepos[256];
583 static int freespacelen[256];
584 static int freespaceidnext;
585 static int freespaceid;
586 static int freespacestart;
587 int freespaceextra;
588 bool freespace_is_freecode;
589
590 static bool freespaceleak[256];
591 static string freespacefile[256];
592
593 static int freespaceorgpos[256];
594 static int freespaceorglen[256];
595 static bool freespacestatic[256];
596 static unsigned char freespacebyte[256];
597
598 586 static void cleartable()
599 {
600
2/2
✓ Branch 0 taken 150016 times.
✓ Branch 1 taken 586 times.
150602 for (unsigned int i=0;i<256;i++) table.table[i]=i;
601 586 }
602
603 struct pushable {
604 int arch;
605 int snespos;
606 int snesstart;
607 int snesposreal;
608 int snesstartreal;
609 int freeid;
610 int freeex;
611 int freest;
612 int arch1;
613 int arch2;
614 int arch3;
615 int arch4;
616 };
617 static autoarray<pushable> pushpc;
618 static int pushpcnum;
619
620 static autoarray<int> basestack;
621 static int basestacknum;
622
623 102 struct ns_pushable {
624 string ns;
625 autoarray<string> namespace_list;
626 bool nested_namespaces;
627 };
628
629 static autoarray<ns_pushable> pushns;
630 static int pushnsnum;
631
632
633 static unsigned char fillbyte[12];
634 static unsigned char padbyte[12];
635
636 static bool nested_namespaces = false;
637
638 936 static int getfreespaceid()
639 {
640 static const int max_num_freespaces = 125;
641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 936 times.
936 if (freespaceidnext > max_num_freespaces) asar_throw_error(pass, error_type_fatal, error_id_freespace_limit_reached, max_num_freespaces);
642 936 return freespaceidnext++;
643 }
644
645 874716 void checkbankcross()
646 {
647
6/8
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 867624 times.
✓ Branch 2 taken 7092 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7092 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3546 times.
✓ Branch 7 taken 3546 times.
874716 if (snespos<0 && realsnespos<0 && startpos<0 && realstartpos<0) return;
648
2/2
✓ Branch 0 taken 433812 times.
✓ Branch 1 taken 433812 times.
867624 if (disable_bank_cross_errors) return;
649
2/2
✓ Branch 0 taken 433479 times.
✓ Branch 1 taken 433479 times.
866958 unsigned int mask = 0x7FFF0000 | (check_half_banks_crossed ? 0x8000 : 0);
650
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 866920 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 36 times.
866958 if (((snespos^ startpos) & mask) && (((snespos - 1) ^ startpos) & mask))
651 {
652 2 asar_throw_error(pass, error_type_fatal, error_id_bank_border_crossed, snespos);
653 }
654
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 866920 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
866956 else if (((realsnespos^realstartpos) & mask) && (((realsnespos - 1) ^ realstartpos) & mask))
655 {
656 asar_throw_error(pass, error_type_fatal, error_id_bank_border_crossed, realsnespos);
657 }
658 }
659
660 2258 static void freespaceend()
661 {
662
4/4
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 930 times.
✓ Branch 3 taken 566 times.
2258 if ((snespos&0x7F000000) && ((unsigned int)snespos&0x80000000)==0)
663 {
664 930 freespacelen[freespaceid]=snespos-freespacestart+freespaceextra;
665 930 snespos=(int)0xFFFFFFFF;
666 }
667 2258 freespaceextra=0;
668 2258 }
669
670 int numopcodes;
671
672 bool warnxkas;
673
674
1/2
✓ Branch 0 taken 2930 times.
✗ Branch 1 not taken.
5860 static void adddefine(const string & key, string & value)
675 {
676
1/2
✓ Branch 0 taken 5860 times.
✗ Branch 1 not taken.
5860 if (!defines.exists(key)) defines.create(key) = value;
677 5860 }
678
679 586 void initstuff()
680 {
681
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 388 times.
586 if (pass==0)
682 {
683
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 198 times.
50886 for (int i=0;i<256;i++)
684 {
685 50688 freespacepos[i]=-1;
686 50688 freespaceleak[i]=true;
687 50688 freespaceorgpos[i]=-2;
688 50688 freespaceorglen[i]=-1;
689 50688 freespacebyte[i] = 0x00;
690 }
691 }
692 586 arch=arch_65816;
693 586 mapper=lorom;
694 586 mapper_set = false;
695 586 reallycalledmacros=0;
696 586 calledmacros=0;
697 586 macrorecursion=0;
698 586 repeatnext=1;
699 586 defines.reset();
700 586 builtindefines.each(adddefine);
701 586 clidefines.each(adddefine);
702 293 ns="";
703 586 namespace_list.reset();
704 586 sublabels.reset();
705 586 poslabels.reset();
706 586 neglabels.reset();
707 586 macroposlabels = nullptr;
708 586 macroneglabels = nullptr;
709 586 macrosublabels = nullptr;
710 586 cleartable();
711 586 pushpc.reset();
712 586 pushpcnum=0;
713 586 pushns.reset();
714 586 pushnsnum = 0;
715 586 bytes=0;
716 586 memset(fillbyte, 0, sizeof(fillbyte));
717 586 memset(padbyte, 0, sizeof(padbyte));
718 586 snespos=(int)0xFFFFFFFF;
719 586 realsnespos= (int)0xFFFFFFFF;
720 586 startpos= (int)0xFFFFFFFF;
721 586 realstartpos= (int)0xFFFFFFFF;
722 //fastrom=false;
723 586 freespaceidnext=1;
724 586 freespaceid=1;
725 586 freespaceextra=0;
726 586 default_freespacebyte=0x00;
727 586 numopcodes=0;
728 586 specifiedasarver = false;
729 586 incsrcdepth = 0;
730
731 586 optimizeforbank = -1;
732 586 optimize_dp = optimize_dp_flag::NONE;
733 586 dp_base = 0;
734 586 optimize_address = optimize_address_flag::DEFAULT;
735
736 586 in_struct = false;
737 586 in_sub_struct = false;
738 586 in_spcblock = false;
739
740 586 math_pri=false;
741 586 math_round=true;
742
743
1/2
✓ Branch 0 taken 586 times.
✗ Branch 1 not taken.
586 if (arch==arch_65816) asinit_65816();
744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586 times.
586 if (arch==arch_spc700) asinit_spc700();
745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586 times.
586 if (arch==arch_spc700_inline) asinit_spc700();
746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586 times.
586 if (arch==arch_superfx) asinit_superfx();
747
748 586 warnxkas=false;
749 586 emulatexkas=false;
750 586 disable_bank_cross_errors = false;
751 586 check_half_banks_crossed = false;
752 586 nested_namespaces = false;
753
754 293 thisfilename = "";
755
756 586 includeonce.reset();
757
758 extern AddressToLineMapping addressToLineMapping;
759 586 addressToLineMapping.reset();
760
761 586 push_warnings(false);
762
763 586 initmathcore();
764 586 }
765
766
767 //void nerf(const string& left, string& right){puts(S left+" = "+right);}
768
769 582 void finishpass()
770 {
771 582 verify_warnings();
772 582 pull_warnings(false);
773
774 //defines.traverse(nerf);
775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 582 times.
582 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_missing_endspcblock);
776
2/4
✓ Branch 0 taken 582 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 582 times.
582 if (in_struct || in_sub_struct) asar_throw_error(pass, error_type_null, error_id_struct_without_endstruct);
777
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
582 else if (pushpcnum && pass == 0) asar_throw_error(pass, error_type_null, error_id_pushpc_without_pullpc);
778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
582 else if (pushnsnum && pass == 0) asar_throw_error(pass, error_type_null, error_id_pushns_without_pullns);
779 582 freespaceend();
780
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 42 times.
582 if (arch==arch_65816) asend_65816();
781
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 558 times.
582 if (arch==arch_spc700) asend_spc700();
782
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 576 times.
582 if (arch==arch_spc700_inline) asend_spc700();
783
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 570 times.
582 if (arch==arch_superfx) asend_superfx();
784
785 582 deinitmathcore();
786 582 }
787
788 873642 static bool addlabel(const char * label, int pos=-1, bool global_label = false)
789 {
790
4/4
✓ Branch 0 taken 651998 times.
✓ Branch 1 taken 221644 times.
✓ Branch 2 taken 325999 times.
✓ Branch 3 taken 325999 times.
873642 if (!label[0] || label[0]==':') return false;//colons are reserved for special labels
791
792 651998 const char* posneglabel = label;
793
1/2
✓ Branch 0 taken 325999 times.
✗ Branch 1 not taken.
651998 string posnegname = posneglabelname(&posneglabel, true);
794
795
4/4
✓ Branch 0 taken 326059 times.
✓ Branch 1 taken 325939 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 325939 times.
651998 if (posnegname.length() > 0)
796 {
797
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 60 times.
120 if (global_label) return false;
798
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if (*posneglabel != '\0' && *posneglabel != ':') asar_throw_error(0, error_type_block, error_id_broken_label_definition);
799
2/4
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
120 setlabel(posnegname, pos);
800 120 return true;
801 }
802
7/8
✓ Branch 0 taken 651122 times.
✓ Branch 1 taken 756 times.
✓ Branch 2 taken 651068 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 651062 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 651062 times.
651878 if (label[strlen(label)-1]==':' || label[0]=='.' || label[0]=='?' || label[0] == '#')
803 {
804
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 408 times.
816 if (!label[1]) return false;
805
6/8
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 21 times.
804 if(global_label && (in_struct || in_sub_struct || label[0]=='?')) return false;
806
807 399 bool define = true;
808
809
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 774 times.
798 if (label[0] == '#')
810 {
811 12 define = false;
812 24 label++;
813 }
814
815 // RPG Hacker: Also checking label[1] now, since it might be a macro sublabel.
816 // Also, apparently this here doesn't account for main labels. I guess because
817 // we don't even get here in the first place if they don't include a colon?
818
6/8
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 540 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 540 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 270 times.
798 bool requirecolon = (label[0] != '.' && label[1] != '.') && (in_struct || in_sub_struct);
819
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 string name=labelname(&label, define);
820
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 42 times.
798 if (label[0]==':') label++;
821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 else if (requirecolon) asar_throw_error(0, error_type_block, error_id_broken_label_definition);
822
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
42 else if (global_label) return false;
823
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
792 if (label[0]) asar_throw_error(0, error_type_block, error_id_broken_label_definition);
824
11/14
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 342 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 348 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 348 times.
✓ Branch 8 taken 48 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 48 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 48 times.
✗ Branch 13 not taken.
840 if (ns && !global_label) name=STR ns+name;
825
9/10
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 588 times.
✓ Branch 4 taken 470 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 396 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 395 times.
✓ Branch 9 taken 1 times.
793 setlabel(name, pos, ((in_struct || in_sub_struct) && static_struct));
826 790 return true;
827 798 }
828 325531 return false;
829 651998 }
830
831 224104 static void add_addr_to_line(int pos)
832 {
833
2/2
✓ Branch 0 taken 74926 times.
✓ Branch 1 taken 149178 times.
224104 if (pass == 2)
834 74926 addressToLineMapping.includeMapping(thisfilename.data(), thisline + 1, pos);
835 224104 }
836
837 static autoarray<bool> elsestatus;
838 int numtrue=0;//if 1 -> increase both
839 int numif = 0; //if 0 or inside if 0 -> increase only numif
840
841 autoarray<whiletracker> whilestatus;
842 int single_line_for_tracker;
843
844 static int freespaceuse=0;
845
846
847 78 static void push_pc()
848 {
849 78 pushpc[pushpcnum].arch=arch;
850 78 pushpc[pushpcnum].snespos=snespos;
851 78 pushpc[pushpcnum].snesstart=startpos;
852 78 pushpc[pushpcnum].snesposreal=realsnespos;
853 78 pushpc[pushpcnum].snesstartreal=realstartpos;
854 78 pushpc[pushpcnum].freeid=freespaceid;
855 78 pushpc[pushpcnum].freeex=freespaceextra;
856 78 pushpc[pushpcnum].freest=freespacestart;
857 78 pushpcnum++;
858 78 }
859
860 78 static void pop_pc()
861 {
862 78 pushpcnum--;
863 78 snespos=pushpc[pushpcnum].snespos;
864 78 startpos=pushpc[pushpcnum].snesstart;
865 78 realsnespos=pushpc[pushpcnum].snesposreal;
866 78 realstartpos=pushpc[pushpcnum].snesstartreal;
867 78 freespaceid=pushpc[pushpcnum].freeid;
868 78 freespaceextra=pushpc[pushpcnum].freeex;
869 78 freespacestart=pushpc[pushpcnum].freest;
870 78 }
871
872
873 132 string handle_print(char* input)
874 {
875
3/6
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
132 if (!confirmqpar(input)) asar_throw_error(0, error_type_block, error_id_mismatched_parentheses);
876 66 string out;
877
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 autoptr<char**> pars = qpsplit(input, ",");
878
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 132 times.
456 for (int i = 0; pars[i]; i++)
879 {
880 if (0);
881
4/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
324 else if (pars[i][0] == '"') out += safedequote(pars[i]);
882
3/6
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 else if (!stricmp(pars[i], "bytes")) out += dec(bytes);
883
3/6
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 else if (!stricmp(pars[i], "freespaceuse")) out += dec(freespaceuse);
884
3/6
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 else if (!stricmp(pars[i], "pc")) out += hex6((unsigned int)(snespos & 0xFFFFFF));
885
3/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 12 times.
159 else if (!strncasecmp(pars[i], "bin(", strlen("bin(")) ||
886
4/4
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 12 times.
123 !strncasecmp(pars[i], "dec(", strlen("dec(")) ||
887
5/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
234 !strncasecmp(pars[i], "hex(", strlen("hex(")) ||
888
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 !strncasecmp(pars[i], "double(", strlen("double(")))
889 {
890 114 char * arg1pos = strchr(pars[i], '(') + 1;
891 114 char * endpos = strchr(arg1pos, '\0');
892
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 114 times.
228 while (*endpos == ' ' || *endpos == '\0') endpos--;
893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if (*endpos != ')') asar_throw_error(0, error_type_block, error_id_invalid_print_function_syntax);
894
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
114 string paramstr = string(arg1pos, (int)(endpos - arg1pos));
895
896 57 int numargs;
897
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 autoptr<char**> params = qpsplit(paramstr.temp_raw(), ",", &numargs);
898
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if (numargs > 2) asar_throw_error(0, error_type_block, error_id_wrong_num_parameters);
899 57 int precision = 0;
900 114 bool hasprec = numargs == 2;
901
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 57 times.
114 if (hasprec)
902 {
903
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 precision = getnum64(params[1]);
904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if (precision < 0) precision = 0;
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
78 if (precision > 64) precision = 64;
906 }
907 114 *(arg1pos - 1) = '\0'; // allows more convenient comparsion functions
908
4/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 45 times.
114 if (!stricmp(pars[i], "bin"))
909 {
910 // sadly printf doesn't have binary, so let's roll our own
911
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
912 12 char buffer[65];
913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (value < 0) {
914 out += '-';
915 value = -value;
916 // decrement precision because we've output one char already
917 precision -= 1;
918 if (precision<0) precision = 0;
919 }
920
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 24 times.
1560 for (int j = 0; j < 64; j++) {
921 1536 buffer[63 - j] = '0' + ((value & (1ull << j)) >> j);
922 }
923 24 buffer[64] = 0;
924 12 int startidx = 0;
925
3/4
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1344 times.
✗ Branch 3 not taken.
1368 while (startidx < 64 - precision && buffer[startidx] == '0') startidx++;
926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if (startidx == 64) startidx--; // always want to print at least one digit
927
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer + startidx;
928 }
929
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 33 times.
90 else if (!stricmp(pars[i], "dec"))
930 {
931
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
932 12 char buffer[65];
933
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 snprintf(buffer, 65, "%0*" PRId64, precision, value);
934
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer;
935 }
936
4/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 21 times.
66 else if (!stricmp(pars[i], "hex"))
937 {
938
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 int64_t value = getnum64(params[0]);
939 12 char buffer[65];
940
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 snprintf(buffer, 65, "%0*" PRIX64, precision, value);
941
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 out += buffer;
942 }
943
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
42 else if (!stricmp(pars[i], "double"))
944 {
945
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 6 times.
42 if (!hasprec) precision = 5;
946
3/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
42 out += ftostrvar(getnumdouble(params[0]), precision);
947 }
948 114 }
949 else asar_throw_error(2, error_type_block, error_id_unknown_variable);
950 }
951 198 return out;
952 132 }
953
954
955 875376 void assembleblock(const char * block, bool isspecialline)
956 {
957
1/2
✓ Branch 0 taken 437688 times.
✗ Branch 1 not taken.
437688 string tmp=block;
958 437688 int numwords;
959
1/2
✓ Branch 0 taken 875376 times.
✗ Branch 1 not taken.
875376 char ** word = qsplit(tmp.temp_raw(), " ", &numwords);
960 437688 string resolved;
961 // when writing out the data for the addrToLine mapping,
962 // we want to write out the snespos we had before writing opcodes
963 875376 int addrToLinePos = realsnespos & 0xFFFFFF;
964
965 #define is(test) (!stricmpwithlower(word[0], test))
966 #define is0(test) (numwords==1 && !stricmpwithlower(word[0], test))
967 #define is1(test) (numwords==2 && !stricmpwithlower(word[0], test))
968 #define is2(test) (numwords==3 && !stricmpwithlower(word[0], test))
969 #define is3(test) (numwords==4 && !stricmpwithlower(word[0], test))
970 #define par word[1]
971
972
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 875376 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 437688 times.
875376 if(!moreonlinecond && !(is("elseif") || is("else"))){
973 return;
974 }
975
976 // RPG Hacker: Hack to fix the bug where defines in elseifs would never get resolved
977 // This really seems like the only possible place for the fix
978
6/6
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 875238 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 437652 times.
875376 if (is("elseif") && numtrue+1==numif)
979 {
980
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 resolvedefines(resolved, block);
981
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
72 free(word);
982
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 word = qsplit(resolved.temp_raw(), " ", &numwords);
983 }
984
985 437688 autoptr<char**> wordcopy=word;
986
8/8
✓ Branch 0 taken 873678 times.
✓ Branch 1 taken 1698 times.
✓ Branch 2 taken 436839 times.
✓ Branch 3 taken 436839 times.
✓ Branch 4 taken 112715 times.
✓ Branch 5 taken 112715 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 437667 times.
875376 if (numif==numtrue && is1("global")) {
987
3/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 30 times.
42 if (!addlabel(word[1], -1, true)) {
988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 asar_throw_error(1, error_type_block, error_id_invalid_global_label, word[1]);
989 }
990 30 return;
991 }
992
14/14
✓ Branch 0 taken 874516 times.
✓ Branch 1 taken 1698 times.
✓ Branch 2 taken 873846 times.
✓ Branch 3 taken 670 times.
✓ Branch 4 taken 437970 times.
✓ Branch 5 taken 435876 times.
✓ Branch 6 taken 437724 times.
✓ Branch 7 taken 246 times.
✓ Branch 8 taken 873598 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 436799 times.
✓ Branch 11 taken 436799 times.
✓ Branch 12 taken 440 times.
✓ Branch 13 taken 437666 times.
876214 while (numif==numtrue && word[0] && (!word[1] || strcmp(word[1], "=")) && addlabel(word[0]))
993 {
994 880 word++;
995 880 numwords--;
996 }
997
4/4
✓ Branch 0 taken 874662 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 437331 times.
✓ Branch 3 taken 437331 times.
875332 if (!word[0] || !word[0][0]) return;
998
4/4
✓ Branch 0 taken 651320 times.
✓ Branch 1 taken 1584 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 651104 times.
652904 if (numif==numtrue && word[0][0]=='%')
999 {
1000
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 6 times.
216 if (!macrorecursion)
1001 {
1002
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 callerfilename=thisfilename;
1003 210 callerline=thisline;
1004 }
1005 216 int fakeendif_prev = fakeendif;
1006 216 int moreonlinecond_prev = moreonlinecond;
1007 216 int calledmacros_prev = calledmacros;
1008 216 int single_line_for_tracker_prev = single_line_for_tracker;
1009
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 12 times.
216 callmacro(strchr(block, '%')+1);
1010 204 fakeendif = fakeendif_prev;
1011 204 moreonlinecond = moreonlinecond_prev;
1012 204 calledmacros = calledmacros_prev;
1013 204 single_line_for_tracker = single_line_for_tracker_prev;
1014
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 6 times.
204 if (!macrorecursion)
1015 {
1016
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 callerfilename="";
1017 198 callerline=-1;
1018 }
1019 204 return;
1020 }
1021
12/12
✓ Branch 0 taken 652352 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 652214 times.
✓ Branch 3 taken 138 times.
✓ Branch 4 taken 652172 times.
✓ Branch 5 taken 42 times.
✓ Branch 6 taken 441188 times.
✓ Branch 7 taken 210984 times.
✓ Branch 8 taken 220594 times.
✓ Branch 9 taken 220594 times.
✓ Branch 10 taken 105924 times.
✓ Branch 11 taken 220420 times.
652688 if (is("if") || is("elseif") || is("assert") || is("while") || is("for"))
1022 {
1023
6/6
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 211512 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 330 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 105921 times.
211848 if(is("if") && moreonline) fakeendif++;
1024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211848 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
1025 105924 string errmsg;
1026 105924 whiletracker wstatus;
1027 211848 wstatus.startline = thisline;
1028 211848 wstatus.iswhile = false;
1029 211848 wstatus.cond = false;
1030 211848 wstatus.is_for = false;
1031 211848 wstatus.for_start = wstatus.for_end = wstatus.for_cur = 0;
1032 211848 wstatus.for_has_var_backup = false;
1033
2/2
✓ Branch 0 taken 210984 times.
✓ Branch 1 taken 864 times.
211848 if (is("while")) wstatus.iswhile = true;
1034
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 211500 times.
211848 if (is("for")) wstatus.is_for = true;
1035 // if we are a for loop and:
1036 // 1) whilestatus has an entry at this level already
1037 // 2) said entry represents an incomplete for loop
1038 // then this loop must be meant "for us".
1039 // check number 2 is necessary because otherwise, 2 for loops back-to-back (not nested) would try to use the same whilestatus entry
1040 105924 bool is_for_cont = false;
1041
14/16
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 211500 times.
✓ Branch 2 taken 346 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 339 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 209 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 166 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 166 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 123 times.
✓ Branch 13 taken 43 times.
✓ Branch 14 taken 123 times.
✓ Branch 15 taken 105801 times.
212021 if (is("for") && whilestatus.count > numif && whilestatus[numif].is_for && whilestatus[numif].for_cur < whilestatus[numif].for_end)
1042 {
1043 // continuation of a for loop
1044 123 is_for_cont = true;
1045 }
1046
5/8
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 105801 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105801 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105801 times.
✗ Branch 7 not taken.
211848 whiletracker& addedwstatus = is_for_cont ? whilestatus[numif] : (whilestatus[numif] = wstatus);
1047
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 211806 times.
211848 if (is("assert"))
1048 {
1049
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 autoptr<char**> tokens = qpsplit(word[numwords - 1], ",");
1050
5/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 15 times.
42 if (tokens[0] != NULL && tokens[1] != NULL)
1051 {
1052 6 string rawerrmsg;
1053 6 size_t pos = 1;
1054
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 12 times.
54 while (tokens[pos])
1055 {
1056
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
42 rawerrmsg += tokens[pos];
1057
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 12 times.
42 if (tokens[pos + 1] != NULL)
1058 {
1059
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 rawerrmsg += ",";
1060 }
1061 21 pos++;
1062 }
1063
1064
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
12 errmsg = handle_print(rawerrmsg.raw());
1065 12 }
1066 42 }
1067
8/8
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 211740 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 105906 times.
211848 if (numtrue!=numif && !(is("elseif") && numtrue+1==numif))
1068 {
1069
5/8
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
36 if ((is("if") || is("while") || is("for"))) numif++;
1070 18 return;
1071 }
1072
8/8
✓ Branch 0 taken 211476 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 210966 times.
✓ Branch 4 taken 330 times.
✓ Branch 5 taken 180 times.
✓ Branch 6 taken 105816 times.
✓ Branch 7 taken 90 times.
211812 if ((is("if") || is("while") || is("for"))) numif++;
1073 bool cond;
1074
1075 211812 bool isassert = is("assert");
1076
1077 211812 char ** nextword=word+1;
1078 105906 char * condstr= nullptr;
1079
2/2
✓ Branch 0 taken 211482 times.
✓ Branch 1 taken 330 times.
211812 if(!is("for")) {
1080 while (true)
1081 {
1082
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211488 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211488 if (!nextword[0]) asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1083 105744 bool thiscond = false;
1084
4/6
✓ Branch 0 taken 211134 times.
✓ Branch 1 taken 354 times.
✓ Branch 2 taken 211134 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 211134 times.
211488 if (!nextword[1] || !strcmp(nextword[1], "&&") || !strcmp(nextword[1], "||"))
1085 {
1086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if (nextword[0][0] == '!')
1087 {
1088 asar_throw_warning(0, warning_id_feature_deprecated, "old style conditional negation (if !condition) ", "the not function");
1089 double val = getnumdouble(nextword[0]+1);
1090 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1091 thiscond = !(val > 0);
1092 }
1093 else
1094 {
1095
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 double val = getnumdouble(nextword[0]);
1096
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
354 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1097 354 thiscond = (val > 0);
1098 }
1099
1100
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (condstr && nextword[1])
1101 {
1102 if (strcmp(condstr, nextword[1])) asar_throw_error(1, error_type_block, error_id_invalid_condition);
1103 }
1104 354 else condstr=nextword[1];
1105 354 nextword+=2;
1106 354 }
1107 else
1108 {
1109
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211134 if (!nextword[2]) asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1110
1/2
✓ Branch 0 taken 211134 times.
✗ Branch 1 not taken.
211134 double par1=getnumdouble(nextword[0]);
1111
6/8
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 211074 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 30 times.
211134 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1112
1/2
✓ Branch 0 taken 211104 times.
✗ Branch 1 not taken.
211104 double par2=getnumdouble(nextword[2]);
1113
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 211104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
211104 if (foundlabel && !foundlabel_static && !isassert) asar_throw_error(0, error_type_block, error_id_label_in_conditional, word[0]);
1114 if(0);
1115
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 210984 times.
211104 else if (!strcmp(nextword[1], ">")) thiscond=(par1>par2);
1116
2/2
✓ Branch 0 taken 210870 times.
✓ Branch 1 taken 114 times.
210984 else if (!strcmp(nextword[1], "<")) thiscond=(par1<par2);
1117
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 108 times.
114 else if (!strcmp(nextword[1], ">=")) thiscond=(par1>=par2);
1118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 else if (!strcmp(nextword[1], "<=")) thiscond=(par1<=par2);
1119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 else if (!strcmp(nextword[1], "="))
1120 {
1121 asar_throw_warning(0, warning_id_feature_deprecated, "if a = b", "use \"if a == b\" instead");
1122 thiscond=(par1==par2);
1123 }
1124
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12 times.
108 else if (!strcmp(nextword[1], "==")) thiscond=(par1==par2);
1125
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 else if (!strcmp(nextword[1], "!=")) thiscond=(par1!=par2);
1126 //else if (!strcmp(nextword[1], "<>")) thiscond=(par1!=par2);
1127 else asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1128
1129
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 211098 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
211104 if (condstr && nextword[3])
1130 {
1131 if (strcmp(condstr, nextword[3])) asar_throw_error(1, error_type_block, error_id_invalid_condition);
1132 }
1133 211104 else condstr=nextword[3];
1134 211104 nextword+=4;
1135 }
1136
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 211440 times.
211458 if (condstr)
1137 {
1138
3/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12 times.
18 if (!strcmp(condstr, "&&")) { if(thiscond) continue; }
1139 else if (!strcmp(condstr, "||")) { if(!thiscond) continue; }
1140 else asar_throw_error(0, error_type_block, error_id_broken_conditional, word[0]);
1141 }
1142 105726 cond=thiscond;
1143 105726 break;
1144 3 }
1145 }
1146
1147
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 211452 times.
211782 if (is("for"))
1148 {
1149 // for loops as anything except the first block cause weirdness
1150 // (while loops do too, but let's not talk about it)
1151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(single_line_for_tracker != 1) {
1152 numif--;
1153 asar_throw_error(0, error_type_line, error_id_bad_single_line_for);
1154 }
1155 // TODO: these errors could probably be a bit more descriptive
1156
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 246 times.
330 if(!is_for_cont)
1157 {
1158 // "for i = 0..16"
1159
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(numwords != 4) asar_throw_error(0, error_type_block, error_id_broken_for_loop);
1160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(strcmp(word[2], "=") != 0) asar_throw_error(0, error_type_block, error_id_broken_for_loop);
1161
1162
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 char* range_sep = strqpstr(word[3], "..");
1163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(!range_sep)
1164 asar_throw_error(0, error_type_block, error_id_broken_for_loop, "invalid loop range");
1165
1166
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string for_start(word[3], range_sep - word[3]);
1167
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string for_end(range_sep+2);
1168
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 addedwstatus.for_start = getnum(for_start);
1169
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_label_in_conditional, "for");
1170
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 addedwstatus.for_end = getnum(for_end);
1171
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_label_in_conditional, "for");
1172
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 string varname = word[1];
1173
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if(!validatedefinename(varname)) asar_throw_error(0, error_type_block, error_id_broken_for_loop);
1174
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
84 addedwstatus.for_variable = varname;
1175 84 addedwstatus.for_cur = addedwstatus.for_start;
1176 84 }
1177 else
1178 {
1179 246 addedwstatus.for_cur++;
1180 }
1181 // this cond is actually also used to tell assemblefile whether to jump back to the beginning of the loop, so keep it updated
1182 330 addedwstatus.cond = addedwstatus.for_cur < addedwstatus.for_end;
1183 330 single_line_for_tracker = 2;
1184
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 84 times.
330 if(addedwstatus.cond)
1185 {
1186
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 27 times.
246 numtrue++;
1187
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 27 times.
246 if(defines.exists(addedwstatus.for_variable)) {
1188 192 addedwstatus.for_has_var_backup = true;
1189
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
192 addedwstatus.for_var_backup = defines.find(addedwstatus.for_variable);
1190 }
1191
3/6
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123 times.
✗ Branch 5 not taken.
246 defines.create(addedwstatus.for_variable) = ftostr(addedwstatus.for_cur);
1192 }
1193 }
1194
6/6
✓ Branch 0 taken 211146 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 105573 times.
✓ Branch 3 taken 105573 times.
✓ Branch 4 taken 105636 times.
✓ Branch 5 taken 90 times.
211452 else if (is("if") || is("while"))
1195 {
1196 if(0);
1197
2/2
✓ Branch 0 taken 211050 times.
✓ Branch 1 taken 222 times.
211272 else if (cond)
1198 {
1199 211050 numtrue++;
1200
1/2
✓ Branch 0 taken 105525 times.
✗ Branch 1 not taken.
211050 elsestatus[numif]=true;
1201 }
1202
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 else if (!cond)
1203 {
1204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(moreonline) moreonlinecond=false;
1205
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
222 elsestatus[numif]=false;
1206 }
1207 211272 addedwstatus.cond = cond;
1208 }
1209
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 42 times.
180 else if (is("elseif"))
1210 {
1211
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
138 if (!numif) asar_throw_error(1, error_type_block, error_id_misplaced_elseif);
1212
3/6
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
138 if (whilestatus[numif - 1].iswhile) asar_throw_error(1, error_type_block, error_id_elseif_in_while);
1213
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 72 times.
138 if (numif==numtrue) numtrue--;
1214
8/8
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 51 times.
171 if (cond && !elsestatus[numif])
1215 {
1216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(moreonline) moreonlinecond = true;
1217 36 numtrue++;
1218
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 elsestatus[numif]=true;
1219 }
1220 }
1221 // otherwise, must be assert command
1222
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 4 times.
42 else if (pass == 2 && !cond)
1223 {
1224
7/10
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
20 if (errmsg) asar_throw_error(2, error_type_block, error_id_assertion_failed, (string(": ") + errmsg).data());
1225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else asar_throw_error(2, error_type_block, error_id_assertion_failed, ".");
1226 }
1227
4/4
✓ Branch 0 taken 105886 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 105886 times.
✓ Branch 3 taken 18 times.
211906 }
1228
8/8
✓ Branch 0 taken 439658 times.
✓ Branch 1 taken 1182 times.
✓ Branch 2 taken 229520 times.
✓ Branch 3 taken 210138 times.
✓ Branch 4 taken 114760 times.
✓ Branch 5 taken 114760 times.
✓ Branch 6 taken 105834 times.
✓ Branch 7 taken 114586 times.
440840 else if (is("endif") || is("endwhile") || is("endfor"))
1229 {
1230
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 211662 times.
211668 if(fakeendif) fakeendif--;
1231
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211668 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211668 if (numwords != 1) asar_throw_error(1, error_type_block, error_id_unknown_command);
1232
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211668 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211668 if (!numif) asar_throw_error(1, error_type_block, error_id_misplaced_endif);
1233
2/2
✓ Branch 0 taken 211200 times.
✓ Branch 1 taken 468 times.
211668 if (numif==numtrue) numtrue--;
1234 211668 numif--;
1235
4/4
✓ Branch 0 taken 106008 times.
✓ Branch 1 taken 105660 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 105660 times.
211668 if(whilestatus[numif].is_for) {
1236
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 288 times.
348 if(single_line_for_tracker == 2) single_line_for_tracker = 3;
1237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
348 if(moreonline) {
1238 // sabotage the whilestatus to prevent the loop running again
1239 // and spamming more of the same error
1240 whilestatus[numif].for_cur = whilestatus[numif].for_end;
1241 whilestatus[numif].cond = false;
1242 asar_throw_error(0, error_type_block, error_id_bad_single_line_for);
1243 }
1244
4/4
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 51 times.
348 if(whilestatus[numif].cond) {
1245
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 27 times.
246 if(whilestatus[numif].for_has_var_backup)
1246
4/8
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
192 defines.create(whilestatus[numif].for_variable) = whilestatus[numif].for_var_backup;
1247
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
54 else defines.remove(whilestatus[numif].for_variable);
1248 }
1249 }
1250
2/2
✓ Branch 0 taken 210818 times.
✓ Branch 1 taken 850 times.
211668 if(warn_endwhile) {
1251
4/4
✓ Branch 0 taken 210479 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 105070 times.
✓ Branch 3 taken 339 times.
210818 if(whilestatus[numif].iswhile) {
1252
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 210138 times.
210140 if(!is("endwhile")) {
1253 2 warn_endwhile = false;
1254
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 asar_throw_warning(0, warning_id_feature_deprecated, "mismatched terminators", "use endwhile to terminate a while statement");
1255 }
1256 }
1257
4/4
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 165 times.
678 else if(whilestatus[numif].is_for) {
1258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
348 if(!is("endfor")) {
1259 warn_endwhile = false;
1260 asar_throw_warning(0, warning_id_feature_deprecated, "mismatched terminators", "use endfor to terminate a for statement");
1261 }
1262 }
1263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 else if(!is("endif")) {
1264 warn_endwhile = false;
1265 asar_throw_warning(0, warning_id_feature_deprecated, "mismatched terminators", "use endif to terminate an if statement");
1266 }
1267 }
1268 }
1269
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 228944 times.
229172 else if (is("else"))
1270 {
1271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(!moreonlinecond) moreonlinecond = true;
1272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
228 if (numwords != 1) asar_throw_error(1, error_type_block, error_id_unknown_command);
1273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
228 if (!numif) asar_throw_error(1, error_type_block, error_id_misplaced_else);
1274
5/12
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 114 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 114 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
228 if (whilestatus[numif - 1].iswhile || whilestatus[numif - 1].is_for) asar_throw_error(1, error_type_block, error_id_else_in_while_loop);
1275
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 114 times.
228 else if (numif==numtrue) numtrue--;
1276
7/8
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 33 times.
171 else if (numif==numtrue+1 && !elsestatus[numif])
1277 {
1278 48 numtrue++;
1279
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 elsestatus[numif]=true;
1280 }
1281 }
1282
2/2
✓ Branch 0 taken 114472 times.
✓ Branch 1 taken 114472 times.
228944 else if (numif!=numtrue) return;
1283
4/4
✓ Branch 0 taken 228048 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 9712 times.
✓ Branch 3 taken 218336 times.
228050 else if (asblock_pick(word, numwords))
1284 {
1285
1/2
✓ Branch 0 taken 9712 times.
✗ Branch 1 not taken.
9712 add_addr_to_line(addrToLinePos);
1286 9712 numopcodes += recent_opcode_num;
1287 }
1288
6/6
✓ Branch 0 taken 217066 times.
✓ Branch 1 taken 1270 times.
✓ Branch 2 taken 108533 times.
✓ Branch 3 taken 108533 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109165 times.
218336 else if (is1("undef"))
1289 {
1290 3 string def;
1291 // RPG Hacker: Not sure if we should allow this?
1292 // Currently, the manual states that we should not include the
1293 // exclamation mark, and I believe that this is for the better
1294 // because I can see this leading to ambiguities or causing
1295 // problems. If we add this back in, we should definitely
1296 // also added it to the defined() function for consistency, though.
1297 // Well, actually I just check and we can't support this in
1298 // defined() (the defined is already replaced at that point), so
1299 // I think we should not support it here, either.
1300 /*if (*par == '!') def = S safedequote(par) + 1;
1301
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
9 else*/ def = STR safedequote(par);
1302
1303
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
6 if (defines.exists(def))
1304 {
1305
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 defines.remove(def);
1306 }
1307 else
1308 {
1309 asar_throw_error(0, error_type_block, error_id_define_not_found, def.data());
1310 }
1311 6 }
1312
6/6
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 217770 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 280 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109162 times.
218330 else if (is0("error"))
1313 {
1314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 asar_throw_error(0, error_type_block, error_id_error_command, ".");
1315 }
1316
6/6
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 217770 times.
✓ Branch 2 taken 277 times.
✓ Branch 3 taken 277 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 109159 times.
218324 else if (is0("warn"))
1317 {
1318
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(2, warning_id_warn_command, ".");
1319 }
1320
6/6
✓ Branch 0 taken 217060 times.
✓ Branch 1 taken 1258 times.
✓ Branch 2 taken 108530 times.
✓ Branch 3 taken 108530 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109153 times.
218318 else if (is1("error"))
1321 {
1322
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string out = handle_print(par);
1323 // RPG Hacker: This used to be on pass 0, which had its merits (you don't want to miss a potentially critical
1324 // user-generated error, just because a bazillion other errors are thrown in passes before it). However, I
1325 // don't see how to support print functions with this without moving it to pass 2. Suggestions are welcome.
1326
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
36 asar_throw_error(2, error_type_block, error_id_error_command, (string(": ") + out).data());
1327 12 }
1328
6/6
✓ Branch 0 taken 217048 times.
✓ Branch 1 taken 1258 times.
✓ Branch 2 taken 108524 times.
✓ Branch 3 taken 108524 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109147 times.
218306 else if (is1("warn"))
1329 {
1330
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string out = handle_print(par);
1331
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 asar_throw_warning(2, warning_id_warn_command, (string(": ") + out).data());
1332 12 }
1333
6/6
✓ Branch 0 taken 217036 times.
✓ Branch 1 taken 1258 times.
✓ Branch 2 taken 108518 times.
✓ Branch 3 taken 108518 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 109129 times.
218294 else if (is1("warnings"))
1334 {
1335
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
36 if (stricmp(word[1], "push") == 0)
1336 {
1337
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 push_warnings();
1338 }
1339
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 else if (stricmp(word[1], "pull") == 0)
1340 {
1341
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 pull_warnings();
1342 }
1343 }
1344
6/6
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 217608 times.
✓ Branch 2 taken 325 times.
✓ Branch 3 taken 325 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 109093 times.
218258 else if (is2("warnings"))
1345 {
1346
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 30 times.
72 if (stricmp(word[1], "enable") == 0)
1347 {
1348
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 asar_warning_id warnid = parse_warning_id_from_string(word[2]);
1349
1350
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (warnid != warning_id_end)
1351 {
1352
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_warning_enabled(warnid, true);
1353 }
1354 else
1355 {
1356 asar_throw_error(0, error_type_null, error_id_invalid_warning_id, "warnings enable", (int)(warning_id_start + 1), (int)(warning_id_end - 1));
1357 }
1358 }
1359
2/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 else if (stricmp(word[1], "disable") == 0)
1360 {
1361
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 asar_warning_id warnid = parse_warning_id_from_string(word[2]);
1362
1363
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if (warnid != warning_id_end)
1364 {
1365
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 set_warning_enabled(warnid, false);
1366 }
1367 else
1368 {
1369 asar_throw_error(0, error_type_null, error_id_invalid_warning_id, "warnings disable", (int)(warning_id_start + 1), (int)(warning_id_end - 1));
1370 }
1371 }
1372 }
1373
6/6
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 217608 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 109059 times.
218186 else if (is2("check"))
1374 {
1375
4/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 31 times.
68 if (stricmp(word[1], "title") == 0)
1376 {
1377 // RPG Hacker: Removed trimming for now - I think requiring an exact match is probably
1378 // better here (not sure, though, it's worth discussing)
1379
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
6 string expected_title = safedequote(word[2]);
1380 // randomdude999: this also removes leading spaces because itrim gets stuck in an endless
1381 // loop when multi is true and one argument is empty
1382 //expected_title = itrim(expected_title.data(), " ", " ", true); // remove trailing spaces
1383 // in hirom the rom needs to be an entire bank for it to have a title, other modes only need 0x8000 bytes
1384
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 if (romlen < ((mapper == hirom || mapper == exhirom) ? 0x10000 : 0x8000)) // too short
1385 {
1386 if (!ignoretitleerrors) // title errors shouldn't be ignored
1387 asar_throw_error(0, error_type_block, error_id_rom_too_short, expected_title.data());
1388 else // title errors should be ignored, throw a warning anyways
1389 asar_throw_warning(0, warning_id_rom_too_short, expected_title.data());
1390 }
1391 else {
1392 3 string actual_title;
1393 3 string actual_display_title;
1394
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 6 times.
132 for (int i = 0;i < 21;i++)
1395 {
1396 126 unsigned char c = romdata[snestopc(0x00FFC0 + i)];
1397
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
126 actual_title += (char)c;
1398 // the replacements are from interface-cli.cpp
1399
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 7) c = 14;
1400
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 8) c = 27;
1401
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == 9) c = 26;
1402
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == '\r') c = 17;
1403
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 63 times.
126 if (c == '\n') c = 25;
1404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (c == '\0') c = 155;
1405
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
126 actual_display_title += (char)c;
1406 }
1407 //actual_display_title = itrim(actual_display_title.data(), " ", " ", true); // remove trailing spaces
1408 //actual_title = itrim(actual_title.data(), " ", " ", true); // remove trailing spaces
1409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (strncmp(expected_title, actual_title, 21) != 0)
1410 {
1411 if (!ignoretitleerrors) // title errors shouldn't be ignored
1412 asar_throw_error(0, error_type_block, error_id_rom_title_incorrect, expected_title.data(), actual_display_title.data());
1413 else // title errors should be ignored, throw a warning anyways
1414 asar_throw_warning(0, warning_id_rom_title_incorrect, expected_title.data(), actual_display_title.data());
1415 }
1416 6 }
1417 6 }
1418
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
62 else if (stricmp(word[1], "bankcross") == 0)
1419 {
1420 if (0);
1421
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 16 times.
62 else if (!stricmp(word[2], "on"))
1422 {
1423
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 asar_throw_warning(0, warning_id_feature_deprecated, "bankcheck on", "bankcheck full or bankcheck half");
1424 }
1425
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
32 else if (!stricmp(word[2], "off"))
1426 {
1427 30 disable_bank_cross_errors = true;
1428 }
1429
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 else if (!stricmp(word[2], "half"))
1430 {
1431 2 disable_bank_cross_errors = false;
1432 2 check_half_banks_crossed = true;
1433 }
1434 else if (!stricmp(word[2], "full"))
1435 {
1436 disable_bank_cross_errors = false;
1437 check_half_banks_crossed = false;
1438 }
1439 else asar_throw_error(0, error_type_block, error_id_invalid_check);
1440
1441 }
1442 else
1443 {
1444 asar_throw_error(0, error_type_block, error_id_invalid_check);
1445 }
1446 }
1447
9/10
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 217570 times.
✓ Branch 2 taken 548 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 217000 times.
✓ Branch 5 taken 1118 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 216970 times.
✓ Branch 8 taken 15 times.
✓ Branch 9 taken 109044 times.
218118 else if (is0("asar") || is1("asar"))
1448 {
1449
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (!asarverallowed) asar_throw_error(0, error_type_block, error_id_start_of_file);
1450
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
30 if (!par) return;
1451
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (emulatexkas) asar_throw_error(0, error_type_block, error_id_xkas_asar_conflict);
1452 15 int dots=0;
1453 15 int dig=0;
1454
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 30 times.
150 for (int i=0;par[i];i++)
1455 {
1456
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 90 times.
120 if (par[i]=='.')
1457 {
1458
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (!dig) asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1459 15 dig=0;
1460 30 dots++;
1461 }
1462
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 else if (is_digit(par[i])) dig++;
1463 else asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1464 }
1465
4/8
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
30 if (!dig || !dots || dots>2) asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1466
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 autoptr<char**> vers=split(par, ".");
1467 30 int vermaj=atoi(vers[0]);
1468
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (vermaj > asarver_maj) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (vermaj<asarver_maj) return;
1470
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (dots==1)
1471 {
1472
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (strlen(vers[1])!=2) asar_throw_error(0, error_type_block, error_id_invalid_version_number);
1473 //if (asarver_min<10 && asarver_bug<10 && strlen(vers[1])>2) error(0, "This version of Asar is too old for this patch.");
1474 30 int verminbug=atoi(vers[1]);
1475 30 int tmpver=asarver_bug;
1476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (tmpver>9) tmpver=9;
1477
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (asarver_min*10+tmpver<verminbug) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1478
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12 times.
30 if(vermaj == 1 && verminbug >= 90) { default_math_pri = true; default_math_round_off = true; }
1479 }
1480 else
1481 {
1482 int vermin=atoi(vers[1]);
1483 if (vermin>asarver_min) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1484 int verbug=atoi(vers[2]);
1485 if (vermin==asarver_min && verbug>asarver_bug) asar_throw_error(pass, error_type_fatal, error_id_asar_too_old);
1486 if(vermaj == 1 && vermin >= 9) { default_math_pri = true; default_math_round_off = true; }
1487 }
1488 30 specifiedasarver = true;
1489
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 }
1490
6/6
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 217540 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 274 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 109038 times.
218088 else if (is0("xkas"))
1491 {
1492
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 asar_throw_warning(0, warning_id_feature_deprecated, "xkas compatibility mode", "UPGRADE YOUR PATCH ITS 2021!!!");
1493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if (!asarverallowed) asar_throw_error(0, error_type_block, error_id_start_of_file);
1494
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
12 if (incsrcdepth != 1 && !emulatexkas) asar_throw_error(0, error_type_block, error_id_command_in_non_root_file);
1495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (specifiedasarver) asar_throw_error(0, error_type_block, error_id_xkas_asar_conflict);
1496 6 emulatexkas=true;
1497 6 optimizeforbank=0x100;
1498
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!force_checksum_fix)
1499 6 checksum_fix_enabled = false;
1500
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 sublabels[0]=":xkasdefault:";
1501 }
1502
7/10
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 217540 times.
✓ Branch 2 taken 536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216970 times.
✓ Branch 5 taken 1106 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 216970 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 109038 times.
218076 else if (is0("include") || is1("includefrom"))
1503 {
1504 if (!asarverallowed) asar_throw_error(0, error_type_block, error_id_start_of_file);
1505 if (istoplevel)
1506 {
1507 if (par) asar_throw_error(pass, error_type_fatal, error_id_cant_be_main_file, (string(" The main file is '") + STR par + STR "'.").data());
1508 else asar_throw_error(pass, error_type_fatal, error_id_cant_be_main_file, "");
1509 }
1510 }
1511
6/6
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 217540 times.
✓ Branch 2 taken 268 times.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 109023 times.
218076 else if (is0("includeonce"))
1512 {
1513
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if (!file_included_once(thisfilename))
1514 {
1515
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 includeonce.append(thisfilename);
1516 }
1517 }
1518
18/18
✓ Branch 0 taken 216970 times.
✓ Branch 1 taken 1076 times.
✓ Branch 2 taken 3772 times.
✓ Branch 3 taken 213198 times.
✓ Branch 4 taken 3772 times.
✓ Branch 5 taken 1076 times.
✓ Branch 6 taken 3728 times.
✓ Branch 7 taken 44 times.
✓ Branch 8 taken 3728 times.
✓ Branch 9 taken 1076 times.
✓ Branch 10 taken 3140 times.
✓ Branch 11 taken 588 times.
✓ Branch 12 taken 3140 times.
✓ Branch 13 taken 1076 times.
✓ Branch 14 taken 72 times.
✓ Branch 15 taken 3068 times.
✓ Branch 16 taken 106951 times.
✓ Branch 17 taken 2072 times.
218046 else if (is1("db") || is1("dw") || is1("dl") || is1("dd"))
1519 {
1520 106951 int len = 0;
1521
2/6
✓ Branch 0 taken 213902 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 213902 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
213902 if (!confirmqpar(par)) asar_throw_error(0, error_type_block, error_id_mismatched_parentheses);
1522
5/6
✓ Branch 0 taken 213902 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106951 times.
✓ Branch 3 taken 106951 times.
✓ Branch 4 taken 106599 times.
✓ Branch 5 taken 352 times.
213902 if (is1("db")) len=1;
1523
5/6
✓ Branch 0 taken 213902 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106951 times.
✓ Branch 3 taken 106951 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 106929 times.
213902 if (is1("dw")) len=2;
1524
5/6
✓ Branch 0 taken 213902 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106951 times.
✓ Branch 3 taken 106951 times.
✓ Branch 4 taken 294 times.
✓ Branch 5 taken 106657 times.
213902 if (is1("dl")) len=3;
1525
5/6
✓ Branch 0 taken 213902 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106951 times.
✓ Branch 3 taken 106951 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 106915 times.
213902 if (is1("dd")) len=4;
1526
1/2
✓ Branch 0 taken 213902 times.
✗ Branch 1 not taken.
213902 autoptr<char**> pars=qpsplit(par, ",");
1527
2/2
✓ Branch 0 taken 214616 times.
✓ Branch 1 taken 213892 times.
428508 for (int i=0;pars[i];i++)
1528 {
1529
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 214448 times.
214616 if (pars[i][0]=='"')
1530 {
1531
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 84 times.
168 if (!strcmp(pars[i],"\"STAR\"") && !emulatexkas)
1532 asar_throw_warning(0, warning_id_xkas_patch);
1533
3/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✓ Branch 3 taken 168 times.
786 for (char * str=const_cast<char*>(safedequote(pars[i]));*str;str++)
1534 {
1535
3/4
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 546 times.
✗ Branch 3 not taken.
618 if (len==1) write1(table.table[(size_t)(unsigned char) *str]);
1536
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
618 if (len==2) write2(table.table[(size_t)(unsigned char) *str]);
1537
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
618 if (len==3) write3(table.table[(size_t)(unsigned char) *str]);
1538
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
618 if (len==4) write4(table.table[(size_t)(unsigned char) *str]);
1539 }
1540 }
1541 else
1542 {
1543 107224 const char * math=pars[i];
1544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214448 times.
214448 if (math[0]=='#') math++;
1545
4/4
✓ Branch 0 taken 71482 times.
✓ Branch 1 taken 142966 times.
✓ Branch 2 taken 71472 times.
✓ Branch 3 taken 10 times.
214448 unsigned int num=(pass==2)?getnum(math):0;
1546
3/4
✓ Branch 0 taken 213752 times.
✓ Branch 1 taken 686 times.
✓ Branch 2 taken 106876 times.
✗ Branch 3 not taken.
214438 if (len == 1) write1(num);
1547
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 214400 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
214438 if (len == 2) write2(num);
1548
3/4
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 213856 times.
✓ Branch 2 taken 582 times.
✗ Branch 3 not taken.
214438 if (len == 3) write3(num);
1549
3/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 214372 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
214438 if (len == 4) write4(num);
1550 }
1551 }
1552
1/2
✓ Branch 0 taken 213892 times.
✗ Branch 1 not taken.
213892 add_addr_to_line(addrToLinePos);
1553 213902 }
1554
6/6
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 3634 times.
✓ Branch 2 taken 378 times.
✓ Branch 3 taken 132 times.
✓ Branch 4 taken 132 times.
✓ Branch 5 taken 123 times.
4144 else if (numwords==3 && !stricmp(word[1], "="))
1555 {
1556
5/8
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
246 if (word[0][0]=='\'' && word[0][1] && word[0][2]=='\'' && word[0][3]=='\0')
1557 {
1558
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 table.table[(unsigned char)word[0][1]]=getnum(word[2]);
1559
3/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
150 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
1560 150 return;
1561 }
1562 // randomdude999: int cast b/c i'm too lazy to also mess with making setlabel()
1563 // unsigned, besides it wouldn't matter anyways.
1564
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 int num=(int)getnum(word[2]);
1565
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
96 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_label_cross_assignment);
1566
1567 90 const char* newlabelname = word[0];
1568 45 bool ismacro = false;
1569
1570
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 84 times.
90 if (newlabelname[0] == '?')
1571 {
1572 3 ismacro = true;
1573 6 newlabelname++;
1574 }
1575
1576
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
48 if (ismacro && macrorecursion == 0)
1577 {
1578 asar_throw_error(0, error_type_block, error_id_macro_label_outside_of_macro);
1579 }
1580
1581
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
90 if (!confirmname(newlabelname)) asar_throw_error(0, error_type_block, error_id_invalid_label_name);
1582
1583 45 string completename;
1584
1585
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 84 times.
90 if (ismacro)
1586 {
1587
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
9 completename += STR":macro_" + dec(calledmacros) + "_";
1588 }
1589
1590
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
90 completename += newlabelname;
1591
1592
2/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
90 setlabel(ns + completename, num, true);
1593 135 }
1594
3/4
✓ Branch 0 taken 3898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3740 times.
✓ Branch 3 taken 158 times.
3898 else if (assemblemapper(word, numwords)) {}
1595
6/6
✓ Branch 0 taken 3050 times.
✓ Branch 1 taken 690 times.
✓ Branch 2 taken 1525 times.
✓ Branch 3 taken 1525 times.
✓ Branch 4 taken 370 times.
✓ Branch 5 taken 1500 times.
3740 else if (is1("org"))
1596 {
1597
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
740 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
1598 740 freespaceend();
1599
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 unsigned int num=getnum(par);
1600
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
740 if (forwardlabel) asar_throw_error(0, error_type_block, error_id_org_label_forward);
1601
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
740 if (num&~0xFFFFFF) asar_throw_error(1, error_type_block, error_id_snes_address_out_of_bounds, hex6(num).data());
1602
5/10
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 474 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 260 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 480 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
740 if ((mapper==lorom || mapper==exlorom) && (num&0x408000)==0x400000 && (num&0x700000)!=0x700000) asar_throw_warning(0, warning_id_set_middle_byte);
1603 //if (fastrom) num|=0x800000;
1604 740 snespos=(int)num;
1605 740 realsnespos=(int)num;
1606 740 startpos=(int)num;
1607 740 realstartpos=(int)num;
1608 }
1609 #define ret_error(errid) { asar_throw_error(0, error_type_block, errid); return; }
1610 #define ret_error_params(errid, ...) { asar_throw_error(0, error_type_block, errid, __VA_ARGS__); return; }
1611
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 2922 times.
3000 else if (is("struct"))
1612 {
1613 //verifysnespos();
1614
2/6
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
78 if (in_struct || in_sub_struct) ret_error(error_id_nested_struct);
1615
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (numwords < 2) ret_error(error_id_missing_struct_params);
1616
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (numwords > 4) ret_error(error_id_too_many_struct_params);
1617
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (!confirmname(word[1])) ret_error(error_id_invalid_struct_name);
1618
1619
6/10
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 39 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
78 if (structs.exists(word[1]) && pass == 0) ret_error_params(error_id_struct_redefined, word[1]);
1620
1621 78 static_struct = false;
1622 78 old_snespos = snespos;
1623 78 old_startpos = startpos;
1624 78 old_optimizeforbank = optimizeforbank;
1625 39 unsigned int base = 0;
1626
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (numwords == 3)
1627 {
1628 30 static_struct = true;
1629
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 base = getnum(word[2]);
1630
1631
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (foundlabel && !foundlabel_static) static_struct = false;
1632 }
1633
1634 78 bool old_in_struct = in_struct;
1635 78 bool old_in_sub_struct = in_sub_struct;
1636
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 12 times.
78 in_struct = numwords == 2 || numwords == 3;
1637 78 in_sub_struct = numwords == 4;
1638
1639 #define ret_error_cleanup(errid) { in_struct = old_in_struct; in_sub_struct = old_in_sub_struct; asar_throw_error(0, error_type_block, errid); return; }
1640 #define ret_error_params_cleanup(errid, ...) { in_struct = old_in_struct; in_sub_struct = old_in_sub_struct; asar_throw_error(0, error_type_block, errid, __VA_ARGS__); return; }
1641
1642
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (numwords == 3)
1643 {
1644
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (base&~0xFFFFFF) ret_error_params_cleanup(error_id_snes_address_out_of_bounds, hex6((unsigned int)base).data());
1645 30 snespos = (int)base;
1646 30 startpos = (int)base;
1647 }
1648
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 else if (numwords == 4)
1649 {
1650
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if (strcasecmp(word[2], "extends")) ret_error_cleanup(error_id_missing_extends);
1651
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if (!confirmname(word[3])) ret_error_cleanup(error_id_struct_invalid_parent_name);
1652
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 string tmp_struct_parent = word[3];
1653
1654
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if (!structs.exists(tmp_struct_parent)) ret_error_params_cleanup(error_id_struct_not_found, tmp_struct_parent.data());
1655
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 snes_struct structure = structs.find(tmp_struct_parent);
1656
1657 24 static_struct = structure.is_static;
1658
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 struct_parent = tmp_struct_parent;
1659 24 snespos = structure.base_end;
1660 24 startpos = structure.base_end;
1661
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 }
1662
1663
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 push_pc();
1664
1665 78 optimizeforbank = -1;
1666
1667
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 struct_name = word[1];
1668 78 struct_base = snespos;
1669 78 realsnespos = 0;
1670 78 realstartpos = 0;
1671
1672
2/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
78 setlabel(struct_name, snespos, static_struct);
1673
1674 #undef ret_error_cleanup
1675 #undef ret_error_params_cleanup
1676 }
1677
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 2844 times.
2922 else if (is("endstruct"))
1678 {
1679
3/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
78 if (numwords != 1 && numwords != 3) ret_error(error_id_invalid_endstruct_count);
1680
5/8
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
78 if (numwords == 3 && strcasecmp(word[1], "align")) ret_error(error_id_expected_align);
1681
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
78 if (!in_struct && !in_sub_struct) ret_error(error_id_endstruct_without_struct);
1682
1683
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
78 int alignment = numwords == 3 ? (int)getnum(word[2]) : 1;
1684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if (alignment < 1) ret_error(error_id_alignment_too_small);
1685
1686 39 snes_struct structure;
1687 78 structure.base_end = snespos;
1688 78 structure.struct_size = alignment * ((snespos - struct_base + alignment - 1) / alignment);
1689 78 structure.object_size = structure.struct_size;
1690 78 structure.is_static = static_struct;
1691
1692
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 24 times.
78 if (in_struct)
1693 {
1694
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
54 structs.create(struct_name) = structure;
1695 }
1696
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 else if (in_sub_struct)
1697 {
1698 12 snes_struct parent;
1699
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 parent = structs.find(struct_parent);
1700
1701
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (parent.object_size < parent.struct_size + structure.struct_size) {
1702 24 parent.object_size = parent.struct_size + structure.struct_size;
1703 }
1704
1705
4/8
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
24 structs.create(struct_parent + "." + struct_name) = structure;
1706
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 structs.create(struct_parent) = parent;
1707 12 }
1708
1709
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
78 pop_pc();
1710 78 in_struct = false;
1711 78 in_sub_struct = false;
1712 78 snespos = old_snespos;
1713 78 startpos = old_startpos;
1714 78 optimizeforbank = old_optimizeforbank;
1715 78 static_struct = false;
1716 39 }
1717 #undef ret_error
1718
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2832 times.
2844 else if(is("spcblock"))
1719 {
1720 //banned features when active: org, freespace(and variants), arch, mapper,namespace,pushns
1721
2/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12 if(in_struct || in_sub_struct) asar_throw_error(0, error_type_block, error_id_spcblock_inside_struct);
1722
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(numwords < 2) asar_throw_error(0, error_type_block, error_id_spcblock_too_few_args);
1723
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(numwords > 4) asar_throw_error(0, error_type_block, error_id_spcblock_too_many_args);
1724
1725
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 spcblock.destination = getnum(par);
1726 12 spcblock.type = spcblock_nspc;
1727
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 spcblock.macro_name = "";
1728
1729
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12 if (spcblock.destination&~0xFFFF) asar_throw_error(0, error_type_block, error_id_snes_address_out_of_bounds, hex6(spcblock.destination).data());
1730
1731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(numwords == 3)
1732 {
1733 if(!stricmp(word[2], "nspc")) spcblock.type = spcblock_nspc;
1734 else if(!stricmp(word[2], "custom")) asar_throw_error(0, error_type_block, error_id_custom_spcblock_missing_macro);
1735 else asar_throw_error(0, error_type_block, error_id_unknown_spcblock_type);
1736 }
1737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(numwords == 4)
1738 {
1739 if(!stricmp(word[2], "custom")) spcblock.type = spcblock_custom;
1740 else asar_throw_error(0, error_type_block, error_id_extra_spcblock_arg_for_type);
1741
1742 if(macros.exists(word[3]))
1743 {
1744 macrodata *macro = macros.find(word[3]);
1745 if(!macro->variadic) asar_throw_error(0, error_type_block, error_id_spcblock_macro_must_be_varadic);
1746 if(macro->numargs != 3) asar_throw_error(0, error_type_block, error_id_spcblock_macro_invalid_static_args);
1747 spcblock.macro_name = word[3];
1748 }
1749 else asar_throw_error(0, error_type_block, error_id_spcblock_macro_doesnt_exist);
1750 }
1751
1752
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(spcblock.type)
1753 {
1754 12 case spcblock_nspc:
1755 12 spcblock.size_address=realsnespos;
1756
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 write2(0x0000);
1757
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 write2(spcblock.destination);
1758 12 snespos=(int)spcblock.destination;
1759 12 startpos=(int)spcblock.destination;
1760 12 spcblock.execute_address = -1u;
1761
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 add_addr_to_line(addrToLinePos);
1762 6 break;
1763 case spcblock_custom:
1764 //this is a todo that probably won't be ready for 1.9
1765 //mostly so we can leverage some cleanups we make in 2.0 for practicality
1766 asar_throw_error(0, error_type_block, error_id_spcblock_custom_types_incomplete);
1767 push_pc();
1768 spcblock.old_mapper = mapper;
1769 mapper = norom;
1770 break;
1771 default:
1772 asar_throw_error(0, error_type_fatal, error_id_internal_error, "invalid spcblock type");
1773 }
1774
1775
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ns_backup = ns;
1776
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 ns = STR":SPCBLOCK:_" + ns_backup;
1777 12 in_spcblock = true;
1778 }
1779
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2820 times.
2832 else if(is("endspcblock"))
1780 {
1781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(!in_spcblock) asar_throw_error(0, error_type_block, error_id_endspcblock_without_spcblock);
1782
1783
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(spcblock.type)
1784 {
1785 12 case spcblock_nspc:
1786
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8 times.
12 if (pass==2)
1787 {
1788 4 int pcpos=snestopc(spcblock.size_address&0xFFFFFF);
1789
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if (pcpos<0) asar_throw_error(2, error_type_block, error_id_snes_address_doesnt_map_to_rom, hex6((unsigned int)realsnespos).data());
1790 4 int num=snespos-startpos;
1791
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 writeromdata_byte(pcpos, (unsigned char)num);
1792
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 writeromdata_byte(pcpos+1, (unsigned char)(num >> 8));
1793 }
1794
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if (numwords == 3)
1795 {
1796
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (strcmp(par, "execute")) asar_throw_error(0, error_type_null, error_id_invalid_endspcblock_arg, par);
1797 else
1798 {
1799
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write2(0x0000);
1800
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 write2((unsigned int)getnum64(word[2]));
1801 }
1802 }
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if (numwords != 1)
1804 {
1805 asar_throw_error(0, error_type_null, error_id_unknown_endspcblock_format);
1806 }
1807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(spcblock.execute_address != -1u)
1808 {
1809 // Legacy case, will be removed with Asar 2.0.
1810 write2(0x0000);
1811 write2((unsigned int)spcblock.execute_address);
1812 }
1813 6 break;
1814 case spcblock_custom:
1815 mapper = spcblock.old_mapper;
1816 pop_pc();
1817 break;
1818 default:
1819 asar_throw_error(0, error_type_fatal, error_id_internal_error, "invalid spcblock type");
1820 }
1821
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ns = ns_backup;
1822 12 in_spcblock = false;
1823 }
1824 // Remember to also remove execute_address entirely from spcblock once removing this deprecated command.
1825
5/6
✓ Branch 0 taken 2274 times.
✓ Branch 1 taken 546 times.
✓ Branch 2 taken 1137 times.
✓ Branch 3 taken 1137 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1410 times.
2820 else if (is1("startpos"))
1826 {
1827 asar_throw_warning(0, warning_id_feature_deprecated, "startpos", "Use the optional argument to \"endspcblock\"");
1828 if(!in_spcblock) asar_throw_error(0, error_type_block, error_id_startpos_without_spcblock);
1829 spcblock.execute_address=getnum64(par);
1830 }
1831
6/6
✓ Branch 0 taken 2274 times.
✓ Branch 1 taken 546 times.
✓ Branch 2 taken 1137 times.
✓ Branch 3 taken 1137 times.
✓ Branch 4 taken 42 times.
✓ Branch 5 taken 1368 times.
2820 else if (is1("base"))
1832 {
1833
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 27 times.
84 if (!stricmp(par, "off"))
1834 {
1835 30 snespos=realsnespos;
1836 30 startpos=realstartpos;
1837 30 return;
1838 }
1839
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 unsigned int num=getnum(par);
1840
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (forwardlabel) asar_throw_error(0, error_type_block, error_id_base_label_invalid);
1841
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if (num&~0xFFFFFF) asar_throw_error(1, error_type_block, error_id_snes_address_out_of_bounds, hex6((unsigned int)num).data());
1842 54 snespos=(int)num;
1843 54 startpos=(int)num;
1844 54 optimizeforbank=-1;
1845 }
1846
6/6
✓ Branch 0 taken 2190 times.
✓ Branch 1 taken 546 times.
✓ Branch 2 taken 1095 times.
✓ Branch 3 taken 1095 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 1362 times.
2736 else if (is1("dpbase"))
1847 {
1848
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 unsigned int num=(int)getnum(par);
1849
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if (forwardlabel) asar_throw_error(0, error_type_block, error_id_base_label_invalid);
1850
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12 if (num&~0xFF00) asar_throw_error(1, error_type_block, error_id_bad_dp_base, hex6((unsigned int)num).data());
1851 12 dp_base = (int)num;
1852 }
1853
6/6
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 111 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 1326 times.
2724 else if (is2("optimize"))
1854 {
1855
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 24 times.
72 if (!stricmp(par, "dp"))
1856 {
1857
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
24 if (!stricmp(word[2], "none"))
1858 {
1859 12 optimize_dp = optimize_dp_flag::NONE;
1860 12 return;
1861 }
1862
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
12 if (!stricmp(word[2], "ram"))
1863 {
1864 6 optimize_dp = optimize_dp_flag::RAM;
1865 6 return;
1866 }
1867
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
6 if (!stricmp(word[2], "always"))
1868 {
1869 6 optimize_dp = optimize_dp_flag::ALWAYS;
1870 6 return;
1871 }
1872 asar_throw_error(1, error_type_block, error_id_bad_dp_optimize, word[2]);
1873 }
1874
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
48 if (!stricmp(par, "address"))
1875 {
1876
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 18 times.
48 if (!stricmp(word[2], "default"))
1877 {
1878 12 optimize_address = optimize_address_flag::DEFAULT;
1879 12 return;
1880 }
1881
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
36 if (!stricmp(word[2], "ram"))
1882 {
1883 18 optimize_address = optimize_address_flag::RAM;
1884 18 return;
1885 }
1886
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 if (!stricmp(word[2], "mirrors"))
1887 {
1888 18 optimize_address = optimize_address_flag::MIRRORS;
1889 18 return;
1890 }
1891 asar_throw_error(1, error_type_block, error_id_bad_address_optimize, word[2]);
1892 }
1893 asar_throw_error(1, error_type_block, error_id_bad_optimize, par);
1894 }
1895
5/6
✓ Branch 0 taken 2178 times.
✓ Branch 1 taken 474 times.
✓ Branch 2 taken 1089 times.
✓ Branch 3 taken 1089 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1326 times.
2652 else if (is1("bank"))
1896 {
1897 if (!stricmp(par, "auto"))
1898 {
1899 optimizeforbank=-1;
1900 return;
1901 }
1902 if (!stricmp(par, "noassume"))
1903 {
1904 optimizeforbank=0x100;
1905 return;
1906 }
1907 unsigned int num=getnum(par);
1908 //if (forwardlabel) error(0, "bank Label is not valid");
1909 //if (foundlabel) num>>=16;
1910 if (num&~0x0000FF) asar_throw_error(1, error_type_block, error_id_snes_address_out_of_bounds, hex6((unsigned int)num).data());
1911 optimizeforbank=(int)num;
1912 }
1913
7/8
✓ Branch 0 taken 2652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1806 times.
✓ Branch 3 taken 846 times.
✓ Branch 4 taken 903 times.
✓ Branch 5 taken 903 times.
✓ Branch 6 taken 465 times.
✓ Branch 7 taken 861 times.
2652 else if (is("freespace") || is("freecode") || is("freedata"))
1914 {
1915
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
930 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
1916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
930 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
1917 465 string parstr;
1918
3/4
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
930 if (numwords==1) parstr="\n";//crappy hack: impossible character to cut out extra commas
1919
2/4
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396 times.
✗ Branch 3 not taken.
792 else if (numwords==2) parstr=word[1];
1920 else asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1921
5/8
✓ Branch 0 taken 846 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 423 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 423 times.
✗ Branch 7 not taken.
1353 if (is("freecode")) parstr=STR"ram,"+parstr;
1922
5/8
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 846 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42 times.
✗ Branch 7 not taken.
972 if (is("freedata")) parstr=STR"noram,"+parstr;
1923
1/2
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
930 autoptr<char**> pars=split(parstr.temp_raw(), ",");
1924 930 unsigned char fsbyte = default_freespacebyte;
1925 465 int useram=-1;
1926 465 bool fixedpos=false;
1927 465 bool align=false;
1928 465 bool leakwarn=true;
1929
2/2
✓ Branch 0 taken 1860 times.
✓ Branch 1 taken 930 times.
2790 for (int i=0;pars[i];i++)
1930 {
1931
2/2
✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 138 times.
1860 if (pars[i][0]=='\n') {}
1932
4/4
✓ Branch 0 taken 1284 times.
✓ Branch 1 taken 438 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 438 times.
1722 else if (!stricmp(pars[i], "ram"))
1933 {
1934
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 846 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
846 if (useram!=-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1935 423 useram=1;
1936 }
1937
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 396 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 396 times.
876 else if (!stricmp(pars[i], "noram"))
1938 {
1939
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if (useram!=-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1940 42 useram=0;
1941 }
1942
6/8
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396 times.
✓ Branch 3 taken 396 times.
✓ Branch 4 taken 396 times.
✓ Branch 5 taken 396 times.
✓ Branch 6 taken 396 times.
✗ Branch 7 not taken.
792 else if (!stricmp(pars[i], "static") || !stricmp(pars[i], "fixed"))
1943 {
1944 if (!stricmp(pars[i], "fixed")) asar_throw_warning(0, warning_id_feature_deprecated, "freespace/code/data fixed", "freespace/code/data static");
1945 if (fixedpos) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1946 fixedpos=true;
1947 }
1948
4/4
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 393 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 393 times.
792 else if (!stricmp(pars[i], "align"))
1949 {
1950
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (align) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1951 3 align=true;
1952 }
1953
2/4
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 393 times.
✗ Branch 3 not taken.
786 else if (!stricmp(pars[i], "cleaned"))
1954 {
1955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
786 if (!leakwarn) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1956 393 leakwarn=false;
1957 }
1958 else
1959 {
1960 asar_throw_warning(0, warning_id_feature_deprecated, "specifying the freespacebyte in the freespace command", "use the separate freespacebyte command");
1961 fsbyte = (unsigned char)getnum(pars[i]);
1962 }
1963 }
1964
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
930 if (useram==-1) asar_throw_error(0, error_type_block, error_id_invalid_freespace_request);
1965
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
930 if (mapper == norom) asar_throw_error(0, error_type_block, error_id_no_freespace_norom);
1966 930 freespaceend();
1967
1/2
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
930 freespaceid=getfreespaceid();
1968 930 freespacebyte[freespaceid] = fsbyte;
1969 930 freespace_is_freecode = (useram != 0);
1970
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 620 times.
930 if (pass==0) snespos=(freespaceid<<24)|0x8000;
1971
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 620 times.
930 if (pass==1)
1972 {
1973
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
310 if (fixedpos && freespaceorgpos[freespaceid]<0)
1974 {
1975 freespacepos[freespaceid]=0x008000;
1976 freespaceleak[freespaceid]=false;//mute some other errors
1977 asar_throw_error(1, error_type_block, error_id_static_freespace_autoclean);
1978 }
1979
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
155 if (fixedpos && freespaceorgpos[freespaceid]) freespacepos[freespaceid]=snespos=(freespaceid<<24)|freespaceorgpos[freespaceid];
1980
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 else freespacepos[freespaceid]=snespos=(freespaceid<<24)|getsnesfreespace(freespacelen[freespaceid], (useram != 0), true, true, align, freespacebyte[freespaceid]);
1981 }
1982
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 620 times.
930 if (pass==2)
1983 {
1984
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
310 if (fixedpos && freespaceorgpos[freespaceid]==-1) return;//to kill some errors
1985 310 snespos=(freespaceid<<24)|freespacepos[freespaceid];
1986
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 resizerats(snespos&0xFFFFFF, freespacelen[freespaceid]);
1987
3/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
310 if (freespaceleak[freespaceid] && leakwarn) asar_throw_warning(2, warning_id_freespace_leaked);
1988
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
310 if (fixedpos && freespaceorgpos[freespaceid]>0 && freespacelen[freespaceid]>freespaceorglen[freespaceid])
1989 asar_throw_error(2, error_type_block, error_id_static_freespace_growing);
1990 310 freespaceuse+=8+freespacelen[freespaceid];
1991
1992 // add a mapping for the start of the rats tag
1993
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 add_addr_to_line(snespos-8);
1994 }
1995 930 freespacestatic[freespaceid]=fixedpos;
1996
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
930 if (snespos < 0 && mapper == sa1rom) asar_throw_error(pass, error_type_fatal, error_id_no_freespace_in_mapped_banks, dec(freespacelen[freespaceid]).data());
1997
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
930 if (snespos < 0) asar_throw_error(pass, error_type_fatal, error_id_no_freespace, dec(freespacelen[freespaceid]).data());
1998 930 bytes+=8;
1999 930 freespacestart=snespos;
2000 930 startpos=snespos;
2001 930 realstartpos=snespos;
2002 930 realsnespos=snespos;
2003 930 optimizeforbank=-1;
2004 930 ratsmetastate=ratsmeta_allow;
2005
2/4
✓ Branch 0 taken 465 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465 times.
✗ Branch 3 not taken.
930 }
2006
6/6
✓ Branch 0 taken 1386 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 693 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 834 times.
1722 else if (is1("prot"))
2007 {
2008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2009
2/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if (!confirmqpar(par)) asar_throw_error(0, error_type_block, error_id_mismatched_parentheses);
2010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (!ratsmetastate) asar_throw_error(2, error_type_block, error_id_prot_not_at_freespace_start);
2011
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 42 times.
54 if (ratsmetastate==ratsmeta_used) step(-5);
2012 27 int num;
2013
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 autoptr<char**> pars=qpsplit(par, ",", &num);
2014
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('P');
2015
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('R');
2016
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('O');
2017
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('T');
2018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (num * 3 > 255) asar_throw_error(0, error_type_block, error_id_prot_too_many_entries);
2019
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 write1((unsigned int)(num*3));
2020
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 54 times.
120 for (int i=0;i<num;i++)
2021 {
2022 //int num=getnum(pars[i]);
2023 66 const char * labeltest=pars[i];
2024
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 string testlabel = labeltest;
2025
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int labelnum=(int)labelval(&labeltest).pos;
2026
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if (*labeltest) asar_throw_error(0, error_type_block, error_id_label_not_found, testlabel.data());
2027
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 write3((unsigned int)labelnum);
2028
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 44 times.
66 if (pass==1) freespaceleak[labelnum >>24]=false;
2029 66 }
2030
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('S');
2031
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('T');
2032
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('O');
2033
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1('P');
2034
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 write1(0);
2035 54 ratsmetastate=ratsmeta_used;
2036
2037
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 add_addr_to_line(addrToLinePos);
2038 54 }
2039
15/18
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 1332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✓ Branch 5 taken 1518 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 114 times.
✓ Branch 8 taken 1332 times.
✓ Branch 9 taken 222 times.
✓ Branch 10 taken 1332 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 36 times.
✓ Branch 13 taken 1518 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 36 times.
✓ Branch 16 taken 57 times.
✓ Branch 17 taken 777 times.
1668 else if (is1("autoclean") || is2("autoclean") || is1("autoclear") || is2("autoclear"))
2040 {
2041
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2042
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 114 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 57 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
114 if (is1("autoclear") || is2("autoclear")) asar_throw_warning(0, warning_id_autoclear_deprecated);
2043
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (numwords==3)
2044 {
2045
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if ((unsigned int)snespos & 0xFF000000) asar_throw_error(0, error_type_block, error_id_autoclean_in_freespace);
2046 114 const char * labeltest = word[2];
2047
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 string testlabel = labeltest;
2048
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 int num=(int)labelval(&labeltest).pos;
2049
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114 if (*labeltest) asar_throw_error(0, error_type_block, error_id_label_not_found, testlabel.data());
2050 57 unsigned char targetid=(unsigned char)(num>>24);
2051
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 76 times.
114 if (pass==1) freespaceleak[targetid]=false;
2052 65 auto is_freespace_reused = [](int ratsloc) -> bool
2053 {
2054
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
32 for (int i = 0; i < freespaceidnext; i++)
2055 {
2056
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
18 if (freespacepos[i] != -1 && (freespacepos[i] & 0xFFFFFF) == ratsloc) {
2057 1 return true;
2058 }
2059 }
2060 7 return false;
2061 };
2062 114 num&=0xFFFFFF;
2063
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
114 if (strlen(par)>3 && !stricmp(par+3, ".l")) par[3]=0;
2064
6/8
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
114 if (!stricmp(par, "JSL") || !stricmp(par, "JML"))
2065 {
2066 114 int orgpos=read3(snespos+1);
2067 114 int ratsloc=freespaceorgpos[targetid];
2068
4/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 45 times.
114 int firstbyte = ((!stricmp(par, "JSL")) ? 0x22 : 0x5C);
2069 114 int pcpos=snestopc(snespos);
2070
4/6
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 66 times.
114 if (/*pass==1 && */pcpos>=0 && pcpos<romlen_r && romdata_r[pcpos]==firstbyte)
2071 {
2072
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 ratsloc=ratsstart(orgpos)+8;
2073 48 freespaceorglen[targetid]=read2(ratsloc-4)+1;
2074
3/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 24 times.
48 if (!freespacestatic[targetid] && pass == 1)
2075 {
2076
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
16 if (!is_freespace_reused(ratsloc)) removerats(orgpos, freespacebyte[targetid]);
2077 }
2078 }
2079
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 15 times.
66 else if (ratsloc<0) ratsloc=0;
2080
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 write1((unsigned int)firstbyte);
2081
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 write3((unsigned int)num);
2082
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 76 times.
114 if (pass==2)
2083 {
2084
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 int start=ratsstart(num);
2085
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
38 if (start>=num || start<0)
2086 {
2087 asar_throw_error(2, error_type_block, error_id_autoclean_label_at_freespace_end);
2088 }
2089
2090
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 add_addr_to_line(addrToLinePos);
2091 }
2092 //freespaceorglen[targetid]=read2(ratsloc-4)+1;
2093 114 freespaceorgpos[targetid]=ratsloc;
2094 57 }
2095 else if (!stricmp(par, "dl"))
2096 {
2097 int orgpos=read3(snespos);
2098 int ratsloc=freespaceorgpos[targetid];
2099 int start=ratsstart(num);
2100 if (pass==1 && num>=0)
2101 {
2102 ratsloc=ratsstart(orgpos)+8;
2103 if (!freespacestatic[targetid] && !is_freespace_reused(ratsloc)) removerats(orgpos, freespacebyte[targetid]);
2104 }
2105 else if (!ratsloc) ratsloc=0;
2106 if ((start==num || start<0) && pass==2)
2107 asar_throw_error(2, error_type_block, error_id_autoclean_label_at_freespace_end);
2108 write3((unsigned int)num);
2109 freespaceorgpos[targetid]=ratsloc;
2110 freespaceorglen[targetid]=read2(ratsloc-4)+1;
2111
2112 add_addr_to_line(addrToLinePos);
2113 }
2114 else asar_throw_error(0, error_type_block, error_id_broken_autoclean);
2115 114 }
2116 else if (pass==0) removerats((int)getnum(word[1]), default_freespacebyte);
2117 }
2118
5/6
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 666 times.
✓ Branch 3 taken 666 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 777 times.
1554 else if (is1("freespacebyte"))
2119 {
2120 default_freespacebyte = getnum(word[1]);
2121 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2122 }
2123
6/6
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 1404 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 75 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 774 times.
1554 else if (is0("pushpc"))
2124 {
2125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
2126
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].arch=arch;
2127
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snespos=snespos;
2128
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesstart=startpos;
2129
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesposreal=realsnespos;
2130
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].snesstartreal=realstartpos;
2131
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freeid=freespaceid;
2132
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freeex=freespaceextra;
2133
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 pushpc[pushpcnum].freest=freespacestart;
2134 6 pushpcnum++;
2135 6 snespos=(int)0xFFFFFFFF;
2136 6 startpos= (int)0xFFFFFFFF;
2137 6 realsnespos= (int)0xFFFFFFFF;
2138 6 realstartpos= (int)0xFFFFFFFF;
2139 }
2140
6/6
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1404 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 771 times.
1548 else if (is0("pullpc"))
2141 {
2142
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (!pushpcnum) asar_throw_error(0, error_type_block, error_id_pullpc_without_pushpc);
2143 6 pushpcnum--;
2144 6 freespaceend();
2145
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (arch != pushpc[pushpcnum].arch) asar_throw_error(0, error_type_block, error_id_pullpc_different_arch);
2146
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 snespos=pushpc[pushpcnum].snespos;
2147
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 startpos=pushpc[pushpcnum].snesstart;
2148
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 realsnespos=pushpc[pushpcnum].snesposreal;
2149
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 realstartpos=pushpc[pushpcnum].snesstartreal;
2150
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespaceid=pushpc[pushpcnum].freeid;
2151
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespaceextra=pushpc[pushpcnum].freeex;
2152
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 freespacestart=pushpc[pushpcnum].freest;
2153 }
2154
6/6
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1404 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 69 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 768 times.
1542 else if (is0("pushbase"))
2155 {
2156
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
2157
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 basestack[basestacknum] = snespos;
2158 6 basestacknum++;
2159 }
2160
6/6
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 1404 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 765 times.
1536 else if (is0("pullbase"))
2161 {
2162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (!basestacknum) asar_throw_error(0, error_type_block, error_id_pullbase_without_pushbase);
2163 6 basestacknum--;
2164
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 snespos = basestack[basestacknum];
2165
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 startpos = basestack[basestacknum];
2166
2167
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (snespos != realstartpos)
2168 {
2169 6 optimizeforbank = -1;
2170 }
2171 }
2172
6/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 1404 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 63 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 759 times.
1530 else if (is0("pushns"))
2173 {
2174
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2175
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
12 pushns[pushnsnum].ns = ns;
2176
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 for(int i = 0; i < namespace_list.count; i++)
2177 {
2178
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 pushns[pushnsnum].namespace_list.append(namespace_list[i]);
2179 }
2180
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 pushns[pushnsnum].nested_namespaces = nested_namespaces;
2181 12 pushnsnum++;
2182
2183
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2184
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ns = "";
2185 12 nested_namespaces = false;
2186 }
2187
6/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 1404 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 753 times.
1518 else if (is0("pullns"))
2188 {
2189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2190
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if (!pushnsnum) asar_throw_error(0, error_type_block, error_id_pullns_without_pushns);
2191 12 pushnsnum--;
2192
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
12 ns = pushns[pushnsnum].ns;
2193
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 nested_namespaces = pushns[pushnsnum].nested_namespaces;
2194
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2195
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 6 times.
36 for(int i = 0; i < pushns[pushnsnum].namespace_list.count; i++)
2196 {
2197
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
24 namespace_list.append(pushns[pushnsnum].namespace_list[i]);
2198 }
2199 }
2200
9/10
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 1206 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 1344 times.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 81 times.
✓ Branch 9 taken 672 times.
1506 else if (is1("namespace") || is2("namespace"))
2201 {
2202
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2203 81 bool leave = false;
2204
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
162 if (par)
2205 {
2206
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 57 times.
162 if (!stricmp(par, "off"))
2207 {
2208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (word[2]) asar_throw_error(0, error_type_block, error_id_invalid_namespace_use);
2209 24 leave = true;
2210 }
2211
4/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 39 times.
114 else if (!stricmp(par, "nested"))
2212 {
2213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36 if (!word[2]) asar_throw_error(0, error_type_block, error_id_invalid_namespace_use);
2214
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
36 else if (!stricmp(word[2], "on")) nested_namespaces = true;
2215
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 else if (!stricmp(word[2], "off")) nested_namespaces = false;
2216 }
2217 else
2218 {
2219
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (word[2]) asar_throw_error(0, error_type_block, error_id_invalid_namespace_use);
2220
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 const char * tmpstr= safedequote(par);
2221
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
78 if (!confirmname(tmpstr)) asar_throw_error(0, error_type_block, error_id_invalid_namespace_name);
2222
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 48 times.
78 if (!nested_namespaces)
2223 {
2224
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 namespace_list.reset();
2225 }
2226
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
78 namespace_list.append(STR tmpstr);
2227 }
2228 }
2229 else
2230 {
2231 leave = true;
2232 }
2233
2234
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 57 times.
81 if (leave)
2235 {
2236
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
48 if (nested_namespaces)
2237 {
2238
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 namespace_list.remove(namespace_list.count - 1);
2239 }
2240 else
2241 {
2242
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
12 namespace_list.reset();
2243 }
2244 }
2245
2246 // recompute ns
2247
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 ns = "";
2248
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 162 times.
354 for (int i = 0; i < namespace_list.count; i++)
2249 {
2250
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
192 ns += namespace_list[i];
2251
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
192 ns += STR"_";
2252 }
2253 }
2254
5/6
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 603 times.
✓ Branch 3 taken 603 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 672 times.
1344 else if (is1("warnpc"))
2255 {
2256 asar_throw_warning(0, warning_id_feature_deprecated, "warnpc", "use \"assert pc() <= $xxxxxx\" instead");
2257 unsigned int maxpos=getnum(par);
2258 if ((unsigned int)snespos & 0xFF000000) asar_throw_error(0, error_type_block, error_id_warnpc_in_freespace);
2259 if ((unsigned int)maxpos & 0xFF000000) asar_throw_error(0, error_type_block, error_id_warnpc_broken_param);
2260 if ((unsigned int)snespos > maxpos) asar_throw_error(0, error_type_block, error_id_warnpc_failed, hex6((unsigned int)snespos).data(), hex6((unsigned int)maxpos).data());
2261 if (warnxkas && (unsigned int)snespos == maxpos) asar_throw_warning(0, warning_id_xkas_warnpc_relaxed);
2262 if (emulatexkas && (unsigned int)snespos==maxpos) asar_throw_error(0, error_type_block, error_id_warnpc_failed_equal, hex6((unsigned int)snespos).data(), hex6((unsigned int)maxpos).data());
2263 }
2264
6/6
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 603 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 657 times.
1344 else if (is1("rep"))
2265 {
2266
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 int rep = (int)getnum64(par);
2267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if (foundlabel) asar_throw_error(0, error_type_block, error_id_rep_label);
2268
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if (rep<=1)
2269 {
2270
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(rep < 0){
2271
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "rep condition < 0", "You probably want conditionals");
2272 }
2273
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (emulatexkas)
2274 {
2275
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 asar_throw_warning(0, warning_id_feature_deprecated, "rep <= 1 xkas behaviour", "You probably want conditionals");
2276
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if (rep==0) rep=1;
2277
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
15 if (rep<0) rep=0;
2278 18 repeatnext=rep;
2279 18 return;
2280 }
2281 }
2282
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "rep X : {command}", "Use while loops, unrolled loops, pseudo opcodes or for loops");
2283 6 repeatnext=rep;
2284 }
2285 #ifdef SANDBOX
2286 else if (is("incsrc") || is("incbin") || is("table"))
2287 {
2288 asar_throw_error(0, error_type_block, error_id_command_disabled);
2289 }
2290 #endif
2291
6/6
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 588 times.
✓ Branch 3 taken 588 times.
✓ Branch 4 taken 309 times.
✓ Branch 5 taken 348 times.
1314 else if (is1("incsrc"))
2292 {
2293 309 string name;
2294
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 309 times.
618 if (warnxkas && (strchr(thisfilename, '/') || strchr(thisfilename, '\\')))
2295 asar_throw_warning(0, warning_id_xkas_incsrc_relative);
2296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
618 if (strchr(par, '\\'))
2297 {
2298 if (emulatexkas)
2299 {
2300 asar_throw_warning(0, warning_id_feature_deprecated, "xkas style paths", "convert paths to crossplatform style");
2301 for (int i=0;par[i];i++)
2302 {
2303 if (par[i]=='\\') par[i]='/';//let's just hope nobody finds I could just enable this for everything.
2304 }
2305 }
2306 #ifdef _WIN32
2307 else asar_throw_warning(0, warning_id_feature_deprecated, "windows specific paths", "convert paths to crossplatform style");
2308 #endif
2309 }
2310
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
618 if (emulatexkas) name= safedequote(par);
2311
3/6
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 309 times.
✗ Branch 5 not taken.
927 else name=STR safedequote(par);
2312
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 498 times.
618 assemblefile(name, false);
2313 618 }
2314
10/10
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 138 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 594 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 312 times.
696 else if (is1("incbin") || is3("incbin"))
2315 {
2316
3/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
72 if (numwords == 4 && strcmp(word[2], "->")) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2317 36 int len;
2318 36 int start=0;
2319 36 int end=0;
2320
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 30 times.
72 if (strqchr(par, ':'))
2321 {
2322 42 char * lengths=strqchr(par, ':');
2323 42 *lengths=0;
2324 42 lengths++;
2325
3/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 6 times.
42 if(strqpstr(lengths, ".."))
2326 {
2327 // new style ranges
2328
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 char* split = strqpstr(lengths, "..");
2329
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 string start_str(lengths, split-lengths);
2330
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 start = getnum(start_str);
2331
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
36 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2332
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 string end_str(split+2);
2333
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 end = getnum(end_str);
2334
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
30 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2335 42 }
2336 else
2337 {
2338
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "old style incbin ranges", "use the :start..end syntax instead");
2339
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (strchr(lengths, '"')) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2340
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(*lengths=='(') {
2341
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 char* tmp = strqpchr(lengths, '-');
2342
2/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if(!tmp || (*(tmp-1)!=')')) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2343
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
9 start = (int)getnum64(string(lengths+1, tmp-1-lengths-1));
2344 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2345 lengths = tmp;
2346 } else {
2347 start=(int)strtoul(lengths, &lengths, 16);
2348 }
2349 if (*lengths!='-') asar_throw_error(0, error_type_block, error_id_broken_incbin);
2350 lengths++;
2351 if(*lengths=='(') {
2352 char* tmp = strchr(lengths, '\0');
2353 if(*(tmp-1)!=')') asar_throw_error(0, error_type_block, error_id_broken_incbin);
2354 end = (int)getnum64(string(lengths+1, tmp-1-lengths-1));
2355 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2356 // no need to check end-of-string here
2357 } else {
2358 end=(int)strtoul(lengths, &lengths, 16);
2359 if (*lengths) asar_throw_error(0, error_type_block, error_id_broken_incbin);
2360 }
2361 }
2362 }
2363 27 string name;
2364
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 27 times.
54 if (warnxkas && (strchr(thisfilename, '/') || strchr(thisfilename, '\\')))
2365 asar_throw_warning(0, warning_id_xkas_incsrc_relative);
2366
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 48 times.
54 if (strchr(par, '\\'))
2367 {
2368
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (emulatexkas)
2369 {
2370
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "xkas style paths", "convert paths to crossplatform style");
2371
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 6 times.
120 for (int i=0;par[i];i++)
2372 {
2373
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 102 times.
114 if (par[i]=='\\') par[i]='/';//let's just hope nobody finds I could just enable this for everything.
2374 }
2375 }
2376 #ifdef _WIN32
2377 else asar_throw_warning(0, warning_id_feature_deprecated, "windows specific paths", "convert paths to crossplatform style");
2378 #endif
2379 }
2380
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
54 if (emulatexkas) name= safedequote(par);
2381
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
72 else name=STR safedequote(par);
2382 27 char * data;//I couldn't find a way to get this into an autoptr
2383
6/10
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6 times.
54 if (!readfile(name, thisfilename, &data, &len)) asar_throw_error(0, error_type_block, vfile_error_to_error_id(asar_get_last_io_error()), name.data());
2384
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
48 autoptr<char*> datacopy=data;
2385
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 if (!end) end=len;
2386
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 if(start < 0) asar_throw_error(0, error_type_block, error_id_file_offset_out_of_bounds, dec(start).data(), name.data());
2387
3/10
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
48 if (end < start || end > len || end < 0) asar_throw_error(0, error_type_block, error_id_file_offset_out_of_bounds, dec(end).data(), name.data());
2388
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 42 times.
48 if (numwords==4)
2389 {
2390
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "incbin with target location", "put an org before the incbin");
2391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!confirmname(word[3]))
2392 {
2393 int pos=(int)getnum(word[3]);
2394 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2395 int offset=snestopc(pos);
2396 if (offset + end - start > 0xFFFFFF) asar_throw_error(0, error_type_block, error_id_16mb_rom_limit);
2397 if (offset+end-start>romlen) romlen=offset+end-start;
2398 if (pass==2)
2399 {
2400 writeromdata(offset, data+start, end-start);
2401 add_addr_to_line(pos);
2402 }
2403 }
2404 else
2405 {
2406 int pos;
2407
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==0)
2408 {
2409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (end - start > 65536) asar_throw_error(0, error_type_block, error_id_incbin_64kb_limit);
2410
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 pos=getpcfreespace(end-start, false, true, false);
2411
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if (pos < 0) asar_throw_error(0, error_type_block, error_id_no_freespace, dec(end - start).data());
2412
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 int foundfreespaceid=getfreespaceid();
2413 2 freespacepos[foundfreespaceid]=pctosnes(pos)|(/*fastrom?0x800000:*/0x000000)|(foundfreespaceid <<24);
2414
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 setlabel(word[3], freespacepos[foundfreespaceid]);
2415
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata_bytes(pos, 0xFF, end-start);
2416 }
2417
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==1)
2418 {
2419
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 getfreespaceid();//nothing to do here, but we want to tick the counter
2420 }
2421
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if (pass==2)
2422 {
2423
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 int foundfreespaceid =getfreespaceid();
2424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (freespaceleak[foundfreespaceid]) asar_throw_warning(2, warning_id_freespace_leaked);
2425
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 writeromdata(snestopc(freespacepos[foundfreespaceid]&0xFFFFFF), data+start, end-start);
2426
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 add_addr_to_line((freespacepos[foundfreespaceid]&0xFFFFFF) - 8);
2427 2 freespaceuse+=8+end-start;
2428 }
2429 }
2430 }
2431 else
2432 {
2433
3/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 42 times.
108 for (int i=start;i<end;i++) write1((unsigned int)data[i]);
2434
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 add_addr_to_line(addrToLinePos);
2435 }
2436 54 }
2437
6/6
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 198 times.
624 else if (is("skip") || is("fill"))
2438 {
2439
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if(numwords != 2 && numwords != 3 && numwords != 5) asar_throw_error(0, error_type_block, error_id_unknown_command);
2440
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if(numwords > 2 && stricmp(word[1], "align")) asar_throw_error(0, error_type_block, error_id_unknown_command);
2441
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 if(numwords == 5 && stricmp(word[3], "offset")) asar_throw_error(0, error_type_block, error_id_unknown_command);
2442 int amount;
2443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(numwords > 2)
2444 {
2445 int alignment = getnum64(word[2]);
2446 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2447 int offset = 0;
2448 if(numwords==5)
2449 {
2450 offset = getnum64(word[4]);
2451 if(foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2452 }
2453 if(alignment > 0x800000) asar_throw_error(0, error_type_block, error_id_alignment_too_big);
2454 if(alignment < 1) asar_throw_error(0, error_type_block, error_id_alignment_too_small);
2455 if(alignment & (alignment-1)) asar_throw_error(0, error_type_block, error_id_invalid_alignment);
2456 // i just guessed this formula but it seems to work
2457 amount = (alignment - ((snespos - offset) & (alignment-1))) & (alignment-1);
2458 }
2459 else
2460 {
2461
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 amount = (int)getnum64(par);
2462
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
228 if (foundlabel && !foundlabel_static) asar_throw_error(0, error_type_block, error_id_no_labels_here);
2463 }
2464
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 30 times.
222 if(is("skip")) step(amount);
2465 else
2466 {
2467
3/4
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 30 times.
288 for(int i=0; i < amount; i++) write1(fillbyte[i%12]);
2468
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 add_addr_to_line(addrToLinePos);
2469 }
2470
2471 }
2472
5/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 51 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 198 times.
396 else if (is0("cleartable"))
2473 {
2474 cleartable();
2475 }
2476
6/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 51 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 195 times.
396 else if (is0("pushtable"))
2477 {
2478
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 tablestack.append(table);
2479 }
2480
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 192 times.
390 else if (is0("pulltable"))
2481 {
2482
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if (tablestack.count <= 0) asar_throw_error(0, error_type_block, error_id_pulltable_without_table);
2483
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 table=tablestack[tablestack.count-1];
2484 6 tablestack.remove(tablestack.count-1);
2485 }
2486
5/6
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 192 times.
384 else if (is1("table"))
2487 {
2488 asar_throw_warning(0, warning_id_feature_deprecated, "table command", "Use direct character assignments. For example: 'a' = $61");
2489 bool fliporder=false;
2490 if(0);
2491 else if (striend(par, ",ltr")) { itrim(par, "", ",ltr"); }
2492 else if (striend(par, ",rtl")) { itrim(par, "", ",rtl"); fliporder=true; }
2493 string name=STR safedequote(par);
2494 autoptr<char*> tablecontents=readfile(name, thisfilename);
2495 if (!tablecontents) asar_throw_error(0, error_type_block, vfile_error_to_error_id(asar_get_last_io_error()), name.data());
2496 autoptr<char**> tablelines=split(tablecontents, "\n");
2497 for (int i=0;i<256;i++) table.table[i]=(unsigned int)(((numopcodes+read2(0x00FFDE)+i)*0x26594131)|0x40028020);
2498 //garbage value so people will notice they're doing it wrong (for bonus points: figure out what 0x26594131 is)
2499 for (int i=0;tablelines[i];i++)
2500 {
2501 string tableline=tablelines[i];
2502 if (!*tableline) continue;
2503 if (strlen(tableline) < 4 || strlen(tableline) & 1 || strlen(tableline) > 10) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2504 if (!fliporder)
2505 {
2506 if (tableline[3]=='x' || tableline[3]=='X') asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2507 char * end;
2508 table.table[(unsigned char)tableline[0]]=(unsigned int)strtol(tableline.data()+2, &end, 16);
2509 if (*end) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2510 }
2511 else
2512 {
2513 if (tableline[1]=='x' || tableline[1]=='X') asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2514 char * eq;
2515 unsigned int val=(unsigned int)strtol(tableline, &eq, 16);
2516 if (eq[0]!='=' || eq[2]) asar_throw_error(0, error_type_block, error_id_invalid_table_file, i+1);
2517 table.table[(unsigned char)eq[1]]=val;
2518 }
2519 }
2520 }
2521
6/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 354 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 177 times.
384 else if (is3("function"))
2522 {
2523 //if (!pass)
2524 //{
2525
3/6
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (stricmp(word[2], "=")) asar_throw_error(0, error_type_block, error_id_broken_function_declaration);
2526
2/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (!confirmqpar(word[1])) asar_throw_error(0, error_type_block, error_id_broken_function_declaration);
2527
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 string line=word[1];
2528
4/8
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30 times.
✗ Branch 7 not taken.
30 clean(line);
2529 30 char * startpar=strqchr(line.data(), '(');
2530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (!startpar) asar_throw_error(0, error_type_block, error_id_broken_function_declaration);
2531 30 *startpar=0;
2532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 startpar++;
2533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (!confirmname(line)) asar_throw_error(0, error_type_block, error_id_invalid_function_name);
2534 30 char * endpar=strqchr(startpar, ')');
2535 //confirmqpar requires that all parentheses are matched, and a starting one exists, therefore it is harmless to not check for nulls
2536
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (endpar[1]) asar_throw_error(0, error_type_block, error_id_broken_function_declaration);
2537 30 *endpar=0;
2538
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 createuserfunc(line, startpar, word[3]);
2539 //}
2540 30 }
2541
6/6
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 132 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 129 times.
354 else if (is1("print"))
2542 {
2543
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 string out = handle_print(par);
2544
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 32 times.
96 if (pass!=2) return;
2545
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 print(out);
2546
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 32 times.
96 }
2547
5/6
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 129 times.
258 else if (is1("reset"))
2548 {
2549 if(0);
2550 else if (!stricmp(par, "bytes")) bytes=0;
2551 else if (!stricmp(par, "freespaceuse")) freespaceuse=0;
2552 else asar_throw_error(2, error_type_block, error_id_unknown_variable);
2553 }
2554
15/18
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 150 times.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✓ Branch 9 taken 90 times.
✓ Branch 10 taken 150 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 150 times.
✓ Branch 13 taken 90 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 150 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 120 times.
258 else if (is1("padbyte") || is1("padword") || is1("padlong") || is1("paddword"))
2555 {
2556 9 int len = 0;
2557
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if (is("padbyte")) len=1;
2558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("padword")) len=2;
2559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("padlong")) len=3;
2560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (is("paddword")) len=4;
2561
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 unsigned int val=getnum(par);
2562
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
18 if(foundlabel && !foundlabel_static) asar_throw_warning(1, warning_id_feature_deprecated, "labels in padbyte", "just... don't.");
2563
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 18 times.
234 for (int i=0;i<12;i+=len)
2564 {
2565 108 unsigned int tmpval=val;
2566
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 216 times.
432 for (int j=0;j<len;j++)
2567 {
2568 216 padbyte[i+j]=(unsigned char)tmpval;
2569 216 tmpval>>=8;
2570 }
2571 }
2572 }
2573
6/6
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 75 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 111 times.
240 else if (is1("pad"))
2574 {
2575
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ((unsigned int)realsnespos & 0xFF000000) asar_throw_error(0, error_type_block, error_id_pad_in_freespace);
2576
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 int num=(int)getnum(par);
2577
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ((unsigned int)num & 0xFF000000) asar_throw_error(0, error_type_block, error_id_snes_address_doesnt_map_to_rom, hex6((unsigned int)num).data());
2578
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if (num>realsnespos)
2579 {
2580 6 int end=snestopc(num);
2581 6 int start=snestopc(realsnespos);
2582 12 int len=end-start;
2583
3/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 12 times.
72 for (int i=0;i<len;i++) write1(padbyte[i%12]);
2584
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 add_addr_to_line(addrToLinePos);
2585 }
2586 }
2587
18/18
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 108 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 108 times.
✓ Branch 9 taken 90 times.
✓ Branch 10 taken 102 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 102 times.
✓ Branch 13 taken 90 times.
✓ Branch 14 taken 6 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 18 times.
✓ Branch 17 taken 93 times.
222 else if (is1("fillbyte") || is1("fillword") || is1("filllong") || is1("filldword"))
2588 {
2589 18 int len = 0;
2590
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 18 times.
36 if (is("fillbyte")) len=1;
2591
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("fillword")) len=2;
2592
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("filllong")) len=3;
2593
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 30 times.
36 if (is("filldword")) len=4;
2594
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 unsigned int val= getnum(par);
2595
5/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
36 if(foundlabel && !foundlabel_static) asar_throw_warning(1, warning_id_feature_deprecated, "labels in fillbyte", "just... don't");
2596
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 36 times.
330 for (int i=0;i<12;i+=len)
2597 {
2598 147 unsigned int tmpval=val;
2599
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 294 times.
726 for (int j=0;j<len;j++)
2600 {
2601 432 fillbyte[i+j]=(unsigned char)tmpval;
2602 432 tmpval>>=8;
2603 }
2604 }
2605 }
2606
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 45 times.
186 else if (is1("arch"))
2607 {
2608
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2609
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if (emulatexkas) asar_throw_warning(0, warning_id_convert_to_asar);
2610
4/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 36 times.
96 if (!stricmp(par, "65816")) { arch=arch_65816; return; }
2611
4/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 21 times.
72 if (!stricmp(par, "spc700")) { arch=arch_spc700; return; }
2612
5/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
42 if (!stricmp(par, "spc700-inline")) { asar_throw_warning(1, warning_id_feature_deprecated, "spc700-inline", " Use spcblock and endspcblock"); arch=arch_spc700_inline; return; }
2613
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12 times.
36 if (!stricmp(par, "spc700-raw")) {
2614
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 asar_throw_warning(1, warning_id_feature_deprecated, "spc700-raw", " Use arch spc700 with norom");
2615 12 arch=arch_spc700;
2616 12 mapper=norom;
2617 12 mapper_set = false;
2618
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!force_checksum_fix)
2619 12 checksum_fix_enabled = false;
2620 12 return;
2621 }
2622
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 if (!stricmp(par, "superfx")) { arch=arch_superfx; return; }
2623 }
2624
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
90 else if (is2("math"))
2625 {
2626 bool val = false;
2627 if(0);
2628 else if (!stricmp(word[2], "on")) val=true;
2629 else if (!stricmp(word[2], "off")) val=false;
2630 else asar_throw_error(0, error_type_block, error_id_invalid_math);
2631 if(0);
2632 else if (!stricmp(word[1], "pri")){ math_pri=val; asar_throw_warning(2, warning_id_feature_deprecated, "math pri", "Rewrite your math statements using parentheses where needed and put \"asar 1.9\" in your patch to enable the future behavior of always enforcing math prioritization rules"); }
2633 else if (!stricmp(word[1], "round")){ math_round=val; asar_throw_warning(2, warning_id_feature_deprecated, "math round", "Put \"asar 1.9\" in your patch to enable the future behavior of never rounding intermediate results. Call the round(), floor() or ceil() functions in places where intermediate rounding is required"); }
2634 else asar_throw_error(0, error_type_block, error_id_invalid_math);
2635 }
2636
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
90 else if (is2("warn"))
2637 {
2638 bool val = false;
2639 if(0);
2640 else if (!stricmp(word[2], "on")) val=true;
2641 else if (!stricmp(word[2], "off")) val=false;
2642 else asar_throw_error(0, error_type_block, error_id_invalid_warn);
2643 if(0);
2644 else if (!stricmp(word[1], "xkas")) {
2645 asar_throw_warning(0, warning_id_feature_deprecated, "xkas compatibility warning", "If you worry about xkas I worry about you. Just stop.");
2646 warnxkas=val;
2647 }
2648 else asar_throw_error(0, error_type_block, error_id_invalid_warn);
2649 }
2650
5/6
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 42 times.
90 else if (is0("fastrom"))
2651 {
2652
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 asar_throw_warning(0, warning_id_feature_deprecated, "fastrom", "This feature has been disabled for years and is a lie. Sorry.");
2653 //removed due to causing more trouble than it's worth.
2654 //if (emulatexkas) warn0("Convert the patch to native Asar format instead of making an Asar-only xkas patch.");
2655 //if (mapper==lorom || mapper==hirom) fastrom=true;
2656 //else error(0, "Can't use fastrom in this mapper.");
2657 }
2658
8/10
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 36 times.
84 else if (is0("{") || is0("}")) {}
2659 else
2660 {
2661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (isspecialline)
2662 {
2663 asar_throw_warning(0, warning_id_unrecognized_special_command);
2664 }
2665 else
2666 {
2667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 asar_throw_error(1, error_type_block, error_id_unknown_command);
2668 }
2669 }
2670
2671
6/6
✓ Branch 0 taken 325347 times.
✓ Branch 1 taken 112011 times.
✓ Branch 2 taken 325347 times.
✓ Branch 3 taken 112011 times.
✓ Branch 4 taken 325347 times.
✓ Branch 5 taken 112011 times.
1100718 }
2672
2673 7552 bool assemblemapper(char** word, int numwords)
2674 {
2675 7552 auto previous_mapper = mapper;
2676 if(0);
2677
6/6
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 6836 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 644 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 3740 times.
7552 else if (is0("lorom"))
2678 {
2679 //this also makes xkas set snespos to $008000 for some reason
2680 72 mapper=lorom;
2681 }
2682
6/6
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 6836 times.
✓ Branch 2 taken 322 times.
✓ Branch 3 taken 322 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 3733 times.
7480 else if (is0("hirom"))
2683 {
2684 //xkas makes this point to $C00000
2685 14 mapper=hirom;
2686 }
2687
6/6
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 6836 times.
✓ Branch 2 taken 315 times.
✓ Branch 3 taken 315 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3730 times.
7466 else if (is0("exlorom"))
2688 {
2689 6 mapper = exlorom;
2690 }
2691
6/6
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 6836 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3727 times.
7460 else if (is0("exhirom"))
2692 {
2693 6 mapper=exhirom;
2694 }
2695
6/6
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 6836 times.
✓ Branch 2 taken 309 times.
✓ Branch 3 taken 309 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 3721 times.
7454 else if (is0("sfxrom"))
2696 {
2697 12 mapper=sfxrom;
2698 //fastrom=false;
2699 }
2700
6/6
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 6836 times.
✓ Branch 2 taken 303 times.
✓ Branch 3 taken 303 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 3712 times.
7442 else if (is0("norom"))
2701 {
2702 //$000000 would be the best snespos for this, but I don't care
2703 18 mapper=norom;
2704 //fastrom=false;
2705
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!force_checksum_fix)
2706 18 checksum_fix_enabled = false;//we don't know where the header is, so don't set the checksum
2707 }
2708
6/6
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 6836 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 294 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3709 times.
7424 else if (is0("fullsa1rom"))
2709 {
2710 6 mapper=bigsa1rom;
2711 //fastrom=false;
2712 }
2713
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 7394 times.
7418 else if (is("sa1rom"))
2714 {
2715 //fastrom=false;
2716
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if (par)
2717 {
2718
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if (word[2]) asar_throw_error(0, error_type_block, error_id_invalid_mapper);
2719
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
27 if (!is_digit(par[0]) || par[1]!=',' ||
2720
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 !is_digit(par[2]) || par[3]!=',' ||
2721
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 !is_digit(par[4]) || par[5]!=',' ||
2722
4/10
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
36 !is_digit(par[6]) || par[7]) asar_throw_error(0, error_type_block, error_id_invalid_mapper);
2723 9 int len;
2724
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
18 autoptr<char**> pars=qpsplit(par, ",", &len);
2725
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if (len!=4) asar_throw_error(0, error_type_block, error_id_invalid_mapper);
2726 18 sa1banks[0]=(par[0]-'0')<<20;
2727 18 sa1banks[1]=(par[2]-'0')<<20;
2728 18 sa1banks[4]=(par[4]-'0')<<20;
2729 18 sa1banks[5]=(par[6]-'0')<<20;
2730 18 }
2731 else
2732 {
2733 6 sa1banks[0]=0<<20;
2734 6 sa1banks[1]=1<<20;
2735 6 sa1banks[4]=2<<20;
2736 6 sa1banks[5]=3<<20;
2737 }
2738 24 mapper=sa1rom;
2739 }
2740
4/6
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 6818 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 576 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3697 times.
7394 else if (is0("header"))
2741 {
2742 //headers are detected elsewhere; ignoring for familiarity
2743 asar_throw_warning(0, warning_id_feature_deprecated, "header", "Remove command, unnecessary.");
2744 }
2745 3697 else return false;
2746
2747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 if(in_spcblock) asar_throw_error(0, error_type_block, error_id_feature_unavaliable_in_spcblock);
2748
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 66 times.
158 if(!mapper_set){
2749 92 mapper_set = true;
2750
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 }else if(previous_mapper != mapper){
2751 54 asar_throw_warning(1, warning_id_mapper_already_set);
2752 }
2753 79 return true;
2754 }
2755