asar coverage - build #208


src/asar/
File: src/asar/assembleblock.h
Date: 2024-02-19 22:06:19
Lines:
10/10
100.0%
Functions:
1/1
100.0%
Branches:
0/2
0.0%

Line Branch Exec Source
1 #pragma once
2
3 enum { arch_65816, arch_spc700, arch_superfx };
4 extern int arch;
5
6 bool assemblemapper(char** word, int numwords);
7
8
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
375 struct snes_struct {
9 string parent;
10 int base_end;
11 int struct_size;
12 int object_size;
13 bool is_static;
14 };
15
16 extern assocarr<snes_struct> structs;
17 extern int label_counter;
18
19
20 struct snes_label {
21 unsigned int pos;
22 int id;
23 int freespace_id;
24 bool is_static;
25
26 11422 snes_label()
27 11422 {
28 11422 pos = 0;
29 11422 is_static = false;
30 11422 freespace_id = 0;
31 11422 id = label_counter++;
32 11422 }
33 };
34
35 // data necessary for one freespace block
36 3970 struct freespace_data {
37 // snespos of the start of the freespace block. set to the found freespace
38 // block during the `freespace` command in pass 1.
39 int pos;
40 // length of the freespace block
41 int len;
42 // whether this freespace is leaked (no autocleans pointing at it)
43 bool leaked;
44 // position of the previous version of this freespace
45 // -2 means "never searched", -1 is "searched but didn't find anything",
46 // nonnegative is previous location
47 int orgpos;
48 // length of previous version
49 int orglen;
50 // whether this freespace is static, i.e. can't be relocated when reinserting
51 bool is_static;
52
53 // options only used for finding freespace:
54
55 // if this freespace is pinned to another one, this holds the name of the label of the target.
56 // we can't resolve this into a freespace number earlier since it could be a forward reference.
57 // we also need to keep the current namespace around since this is necessary for resolving label references.
58 string pin_target;
59 string pin_target_ns;
60 // computed at the end of pass 0. this is the freespace id of the final pin
61 // target, in case of multiple "nested" pins or whatnot.
62 int pin_target_id;
63 // what address to start searching for freespace at
64 int search_start;
65 // what bank to search for freespace in: -1 for any bank, -2 for banks with
66 // code mirrors, positive for specific bank
67 int bank;
68 bool write_rats;
69 // should rework this...
70 bool flag_align;
71 // whether the `cleaned` argument was given
72 bool flag_cleaned;
73 // pinned freespaces: how much space is actually needed for this freespace
74 int total_len;
75 // pinned freespaces: how much of this block we've already used
76 int used_len;
77 };
78 extern autoarray<freespace_data> freespaces;
79
80 // RPG Hacker: Really the only purpose of this struct is to support pushtable and pulltable
81 // Also don't know where else to put this, so putting it in this header
82 /*struct chartabledata {
83 unsigned int table[256];
84 };
85
86 extern chartabledata table;
87 unsigned int get_table_val(int inp);
88 void set_table_val(int inp, unsigned int out);*/
89
90 5006 struct whiletracker {
91 bool iswhile;
92 int startline;
93 bool cond;
94 bool is_for;
95 string for_variable;
96 string for_var_backup;
97 bool for_has_var_backup;
98 int for_start;
99 int for_end;
100 int for_cur;
101 };
102
103 extern autoarray<whiletracker> whilestatus;
104
105 // 0 - not first block, not in for
106 // 1 - first block
107 // 2 - inside single-line for
108 // 3 - after endfor
109 extern int single_line_for_tracker;
110
111 bool confirmname(const char * name);
112 string posneglabelname(const char ** input, bool define);
113
114 void write1_pick(unsigned int num);
115 void write2(unsigned int num);
116 void write3(unsigned int num);
117 void write4(unsigned int num);
118
119 int snestopc_pick(int addr);
120
121 int getlenfromchar(char c);
122
123 snes_label labelval(const char ** rawname, bool define = false);
124 snes_label labelval(string name, bool define = false);
125 bool labelval(const char ** rawname, snes_label * rval, bool define = false);
126 bool labelval(string name, snes_label * rval, bool define = false);
127
128 const char * safedequote(char * str);
129
130 void checkbankcross();
131
132 void initstuff();
133 void finishpass();
134
135 void handle_autoclean(string& arg, int checkbyte, int orgpos);
136
137 void assembleblock(const char * block, int& single_line_for_tracker);
138
139 extern int snespos;
140 extern int realsnespos;
141 extern int startpos;
142 extern int realstartpos;
143
144 extern int bytes;
145
146 extern int numif;
147 extern int numtrue;
148
149 extern int freespaceid;
150
151 extern assocarr<snes_label> labels;
152
153 extern autoarray<int>* macroposlabels;
154 extern autoarray<int>* macroneglabels;
155 extern autoarray<string>* macrosublabels;
156
157 extern autoarray<string> sublabels;
158 extern string ns;
159 extern autoarray<string> namespace_list;
160
161 extern autoarray<string> includeonce;
162