Debian Codegraph @

src/asm/macro.c

raw symbols SCIP
1 //cxx . . $ `<file>/src/asm/macro.c`/
2 // ACME - a crossassembler for producing 6502/65c02/65816 code.
3 // Copyright (C) 1998-2006 Marco Baye
4 // Have a look at "acme.c" for further info
5 //
6 // Macro stuff
7
8 #include <string.h> // needs strlen() + memcpy()
9 #include "config.h"cxx . . $ `<file>/src/asm/config.h`/
10 #include "platform.h"cxx . . $ `<file>/src/asm/platform.h`/ // done first in case "inline" is redefined
11 #include "acme.h"cxx . . $ `<file>/src/asm/acme.h`/
12 #include "alu.h"cxx . . $ `<file>/src/asm/alu.h`/
13 #include "dynabuf.h"cxx . . $ `<file>/src/asm/dynabuf.h`/
14 #include "global.h"cxx . . $ `<file>/src/asm/global.h`/
15 #include "input.h"cxx . . $ `<file>/src/asm/input.h`/
16 #include "label.h"cxx . . $ `<file>/src/asm/label.h`/
17 #include "section.h"cxx . . $ `<file>/src/asm/section.h`/
18 #include "tree.h"cxx . . $ `<file>/src/asm/tree.h`/
19 #include "macro.h"cxx . . $ `<file>/src/asm/macro.h`/
20
21
22 // Constants
23 #define MACRONAME_DYNABUF_INITIALSIZEcxx . . $ `src/asm/macro.c:23:9`! 128
24 #define ARG_SEPARATORcxx . . $ `src/asm/macro.c:24:9`! ' ' // separates macro title from arg types
25 #define ARGTYPE_NUM_VALcxx . . $ `src/asm/macro.c:25:9`! 'v'
26 #define ARGTYPE_NUM_REFcxx . . $ `src/asm/macro.c:26:9`! 'V'
27 //#define ARGTYPE_STR_VAL 's'
28 //#define ARGTYPE_STR_REF 'S'
29 #define REFERENCE_CHARcxx . . $ `src/asm/macro.c:29:9`! '~' // prefix for call-by-reference
30 #define HALF_INITIAL_ARG_TABLE_SIZEcxx . . $ `src/asm/macro.c:30:9`! 4
31 static const char exception_macro_twicecxx . . $ exception_macro_twice.[] = "Macro already defined.";
32
33
34 // macro struct type definition
35 struct macro_tcxx . . $ macro_t# {
36 int def_line_numbercxx . . $ macro_t#def_line_number.;// line number of definition for error msgs
37 char* def_filenamecxx . . $ macro_t#def_filename.; // file name of definition for error msgs
38 char* original_namecxx . . $ macro_t#original_name.; // user-supplied name for error msgs
39 char* parameter_listcxx . . $ macro_t#parameter_list.; // parameters (whole line)
40 char* bodycxx . . $ macro_t#body.; // RAM block containing macro body
41 };
42 // there's no need to make this a struct and add a type component:
43 // when the macro has been found, accessing its parameter_list component
44 // gives us the possibility to find out which args are call-by-value and
45 // which ones are call-by-reference.
46 union macro_arg_tcxx . . $ macro_arg_t# {
47 result_tcxx . . $ result_t# resultcxx . . $ macro_arg_t#result.; // value and flags (call by value)
48 label_tcxx . . $ label_t#* labelcxx . . $ macro_arg_t#label.; // pointer to label struct (call by reference)
49 };
50
51
52 // Variables
53 static dynabuf_tcxx . . $ dynabuf_t#* user_macro_namecxx . . $ user_macro_name.; // original macro title
54 static dynabuf_tcxx . . $ dynabuf_t#* internal_namecxx . . $ internal_name.; // plus param type chars
55 static node_ra_tcxx . . $ node_ra_t#* macro_forestcxx . . $ macro_forest.[256]; // trees (because of 8b hash)
56 // Dynamic argument table
57 static union macro_arg_tcxx . . $ macro_arg_t#* arg_tablecxx . . $ arg_table. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
58 static int argtable_sizecxx . . $ argtable_size. = HALF_INITIAL_ARG_TABLE_SIZEcxx . . $ `src/asm/macro.c:30:9`!;
59
60
61 // Functions
62
63 // Enlarge the argument table
64 static void enlarge_arg_tablecxx . . $ enlarge_arg_table(49f6e7a06ebc5aa8).(void) {
65 argtable_sizecxx . . $ argtable_size. *= 2;
66 arg_tablecxx . . $ arg_table. =
67 realloccxx . . $ realloc(417ab160f6baadc6).(arg_tablecxx . . $ arg_table., argtable_sizecxx . . $ argtable_size. * sizeof(union macro_arg_tcxx . . $ macro_arg_t#));
68 if(arg_tablecxx . . $ arg_table. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
69 Throw_serious_errorcxx . . $ Throw_serious_error(85c52e162fed56f9).(exception_no_memory_leftcxx . . $ exception_no_memory_left.);
70 }
71
72 // create dynamic buffers and arg table
73 void Macro_initcxx . . $ Macro_init(49f6e7a06ebc5aa8).(void) {
74 user_macro_namecxx . . $ user_macro_name. = DynaBuf_createcxx . . $ DynaBuf_create(139370366a5bf8f7).(MACRONAME_DYNABUF_INITIALSIZEcxx . . $ `src/asm/macro.c:23:9`!);
75 internal_namecxx . . $ internal_name. = DynaBuf_createcxx . . $ DynaBuf_create(139370366a5bf8f7).(MACRONAME_DYNABUF_INITIALSIZEcxx . . $ `src/asm/macro.c:23:9`!);
76 enlarge_arg_tablecxx . . $ enlarge_arg_table(49f6e7a06ebc5aa8).();
77 }
78
79 // Read macro zone and title. Title is read to GlobalDynaBuf and then copied
80 // over to internal_name DynaBuf, where ARG_SEPARATOR is added.
81 // In user_macro_name DynaBuf, the original name is reconstructed (even with
82 // '.' prefix) so a copy can be linked to the resulting macro struct.
83 static zone_tcxx . . $ zone_t# get_zone_and_titlecxx . . $ get_zone_and_title(db52760e79bf9054).(void) {
84 zone_tcxx . . $ zone_t# macro_zone;
85
86 Input_read_zone_and_keywordcxx . . $ Input_read_zone_and_keyword(4ebf403dd87dd80).(&macro_zone); // skips spaces before
87 // now GotByte = illegal character after title
88 // copy macro title to private dynabuf and add separator character
89 DYNABUF_CLEARcxx . . $ `src/asm/dynabuf.h:14:9`!(user_macro_name);
90 DYNABUF_CLEARcxx . . $ `src/asm/dynabuf.h:14:9`!(internal_name);
91 if(macro_zone != ZONE_GLOBALcxx . . $ `src/asm/section.h:23:9`!)
92 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(user_macro_namecxx . . $ user_macro_name., '.');
93 DynaBuf_add_stringcxx . . $ DynaBuf_add_string(9294670b9d26a99f).(user_macro_namecxx . . $ user_macro_name., GLOBALDYNABUF_CURRENTcxx . . $ `src/asm/dynabuf.h:23:9`!);
94 DynaBuf_add_stringcxx . . $ DynaBuf_add_string(9294670b9d26a99f).(internal_namecxx . . $ internal_name., GLOBALDYNABUF_CURRENTcxx . . $ `src/asm/dynabuf.h:23:9`!);
95 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(user_macro_namecxx . . $ user_macro_name., '\0');
96 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(internal_namecxx . . $ internal_name., ARG_SEPARATORcxx . . $ `src/asm/macro.c:24:9`!);
97 SKIPSPACEcxx . . $ `src/asm/global.h:75:9`!();// done here once so it's not necessary at two callers
98 return(macro_zone);
99 }
100
101 // Check for comma. If there, append to GlobalDynaBuf.
102 static inline boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! pipe_commacxx . . $ pipe_comma(c9857a73d68e59ba).(void) {
103 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! result;
104
105 result = Input_accept_commacxx . . $ Input_accept_comma(c9857a73d68e59ba).();
106 if(result)
107 DYNABUF_APPENDcxx . . $ `src/asm/dynabuf.h:15:9`!(GlobalDynaBuf, ',');
108 return(result);
109 }
110
111 // Return malloc'd copy of string
112 static char* get_string_copycxx . . $ get_string_copy(a8b8e32347182212).(const char* original) {
113 size_t size;
114 char* copy;
115
116 size = strlencxx . . $ strlen(751346f8406fd082).(original) + 1;
117 copy = safe_malloccxx . . $ safe_malloc(bfcfa4d6b7f7ef64).(size);
118 memcpycxx . . $ memcpy(cc817cb175f282d).(copy, original, size);
119 return(copy);
120 }
121
122 // This function is called from both macro definition and macro call.
123 // Terminate macro name and copy from internal_name to GlobalDynaBuf
124 // (because that's where Tree_hard_scan() looks for the search string).
125 // Then try to find macro and return whether it was created.
126 static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! search_for_macrocxx . . $ search_for_macro(b0344d4004896e26).(node_ra_tcxx . . $ node_ra_t#** result, zone_tcxx . . $ zone_t# zone, boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! create) {
127 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(internal_namecxx . . $ internal_name., '\0'); // terminate macro name
128 // now internal_name = macro_title SPC argument_specifiers NUL
129 DYNABUF_CLEARcxx . . $ `src/asm/dynabuf.h:14:9`!(GlobalDynaBuf);
130 DynaBuf_add_stringcxx . . $ DynaBuf_add_string(9294670b9d26a99f).(GlobalDynaBufcxx . . $ GlobalDynaBuf., internal_namecxx . . $ internal_name.->buffercxx . . $ dynabuf_t#buffer.);
131 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(GlobalDynaBufcxx . . $ GlobalDynaBuf., '\0');
132 return(Tree_hard_scancxx . . $ Tree_hard_scan(fbd309352d4134f6).(result, macro_forestcxx . . $ macro_forest., zone, create));
133 }
134
135 // This function is called when an already existing macro is re-defined.
136 // It first outputs a warning and then a serious error, stopping assembly.
137 // Showing the first message as a warning guarantees that ACME does not reach
138 // the maximum error limit inbetween.
139 static void report_redefinitioncxx . . $ report_redefinition(b92ca72675ccef7f).(node_ra_tcxx . . $ node_ra_t#* macro_node) {
140 struct macro_tcxx . . $ macro_t#* original_macro = macro_node->bodycxx . . $ node_ra_t#body.;
141
142 // show warning with location of current definition
143 Throw_warningcxx . . $ Throw_warning(85c52e162fed56f9).(exception_macro_twicecxx . . $ exception_macro_twice.);
144 // CAUTION, ugly kluge: fiddle with Input_now and Section_now
145 // data to generate helpful error messages
146 Input_nowcxx . . $ Input_now.->original_filenamecxx . . $ $anonymous_type_5e15f442b66098d4_0#original_filename. = original_macro->def_filenamecxx . . $ macro_t#def_filename.;
147 Input_nowcxx . . $ Input_now.->line_numbercxx . . $ $anonymous_type_5e15f442b66098d4_0#line_number. = original_macro->def_line_numbercxx . . $ macro_t#def_line_number.;
148 Section_nowcxx . . $ Section_now.->typecxx . . $ $anonymous_type_4270326a5ce8d2d2_0#type. = "original";
149 Section_nowcxx . . $ Section_now.->titlecxx . . $ $anonymous_type_4270326a5ce8d2d2_0#title. = "definition";
150 // show serious error with location of original definition
151 Throw_serious_errorcxx . . $ Throw_serious_error(85c52e162fed56f9).(exception_macro_twicecxx . . $ exception_macro_twice.);
152 }
153
154 // This function is only called during the first pass, so there's no need to
155 // check whether to skip the definition or not.
156 // Return with GotByte = '}'
157 void Macro_parse_definitioncxx . . $ Macro_parse_definition(49f6e7a06ebc5aa8).(void) {// Now GotByte = illegal char after "!macro"
158 char* formal_parameters;
159 node_ra_tcxx . . $ node_ra_t#* macro_node;
160 struct macro_tcxx . . $ macro_t#* new_macro;
161 zone_tcxx . . $ zone_t# macro_zone = get_zone_and_titlecxx . . $ get_zone_and_title(db52760e79bf9054).();
162
163 // now GotByte = first non-space after title
164 DYNABUF_CLEARcxx . . $ `src/asm/dynabuf.h:14:9`!(GlobalDynaBuf); // prepare to hold formal parameters
165 // GlobalDynaBuf = "" (will hold formal parameter list)
166 // user_macro_name = ['.'] MacroTitle NUL
167 // internal_name = MacroTitle ARG_SEPARATOR (grows to signature)
168 // Accept n>=0 comma-separated formal parameters before CHAR_SOB ('{').
169 // Valid argument formats are:
170 // .LOCAL_LABEL_BY_VALUE
171 // ~.LOCAL_LABEL_BY_REFERENCE
172 // GLOBAL_LABEL_BY_VALUE global args are very uncommon,
173 // ~GLOBAL_LABEL_BY_REFERENCE but not forbidden
174 // now GotByte = non-space
175 if(GotBytecxx . . $ GotByte. != CHAR_SOBcxx . . $ `src/asm/input.h:49:9`!) { // any at all?
176 do {
177 // handle call-by-reference character ('~')
178 if(GotBytecxx . . $ GotByte. != REFERENCE_CHARcxx . . $ `src/asm/macro.c:29:9`!)
179 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(internal_namecxx . . $ internal_name., ARGTYPE_NUM_VALcxx . . $ `src/asm/macro.c:25:9`!);
180 else {
181 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(internal_namecxx . . $ internal_name., ARGTYPE_NUM_REFcxx . . $ `src/asm/macro.c:26:9`!);
182 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(GlobalDynaBufcxx . . $ GlobalDynaBuf., REFERENCE_CHARcxx . . $ `src/asm/macro.c:29:9`!);
183 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
184 }
185 // handle prefix for local labels ('.')
186 if(GotBytecxx . . $ GotByte. == '.') {
187 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(GlobalDynaBufcxx . . $ GlobalDynaBuf., '.');
188 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).();
189 }
190 // handle label name
191 Input_append_keyword_to_global_dynabufcxx . . $ Input_append_keyword_to_global_dynabuf(b126dc7c1de90089).();
192 } while(pipe_commacxx . . $ pipe_comma(c9857a73d68e59ba).());
193 // ensure CHAR_SOB ('{')
194 if(GotBytecxx . . $ GotByte. != CHAR_SOBcxx . . $ `src/asm/input.h:49:9`!)
195 Throw_serious_errorcxx . . $ Throw_serious_error(85c52e162fed56f9).(exception_no_left_bracecxx . . $ exception_no_left_brace.);
196 }
197 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(GlobalDynaBufcxx . . $ GlobalDynaBuf., CHAR_EOScxx . . $ `src/asm/input.h:48:9`!); // terminate param list
198 // now GlobalDynaBuf = comma-separated parameter list without spaces,
199 // but terminated with CHAR_EOS.
200 formal_parameters = DynaBuf_get_copycxx . . $ DynaBuf_get_copy(d7229e135d075701).(GlobalDynaBufcxx . . $ GlobalDynaBuf.);
201 // now GlobalDynaBuf = unused
202 // Reading the macro body would change the line number. To have correct
203 // error messages, we're checking for "macro twice" *now*.
204 // Search for macro. Create if not found.
205 // But if found, complain (macro twice).
206 if(search_for_macrocxx . . $ search_for_macro(b0344d4004896e26).(&macro_node, macro_zone, TRUEcxx . . $ `src/asm/config.h:55:9`!) == FALSEcxx . . $ `src/asm/config.h:54:9`!)
207 report_redefinitioncxx . . $ report_redefinition(b92ca72675ccef7f).(macro_node);// quits with serious error
208 // Create new macro struct and set it up. Finally we'll read the body.
209 new_macro = safe_malloccxx . . $ safe_malloc(bfcfa4d6b7f7ef64).(sizeof(struct macro_tcxx . . $ macro_t#));
210 new_macro->def_line_numbercxx . . $ macro_t#def_line_number. = Input_nowcxx . . $ Input_now.->line_numbercxx . . $ $anonymous_type_5e15f442b66098d4_0#line_number.;
211 new_macro->def_filenamecxx . . $ macro_t#def_filename. = get_string_copycxx . . $ get_string_copy(a8b8e32347182212).(Input_nowcxx . . $ Input_now.->original_filenamecxx . . $ $anonymous_type_5e15f442b66098d4_0#original_filename.);
212 new_macro->original_namecxx . . $ macro_t#original_name. = get_string_copycxx . . $ get_string_copy(a8b8e32347182212).(user_macro_namecxx . . $ user_macro_name.->buffercxx . . $ dynabuf_t#buffer.);
213 new_macro->parameter_listcxx . . $ macro_t#parameter_list. = formal_parameters;
214 new_macro->bodycxx . . $ macro_t#body. = Input_skip_or_store_blockcxx . . $ Input_skip_or_store_block(cd68a792b21c61df).(TRUEcxx . . $ `src/asm/config.h:55:9`!);// changes LineNumber
215 macro_node->bodycxx . . $ node_ra_t#body. = new_macro; // link macro struct to tree node
216 // and that about sums it up
217 }
218
219 // Parse macro call ("+MACROTITLE"). Has to be re-entrant.
220 void Macro_parse_callcxx . . $ Macro_parse_call(49f6e7a06ebc5aa8).(void) { // Now GotByte = dot or first char of macro name
221 char local_gotbyte;
222 label_tcxx . . $ label_t#* label;
223 section_tcxx . . $ section_t# new_section,
224 *outer_section;
225 input_tcxx . . $ input_t# new_input,
226 *outer_input;
227 struct macro_tcxx . . $ macro_t#* actual_macro;
228 node_ra_tcxx . . $ node_ra_t# *macro_node,
229 *label_node;
230 zone_tcxx . . $ zone_t# macro_zone,
231 label_zone;
232 int arg_count = 0;
233
234 // Enter deeper nesting level
235 // Quit program if recursion too deep.
236 if(--macro_recursions_leftcxx . . $ macro_recursions_left. < 0)
237 Throw_serious_errorcxx . . $ Throw_serious_error(85c52e162fed56f9).("Too deeply nested. Recursive macro calls?");
238 macro_zone = get_zone_and_titlecxx . . $ get_zone_and_title(db52760e79bf9054).();
239 // now GotByte = first non-space after title
240 // internal_name = MacroTitle ARG_SEPARATOR (grows to signature)
241 // Accept n>=0 comma-separated arguments before CHAR_EOS.
242 // Valid argument formats are:
243 // EXPRESSION (everything that does NOT start with '~'
244 // ~.LOCAL_LABEL_BY_REFERENCE
245 // ~GLOBAL_LABEL_BY_REFERENCE
246 // now GotByte = non-space
247 if(GotBytecxx . . $ GotByte. != CHAR_EOScxx . . $ `src/asm/input.h:48:9`!) { // any at all?
248 do {
249 // if arg table cannot take another element, enlarge
250 if(argtable_sizecxx . . $ argtable_size. <= arg_count)
251 enlarge_arg_tablecxx . . $ enlarge_arg_table(49f6e7a06ebc5aa8).();
252 // Decide whether call-by-reference or call-by-value
253 // In both cases, GlobalDynaBuf may be used.
254 if(GotBytecxx . . $ GotByte. == REFERENCE_CHARcxx . . $ `src/asm/macro.c:29:9`!) {
255 // read call-by-reference arg
256 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(internal_namecxx . . $ internal_name., ARGTYPE_NUM_REFcxx . . $ `src/asm/macro.c:26:9`!);
257 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).(); // skip '~' character
258 Input_read_zone_and_keywordcxx . . $ Input_read_zone_and_keyword(4ebf403dd87dd80).(&label_zone);
259 // GotByte = illegal char
260 arg_tablecxx . . $ arg_table.[arg_count].labelcxx . . $ macro_arg_t#label. =
261 Label_findcxx . . $ Label_find(dc7499a14ef462f5).(label_zone, 0);
262 } else {
263 // read call-by-value arg
264 DynaBuf_appendcxx . . $ DynaBuf_append(11d1e1bb7092144).(internal_namecxx . . $ internal_name., ARGTYPE_NUM_VALcxx . . $ `src/asm/macro.c:25:9`!);
265 ALU_any_resultcxx . . $ ALU_any_result(64a63ef514ec9b8a).(&(arg_tablecxx . . $ arg_table.[arg_count].resultcxx . . $ macro_arg_t#result.));
266 }
267 arg_count++;
268 } while(Input_accept_commacxx . . $ Input_accept_comma(c9857a73d68e59ba).());
269 }
270 // now arg_table contains the arguments
271 // now GlobalDynaBuf = unused
272 // check for "unknown macro"
273 // Search for macro. Do not create if not found.
274 search_for_macrocxx . . $ search_for_macro(b0344d4004896e26).(&macro_node, macro_zone, FALSEcxx . . $ `src/asm/config.h:54:9`!);
275 if(macro_node == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
276 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).("Macro not defined (or wrong signature).");
277 Input_skip_remaindercxx . . $ Input_skip_remainder(49f6e7a06ebc5aa8).();
278 } else {
279 // make macro_node point to the macro struct
280 actual_macro = macro_node->bodycxx . . $ node_ra_t#body.;
281 local_gotbyte = GotBytecxx . . $ GotByte.;// CAUTION - ugly kluge
282 // set up new input
283 new_input.original_filenamecxx . . $ $anonymous_type_5e15f442b66098d4_0#original_filename. = actual_macro->def_filenamecxx . . $ macro_t#def_filename.;
284 new_input.line_numbercxx . . $ $anonymous_type_5e15f442b66098d4_0#line_number. = actual_macro->def_line_numbercxx . . $ macro_t#def_line_number.;
285 new_input.source_is_ramcxx . . $ $anonymous_type_5e15f442b66098d4_0#source_is_ram. = TRUEcxx . . $ `src/asm/config.h:55:9`!;
286 new_input.statecxx . . $ $anonymous_type_5e15f442b66098d4_0#state. = INPUTSTATE_NORMALcxx . . $ INPUTSTATE_NORMAL.; // FIXME - fix others!
287 new_input.srccxx . . $ $anonymous_type_5e15f442b66098d4_0#src..ram_ptrcxx . . $ $anonymous_type_5e15f442b66098d4_0#$anonymous_type_1#ram_ptr. = actual_macro->parameter_listcxx . . $ macro_t#parameter_list.;
288 // remember old input
289 outer_input = Input_nowcxx . . $ Input_now.;
290 // activate new input
291 Input_nowcxx . . $ Input_now. = &new_input;
292 // remember old section
293 outer_section = Section_nowcxx . . $ Section_now.;
294 // start new section (with new zone)
295 // FALSE = title mustn't be freed
296 Section_new_zonecxx . . $ Section_new_zone(ef0b653b3680aef).(&new_section, "Macro",
297 actual_macro->original_namecxx . . $ macro_t#original_name., FALSEcxx . . $ `src/asm/config.h:54:9`!);
298 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).(); // fetch first byte of parameter list
299 // assign arguments
300 if(GotBytecxx . . $ GotByte. != CHAR_EOScxx . . $ `src/asm/input.h:48:9`!) { // any at all?
301 arg_count = 0;
302 do {
303 // Decide whether call-by-reference
304 // or call-by-value
305 // In both cases, GlobalDynaBuf may be used.
306 if(GotBytecxx . . $ GotByte. == REFERENCE_CHARcxx . . $ `src/asm/macro.c:29:9`!) {
307 // assign call-by-reference arg
308 GetBytecxx . . $ GetByte(6e9c618e4dd2eafc).(); // skip '~' character
309 Input_read_zone_and_keywordcxx . . $ Input_read_zone_and_keyword(4ebf403dd87dd80).(&label_zone);
310 if((Tree_hard_scancxx . . $ Tree_hard_scan(fbd309352d4134f6).(&label_node, Label_forestcxx . . $ Label_forest., label_zone, TRUEcxx . . $ `src/asm/config.h:55:9`!) == FALSEcxx . . $ `src/asm/config.h:54:9`!)
311 && (pass_countcxx . . $ pass_count. == 0))
312 Throw_errorcxx . . $ Throw_error(85c52e162fed56f9).("Macro parameter twice.");
313 label_node->bodycxx . . $ node_ra_t#body. = arg_tablecxx . . $ arg_table.[arg_count].labelcxx . . $ macro_arg_t#label.;
314 } else {
315 // assign call-by-value arg
316 Input_read_zone_and_keywordcxx . . $ Input_read_zone_and_keyword(4ebf403dd87dd80).(&label_zone);
317 label = Label_findcxx . . $ Label_find(dc7499a14ef462f5).(label_zone, 0);
318 // FIXME - add a possibility to Label_find to make it possible to find out
319 // whether label was just created. Then check for the same error message here
320 // as above ("Macro parameter twice.").
321 label->resultcxx . . $ label_t#result. = arg_tablecxx . . $ arg_table.[arg_count].resultcxx . . $ macro_arg_t#result.;
322 }
323 arg_count++;
324 } while(Input_accept_commacxx . . $ Input_accept_comma(c9857a73d68e59ba).());
325 }
326 // and now, finally, parse the actual macro body
327 Input_nowcxx . . $ Input_now.->statecxx . . $ $anonymous_type_5e15f442b66098d4_0#state. = INPUTSTATE_NORMALcxx . . $ INPUTSTATE_NORMAL.; // FIXME - fix others!
328 // maybe call parse_ram_block(actual_macro->def_line_number, actual_macro->body)
329 Input_nowcxx . . $ Input_now.->srccxx . . $ $anonymous_type_5e15f442b66098d4_0#src..ram_ptrcxx . . $ $anonymous_type_5e15f442b66098d4_0#$anonymous_type_1#ram_ptr. = actual_macro->bodycxx . . $ macro_t#body.;
330 Parse_until_eob_or_eofcxx . . $ Parse_until_eob_or_eof(49f6e7a06ebc5aa8).();
331 if(GotBytecxx . . $ GotByte. != CHAR_EOBcxx . . $ `src/asm/input.h:50:9`!)
332 Bug_foundcxx . . $ Bug_found(34d26762b42c433a).("IllegalBlockTerminator", GotBytecxx . . $ GotByte.);
333 // end section (free title memory, if needed)
334 Section_finalizecxx . . $ Section_finalize(91b759fd9e8cb2c0).(&new_section);
335 // restore previous section
336 Section_nowcxx . . $ Section_now. = outer_section;
337 // restore previous input:
338 Input_nowcxx . . $ Input_now. = outer_input;
339 // restore old Gotbyte context
340 GotBytecxx . . $ GotByte. = local_gotbyte;// CAUTION - ugly kluge
341 Input_ensure_EOScxx . . $ Input_ensure_EOS(49f6e7a06ebc5aa8).();
342 }
343 macro_recursions_leftcxx . . $ macro_recursions_left.++; // leave this nesting level
344 }