Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2GCCDeclare. */
2 : : /* M2GCCDeclare.mod declares Modula-2 types to GCC.
3 : :
4 : : Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 : : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 : :
7 : : This file is part of GNU Modula-2.
8 : :
9 : : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : : it under the terms of the GNU General Public License as published by
11 : : the Free Software Foundation; either version 3, or (at your option)
12 : : any later version.
13 : :
14 : : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include <stdbool.h>
26 : : # if !defined (PROC_D)
27 : : # define PROC_D
28 : : typedef void (*PROC_t) (void);
29 : : typedef struct { PROC_t proc; } PROC;
30 : : # endif
31 : :
32 : : # if !defined (TRUE)
33 : : # define TRUE (1==1)
34 : : # endif
35 : :
36 : : # if !defined (FALSE)
37 : : # define FALSE (1==0)
38 : : # endif
39 : :
40 : : # include "GStorage.h"
41 : : # include "Gmcrts.h"
42 : : #if defined(__cplusplus)
43 : : # undef NULL
44 : : # define NULL 0
45 : : #endif
46 : : typedef unsigned int m2linemap_location_t;
47 : :
48 : : typedef void *m2tree_Tree;
49 : :
50 : : typedef struct SymbolKey_PerformOperation_p SymbolKey_PerformOperation;
51 : :
52 : : typedef unsigned int FIO_File;
53 : :
54 : : typedef struct Sets__T9_r Sets__T9;
55 : :
56 : : typedef Sets__T9 *Sets_Set;
57 : :
58 : : typedef unsigned int *Sets_PtrToBitset;
59 : :
60 : : extern FIO_File FIO_StdOut;
61 : : # define SymbolTable_NulSym 0
62 : : typedef struct M2GCCDeclare_WalkAction_p M2GCCDeclare_WalkAction;
63 : :
64 : : typedef struct SymbolTable_FamilyOperation_p SymbolTable_FamilyOperation;
65 : :
66 : : extern unsigned int M2Base_Cardinal;
67 : : typedef struct M2ALU_cell_r M2ALU_cell;
68 : :
69 : : typedef M2ALU_cell *M2ALU_PtrToValue;
70 : :
71 : : extern unsigned int M2Base_Integer;
72 : : extern unsigned int M2Base_Char;
73 : : extern unsigned int M2Base_Proc;
74 : : extern unsigned int M2Base_LongReal;
75 : : typedef unsigned int NameKey_Name;
76 : :
77 : : typedef struct Indexing__T7_r Indexing__T7;
78 : :
79 : : typedef Indexing__T7 *Indexing_Index;
80 : :
81 : : typedef struct M2GCCDeclare_IsAction_p M2GCCDeclare_IsAction;
82 : :
83 : : # define NameKey_NulName 0
84 : : extern bool M2Options_WholeProgram;
85 : : extern unsigned int M2Base_ZType;
86 : : typedef struct DynamicStrings_stringRecord_r DynamicStrings_stringRecord;
87 : :
88 : : typedef struct DynamicStrings_Contents_r DynamicStrings_Contents;
89 : :
90 : : typedef struct DynamicStrings__T4_a DynamicStrings__T4;
91 : :
92 : : typedef DynamicStrings_stringRecord *DynamicStrings_String;
93 : :
94 : : extern unsigned int M2Base_Boolean;
95 : : typedef struct M2Scope_ScopeProcedure3_p M2Scope_ScopeProcedure3;
96 : :
97 : : typedef struct M2Scope__T10_r M2Scope__T10;
98 : :
99 : : typedef M2Scope__T10 *M2Scope_ScopeBlock;
100 : :
101 : : extern unsigned int M2Base_True;
102 : : typedef struct Lists_list_r Lists_list;
103 : :
104 : : typedef struct Lists__T8_a Lists__T8;
105 : :
106 : : typedef Lists_list *Lists_List;
107 : :
108 : : extern unsigned int M2Base_False;
109 : : extern unsigned int M2Base_RType;
110 : : extern unsigned int M2Base_CType;
111 : : extern unsigned int M2System_Loc;
112 : : extern bool M2Options_Iso;
113 : : extern unsigned int M2System_Byte;
114 : : extern unsigned int M2System_Word;
115 : : extern unsigned int M2System_Address;
116 : : extern unsigned int M2Base_LongInt;
117 : : extern unsigned int M2Base_LongCard;
118 : : extern unsigned int M2Base_ShortInt;
119 : : extern unsigned int M2Base_ShortCard;
120 : : extern unsigned int M2Base_ShortReal;
121 : : extern unsigned int M2Base_Real;
122 : : extern unsigned int M2Bitset_Bitnum;
123 : : extern unsigned int M2Bitset_Bitset;
124 : : extern unsigned int M2Base_Complex;
125 : : extern unsigned int M2Base_LongComplex;
126 : : extern unsigned int M2Base_ShortComplex;
127 : : extern unsigned int M2System_CSizeT;
128 : : extern unsigned int M2System_CSSizeT;
129 : : extern unsigned int M2Base_Nil;
130 : : # define SYSTEM_BITSPERBYTE 8
131 : : # define SYSTEM_BYTESPERWORD 4
132 : : typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP;
133 : :
134 : : # define ASCII_nul (char) 000
135 : : # define ASCII_soh (char) 001
136 : : # define ASCII_stx (char) 002
137 : : # define ASCII_etx (char) 003
138 : : # define ASCII_eot (char) 004
139 : : # define ASCII_enq (char) 005
140 : : # define ASCII_ack (char) 006
141 : : # define ASCII_bel (char) 007
142 : : # define ASCII_bs (char) 010
143 : : # define ASCII_ht (char) 011
144 : : # define ASCII_nl (char) 012
145 : : # define ASCII_vt (char) 013
146 : : # define ASCII_np (char) 014
147 : : # define ASCII_cr (char) 015
148 : : # define ASCII_so (char) 016
149 : : # define ASCII_si (char) 017
150 : : # define ASCII_dle (char) 020
151 : : # define ASCII_dc1 (char) 021
152 : : # define ASCII_dc2 (char) 022
153 : : # define ASCII_dc3 (char) 023
154 : : # define ASCII_dc4 (char) 024
155 : : # define ASCII_nak (char) 025
156 : : # define ASCII_syn (char) 026
157 : : # define ASCII_etb (char) 027
158 : : # define ASCII_can (char) 030
159 : : # define ASCII_em (char) 031
160 : : # define ASCII_sub (char) 032
161 : : # define ASCII_esc (char) 033
162 : : # define ASCII_fs (char) 034
163 : : # define ASCII_gs (char) 035
164 : : # define ASCII_rs (char) 036
165 : : # define ASCII_us (char) 037
166 : : # define ASCII_sp (char) 040
167 : : # define ASCII_lf ASCII_nl
168 : : # define ASCII_ff ASCII_np
169 : : # define ASCII_eof ASCII_eot
170 : : # define ASCII_tab ASCII_ht
171 : : # define ASCII_del (char) 0177
172 : : # define ASCII_EOL ASCII_nl
173 : : extern FIO_File FIO_StdErr;
174 : : extern FIO_File FIO_StdIn;
175 : : extern bool M2Options_Profiling;
176 : : extern bool M2Options_Coding;
177 : : extern bool M2Options_GenerateStatementNote;
178 : : extern bool M2Options_ForcedLocation;
179 : : extern bool M2Options_SharedFlag;
180 : : extern bool M2Options_GenModuleList;
181 : : extern bool M2Options_ScaffoldMain;
182 : : extern bool M2Options_ScaffoldDynamic;
183 : : extern bool M2Options_SaveTemps;
184 : : extern bool M2Options_AutoInit;
185 : : extern bool M2Options_DebugBuiltins;
186 : : extern bool M2Options_LowerCaseKeywords;
187 : : extern bool M2Options_UninitVariableConditionalChecking;
188 : : extern bool M2Options_UninitVariableChecking;
189 : : extern bool M2Options_UnusedParameterChecking;
190 : : extern bool M2Options_UnusedVariableChecking;
191 : : extern bool M2Options_Exceptions;
192 : : extern bool M2Options_GenerateSwig;
193 : : extern bool M2Options_DumpSystemExports;
194 : : extern bool M2Options_ExtendedOpaque;
195 : : extern bool M2Options_Xcode;
196 : : extern bool M2Options_CPreProcessor;
197 : : extern bool M2Options_StrictTypeChecking;
198 : : extern bool M2Options_LineDirectives;
199 : : extern bool M2Options_Quiet;
200 : : extern bool M2Options_CaseEnumChecking;
201 : : extern bool M2Options_VariantValueChecking;
202 : : extern bool M2Options_CaseElseChecking;
203 : : extern bool M2Options_ReturnChecking;
204 : : extern bool M2Options_RangeChecking;
205 : : extern bool M2Options_IndexChecking;
206 : : extern bool M2Options_FloatValueChecking;
207 : : extern bool M2Options_WholeValueChecking;
208 : : extern bool M2Options_WholeDivChecking;
209 : : extern bool M2Options_NilChecking;
210 : : extern bool M2Options_OptimizeCommonSubExpressions;
211 : : extern bool M2Options_OptimizeBasicBlock;
212 : : extern bool M2Options_OptimizeUncalledProcedures;
213 : : extern bool M2Options_VerboseUnbounded;
214 : : extern bool M2Options_UnboundedByReference;
215 : : extern bool M2Options_DumpLangQuad;
216 : : extern bool M2Options_DumpLangGimple;
217 : : extern bool M2Options_DumpLangDecl;
218 : : extern bool M2Options_StyleChecking;
219 : : extern bool M2Options_Statistics;
220 : : extern bool M2Options_PedanticCast;
221 : : extern bool M2Options_PedanticParamNames;
222 : : extern bool M2Options_Pedantic;
223 : : extern bool M2Options_Verbose;
224 : : extern bool M2Options_CompilerDebugging;
225 : : extern bool M2Options_PositiveModFloorDiv;
226 : : extern bool M2Options_Pim4;
227 : : extern bool M2Options_Pim3;
228 : : extern bool M2Options_Pim2;
229 : : extern bool M2Options_Pim;
230 : : extern bool M2Options_cflag;
231 : : extern bool M2Options_PPonly;
232 : : extern bool M2Options_ScaffoldStatic;
233 : : extern bool M2Options_Optimizing;
234 : : extern bool M2Options_GenerateLineDebug;
235 : : extern bool M2Options_GenerateDebugging;
236 : : typedef struct M2Batch_DoProcedure_p M2Batch_DoProcedure;
237 : :
238 : : # define M2LexBuf_UnknownTokenNo 0
239 : : # define M2LexBuf_BuiltinTokenNo 1
240 : : extern int M2LexBuf_currentinteger;
241 : : extern unsigned int M2LexBuf_currentcolumn;
242 : : extern void * M2LexBuf_currentstring;
243 : : typedef struct M2Error__T5_r M2Error__T5;
244 : :
245 : : typedef struct M2Error__T6_r M2Error__T6;
246 : :
247 : : typedef M2Error__T5 *M2Error_Error;
248 : :
249 : : typedef M2Error__T6 *M2Error_ErrorScope;
250 : :
251 : : typedef struct Indexing_IndexProcedure_p Indexing_IndexProcedure;
252 : :
253 : : extern unsigned int M2Base_ExceptionNo;
254 : : extern unsigned int M2Base_ExceptionParameterBounds;
255 : : extern unsigned int M2Base_ExceptionRealValue;
256 : : extern unsigned int M2Base_ExceptionWholeValue;
257 : : extern unsigned int M2Base_ExceptionZeroRem;
258 : : extern unsigned int M2Base_ExceptionZeroDiv;
259 : : extern unsigned int M2Base_ExceptionNonPosMod;
260 : : extern unsigned int M2Base_ExceptionNonPosDiv;
261 : : extern unsigned int M2Base_ExceptionCase;
262 : : extern unsigned int M2Base_ExceptionNoReturn;
263 : : extern unsigned int M2Base_ExceptionPointerNil;
264 : : extern unsigned int M2Base_ExceptionForLoopEnd;
265 : : extern unsigned int M2Base_ExceptionForLoopTo;
266 : : extern unsigned int M2Base_ExceptionForLoopBegin;
267 : : extern unsigned int M2Base_ExceptionDynamicArray;
268 : : extern unsigned int M2Base_ExceptionStaticArray;
269 : : extern unsigned int M2Base_ExceptionRotate;
270 : : extern unsigned int M2Base_ExceptionShift;
271 : : extern unsigned int M2Base_ExceptionExcl;
272 : : extern unsigned int M2Base_ExceptionIncl;
273 : : extern unsigned int M2Base_ExceptionDec;
274 : : extern unsigned int M2Base_ExceptionInc;
275 : : extern unsigned int M2Base_ExceptionReturn;
276 : : extern unsigned int M2Base_ExceptionAssign;
277 : : extern unsigned int M2Base_ActivationPointer;
278 : : extern unsigned int M2Base_TemplateProcedure;
279 : : extern unsigned int M2Base_Excl;
280 : : extern unsigned int M2Base_Incl;
281 : : extern unsigned int M2Base_Dec;
282 : : extern unsigned int M2Base_Inc;
283 : : extern unsigned int M2Base_Dispose;
284 : : extern unsigned int M2Base_New;
285 : : extern unsigned int M2Base_Val;
286 : : extern unsigned int M2Base_Chr;
287 : : extern unsigned int M2Base_Odd;
288 : : extern unsigned int M2Base_Abs;
289 : : extern unsigned int M2Base_Cap;
290 : : extern unsigned int M2Base_Cmplx;
291 : : extern unsigned int M2Base_Im;
292 : : extern unsigned int M2Base_Re;
293 : : extern unsigned int M2Base_Convert;
294 : : extern unsigned int M2Base_LengthS;
295 : : extern unsigned int M2Base_Max;
296 : : extern unsigned int M2Base_Min;
297 : : extern unsigned int M2Base_High;
298 : : extern unsigned int M2System_TBitSize;
299 : : extern unsigned int M2System_Throw;
300 : : extern unsigned int M2System_Shift;
301 : : extern unsigned int M2System_Rotate;
302 : : extern unsigned int M2System_MakeAdr;
303 : : extern unsigned int M2System_DifAdr;
304 : : extern unsigned int M2System_SubAdr;
305 : : extern unsigned int M2System_AddAdr;
306 : : extern unsigned int M2System_TSize;
307 : : extern unsigned int M2System_Adr;
308 : : extern unsigned int M2System_Cast;
309 : : extern unsigned int M2System_System;
310 : : typedef struct M2Scope_ScopeProcedure2_p M2Scope_ScopeProcedure2;
311 : :
312 : : typedef void *m2type_Constructor;
313 : :
314 : : typedef struct m2expr_BuildBinCheckProcedure_p m2expr_BuildBinCheckProcedure;
315 : :
316 : : typedef struct m2expr_BuildBinProcedure_p m2expr_BuildBinProcedure;
317 : :
318 : : typedef struct m2expr_BuildUnaryProcedure_p m2expr_BuildUnaryProcedure;
319 : :
320 : : typedef struct m2expr_BuildUnaryCheckProcedure_p m2expr_BuildUnaryCheckProcedure;
321 : :
322 : : typedef struct m2expr_BuildExprProcedure_p m2expr_BuildExprProcedure;
323 : :
324 : : typedef struct m2expr_BuildSetProcedure_p m2expr_BuildSetProcedure;
325 : :
326 : : typedef struct m2expr_BuildUnarySetProcedure_p m2expr_BuildUnarySetProcedure;
327 : :
328 : : typedef struct m2expr_BuildUnarySetFunction_p m2expr_BuildUnarySetFunction;
329 : :
330 : : typedef long int libc_time_t;
331 : :
332 : : typedef struct libc_tm_r libc_tm;
333 : :
334 : : typedef libc_tm *libc_ptrToTM;
335 : :
336 : : typedef struct libc_timeb_r libc_timeb;
337 : :
338 : : typedef struct libc_exitP_p libc_exitP;
339 : :
340 : : extern NameKey_Name M2Reserved_RDirectiveTok;
341 : : extern NameKey_Name M2Reserved_LDirectiveTok;
342 : : extern NameKey_Name M2Reserved_InlineTok;
343 : : extern NameKey_Name M2Reserved_BuiltinTok;
344 : : extern NameKey_Name M2Reserved_AttributeTok;
345 : : extern NameKey_Name M2Reserved_FileTok;
346 : : extern NameKey_Name M2Reserved_LineTok;
347 : : extern NameKey_Name M2Reserved_DateTok;
348 : : extern NameKey_Name M2Reserved_VolatileTok;
349 : : extern NameKey_Name M2Reserved_AsmTok;
350 : : extern NameKey_Name M2Reserved_EofTok;
351 : : extern NameKey_Name M2Reserved_WithTok;
352 : : extern NameKey_Name M2Reserved_WhileTok;
353 : : extern NameKey_Name M2Reserved_VarTok;
354 : : extern NameKey_Name M2Reserved_UntilTok;
355 : : extern NameKey_Name M2Reserved_TypeTok;
356 : : extern NameKey_Name M2Reserved_ToTok;
357 : : extern NameKey_Name M2Reserved_ThenTok;
358 : : extern NameKey_Name M2Reserved_SetTok;
359 : : extern NameKey_Name M2Reserved_ReturnTok;
360 : : extern NameKey_Name M2Reserved_RepeatTok;
361 : : extern NameKey_Name M2Reserved_RemTok;
362 : : extern NameKey_Name M2Reserved_RetryTok;
363 : : extern NameKey_Name M2Reserved_RecordTok;
364 : : extern NameKey_Name M2Reserved_UnQualifiedTok;
365 : : extern NameKey_Name M2Reserved_QualifiedTok;
366 : : extern NameKey_Name M2Reserved_ProcedureTok;
367 : : extern NameKey_Name M2Reserved_PointerTok;
368 : : extern NameKey_Name M2Reserved_PackedSetTok;
369 : : extern NameKey_Name M2Reserved_OrTok;
370 : : extern NameKey_Name M2Reserved_OfTok;
371 : : extern NameKey_Name M2Reserved_NotTok;
372 : : extern NameKey_Name M2Reserved_ModuleTok;
373 : : extern NameKey_Name M2Reserved_ModTok;
374 : : extern NameKey_Name M2Reserved_LoopTok;
375 : : extern NameKey_Name M2Reserved_InTok;
376 : : extern NameKey_Name M2Reserved_ImportTok;
377 : : extern NameKey_Name M2Reserved_ImplementationTok;
378 : : extern NameKey_Name M2Reserved_IfTok;
379 : : extern NameKey_Name M2Reserved_FromTok;
380 : : extern NameKey_Name M2Reserved_ForTok;
381 : : extern NameKey_Name M2Reserved_FinallyTok;
382 : : extern NameKey_Name M2Reserved_ExportTok;
383 : : extern NameKey_Name M2Reserved_ExitTok;
384 : : extern NameKey_Name M2Reserved_ExceptTok;
385 : : extern NameKey_Name M2Reserved_EndTok;
386 : : extern NameKey_Name M2Reserved_ElsifTok;
387 : : extern NameKey_Name M2Reserved_ElseTok;
388 : : extern NameKey_Name M2Reserved_DoTok;
389 : : extern NameKey_Name M2Reserved_DivTok;
390 : : extern NameKey_Name M2Reserved_DefinitionTok;
391 : : extern NameKey_Name M2Reserved_ConstTok;
392 : : extern NameKey_Name M2Reserved_CaseTok;
393 : : extern NameKey_Name M2Reserved_ByTok;
394 : : extern NameKey_Name M2Reserved_BeginTok;
395 : : extern NameKey_Name M2Reserved_ArrayTok;
396 : : extern NameKey_Name M2Reserved_AndTok;
397 : : extern NameKey_Name M2Reserved_DoubleQuotesTok;
398 : : extern NameKey_Name M2Reserved_BarTok;
399 : : extern NameKey_Name M2Reserved_RCBraTok;
400 : : extern NameKey_Name M2Reserved_RSBraTok;
401 : : extern NameKey_Name M2Reserved_RParaTok;
402 : : extern NameKey_Name M2Reserved_ColonTok;
403 : : extern NameKey_Name M2Reserved_PeriodPeriodTok;
404 : : extern NameKey_Name M2Reserved_GreaterEqualTok;
405 : : extern NameKey_Name M2Reserved_LessEqualTok;
406 : : extern NameKey_Name M2Reserved_LessGreaterTok;
407 : : extern NameKey_Name M2Reserved_GreaterTok;
408 : : extern NameKey_Name M2Reserved_LessTok;
409 : : extern NameKey_Name M2Reserved_HashTok;
410 : : extern NameKey_Name M2Reserved_EqualTok;
411 : : extern NameKey_Name M2Reserved_SingleQuoteTok;
412 : : extern NameKey_Name M2Reserved_UpArrowTok;
413 : : extern NameKey_Name M2Reserved_LCBraTok;
414 : : extern NameKey_Name M2Reserved_LSBraTok;
415 : : extern NameKey_Name M2Reserved_LParaTok;
416 : : extern NameKey_Name M2Reserved_SemiColonTok;
417 : : extern NameKey_Name M2Reserved_CommaTok;
418 : : extern NameKey_Name M2Reserved_PeriodTok;
419 : : extern NameKey_Name M2Reserved_AmbersandTok;
420 : : extern NameKey_Name M2Reserved_BecomesTok;
421 : : extern NameKey_Name M2Reserved_DivideTok;
422 : : extern NameKey_Name M2Reserved_TimesTok;
423 : : extern NameKey_Name M2Reserved_MinusTok;
424 : : extern NameKey_Name M2Reserved_PlusTok;
425 : : extern NameKey_Name M2Reserved_NulTok;
426 : : typedef struct M2StackAddress__T11_r M2StackAddress__T11;
427 : :
428 : : typedef M2StackAddress__T11 *M2StackAddress_StackOfAddress;
429 : :
430 : : typedef struct M2StackAddress__T12_r M2StackAddress__T12;
431 : :
432 : : typedef M2StackAddress__T12 *M2StackAddress_StackBucket;
433 : :
434 : : typedef struct M2StackAddress__T13_a M2StackAddress__T13;
435 : :
436 : : # define SymbolKey_NulKey 0
437 : : typedef struct SymbolKey_IsSymbol_p SymbolKey_IsSymbol;
438 : :
439 : : typedef struct SymbolKey_Node_r SymbolKey_Node;
440 : :
441 : : typedef SymbolKey_Node *SymbolKey_SymbolTree;
442 : :
443 : : typedef struct M2StackWord_StackDescriptor_r M2StackWord_StackDescriptor;
444 : :
445 : : typedef M2StackWord_StackDescriptor *M2StackWord_StackOfWord;
446 : :
447 : : typedef struct M2StackWord_BucketWord_r M2StackWord_BucketWord;
448 : :
449 : : typedef M2StackWord_BucketWord *M2StackWord_StackBucketWord;
450 : :
451 : : typedef struct M2StackWord__T14_a M2StackWord__T14;
452 : :
453 : : # define Debugging false
454 : : # define Progress false
455 : : # define EnableSSA false
456 : : # define EnableWatch true
457 : : # define TraceQuadruples false
458 : : typedef struct M2GCCDeclare_StartProcedure_p M2GCCDeclare_StartProcedure;
459 : :
460 : : typedef struct M2GCCDeclare_doDeclareProcedure_p M2GCCDeclare_doDeclareProcedure;
461 : :
462 : : typedef struct M2GCCDeclare__T15_r M2GCCDeclare__T15;
463 : :
464 : : typedef M2GCCDeclare__T15 *M2GCCDeclare_Group;
465 : :
466 : : typedef enum {M2ALU_none, M2ALU_integer, M2ALU_real, M2ALU_complex, M2ALU_set, M2ALU_constructor, M2ALU_array, M2ALU_record} M2ALU_cellType;
467 : :
468 : : typedef struct M2ALU_rList_r M2ALU_rList;
469 : :
470 : : typedef M2ALU_rList *M2ALU_listOfRange;
471 : :
472 : : typedef struct M2ALU_fList_r M2ALU_fList;
473 : :
474 : : typedef M2ALU_fList *M2ALU_listOfFields;
475 : :
476 : : typedef struct M2ALU_eList_r M2ALU_eList;
477 : :
478 : : typedef M2ALU_eList *M2ALU_listOfElements;
479 : :
480 : : # define MaxBuf 127
481 : : typedef enum {M2Scope_unsetscope, M2Scope_ignorescope, M2Scope_procedurescope, M2Scope_modulescope, M2Scope_definitionscope, M2Scope_implementationscope, M2Scope_programscope} M2Scope_scopeKind;
482 : :
483 : : typedef enum {SymbolTable_NoValue, SymbolTable_ImmediateValue, SymbolTable_RightValue, SymbolTable_LeftValue} SymbolTable_ModeOfAddr;
484 : :
485 : : # define MaxNoOfElements 5
486 : : typedef enum {M2GCCDeclare_fullydeclared, M2GCCDeclare_partiallydeclared, M2GCCDeclare_niltypedarrays, M2GCCDeclare_heldbyalignment, M2GCCDeclare_finishedalignment, M2GCCDeclare_todolist, M2GCCDeclare_tobesolvedbyquads, M2GCCDeclare_finishedsetarray} M2GCCDeclare_ListType;
487 : :
488 : : typedef enum {M2GCCDeclare_norule, M2GCCDeclare_partialtype, M2GCCDeclare_arraynil, M2GCCDeclare_pointernilarray, M2GCCDeclare_arraypartial, M2GCCDeclare_pointerfully, M2GCCDeclare_recordkind, M2GCCDeclare_recordfully, M2GCCDeclare_typeconstfully, M2GCCDeclare_pointerfrompartial, M2GCCDeclare_typefrompartial, M2GCCDeclare_partialfrompartial, M2GCCDeclare_partialtofully, M2GCCDeclare_circulartodo, M2GCCDeclare_circularpartial, M2GCCDeclare_circularniltyped} M2GCCDeclare_Rule;
489 : :
490 : : # define DebugLoop 1000
491 : : typedef enum {M2Quads_AddOp, M2Quads_AddrOp, M2Quads_ArithAddOp, M2Quads_ArrayOp, M2Quads_BecomesOp, M2Quads_BuiltinConstOp, M2Quads_BuiltinTypeInfoOp, M2Quads_CallOp, M2Quads_CastOp, M2Quads_CatchBeginOp, M2Quads_CatchEndOp, M2Quads_CodeOffOp, M2Quads_CodeOnOp, M2Quads_CoerceOp, M2Quads_ConvertOp, M2Quads_DivCeilOp, M2Quads_DivFloorOp, M2Quads_DivM2Op, M2Quads_DivTruncOp, M2Quads_DummyOp, M2Quads_ElementSizeOp, M2Quads_EndFileOp, M2Quads_ErrorOp, M2Quads_ExclOp, M2Quads_FinallyEndOp, M2Quads_FinallyStartOp, M2Quads_FunctValueOp, M2Quads_GotoOp, M2Quads_HighOp, M2Quads_IfEquOp, M2Quads_IfGreEquOp, M2Quads_IfGreOp, M2Quads_IfInOp, M2Quads_IfLessEquOp, M2Quads_IfLessOp, M2Quads_IfNotEquOp, M2Quads_IfNotInOp, M2Quads_InclOp, M2Quads_IndrXOp, M2Quads_InitAddressOp, M2Quads_InitEndOp, M2Quads_InitStartOp, M2Quads_InlineOp, M2Quads_KillLocalVarOp, M2Quads_LineNumberOp, M2Quads_LogicalAndOp, M2Quads_LogicalDiffOp, M2Quads_LogicalOrOp, M2Quads_LogicalRotateOp, M2Quads_LogicalShiftOp, M2Quads_LogicalXorOp, M2Quads_ModCeilOp, M2Quads_ModFloorOp, M2Quads_ModM2Op, M2Quads_ModTruncOp, M2Quads_ModuleScopeOp, M2Quads_MultOp, M2Quads_NegateOp, M2Quads_NewLocalVarOp, M2Quads_OptimizeOffOp, M2Quads_OptimizeOnOp, M2Quads_OptParamOp, M2Quads_ParamOp, M2Quads_ProcedureScopeOp, M2Quads_ProfileOffOp, M2Quads_ProfileOnOp, M2Quads_RangeCheckOp, M2Quads_RecordFieldOp, M2Quads_RestoreExceptionOp, M2Quads_RestorePriorityOp, M2Quads_RetryOp, M2Quads_ReturnOp, M2Quads_ReturnValueOp, M2Quads_SaveExceptionOp, M2Quads_SavePriorityOp, M2Quads_SizeOp, M2Quads_StandardFunctionOp, M2Quads_StartDefFileOp, M2Quads_StartModFileOp, M2Quads_StatementNoteOp, M2Quads_SubOp, M2Quads_SubrangeHighOp, M2Quads_SubrangeLowOp, M2Quads_StringConvertCnulOp, M2Quads_StringConvertM2nulOp, M2Quads_StringLengthOp, M2Quads_ThrowOp, M2Quads_TryOp, M2Quads_UnboundedOp, M2Quads_XIndrOp} M2Quads_QuadOperator;
492 : :
493 : : typedef enum {M2Reserved_eoftok, M2Reserved_plustok, M2Reserved_minustok, M2Reserved_timestok, M2Reserved_dividetok, M2Reserved_becomestok, M2Reserved_ambersandtok, M2Reserved_periodtok, M2Reserved_commatok, M2Reserved_semicolontok, M2Reserved_lparatok, M2Reserved_rparatok, M2Reserved_lsbratok, M2Reserved_rsbratok, M2Reserved_lcbratok, M2Reserved_rcbratok, M2Reserved_uparrowtok, M2Reserved_singlequotetok, M2Reserved_equaltok, M2Reserved_hashtok, M2Reserved_lesstok, M2Reserved_greatertok, M2Reserved_lessgreatertok, M2Reserved_lessequaltok, M2Reserved_greaterequaltok, M2Reserved_ldirectivetok, M2Reserved_rdirectivetok, M2Reserved_periodperiodtok, M2Reserved_colontok, M2Reserved_doublequotestok, M2Reserved_bartok, M2Reserved_andtok, M2Reserved_arraytok, M2Reserved_begintok, M2Reserved_bytok, M2Reserved_casetok, M2Reserved_consttok, M2Reserved_definitiontok, M2Reserved_divtok, M2Reserved_dotok, M2Reserved_elsetok, M2Reserved_elsiftok, M2Reserved_endtok, M2Reserved_excepttok, M2Reserved_exittok, M2Reserved_exporttok, M2Reserved_finallytok, M2Reserved_fortok, M2Reserved_fromtok, M2Reserved_iftok, M2Reserved_implementationtok, M2Reserved_importtok, M2Reserved_intok, M2Reserved_looptok, M2Reserved_modtok, M2Reserved_moduletok, M2Reserved_nottok, M2Reserved_oftok, M2Reserved_ortok, M2Reserved_packedsettok, M2Reserved_pointertok, M2Reserved_proceduretok, M2Reserved_qualifiedtok, M2Reserved_unqualifiedtok, M2Reserved_recordtok, M2Reserved_remtok, M2Reserved_repeattok, M2Reserved_retrytok, M2Reserved_returntok, M2Reserved_settok, M2Reserved_thentok, M2Reserved_totok, M2Reserved_typetok, M2Reserved_untiltok, M2Reserved_vartok, M2Reserved_whiletok, M2Reserved_withtok, M2Reserved_asmtok, M2Reserved_volatiletok, M2Reserved_periodperiodperiodtok, M2Reserved_datetok, M2Reserved_linetok, M2Reserved_filetok, M2Reserved_attributetok, M2Reserved_builtintok, M2Reserved_inlinetok, M2Reserved_integertok, M2Reserved_identtok, M2Reserved_realtok, M2Reserved_stringtok, M2Reserved_virtualrangetok} M2Reserved_toktype;
494 : :
495 : : extern M2Reserved_toktype M2LexBuf_currenttoken;
496 : : typedef enum {M2Error_noscope, M2Error_definition, M2Error_implementation, M2Error_program, M2Error_module, M2Error_procedure} M2Error_KindScope;
497 : :
498 : : # define MaxBucket 10
499 : : # define MaxBucket 10
500 : : typedef void (*SymbolKey_PerformOperation_t) (unsigned int);
501 : : struct SymbolKey_PerformOperation_p { SymbolKey_PerformOperation_t proc; };
502 : :
503 : : struct Sets__T9_r {
504 : : unsigned int init;
505 : : unsigned int start;
506 : : unsigned int end;
507 : : Sets_PtrToBitset pb;
508 : : unsigned int bytes;
509 : : unsigned int elements;
510 : : };
511 : :
512 : : typedef void (*M2GCCDeclare_WalkAction_t) (unsigned int);
513 : : struct M2GCCDeclare_WalkAction_p { M2GCCDeclare_WalkAction_t proc; };
514 : :
515 : : typedef void (*SymbolTable_FamilyOperation_t) (unsigned int, unsigned int, unsigned int);
516 : : struct SymbolTable_FamilyOperation_p { SymbolTable_FamilyOperation_t proc; };
517 : :
518 : : struct M2ALU_cell_r {
519 : : m2linemap_location_t location;
520 : : bool areAllConstants;
521 : : bool solved;
522 : : unsigned int constructorType;
523 : : M2ALU_PtrToValue next;
524 : : m2tree_Tree numberValue;
525 : : M2ALU_cellType type; /* case tag */
526 : : union {
527 : : M2ALU_listOfRange setValue;
528 : : M2ALU_listOfFields fieldValues;
529 : : M2ALU_listOfElements arrayValues;
530 : : };
531 : : };
532 : :
533 : : struct Indexing__T7_r {
534 : : void *ArrayStart;
535 : : unsigned int ArraySize;
536 : : unsigned int Used;
537 : : unsigned int Low;
538 : : unsigned int High;
539 : : bool Debug;
540 : : unsigned int Map;
541 : : unsigned int GrowFactor;
542 : : };
543 : :
544 : : typedef bool (*M2GCCDeclare_IsAction_t) (unsigned int);
545 : : struct M2GCCDeclare_IsAction_p { M2GCCDeclare_IsAction_t proc; };
546 : :
547 : : struct DynamicStrings__T4_a { char array[(MaxBuf-1)+1]; };
548 : : typedef void (*M2Scope_ScopeProcedure3_t) (unsigned int, unsigned int, unsigned int);
549 : : struct M2Scope_ScopeProcedure3_p { M2Scope_ScopeProcedure3_t proc; };
550 : :
551 : : struct M2Scope__T10_r {
552 : : unsigned int scopeSym;
553 : : M2Scope_scopeKind kindScope;
554 : : unsigned int low;
555 : : unsigned int high;
556 : : M2Scope_ScopeBlock next;
557 : : };
558 : :
559 : : struct Lists__T8_a { unsigned int array[MaxNoOfElements-1+1]; };
560 : : typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *);
561 : : struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; };
562 : :
563 : : typedef void (*M2Batch_DoProcedure_t) (unsigned int);
564 : : struct M2Batch_DoProcedure_p { M2Batch_DoProcedure_t proc; };
565 : :
566 : : struct M2Error__T5_r {
567 : : M2Error_Error parent;
568 : : M2Error_Error child;
569 : : M2Error_Error next;
570 : : bool note;
571 : : bool fatal;
572 : : DynamicStrings_String s;
573 : : unsigned int token;
574 : : bool color;
575 : : M2Error_ErrorScope scope;
576 : : };
577 : :
578 : : struct M2Error__T6_r {
579 : : M2Error_KindScope scopeKind;
580 : : NameKey_Name scopeName;
581 : : unsigned int symbol;
582 : : };
583 : :
584 : : typedef void (*Indexing_IndexProcedure_t) (void *);
585 : : struct Indexing_IndexProcedure_p { Indexing_IndexProcedure_t proc; };
586 : :
587 : : typedef void (*M2Scope_ScopeProcedure2_t) (unsigned int, unsigned int);
588 : : struct M2Scope_ScopeProcedure2_p { M2Scope_ScopeProcedure2_t proc; };
589 : :
590 : : typedef m2tree_Tree (*m2expr_BuildBinCheckProcedure_t) (m2linemap_location_t, m2tree_Tree, m2tree_Tree, m2tree_Tree, m2tree_Tree, m2tree_Tree);
591 : : typedef m2expr_BuildBinCheckProcedure_t m2expr_BuildBinCheckProcedure_C;
592 : :
593 : : struct m2expr_BuildBinCheckProcedure_p { m2expr_BuildBinCheckProcedure_t proc; };
594 : :
595 : : typedef m2tree_Tree (*m2expr_BuildBinProcedure_t) (m2linemap_location_t, m2tree_Tree, m2tree_Tree, bool);
596 : : typedef m2expr_BuildBinProcedure_t m2expr_BuildBinProcedure_C;
597 : :
598 : : struct m2expr_BuildBinProcedure_p { m2expr_BuildBinProcedure_t proc; };
599 : :
600 : : typedef m2tree_Tree (*m2expr_BuildUnaryProcedure_t) (m2linemap_location_t, m2tree_Tree, bool);
601 : : typedef m2expr_BuildUnaryProcedure_t m2expr_BuildUnaryProcedure_C;
602 : :
603 : : struct m2expr_BuildUnaryProcedure_p { m2expr_BuildUnaryProcedure_t proc; };
604 : :
605 : : typedef m2tree_Tree (*m2expr_BuildUnaryCheckProcedure_t) (m2linemap_location_t, m2tree_Tree, m2tree_Tree, m2tree_Tree, m2tree_Tree);
606 : : typedef m2expr_BuildUnaryCheckProcedure_t m2expr_BuildUnaryCheckProcedure_C;
607 : :
608 : : struct m2expr_BuildUnaryCheckProcedure_p { m2expr_BuildUnaryCheckProcedure_t proc; };
609 : :
610 : : typedef m2tree_Tree (*m2expr_BuildExprProcedure_t) (m2linemap_location_t, m2tree_Tree, m2tree_Tree);
611 : : typedef m2expr_BuildExprProcedure_t m2expr_BuildExprProcedure_C;
612 : :
613 : : struct m2expr_BuildExprProcedure_p { m2expr_BuildExprProcedure_t proc; };
614 : :
615 : : typedef void (*m2expr_BuildSetProcedure_t) (m2linemap_location_t, m2tree_Tree, m2tree_Tree, m2tree_Tree, m2tree_Tree, bool);
616 : : typedef m2expr_BuildSetProcedure_t m2expr_BuildSetProcedure_C;
617 : :
618 : : struct m2expr_BuildSetProcedure_p { m2expr_BuildSetProcedure_t proc; };
619 : :
620 : : typedef void (*m2expr_BuildUnarySetProcedure_t) (m2linemap_location_t, m2tree_Tree, bool);
621 : : typedef m2expr_BuildUnarySetProcedure_t m2expr_BuildUnarySetProcedure_C;
622 : :
623 : : struct m2expr_BuildUnarySetProcedure_p { m2expr_BuildUnarySetProcedure_t proc; };
624 : :
625 : : typedef m2tree_Tree (*m2expr_BuildUnarySetFunction_t) (m2linemap_location_t, m2tree_Tree, bool);
626 : : typedef m2expr_BuildUnarySetFunction_t m2expr_BuildUnarySetFunction_C;
627 : :
628 : : struct m2expr_BuildUnarySetFunction_p { m2expr_BuildUnarySetFunction_t proc; };
629 : :
630 : : struct libc_tm_r {
631 : : int tm_sec;
632 : : int tm_min;
633 : : int tm_hour;
634 : : int tm_mday;
635 : : int tm_mon;
636 : : int tm_year;
637 : : int tm_wday;
638 : : int tm_yday;
639 : : int tm_isdst;
640 : : long int tm_gmtoff;
641 : : void *tm_zone;
642 : : };
643 : :
644 : : struct libc_timeb_r {
645 : : libc_time_t time_;
646 : : short unsigned int millitm;
647 : : short unsigned int timezone;
648 : : short unsigned int dstflag;
649 : : };
650 : :
651 : : typedef int (*libc_exitP_t) (void);
652 : : typedef libc_exitP_t libc_exitP_C;
653 : :
654 : : struct libc_exitP_p { libc_exitP_t proc; };
655 : :
656 : : struct M2StackAddress__T11_r {
657 : : M2StackAddress_StackBucket tail;
658 : : };
659 : :
660 : : struct M2StackAddress__T13_a { void * array[(MaxBucket-1)+1]; };
661 : : typedef bool (*SymbolKey_IsSymbol_t) (unsigned int);
662 : : struct SymbolKey_IsSymbol_p { SymbolKey_IsSymbol_t proc; };
663 : :
664 : : struct SymbolKey_Node_r {
665 : : NameKey_Name KeyName;
666 : : unsigned int KeySym;
667 : : SymbolKey_SymbolTree Left;
668 : : SymbolKey_SymbolTree Right;
669 : : };
670 : :
671 : : struct M2StackWord_StackDescriptor_r {
672 : : M2StackWord_StackBucketWord tail;
673 : : };
674 : :
675 : : struct M2StackWord__T14_a { unsigned int array[(MaxBucket-1)+1]; };
676 : : typedef m2tree_Tree (*M2GCCDeclare_StartProcedure_t) (m2linemap_location_t, void *);
677 : : struct M2GCCDeclare_StartProcedure_p { M2GCCDeclare_StartProcedure_t proc; };
678 : :
679 : : typedef void (*M2GCCDeclare_doDeclareProcedure_t) (unsigned int, unsigned int);
680 : : struct M2GCCDeclare_doDeclareProcedure_p { M2GCCDeclare_doDeclareProcedure_t proc; };
681 : :
682 : : struct M2GCCDeclare__T15_r {
683 : : Sets_Set ToBeSolvedByQuads;
684 : : Sets_Set FinishedSetArray;
685 : : Sets_Set NilTypedArrays;
686 : : Sets_Set FullyDeclared;
687 : : Sets_Set PartiallyDeclared;
688 : : Sets_Set HeldByAlignment;
689 : : Sets_Set FinishedAlignment;
690 : : Sets_Set ToDoList;
691 : : M2GCCDeclare_Group Next;
692 : : };
693 : :
694 : : struct M2ALU_rList_r {
695 : : unsigned int low;
696 : : unsigned int high;
697 : : M2ALU_listOfRange next;
698 : : };
699 : :
700 : : struct M2ALU_fList_r {
701 : : unsigned int field;
702 : : M2ALU_listOfFields next;
703 : : };
704 : :
705 : : struct M2ALU_eList_r {
706 : : unsigned int element;
707 : : unsigned int by;
708 : : M2ALU_listOfElements next;
709 : : };
710 : :
711 : : struct DynamicStrings_Contents_r {
712 : : DynamicStrings__T4 buf;
713 : : unsigned int len;
714 : : DynamicStrings_String next;
715 : : };
716 : :
717 : : struct Lists_list_r {
718 : : unsigned int NoOfElements;
719 : : Lists__T8 Elements;
720 : : Lists_List Next;
721 : : };
722 : :
723 : : struct M2StackAddress__T12_r {
724 : : M2StackAddress__T13 bucket;
725 : : unsigned int items;
726 : : M2StackAddress_StackBucket prev;
727 : : };
728 : :
729 : : struct M2StackWord_BucketWord_r {
730 : : M2StackWord__T14 bucket;
731 : : unsigned int items;
732 : : M2StackWord_StackBucketWord last;
733 : : };
734 : :
735 : : typedef struct DynamicStrings_descriptor_r DynamicStrings_descriptor;
736 : :
737 : : typedef DynamicStrings_descriptor *DynamicStrings_Descriptor;
738 : :
739 : : typedef struct DynamicStrings_DebugInfo_r DynamicStrings_DebugInfo;
740 : :
741 : : typedef enum {DynamicStrings_inuse, DynamicStrings_marked, DynamicStrings_onlist, DynamicStrings_poisoned} DynamicStrings_desState;
742 : :
743 : : struct DynamicStrings_descriptor_r {
744 : : bool charStarUsed;
745 : : void *charStar;
746 : : unsigned int charStarSize;
747 : : bool charStarValid;
748 : : DynamicStrings_desState state;
749 : : DynamicStrings_String garbage;
750 : : };
751 : :
752 : : struct DynamicStrings_DebugInfo_r {
753 : : DynamicStrings_String next;
754 : : void *file;
755 : : unsigned int line;
756 : : void *proc;
757 : : };
758 : :
759 : : static M2GCCDeclare_Group FreeGroup;
760 : : static M2GCCDeclare_Group GlobalGroup;
761 : : static Sets_Set VisitedList;
762 : : static Sets_Set ChainedList;
763 : : static bool HaveInitDefaultTypes;
764 : : static Sets_Set WatchList;
765 : : static Indexing_Index EnumerationIndex;
766 : : static M2GCCDeclare_IsAction action;
767 : : static bool enumDeps;
768 : : static M2GCCDeclare_WalkAction bodyp;
769 : : static M2GCCDeclare_IsAction bodyq;
770 : : static M2GCCDeclare_ListType bodyt;
771 : : static M2GCCDeclare_Rule bodyr;
772 : : static bool recursionCaught;
773 : : static bool oneResolved;
774 : : static bool noMoreWritten;
775 : : static M2GCCDeclare_WalkAction unboundedp;
776 : : static unsigned int MaxEnumerationField;
777 : : static unsigned int MinEnumerationField;
778 : : struct DynamicStrings_stringRecord_r {
779 : : DynamicStrings_Contents contents;
780 : : DynamicStrings_Descriptor head;
781 : : DynamicStrings_DebugInfo debug;
782 : : };
783 : :
784 : : extern "C" void SYSTEM_ShiftVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int ShiftCount);
785 : : extern "C" void SYSTEM_ShiftLeft (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int ShiftCount);
786 : : extern "C" void SYSTEM_ShiftRight (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int ShiftCount);
787 : : extern "C" void SYSTEM_RotateVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int RotateCount);
788 : : extern "C" void SYSTEM_RotateLeft (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int RotateCount);
789 : : extern "C" void SYSTEM_RotateRight (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, unsigned int RotateCount);
790 : : extern "C" void M2RTS_ConstructModules (void * applicationmodule, void * libname, void * overrideliborder, int argc, void * argv, void * envp);
791 : : extern "C" void M2RTS_DeconstructModules (void * applicationmodule, void * libname, int argc, void * argv, void * envp);
792 : : extern "C" void M2RTS_RegisterModule (void * name, void * libname, M2RTS_ArgCVEnvP init, M2RTS_ArgCVEnvP fini, PROC dependencies);
793 : : extern "C" void M2RTS_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname);
794 : : extern "C" bool M2RTS_InstallTerminationProcedure (PROC p);
795 : : extern "C" void M2RTS_ExecuteInitialProcedures (void);
796 : : extern "C" bool M2RTS_InstallInitialProcedure (PROC p);
797 : : extern "C" void M2RTS_ExecuteTerminationProcedures (void);
798 : : extern "C" void M2RTS_Terminate (void) __attribute__ ((noreturn));
799 : : extern "C" void M2RTS_HALT (int exitcode) __attribute__ ((noreturn));
800 : : extern "C" void M2RTS_Halt (const char *description_, unsigned int _description_high, const char *filename_, unsigned int _filename_high, const char *function_, unsigned int _function_high, unsigned int line) __attribute__ ((noreturn));
801 : : extern "C" void M2RTS_HaltC (void * description, void * filename, void * function, unsigned int line) __attribute__ ((noreturn));
802 : : extern "C" void M2RTS_ExitOnHalt (int e);
803 : : extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn));
804 : : extern "C" unsigned int M2RTS_Length (const char *a_, unsigned int _a_high);
805 : : extern "C" void M2RTS_AssignmentException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
806 : : extern "C" void M2RTS_ReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
807 : : extern "C" void M2RTS_IncException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
808 : : extern "C" void M2RTS_DecException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
809 : : extern "C" void M2RTS_InclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
810 : : extern "C" void M2RTS_ExclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
811 : : extern "C" void M2RTS_ShiftException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
812 : : extern "C" void M2RTS_RotateException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
813 : : extern "C" void M2RTS_StaticArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
814 : : extern "C" void M2RTS_DynamicArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
815 : : extern "C" void M2RTS_ForLoopBeginException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
816 : : extern "C" void M2RTS_ForLoopToException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
817 : : extern "C" void M2RTS_ForLoopEndException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
818 : : extern "C" void M2RTS_PointerNilException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
819 : : extern "C" void M2RTS_NoReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
820 : : extern "C" void M2RTS_CaseException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
821 : : extern "C" void M2RTS_WholeNonPosDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
822 : : extern "C" void M2RTS_WholeNonPosModException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
823 : : extern "C" void M2RTS_WholeZeroDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
824 : : extern "C" void M2RTS_WholeZeroRemException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
825 : : extern "C" void M2RTS_WholeValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
826 : : extern "C" void M2RTS_RealValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
827 : : extern "C" void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
828 : : extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
829 : :
830 : : /*
831 : : FoldConstants - a wrapper for ResolveConstantExpressions.
832 : : */
833 : :
834 : : extern "C" void M2GCCDeclare_FoldConstants (unsigned int start, unsigned int end);
835 : :
836 : : /*
837 : : StartDeclareScope - declares types, variables associated with this scope.
838 : : */
839 : :
840 : : extern "C" void M2GCCDeclare_StartDeclareScope (unsigned int scope);
841 : :
842 : : /*
843 : : EndDeclareScope -
844 : : */
845 : :
846 : : extern "C" void M2GCCDeclare_EndDeclareScope (void);
847 : :
848 : : /*
849 : : DeclareParameters -
850 : : */
851 : :
852 : : extern "C" void M2GCCDeclare_DeclareParameters (unsigned int sym);
853 : :
854 : : /*
855 : : DeclareConstant - checks to see whether, sym, is a constant and
856 : : declares the constant to gcc.
857 : : */
858 : :
859 : : extern "C" void M2GCCDeclare_DeclareConstant (unsigned int tokenno, unsigned int sym);
860 : :
861 : : /*
862 : : DeclareConstructor - declares a constructor.
863 : : */
864 : :
865 : : extern "C" void M2GCCDeclare_DeclareConstructor (unsigned int tokenno, unsigned int quad, unsigned int sym);
866 : :
867 : : /*
868 : : TryDeclareConstant - try and declare a constant. If, sym, is a
869 : : constant try and declare it, if we cannot
870 : : then enter it into the to do list.
871 : : */
872 : :
873 : : extern "C" void M2GCCDeclare_TryDeclareConstant (unsigned int tokenno, unsigned int sym);
874 : :
875 : : /*
876 : : TryDeclareConstructor - try and declare a constructor. If, sym, is a
877 : : constructor try and declare it, if we cannot
878 : : then enter it into the to do list.
879 : : */
880 : :
881 : : extern "C" void M2GCCDeclare_TryDeclareConstructor (unsigned int tokenno, unsigned int sym);
882 : :
883 : : /*
884 : : DeclareLocalVariables - declares Local variables for procedure.
885 : : */
886 : :
887 : : extern "C" void M2GCCDeclare_DeclareLocalVariables (unsigned int procedure);
888 : :
889 : : /*
890 : : DeclareLocalVariable - declare a local variable var.
891 : : */
892 : :
893 : : extern "C" void M2GCCDeclare_DeclareLocalVariable (unsigned int var);
894 : :
895 : : /*
896 : : DeclareProcedure - declares procedure, sym, or all procedures inside
897 : : module sym.
898 : : */
899 : :
900 : : extern "C" void M2GCCDeclare_DeclareProcedure (unsigned int sym);
901 : :
902 : : /*
903 : : DeclareModuleVariables - declares Module variables for a module
904 : : which was declared inside a procedure.
905 : : */
906 : :
907 : : extern "C" void M2GCCDeclare_DeclareModuleVariables (unsigned int sym);
908 : :
909 : : /*
910 : : IsProcedureGccNested - returns TRUE if procedure, sym, will be considered
911 : : as nested by GCC.
912 : : This will occur if either its outer defining scope
913 : : is a procedure or is a module which is inside a
914 : : procedure.
915 : : */
916 : :
917 : : extern "C" bool M2GCCDeclare_IsProcedureGccNested (unsigned int sym);
918 : :
919 : : /*
920 : : PoisonSymbols - poisons all gcc symbols from procedure, sym.
921 : : A debugging aid.
922 : : */
923 : :
924 : : extern "C" void M2GCCDeclare_PoisonSymbols (unsigned int sym);
925 : :
926 : : /*
927 : : PromoteToString - declare, sym, and then promote it to a string.
928 : : Note that if sym is a single character we do
929 : : *not* record it as a string
930 : : but as a char however we always
931 : : return a string constant.
932 : : */
933 : :
934 : : extern "C" m2tree_Tree M2GCCDeclare_PromoteToString (unsigned int tokenno, unsigned int sym);
935 : :
936 : : /*
937 : : PromoteToCString - declare, sym, and then promote it to a string.
938 : : Note that if sym is a single character we do
939 : : *not* record it as a string
940 : : but as a char however we always
941 : : return a string constant.
942 : : */
943 : :
944 : : extern "C" m2tree_Tree M2GCCDeclare_PromoteToCString (unsigned int tokenno, unsigned int sym);
945 : :
946 : : /*
947 : : CompletelyResolved - returns TRUE if a symbols has been completely resolved
948 : : and is not partically declared (such as a record).
949 : : */
950 : :
951 : : extern "C" bool M2GCCDeclare_CompletelyResolved (unsigned int sym);
952 : :
953 : : /*
954 : : ConstantKnownAndUsed -
955 : : */
956 : :
957 : : extern "C" void M2GCCDeclare_ConstantKnownAndUsed (unsigned int sym, m2tree_Tree t);
958 : :
959 : : /*
960 : : PutToBeSolvedByQuads - places, sym, to this list and returns,
961 : : sym.
962 : : */
963 : :
964 : : extern "C" void M2GCCDeclare_PutToBeSolvedByQuads (unsigned int sym);
965 : :
966 : : /*
967 : : MarkExported - tell GCC to mark all exported procedures in module sym.
968 : : */
969 : :
970 : : extern "C" void M2GCCDeclare_MarkExported (unsigned int sym);
971 : :
972 : : /*
973 : : GetTypeMin -
974 : : */
975 : :
976 : : extern "C" unsigned int M2GCCDeclare_GetTypeMin (unsigned int type);
977 : :
978 : : /*
979 : : GetTypeMax -
980 : : */
981 : :
982 : : extern "C" unsigned int M2GCCDeclare_GetTypeMax (unsigned int type);
983 : :
984 : : /*
985 : : PrintSym - prints limited information about a symbol.
986 : : This procedure is externally visible.
987 : : */
988 : :
989 : : extern "C" void M2GCCDeclare_PrintSym (unsigned int sym);
990 : :
991 : : /*
992 : : IncludeDumpSymbol - include sym into the watch list and all syms dependants.
993 : : */
994 : :
995 : : extern "C" void M2GCCDeclare_IncludeDumpSymbol (unsigned int sym);
996 : :
997 : : /*
998 : : DumpFilteredResolver - dumps the gimple or tree representation of all watched symbols.
999 : : */
1000 : :
1001 : : extern "C" void M2GCCDeclare_DumpFilteredResolver (void);
1002 : :
1003 : : /*
1004 : : DumpFilteredDefinitive - dumps the gimple or tree representation of all watched symbols.
1005 : : */
1006 : :
1007 : : extern "C" void M2GCCDeclare_DumpFilteredDefinitive (void);
1008 : :
1009 : : /*
1010 : : InitDeclarations - initializes default types and the source filename.
1011 : : */
1012 : :
1013 : : extern "C" void M2GCCDeclare_InitDeclarations (void);
1014 : : extern "C" bool m2tree_IsAConstant (m2tree_Tree t);
1015 : : extern "C" bool m2tree_IsOrdinal (m2tree_Tree type);
1016 : : extern "C" bool m2tree_IsTreeOverflow (m2tree_Tree value);
1017 : : extern "C" m2tree_Tree m2tree_skip_const_decl (m2tree_Tree exp);
1018 : : extern "C" m2tree_Tree m2tree_skip_type_decl (m2tree_Tree type);
1019 : : extern "C" bool m2tree_is_type (m2tree_Tree type);
1020 : : extern "C" bool m2tree_is_array (m2tree_Tree array);
1021 : : extern "C" bool m2tree_is_var (m2tree_Tree var);
1022 : : extern "C" void m2tree_debug_tree (m2tree_Tree t);
1023 : : extern "C" void Storage_ALLOCATE (void * *a, unsigned int Size);
1024 : : extern "C" void Storage_DEALLOCATE (void * *a, unsigned int Size);
1025 : : extern "C" void Storage_REALLOCATE (void * *a, unsigned int Size);
1026 : : extern "C" bool Storage_Available (unsigned int Size);
1027 : : extern "C" void M2Debug_Assert (bool q);
1028 : : extern "C" void M2Debug_WriteDebug (const char *a_, unsigned int _a_high);
1029 : : extern "C" void M2Quads_SetOptionCoding (bool b);
1030 : : extern "C" void M2Quads_SetOptionProfiling (bool b);
1031 : : extern "C" void M2Quads_SetOptionOptimizing (bool b);
1032 : : extern "C" M2Quads_QuadOperator M2Quads_Opposite (M2Quads_QuadOperator Operator);
1033 : : extern "C" bool M2Quads_IsReferenced (unsigned int QuadNo);
1034 : : extern "C" bool M2Quads_IsBackReference (unsigned int q);
1035 : : extern "C" bool M2Quads_IsUnConditional (unsigned int QuadNo);
1036 : : extern "C" bool M2Quads_IsConditional (unsigned int QuadNo);
1037 : : extern "C" bool M2Quads_IsBackReferenceConditional (unsigned int q);
1038 : : extern "C" bool M2Quads_IsGoto (unsigned int QuadNo);
1039 : : extern "C" bool M2Quads_IsCall (unsigned int QuadNo);
1040 : : extern "C" bool M2Quads_IsReturn (unsigned int QuadNo);
1041 : : extern "C" bool M2Quads_IsProcedureScope (unsigned int QuadNo);
1042 : : extern "C" bool M2Quads_IsNewLocalVar (unsigned int QuadNo);
1043 : : extern "C" bool M2Quads_IsKillLocalVar (unsigned int QuadNo);
1044 : : extern "C" bool M2Quads_IsCatchBegin (unsigned int QuadNo);
1045 : : extern "C" bool M2Quads_IsCatchEnd (unsigned int QuadNo);
1046 : : extern "C" bool M2Quads_IsInitStart (unsigned int QuadNo);
1047 : : extern "C" bool M2Quads_IsInitEnd (unsigned int QuadNo);
1048 : : extern "C" bool M2Quads_IsFinallyStart (unsigned int QuadNo);
1049 : : extern "C" bool M2Quads_IsFinallyEnd (unsigned int QuadNo);
1050 : : extern "C" bool M2Quads_IsBecomes (unsigned int QuadNo);
1051 : : extern "C" bool M2Quads_IsDummy (unsigned int QuadNo);
1052 : : extern "C" bool M2Quads_IsQuadConstExpr (unsigned int QuadNo);
1053 : : extern "C" void M2Quads_SetQuadConstExpr (unsigned int QuadNo, bool value);
1054 : : extern "C" unsigned int M2Quads_GetQuadDest (unsigned int QuadNo);
1055 : : extern "C" unsigned int M2Quads_GetQuadOp1 (unsigned int QuadNo);
1056 : : extern "C" unsigned int M2Quads_GetQuadOp2 (unsigned int QuadNo);
1057 : : extern "C" unsigned int M2Quads_GetQuadOp3 (unsigned int QuadNo);
1058 : : extern "C" bool M2Quads_IsInitialisingConst (unsigned int QuadNo);
1059 : : extern "C" bool M2Quads_IsOptimizeOn (unsigned int QuadNo);
1060 : : extern "C" bool M2Quads_IsProfileOn (unsigned int QuadNo);
1061 : : extern "C" bool M2Quads_IsCodeOn (unsigned int QuadNo);
1062 : : extern "C" bool M2Quads_IsPseudoQuad (unsigned int QuadNo);
1063 : : extern "C" bool M2Quads_IsDefOrModFile (unsigned int QuadNo);
1064 : : extern "C" void M2Quads_DumpQuadruples (const char *title_, unsigned int _title_high);
1065 : : extern "C" void M2Quads_DisplayQuadRange (unsigned int scope, unsigned int start, unsigned int end);
1066 : : extern "C" void M2Quads_DisplayQuad (unsigned int QuadNo);
1067 : : extern "C" unsigned int M2Quads_GetLastFileQuad (unsigned int QuadNo);
1068 : : extern "C" unsigned int M2Quads_GetLastQuadNo (void);
1069 : : extern "C" unsigned int M2Quads_QuadToTokenNo (unsigned int QuadNo);
1070 : : extern "C" unsigned int M2Quads_QuadToLineNo (unsigned int QuadNo);
1071 : : extern "C" void M2Quads_GetQuad (unsigned int QuadNo, M2Quads_QuadOperator *Op, unsigned int *Oper1, unsigned int *Oper2, unsigned int *Oper3);
1072 : : extern "C" M2Quads_QuadOperator M2Quads_GetQuadOp (unsigned int quad);
1073 : : extern "C" DynamicStrings_String M2Quads_GetM2OperatorDesc (M2Quads_QuadOperator op);
1074 : : extern "C" void M2Quads_GetQuadtok (unsigned int QuadNo, M2Quads_QuadOperator *Op, unsigned int *Oper1, unsigned int *Oper2, unsigned int *Oper3, unsigned int *Op1Pos, unsigned int *Op2Pos, unsigned int *Op3Pos);
1075 : : extern "C" void M2Quads_GetQuadOtok (unsigned int QuadNo, unsigned int *tok, M2Quads_QuadOperator *Op, unsigned int *Oper1, unsigned int *Oper2, unsigned int *Oper3, bool *overflowChecking, bool *constExpr, unsigned int *Op1Pos, unsigned int *Op2Pos, unsigned int *Op3Pos);
1076 : : extern "C" void M2Quads_GetQuadOTypetok (unsigned int QuadNo, unsigned int *tok, M2Quads_QuadOperator *Op, unsigned int *Oper1, unsigned int *Oper2, unsigned int *Oper3, bool *overflowChecking, bool *typeChecking, bool *constExpr, unsigned int *Op1Pos, unsigned int *Op2Pos, unsigned int *Op3Pos);
1077 : : extern "C" void M2Quads_PutQuadOtok (unsigned int QuadNo, unsigned int tok, M2Quads_QuadOperator Op, unsigned int Oper1, unsigned int Oper2, unsigned int Oper3, bool overflowChecking, bool constExpr, unsigned int Op1Pos, unsigned int Op2Pos, unsigned int Op3Pos);
1078 : : extern "C" void M2Quads_PutQuad (unsigned int QuadNo, M2Quads_QuadOperator Op, unsigned int Oper1, unsigned int Oper2, unsigned int Oper3);
1079 : : extern "C" unsigned int M2Quads_GetFirstQuad (void);
1080 : : extern "C" unsigned int M2Quads_GetNextQuad (unsigned int QuadNo);
1081 : : extern "C" unsigned int M2Quads_GetRealQuad (unsigned int QuadNo);
1082 : : extern "C" void M2Quads_SubQuad (unsigned int QuadNo);
1083 : : extern "C" void M2Quads_EraseQuad (unsigned int QuadNo);
1084 : : extern "C" unsigned int M2Quads_CountQuads (void);
1085 : : extern "C" void M2Quads_BuildScaffold (unsigned int tok, unsigned int moduleSym);
1086 : : extern "C" void M2Quads_StartBuildDefFile (unsigned int tok);
1087 : : extern "C" void M2Quads_StartBuildModFile (unsigned int tok);
1088 : : extern "C" void M2Quads_EndBuildFile (unsigned int tok);
1089 : : extern "C" void M2Quads_StartBuildInit (unsigned int tok);
1090 : : extern "C" void M2Quads_EndBuildInit (unsigned int tok);
1091 : : extern "C" void M2Quads_StartBuildFinally (unsigned int tok);
1092 : : extern "C" void M2Quads_EndBuildFinally (unsigned int tok);
1093 : : extern "C" void M2Quads_BuildExceptInitial (unsigned int tok);
1094 : : extern "C" void M2Quads_BuildExceptFinally (unsigned int tok);
1095 : : extern "C" void M2Quads_BuildExceptProcedure (unsigned int tok);
1096 : : extern "C" void M2Quads_BuildRetry (unsigned int tok);
1097 : : extern "C" void M2Quads_BuildReThrow (unsigned int tokenno);
1098 : : extern "C" void M2Quads_StartBuildInnerInit (unsigned int tok);
1099 : : extern "C" void M2Quads_EndBuildInnerInit (unsigned int tok);
1100 : : extern "C" void M2Quads_BuildBuiltinConst (void);
1101 : : extern "C" void M2Quads_BuildBuiltinTypeInfo (void);
1102 : : extern "C" void M2Quads_BuildAssignment (unsigned int becomesTokNo);
1103 : : extern "C" void M2Quads_BuildAssignConstant (unsigned int equalsTokNo);
1104 : : extern "C" void M2Quads_BuildAlignment (void);
1105 : : extern "C" void M2Quads_BuildBitLength (void);
1106 : : extern "C" void M2Quads_BuildPragmaField (void);
1107 : : extern "C" void M2Quads_BuildDefaultFieldAlignment (void);
1108 : : extern "C" void M2Quads_BuildRepeat (void);
1109 : : extern "C" void M2Quads_BuildUntil (void);
1110 : : extern "C" void M2Quads_BuildWhile (void);
1111 : : extern "C" void M2Quads_BuildDoWhile (void);
1112 : : extern "C" void M2Quads_BuildEndWhile (void);
1113 : : extern "C" void M2Quads_BuildLoop (void);
1114 : : extern "C" void M2Quads_BuildExit (void);
1115 : : extern "C" void M2Quads_BuildEndLoop (void);
1116 : : extern "C" void M2Quads_BuildThenIf (void);
1117 : : extern "C" void M2Quads_BuildElse (void);
1118 : : extern "C" void M2Quads_BuildEndIf (void);
1119 : : extern "C" void M2Quads_BuildElsif1 (void);
1120 : : extern "C" void M2Quads_BuildElsif2 (void);
1121 : : extern "C" void M2Quads_BuildForToByDo (void);
1122 : : extern "C" void M2Quads_BuildPseudoBy (void);
1123 : : extern "C" void M2Quads_BuildEndFor (unsigned int endpostok);
1124 : : extern "C" void M2Quads_BuildCaseStart (void);
1125 : : extern "C" void M2Quads_BuildCaseStartStatementSequence (void);
1126 : : extern "C" void M2Quads_BuildCaseEndStatementSequence (void);
1127 : : extern "C" void M2Quads_BuildCaseRange (void);
1128 : : extern "C" void M2Quads_BuildCaseEquality (void);
1129 : : extern "C" void M2Quads_BuildCaseList (void);
1130 : : extern "C" void M2Quads_BuildCaseOr (void);
1131 : : extern "C" void M2Quads_BuildCaseElse (void);
1132 : : extern "C" void M2Quads_BuildCaseEnd (void);
1133 : : extern "C" void M2Quads_BuildCaseCheck (void);
1134 : : extern "C" void M2Quads_BuildNulParam (void);
1135 : : extern "C" void M2Quads_BuildProcedureCall (unsigned int tokno);
1136 : : extern "C" bool M2Quads_CheckBuildFunction (void);
1137 : : extern "C" void M2Quads_BuildFunctionCall (bool ConstExpr);
1138 : : extern "C" void M2Quads_BuildConstFunctionCall (void);
1139 : : extern "C" void M2Quads_BuildBooleanVariable (void);
1140 : : extern "C" void M2Quads_BuildModuleStart (unsigned int tok);
1141 : : extern "C" void M2Quads_BuildProcedureStart (void);
1142 : : extern "C" void M2Quads_BuildProcedureBegin (void);
1143 : : extern "C" void M2Quads_BuildProcedureEnd (void);
1144 : : extern "C" void M2Quads_BuildReturn (unsigned int tokreturn);
1145 : : extern "C" void M2Quads_BuildModulePriority (void);
1146 : : extern "C" void M2Quads_StartBuildWith (unsigned int withTok);
1147 : : extern "C" void M2Quads_EndBuildWith (void);
1148 : : extern "C" void M2Quads_CheckWithReference (void);
1149 : : extern "C" void M2Quads_BuildDesignatorRecord (unsigned int dottok);
1150 : : extern "C" void M2Quads_BuildDesignatorArray (void);
1151 : : extern "C" void M2Quads_BuildDesignatorPointer (unsigned int ptrtok);
1152 : : extern "C" void M2Quads_BuildNulExpression (unsigned int tokpos);
1153 : : extern "C" void M2Quads_BuildSetStart (unsigned int tokpos);
1154 : : extern "C" void M2Quads_BuildSetEnd (void);
1155 : : extern "C" void M2Quads_BuildEmptySet (unsigned int tokpos);
1156 : : extern "C" void M2Quads_BuildInclRange (void);
1157 : : extern "C" void M2Quads_BuildInclBit (void);
1158 : : extern "C" void M2Quads_SilentBuildConstructor (void);
1159 : : extern "C" void M2Quads_SilentBuildConstructorStart (void);
1160 : : extern "C" void M2Quads_BuildConstructor (unsigned int tokcbrpos);
1161 : : extern "C" void M2Quads_BuildConstructorStart (unsigned int cbratokpos);
1162 : : extern "C" void M2Quads_BuildConstructorEnd (unsigned int startpos, unsigned int cbratokpos);
1163 : : extern "C" void M2Quads_NextConstructorField (void);
1164 : : extern "C" void M2Quads_BuildTypeForConstructor (unsigned int tokpos);
1165 : : extern "C" void M2Quads_BuildComponentValue (void);
1166 : : extern "C" void M2Quads_PopConstructor (void);
1167 : : extern "C" void M2Quads_BuildNot (unsigned int notTokPos);
1168 : : extern "C" void M2Quads_RecordOp (void);
1169 : : extern "C" void M2Quads_BuildRelOp (unsigned int optokpos);
1170 : : extern "C" void M2Quads_BuildBinaryOp (void);
1171 : : extern "C" void M2Quads_BuildUnaryOp (void);
1172 : : extern "C" unsigned int M2Quads_OperandT (unsigned int pos);
1173 : : extern "C" unsigned int M2Quads_OperandF (unsigned int pos);
1174 : : extern "C" void M2Quads_PushTF (unsigned int True, unsigned int False);
1175 : : extern "C" void M2Quads_PopTF (unsigned int *True, unsigned int *False);
1176 : : extern "C" void M2Quads_PushT (unsigned int True);
1177 : : extern "C" void M2Quads_PopT (unsigned int *True);
1178 : : extern "C" void M2Quads_PushTtok (unsigned int True, unsigned int tokno);
1179 : : extern "C" void M2Quads_PushTFtok (unsigned int True, unsigned int False, unsigned int tokno);
1180 : : extern "C" void M2Quads_PopTFtok (unsigned int *True, unsigned int *False, unsigned int *tokno);
1181 : : extern "C" void M2Quads_PushTFAtok (unsigned int True, unsigned int False, unsigned int Array, unsigned int tokno);
1182 : : extern "C" void M2Quads_PopTtok (unsigned int *True, unsigned int *tok);
1183 : : extern "C" void M2Quads_PushTFn (unsigned int True, unsigned int False, unsigned int n);
1184 : : extern "C" void M2Quads_PushTFntok (unsigned int True, unsigned int False, unsigned int n, unsigned int tokno);
1185 : : extern "C" void M2Quads_PopTFn (unsigned int *True, unsigned int *False, unsigned int *n);
1186 : : extern "C" void M2Quads_PopNothing (void);
1187 : : extern "C" void M2Quads_PopN (unsigned int n);
1188 : : extern "C" void M2Quads_PushTFA (unsigned int True, unsigned int False, unsigned int Array);
1189 : : extern "C" unsigned int M2Quads_OperandTok (unsigned int pos);
1190 : : extern "C" unsigned int M2Quads_OperandA (unsigned int pos);
1191 : : extern "C" DynamicStrings_String M2Quads_OperandAnno (unsigned int n);
1192 : : extern "C" void M2Quads_Annotate (const char *a_, unsigned int _a_high);
1193 : : extern "C" void M2Quads_DisplayStack (void);
1194 : : extern "C" unsigned int M2Quads_Top (void);
1195 : : extern "C" void M2Quads_WriteOperand (unsigned int Sym);
1196 : : extern "C" void M2Quads_BeginVarient (void);
1197 : : extern "C" void M2Quads_EndVarient (void);
1198 : : extern "C" void M2Quads_ElseVarient (void);
1199 : : extern "C" void M2Quads_BeginVarientList (void);
1200 : : extern "C" void M2Quads_EndVarientList (void);
1201 : : extern "C" void M2Quads_AddRecordToList (void);
1202 : : extern "C" void M2Quads_AddVarientToList (void);
1203 : : extern "C" void M2Quads_AddVarientFieldToList (unsigned int f);
1204 : : extern "C" void M2Quads_AddVarientRange (void);
1205 : : extern "C" void M2Quads_AddVarientEquality (void);
1206 : : extern "C" void M2Quads_BuildCodeOn (void);
1207 : : extern "C" void M2Quads_BuildCodeOff (void);
1208 : : extern "C" void M2Quads_BuildProfileOn (void);
1209 : : extern "C" void M2Quads_BuildProfileOff (void);
1210 : : extern "C" void M2Quads_BuildOptimizeOn (void);
1211 : : extern "C" void M2Quads_BuildOptimizeOff (void);
1212 : : extern "C" void M2Quads_BuildAsm (unsigned int tok);
1213 : : extern "C" void M2Quads_BuildLineNo (void);
1214 : : extern "C" void M2Quads_PushLineNo (void);
1215 : : extern "C" void M2Quads_BuildStmtNote (int offset);
1216 : : extern "C" void M2Quads_LoopAnalysis (unsigned int Scope, unsigned int Current, unsigned int End);
1217 : : extern "C" void M2Quads_ForLoopAnalysis (void);
1218 : : extern "C" void M2Quads_BuildSizeCheckStart (void);
1219 : : extern "C" void M2Quads_BackPatchSubrangesAndOptParam (void);
1220 : : extern "C" void M2Quads_WriteOperator (M2Quads_QuadOperator Operator);
1221 : : extern "C" void M2Quads_PushAutoOn (void);
1222 : : extern "C" void M2Quads_PushAutoOff (void);
1223 : : extern "C" bool M2Quads_IsAutoPushOn (void);
1224 : : extern "C" void M2Quads_PopAuto (void);
1225 : : extern "C" bool M2Quads_MustCheckOverflow (unsigned int q);
1226 : : extern "C" void M2Quads_PushInConstExpression (void);
1227 : : extern "C" void M2Quads_PopInConstExpression (void);
1228 : : extern "C" bool M2Quads_IsInConstExpression (void);
1229 : : extern "C" void M2Quads_PushInConstParameters (void);
1230 : : extern "C" void M2Quads_PopInConstParameters (void);
1231 : : extern "C" bool M2Quads_IsInConstParameters (void);
1232 : : extern "C" void M2Quads_BuildAsmElement (bool input, bool output);
1233 : : extern "C" void M2Quads_BuildAsmTrash (void);
1234 : : extern "C" unsigned int M2Quads_GetQuadTrash (unsigned int quad);
1235 : : extern "C" void m2pp_CreateDumpGimple (void * templatename, unsigned int templatelen);
1236 : : extern "C" void m2pp_CloseDumpGimple (void);
1237 : : extern "C" void m2pp_DumpGimpleFd (int fd, m2tree_Tree fndecl);
1238 : : extern "C" bool FIO_IsNoError (FIO_File f);
1239 : : extern "C" bool FIO_IsActive (FIO_File f);
1240 : : extern "C" bool FIO_Exists (const char *fname_, unsigned int _fname_high);
1241 : : extern "C" FIO_File FIO_OpenToRead (const char *fname_, unsigned int _fname_high);
1242 : : extern "C" FIO_File FIO_OpenToWrite (const char *fname_, unsigned int _fname_high);
1243 : : extern "C" FIO_File FIO_OpenForRandom (const char *fname_, unsigned int _fname_high, bool towrite, bool newfile);
1244 : : extern "C" void FIO_Close (FIO_File f);
1245 : : extern "C" bool FIO_exists (void * fname, unsigned int flength);
1246 : : extern "C" FIO_File FIO_openToRead (void * fname, unsigned int flength);
1247 : : extern "C" FIO_File FIO_openToWrite (void * fname, unsigned int flength);
1248 : : extern "C" FIO_File FIO_openForRandom (void * fname, unsigned int flength, bool towrite, bool newfile);
1249 : : extern "C" void FIO_FlushBuffer (FIO_File f);
1250 : : extern "C" unsigned int FIO_ReadNBytes (FIO_File f, unsigned int nBytes, void * dest);
1251 : : extern "C" void FIO_ReadAny (FIO_File f, unsigned char *a, unsigned int _a_high);
1252 : : extern "C" unsigned int FIO_WriteNBytes (FIO_File f, unsigned int nBytes, void * src);
1253 : : extern "C" void FIO_WriteAny (FIO_File f, unsigned char *a, unsigned int _a_high);
1254 : : extern "C" void FIO_WriteChar (FIO_File f, char ch);
1255 : : extern "C" bool FIO_EOF (FIO_File f);
1256 : : extern "C" bool FIO_EOLN (FIO_File f);
1257 : : extern "C" bool FIO_WasEOLN (FIO_File f);
1258 : : extern "C" char FIO_ReadChar (FIO_File f);
1259 : : extern "C" void FIO_UnReadChar (FIO_File f, char ch);
1260 : : extern "C" void FIO_WriteLine (FIO_File f);
1261 : : extern "C" void FIO_WriteString (FIO_File f, const char *a_, unsigned int _a_high);
1262 : : extern "C" void FIO_ReadString (FIO_File f, char *a, unsigned int _a_high);
1263 : : extern "C" void FIO_WriteCardinal (FIO_File f, unsigned int c);
1264 : : extern "C" unsigned int FIO_ReadCardinal (FIO_File f);
1265 : : extern "C" int FIO_GetUnixFileDescriptor (FIO_File f);
1266 : : extern "C" void FIO_SetPositionFromBeginning (FIO_File f, long int pos);
1267 : : extern "C" void FIO_SetPositionFromEnd (FIO_File f, long int pos);
1268 : : extern "C" long int FIO_FindPosition (FIO_File f);
1269 : : extern "C" void FIO_GetFileName (FIO_File f, char *a, unsigned int _a_high);
1270 : : extern "C" void * FIO_getFileName (FIO_File f);
1271 : : extern "C" unsigned int FIO_getFileNameLength (FIO_File f);
1272 : : extern "C" void FIO_FlushOutErr (void);
1273 : : extern "C" void M2Options_SetM (bool value);
1274 : : extern "C" bool M2Options_GetM (void);
1275 : : extern "C" void M2Options_SetMM (bool value);
1276 : : extern "C" bool M2Options_GetMM (void);
1277 : : extern "C" void M2Options_SetMF (void * arg);
1278 : : extern "C" void * M2Options_GetMF (void);
1279 : : extern "C" void M2Options_SetM2Prefix (void * arg);
1280 : : extern "C" void * M2Options_GetM2Prefix (void);
1281 : : extern "C" void M2Options_SetM2PathName (void * arg);
1282 : : extern "C" void * M2Options_GetM2PathName (void);
1283 : : extern "C" void M2Options_SetPPOnly (bool value);
1284 : : extern "C" bool M2Options_GetPPOnly (void);
1285 : : extern "C" void M2Options_Setc (bool value);
1286 : : extern "C" bool M2Options_Getc (void);
1287 : : extern "C" void M2Options_SetB (void * arg);
1288 : : extern "C" void * M2Options_GetB (void);
1289 : : extern "C" void M2Options_SetMD (bool value);
1290 : : extern "C" bool M2Options_GetMD (void);
1291 : : extern "C" void M2Options_SetMMD (bool value);
1292 : : extern "C" bool M2Options_GetMMD (void);
1293 : : extern "C" void M2Options_SetMQ (void * arg);
1294 : : extern "C" void * M2Options_GetMQ (void);
1295 : : extern "C" void M2Options_SetMT (void * arg);
1296 : : extern "C" void * M2Options_GetMT (void);
1297 : : extern "C" void * M2Options_GetDepTarget (void);
1298 : : extern "C" void M2Options_SetMP (bool value);
1299 : : extern "C" bool M2Options_GetMP (void);
1300 : : extern "C" void M2Options_SetObj (void * arg);
1301 : : extern "C" void * M2Options_GetObj (void);
1302 : : extern "C" bool M2Options_SetCpp (bool value);
1303 : : extern "C" bool M2Options_GetCpp (void);
1304 : : extern "C" bool M2Options_GetLineDirectives (void);
1305 : : extern "C" void M2Options_SetScaffoldDynamic (bool value);
1306 : : extern "C" void M2Options_SetScaffoldStatic (bool value);
1307 : : extern "C" bool M2Options_GetScaffoldDynamic (void);
1308 : : extern "C" bool M2Options_GetScaffoldStatic (void);
1309 : : extern "C" void M2Options_SetScaffoldMain (bool value);
1310 : : extern "C" void M2Options_SetRuntimeModuleOverride (void * override);
1311 : : extern "C" void * M2Options_GetRuntimeModuleOverride (void);
1312 : : extern "C" void M2Options_SetUselist (bool value, void * filename);
1313 : : extern "C" bool M2Options_GetUselist (void);
1314 : : extern "C" DynamicStrings_String M2Options_GetUselistFilename (void);
1315 : : extern "C" void M2Options_SetWholeProgram (bool value);
1316 : : extern "C" bool M2Options_SetAutoInit (bool value);
1317 : : extern "C" bool M2Options_SetReturnCheck (bool value);
1318 : : extern "C" bool M2Options_SetNilCheck (bool value);
1319 : : extern "C" bool M2Options_SetCaseCheck (bool value);
1320 : : extern "C" bool M2Options_SetCheckAll (bool value);
1321 : : extern "C" bool M2Options_SetVerboseUnbounded (bool value);
1322 : : extern "C" bool M2Options_SetQuiet (bool value);
1323 : : extern "C" void M2Options_SetCC1Quiet (bool value);
1324 : : extern "C" bool M2Options_SetM2g (bool value);
1325 : : extern "C" bool M2Options_GetM2g (void);
1326 : : extern "C" bool M2Options_SetLowerCaseKeywords (bool value);
1327 : : extern "C" bool M2Options_SetUnboundedByReference (bool value);
1328 : : extern "C" void M2Options_SetSearchPath (void * arg);
1329 : : extern "C" void M2Options_SetISO (bool value);
1330 : : extern "C" void M2Options_SetPIM (bool value);
1331 : : extern "C" void M2Options_SetPIM2 (bool value);
1332 : : extern "C" void M2Options_SetPIM3 (bool value);
1333 : : extern "C" void M2Options_SetPIM4 (bool value);
1334 : : extern "C" void M2Options_SetPositiveModFloor (bool value);
1335 : : extern "C" void M2Options_SetWholeDiv (bool value);
1336 : : extern "C" void M2Options_SetIndex (bool value);
1337 : : extern "C" void M2Options_SetRange (bool value);
1338 : : extern "C" void M2Options_SetExceptions (bool value);
1339 : : extern "C" void M2Options_SetStyle (bool value);
1340 : : extern "C" void M2Options_SetPedantic (bool value);
1341 : : extern "C" void M2Options_SetPedanticParamNames (bool value);
1342 : : extern "C" void M2Options_SetPedanticCast (bool value);
1343 : : extern "C" void M2Options_SetExtendedOpaque (bool value);
1344 : : extern "C" void M2Options_SetXCode (bool value);
1345 : : extern "C" void M2Options_SetCompilerDebugging (bool value);
1346 : : extern "C" void M2Options_SetQuadDebugging (bool value);
1347 : : extern "C" void M2Options_SetM2DebugTraceFilter (bool value, void * filter);
1348 : : extern "C" void M2Options_SetDebugFunctionLineNumbers (bool value);
1349 : : extern "C" void M2Options_SetGenerateStatementNote (bool value);
1350 : : extern "C" void M2Options_SetSources (bool value);
1351 : : extern "C" void M2Options_SetDumpSystemExports (bool value);
1352 : : extern "C" void M2Options_SetSwig (bool value);
1353 : : extern "C" void M2Options_SetOptimizing (unsigned int value);
1354 : : extern "C" m2linemap_location_t M2Options_OverrideLocation (m2linemap_location_t location);
1355 : : extern "C" void M2Options_SetForcedLocation (m2linemap_location_t location);
1356 : : extern "C" void M2Options_SetUnusedVariableChecking (bool value);
1357 : : extern "C" void M2Options_SetUnusedParameterChecking (bool value);
1358 : : extern "C" void M2Options_SetStrictTypeChecking (bool value);
1359 : : extern "C" void M2Options_setdefextension (void * arg);
1360 : : extern "C" void M2Options_setmodextension (void * arg);
1361 : : extern "C" void M2Options_SetStatistics (bool on);
1362 : : extern "C" bool M2Options_SetVerbose (bool value);
1363 : : extern "C" void M2Options_CppArg (void * opt, void * arg, bool joined);
1364 : : extern "C" DynamicStrings_String M2Options_CppCommandLine (void);
1365 : : extern "C" void M2Options_CppRemember (DynamicStrings_String s);
1366 : : extern "C" bool M2Options_GetISO (void);
1367 : : extern "C" bool M2Options_GetPIM (void);
1368 : : extern "C" bool M2Options_GetPIM2 (void);
1369 : : extern "C" bool M2Options_GetPIM3 (void);
1370 : : extern "C" bool M2Options_GetPIM4 (void);
1371 : : extern "C" bool M2Options_GetPositiveModFloor (void);
1372 : : extern "C" bool M2Options_GetFloatValueCheck (void);
1373 : : extern "C" void M2Options_SetFloatValueCheck (bool value);
1374 : : extern "C" bool M2Options_GetWholeValueCheck (void);
1375 : : extern "C" void M2Options_SetWholeValueCheck (bool value);
1376 : : extern "C" void M2Options_SetWall (bool value);
1377 : : extern "C" void M2Options_SetSaveTemps (bool value);
1378 : : extern "C" void M2Options_SetSaveTempsDir (void * arg);
1379 : : extern "C" DynamicStrings_String M2Options_GetSaveTempsDir (void);
1380 : : extern "C" void M2Options_SetDumpDir (void * arg);
1381 : : extern "C" DynamicStrings_String M2Options_GetDumpDir (void);
1382 : : extern "C" void M2Options_SetGenModuleList (bool value, void * filename);
1383 : : extern "C" DynamicStrings_String M2Options_GetGenModuleFilename (void);
1384 : : extern "C" void M2Options_SetShared (bool value);
1385 : : extern "C" int M2Options_SetUninitVariableChecking (bool value, void * arg);
1386 : : extern "C" void M2Options_SetCaseEnumChecking (bool value);
1387 : : extern "C" void M2Options_SetDebugBuiltins (bool value);
1388 : : extern "C" void M2Options_SetIBMLongDouble (bool value);
1389 : : extern "C" bool M2Options_GetIBMLongDouble (void);
1390 : : extern "C" void M2Options_SetIEEELongDouble (bool value);
1391 : : extern "C" bool M2Options_GetIEEELongDouble (void);
1392 : : extern "C" DynamicStrings_String M2Options_GetDumpLangDeclFilename (void);
1393 : : extern "C" void M2Options_SetDumpLangDeclFilename (bool value, void * filename);
1394 : : extern "C" DynamicStrings_String M2Options_GetDumpLangQuadFilename (void);
1395 : : extern "C" void M2Options_SetDumpLangQuadFilename (bool value, void * filename);
1396 : : extern "C" DynamicStrings_String M2Options_GetDumpLangGimpleFilename (void);
1397 : : extern "C" void M2Options_SetDumpLangGimpleFilename (bool value, void * filename);
1398 : : extern "C" void M2Options_SetM2DumpFilter (bool value, void * filter);
1399 : : extern "C" void * M2Options_GetM2DumpFilter (void);
1400 : : extern "C" bool M2Options_GetDumpLangGimple (void);
1401 : : extern "C" bool M2Options_GetDebugTraceQuad (void);
1402 : : extern "C" bool M2Options_GetDebugTraceTree (void);
1403 : : extern "C" bool M2Options_GetDebugTraceToken (void);
1404 : : extern "C" bool M2Options_GetDebugTraceLine (void);
1405 : : extern "C" bool M2Options_GetDebugFunctionLineNumbers (void);
1406 : : extern "C" void M2Options_FinaliseOptions (void);
1407 : : extern "C" NameKey_Name M2AsmUtil_GetFullSymName (unsigned int sym);
1408 : : extern "C" NameKey_Name M2AsmUtil_GetFullScopeAsmName (unsigned int sym);
1409 : : extern "C" unsigned int M2Batch_MakeDefinitionSource (unsigned int tok, NameKey_Name n);
1410 : : extern "C" unsigned int M2Batch_MakeImplementationSource (unsigned int tok, NameKey_Name n);
1411 : : extern "C" unsigned int M2Batch_MakeProgramSource (unsigned int tok, NameKey_Name n);
1412 : : extern "C" unsigned int M2Batch_GetSource (void);
1413 : : extern "C" unsigned int M2Batch_GetModuleNo (unsigned int nth);
1414 : : extern "C" bool M2Batch_IsModuleKnown (NameKey_Name n);
1415 : : extern "C" DynamicStrings_String M2Batch_AssociateDefinition (DynamicStrings_String filename, unsigned int Sym);
1416 : : extern "C" DynamicStrings_String M2Batch_GetDefinitionModuleFile (unsigned int Sym);
1417 : : extern "C" DynamicStrings_String M2Batch_AssociateModule (DynamicStrings_String filename, unsigned int Sym);
1418 : : extern "C" DynamicStrings_String M2Batch_GetModuleFile (unsigned int Sym);
1419 : : extern "C" void M2Batch_ForeachSourceModuleDo (M2Batch_DoProcedure p);
1420 : : extern "C" bool M2Batch_IsSourceSeen (unsigned int sym);
1421 : : extern "C" bool M2Batch_IsModuleSeen (NameKey_Name n);
1422 : : extern "C" unsigned int M2Batch_LookupModule (unsigned int tok, NameKey_Name n);
1423 : : extern "C" unsigned int M2Batch_LookupOuterModule (unsigned int tok, NameKey_Name n);
1424 : : extern "C" unsigned int M2Batch_Get (NameKey_Name n);
1425 : : extern "C" void M2Batch_DisplayModules (void);
1426 : : extern "C" NameKey_Name NameKey_MakeKey (const char *a_, unsigned int _a_high);
1427 : : extern "C" NameKey_Name NameKey_makekey (void * a);
1428 : : extern "C" void NameKey_GetKey (NameKey_Name key, char *a, unsigned int _a_high);
1429 : : extern "C" unsigned int NameKey_LengthKey (NameKey_Name Key);
1430 : : extern "C" bool NameKey_IsKey (const char *a_, unsigned int _a_high);
1431 : : extern "C" void NameKey_WriteKey (NameKey_Name key);
1432 : : extern "C" bool NameKey_IsSameExcludingCase (NameKey_Name key1, NameKey_Name key2);
1433 : : extern "C" void * NameKey_KeyToCharStar (NameKey_Name key);
1434 : : extern "C" char NameKey_CharKey (NameKey_Name key, unsigned int i);
1435 : : extern "C" DynamicStrings_String M2FileName_CalculateFileName (DynamicStrings_String Module, DynamicStrings_String Extension);
1436 : : extern "C" DynamicStrings_String M2FileName_CalculateStemName (DynamicStrings_String Module);
1437 : : extern "C" DynamicStrings_String M2FileName_ExtractExtension (DynamicStrings_String filename, DynamicStrings_String ext);
1438 : : extern "C" DynamicStrings_String M2FileName_ExtractModule (DynamicStrings_String filename);
1439 : :
1440 : : /*
1441 : : InitString - creates and returns a String type object.
1442 : : Initial contents are, a.
1443 : : */
1444 : :
1445 : : extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsigned int _a_high);
1446 : :
1447 : : /*
1448 : : KillString - frees String, s, and its contents.
1449 : : NIL is returned.
1450 : : */
1451 : :
1452 : : extern "C" DynamicStrings_String DynamicStrings_KillString (DynamicStrings_String s);
1453 : :
1454 : : /*
1455 : : Fin - finishes with a string, it calls KillString with, s.
1456 : : The purpose of the procedure is to provide a short cut
1457 : : to calling KillString and then testing the return result.
1458 : : */
1459 : :
1460 : : extern "C" void DynamicStrings_Fin (DynamicStrings_String s);
1461 : :
1462 : : /*
1463 : : InitStringCharStar - initializes and returns a String to contain the C string.
1464 : : */
1465 : :
1466 : : extern "C" DynamicStrings_String DynamicStrings_InitStringCharStar (void * a);
1467 : :
1468 : : /*
1469 : : InitStringChar - initializes and returns a String to contain the single character, ch.
1470 : : */
1471 : :
1472 : : extern "C" DynamicStrings_String DynamicStrings_InitStringChar (char ch);
1473 : :
1474 : : /*
1475 : : Mark - marks String, s, ready for garbage collection.
1476 : : */
1477 : :
1478 : : extern "C" DynamicStrings_String DynamicStrings_Mark (DynamicStrings_String s);
1479 : :
1480 : : /*
1481 : : Length - returns the length of the String, s.
1482 : : */
1483 : :
1484 : : extern "C" unsigned int DynamicStrings_Length (DynamicStrings_String s);
1485 : :
1486 : : /*
1487 : : ConCat - returns String, a, after the contents of, b, have been appended.
1488 : : */
1489 : :
1490 : : extern "C" DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, DynamicStrings_String b);
1491 : :
1492 : : /*
1493 : : ConCatChar - returns String, a, after character, ch, has been appended.
1494 : : */
1495 : :
1496 : : extern "C" DynamicStrings_String DynamicStrings_ConCatChar (DynamicStrings_String a, char ch);
1497 : :
1498 : : /*
1499 : : Assign - assigns the contents of, b, into, a.
1500 : : String, a, is returned.
1501 : : */
1502 : :
1503 : : extern "C" DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, DynamicStrings_String b);
1504 : :
1505 : : /*
1506 : : ReplaceChar - returns string s after it has changed all occurances of from to to.
1507 : : */
1508 : :
1509 : : extern "C" DynamicStrings_String DynamicStrings_ReplaceChar (DynamicStrings_String s, char from, char to);
1510 : :
1511 : : /*
1512 : : Dup - duplicate a String, s, returning the copy of s.
1513 : : */
1514 : :
1515 : : extern "C" DynamicStrings_String DynamicStrings_Dup (DynamicStrings_String s);
1516 : :
1517 : : /*
1518 : : Add - returns a new String which contains the contents of a and b.
1519 : : */
1520 : :
1521 : : extern "C" DynamicStrings_String DynamicStrings_Add (DynamicStrings_String a, DynamicStrings_String b);
1522 : :
1523 : : /*
1524 : : Equal - returns TRUE if String, a, and, b, are equal.
1525 : : */
1526 : :
1527 : : extern "C" bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_String b);
1528 : :
1529 : : /*
1530 : : EqualCharStar - returns TRUE if contents of String, s, is the same as the
1531 : : string, a.
1532 : : */
1533 : :
1534 : : extern "C" bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a);
1535 : :
1536 : : /*
1537 : : EqualArray - returns TRUE if contents of String, s, is the same as the
1538 : : string, a.
1539 : : */
1540 : :
1541 : : extern "C" bool DynamicStrings_EqualArray (DynamicStrings_String s, const char *a_, unsigned int _a_high);
1542 : :
1543 : : /*
1544 : : Mult - returns a new string which is n concatenations of String, s.
1545 : : */
1546 : :
1547 : : extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, unsigned int n);
1548 : :
1549 : : /*
1550 : : Slice - returns a new string which contains the elements
1551 : : low..high-1
1552 : :
1553 : : strings start at element 0
1554 : : Slice(s, 0, 2) will return elements 0, 1 but not 2
1555 : : Slice(s, 1, 3) will return elements 1, 2 but not 3
1556 : : Slice(s, 2, 0) will return elements 2..max
1557 : : Slice(s, 3, -1) will return elements 3..max-1
1558 : : Slice(s, 4, -2) will return elements 4..max-2
1559 : : */
1560 : :
1561 : : extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, int low, int high);
1562 : :
1563 : : /*
1564 : : Index - returns the indice of the first occurance of, ch, in
1565 : : String, s. -1 is returned if, ch, does not exist.
1566 : : The search starts at position, o.
1567 : : */
1568 : :
1569 : : extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned int o);
1570 : :
1571 : : /*
1572 : : RIndex - returns the indice of the last occurance of, ch,
1573 : : in String, s. The search starts at position, o.
1574 : : -1 is returned if, ch, is not found. The search
1575 : : is performed left to right.
1576 : : */
1577 : :
1578 : : extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned int o);
1579 : :
1580 : : /*
1581 : : ReverseIndex - returns the indice of the last occurance of ch
1582 : : in String s. The search starts at position o
1583 : : and searches from right to left. The start position
1584 : : may be indexed negatively from the right (-1 is the
1585 : : last index).
1586 : : The return value if ch is found will always be positive.
1587 : : -1 is returned if ch is not found.
1588 : : */
1589 : :
1590 : : extern "C" int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, int o);
1591 : :
1592 : : /*
1593 : : RemoveComment - assuming that, comment, is a comment delimiter
1594 : : which indicates anything to its right is a comment
1595 : : then strip off the comment and also any white space
1596 : : on the remaining right hand side.
1597 : : It leaves any white space on the left hand side alone.
1598 : : */
1599 : :
1600 : : extern "C" DynamicStrings_String DynamicStrings_RemoveComment (DynamicStrings_String s, char comment);
1601 : :
1602 : : /*
1603 : : RemoveWhitePrefix - removes any leading white space from String, s.
1604 : : A new string is returned.
1605 : : */
1606 : :
1607 : : extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePrefix (DynamicStrings_String s);
1608 : :
1609 : : /*
1610 : : RemoveWhitePostfix - removes any leading white space from String, s.
1611 : : A new string is returned.
1612 : : */
1613 : :
1614 : : extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePostfix (DynamicStrings_String s);
1615 : :
1616 : : /*
1617 : : ToUpper - returns string, s, after it has had its lower case characters
1618 : : replaced by upper case characters.
1619 : : The string, s, is not duplicated.
1620 : : */
1621 : :
1622 : : extern "C" DynamicStrings_String DynamicStrings_ToUpper (DynamicStrings_String s);
1623 : :
1624 : : /*
1625 : : ToLower - returns string, s, after it has had its upper case characters
1626 : : replaced by lower case characters.
1627 : : The string, s, is not duplicated.
1628 : : */
1629 : :
1630 : : extern "C" DynamicStrings_String DynamicStrings_ToLower (DynamicStrings_String s);
1631 : :
1632 : : /*
1633 : : CopyOut - copies string, s, to a.
1634 : : */
1635 : :
1636 : : extern "C" void DynamicStrings_CopyOut (char *a, unsigned int _a_high, DynamicStrings_String s);
1637 : :
1638 : : /*
1639 : : char - returns the character, ch, at position, i, in String, s.
1640 : : */
1641 : :
1642 : : extern "C" char DynamicStrings_char (DynamicStrings_String s, int i);
1643 : :
1644 : : /*
1645 : : string - returns the C style char * of String, s.
1646 : : */
1647 : :
1648 : : extern "C" void * DynamicStrings_string (DynamicStrings_String s);
1649 : :
1650 : : /*
1651 : : InitStringDB - the debug version of InitString.
1652 : : */
1653 : :
1654 : : extern "C" DynamicStrings_String DynamicStrings_InitStringDB (const char *a_, unsigned int _a_high, const char *file_, unsigned int _file_high, unsigned int line);
1655 : :
1656 : : /*
1657 : : InitStringCharStarDB - the debug version of InitStringCharStar.
1658 : : */
1659 : :
1660 : : extern "C" DynamicStrings_String DynamicStrings_InitStringCharStarDB (void * a, const char *file_, unsigned int _file_high, unsigned int line);
1661 : :
1662 : : /*
1663 : : InitStringCharDB - the debug version of InitStringChar.
1664 : : */
1665 : :
1666 : : extern "C" DynamicStrings_String DynamicStrings_InitStringCharDB (char ch, const char *file_, unsigned int _file_high, unsigned int line);
1667 : :
1668 : : /*
1669 : : MultDB - the debug version of MultDB.
1670 : : */
1671 : :
1672 : : extern "C" DynamicStrings_String DynamicStrings_MultDB (DynamicStrings_String s, unsigned int n, const char *file_, unsigned int _file_high, unsigned int line);
1673 : :
1674 : : /*
1675 : : DupDB - the debug version of Dup.
1676 : : */
1677 : :
1678 : : extern "C" DynamicStrings_String DynamicStrings_DupDB (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line);
1679 : :
1680 : : /*
1681 : : SliceDB - debug version of Slice.
1682 : : */
1683 : :
1684 : : extern "C" DynamicStrings_String DynamicStrings_SliceDB (DynamicStrings_String s, int low, int high, const char *file_, unsigned int _file_high, unsigned int line);
1685 : :
1686 : : /*
1687 : : PushAllocation - pushes the current allocation/deallocation lists.
1688 : : */
1689 : :
1690 : : extern "C" void DynamicStrings_PushAllocation (void);
1691 : :
1692 : : /*
1693 : : PopAllocation - test to see that all strings are deallocated since
1694 : : the last push. Then it pops to the previous
1695 : : allocation/deallocation lists.
1696 : :
1697 : : If halt is true then the application terminates
1698 : : with an exit code of 1.
1699 : : */
1700 : :
1701 : : extern "C" void DynamicStrings_PopAllocation (bool halt);
1702 : :
1703 : : /*
1704 : : PopAllocationExemption - test to see that all strings are deallocated, except
1705 : : string e since the last push.
1706 : : Post-condition: it pops to the previous allocation/deallocation
1707 : : lists.
1708 : :
1709 : : If halt is true then the application terminates
1710 : : with an exit code of 1.
1711 : : */
1712 : :
1713 : : extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool halt, DynamicStrings_String e);
1714 : : extern "C" DynamicStrings_String FormatStrings_Sprintf0 (DynamicStrings_String fmt);
1715 : : extern "C" DynamicStrings_String FormatStrings_Sprintf1 (DynamicStrings_String fmt, const unsigned char *w_, unsigned int _w_high);
1716 : : extern "C" DynamicStrings_String FormatStrings_Sprintf2 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
1717 : : extern "C" DynamicStrings_String FormatStrings_Sprintf3 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
1718 : : extern "C" DynamicStrings_String FormatStrings_Sprintf4 (DynamicStrings_String fmt, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high);
1719 : : extern "C" DynamicStrings_String FormatStrings_HandleEscape (DynamicStrings_String s);
1720 : : extern "C" bool M2LexBuf_OpenSource (DynamicStrings_String s);
1721 : : extern "C" void M2LexBuf_CloseSource (void);
1722 : : extern "C" void M2LexBuf_ReInitialize (void);
1723 : : extern "C" void M2LexBuf_ResetForNewPass (void);
1724 : : extern "C" void M2LexBuf_GetToken (void);
1725 : : extern "C" void M2LexBuf_InsertToken (M2Reserved_toktype token);
1726 : : extern "C" void M2LexBuf_InsertTokenAndRewind (M2Reserved_toktype token);
1727 : : extern "C" unsigned int M2LexBuf_GetPreviousTokenLineNo (void);
1728 : : extern "C" unsigned int M2LexBuf_GetLineNo (void);
1729 : : extern "C" unsigned int M2LexBuf_GetTokenNo (void);
1730 : : extern "C" NameKey_Name M2LexBuf_GetTokenName (unsigned int tokenno);
1731 : : extern "C" unsigned int M2LexBuf_TokenToLineNo (unsigned int tokenno, unsigned int depth);
1732 : : extern "C" unsigned int M2LexBuf_GetColumnNo (void);
1733 : : extern "C" unsigned int M2LexBuf_TokenToColumnNo (unsigned int tokenno, unsigned int depth);
1734 : : extern "C" m2linemap_location_t M2LexBuf_TokenToLocation (unsigned int tokenno);
1735 : : extern "C" DynamicStrings_String M2LexBuf_FindFileNameFromToken (unsigned int tokenno, unsigned int depth);
1736 : : extern "C" DynamicStrings_String M2LexBuf_GetFileName (void);
1737 : : extern "C" unsigned int M2LexBuf_MakeVirtualTok (unsigned int caret, unsigned int left, unsigned int right);
1738 : : extern "C" unsigned int M2LexBuf_MakeVirtual2Tok (unsigned int left, unsigned int right);
1739 : : extern "C" void M2LexBuf_AddTok (M2Reserved_toktype t);
1740 : : extern "C" void M2LexBuf_AddTokCharStar (M2Reserved_toktype t, void * s);
1741 : : extern "C" void M2LexBuf_AddTokInteger (M2Reserved_toktype t, int i);
1742 : : extern "C" void M2LexBuf_SetFile (void * filename);
1743 : : extern "C" void M2LexBuf_PushFile (void * filename);
1744 : : extern "C" void M2LexBuf_PopFile (void * filename);
1745 : : extern "C" void M2LexBuf_PrintTokenNo (unsigned int tokenno);
1746 : : extern "C" void M2LexBuf_DisplayToken (M2Reserved_toktype tok);
1747 : : extern "C" void M2LexBuf_DumpTokens (void);
1748 : : extern "C" void M2MetaError_MetaError0 (const char *m_, unsigned int _m_high);
1749 : : extern "C" void M2MetaError_MetaError1 (const char *m_, unsigned int _m_high, unsigned int s);
1750 : : extern "C" void M2MetaError_MetaError2 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2);
1751 : : extern "C" void M2MetaError_MetaError3 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3);
1752 : : extern "C" void M2MetaError_MetaError4 (const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
1753 : : extern "C" void M2MetaError_MetaErrors1 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s);
1754 : : extern "C" void M2MetaError_MetaErrors2 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2);
1755 : : extern "C" void M2MetaError_MetaErrors3 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3);
1756 : : extern "C" void M2MetaError_MetaErrors4 (const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
1757 : : extern "C" void M2MetaError_MetaErrorT0 (unsigned int tok, const char *m_, unsigned int _m_high);
1758 : : extern "C" void M2MetaError_MetaErrorT1 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s);
1759 : : extern "C" void M2MetaError_MetaErrorT2 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2);
1760 : : extern "C" void M2MetaError_MetaErrorT3 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3);
1761 : : extern "C" void M2MetaError_MetaErrorT4 (unsigned int tok, const char *m_, unsigned int _m_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
1762 : : extern "C" void M2MetaError_MetaErrorsT1 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s);
1763 : : extern "C" void M2MetaError_MetaErrorsT2 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2);
1764 : : extern "C" void M2MetaError_MetaErrorsT3 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3);
1765 : : extern "C" void M2MetaError_MetaErrorsT4 (unsigned int tok, const char *m1_, unsigned int _m1_high, const char *m2_, unsigned int _m2_high, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
1766 : : extern "C" void M2MetaError_MetaErrorString0 (DynamicStrings_String m);
1767 : : extern "C" void M2MetaError_MetaErrorString1 (DynamicStrings_String m, unsigned int s);
1768 : : extern "C" void M2MetaError_MetaErrorString2 (DynamicStrings_String m, unsigned int s1, unsigned int s2);
1769 : : extern "C" void M2MetaError_MetaErrorString3 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3);
1770 : : extern "C" void M2MetaError_MetaErrorString4 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
1771 : : extern "C" void M2MetaError_MetaErrorStringT0 (unsigned int tok, DynamicStrings_String m);
1772 : : extern "C" void M2MetaError_MetaErrorStringT1 (unsigned int tok, DynamicStrings_String m, unsigned int s);
1773 : : extern "C" void M2MetaError_MetaErrorStringT2 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2);
1774 : : extern "C" void M2MetaError_MetaErrorStringT3 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3);
1775 : : extern "C" void M2MetaError_MetaErrorStringT4 (unsigned int tok, DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
1776 : : extern "C" void M2MetaError_MetaErrorN1 (const char *m_, unsigned int _m_high, NameKey_Name n);
1777 : : extern "C" void M2MetaError_MetaErrorN2 (const char *m_, unsigned int _m_high, NameKey_Name n1, NameKey_Name n2);
1778 : : extern "C" void M2MetaError_MetaErrorNT0 (unsigned int tok, const char *format_, unsigned int _format_high);
1779 : : extern "C" void M2MetaError_MetaErrorNT1 (unsigned int tok, const char *format_, unsigned int _format_high, NameKey_Name name);
1780 : : extern "C" void M2MetaError_MetaErrorNT2 (unsigned int tok, const char *format_, unsigned int _format_high, NameKey_Name name1, NameKey_Name name2);
1781 : : extern "C" DynamicStrings_String M2MetaError_MetaString0 (DynamicStrings_String m);
1782 : : extern "C" DynamicStrings_String M2MetaError_MetaString1 (DynamicStrings_String m, unsigned int s);
1783 : : extern "C" DynamicStrings_String M2MetaError_MetaString2 (DynamicStrings_String m, unsigned int s1, unsigned int s2);
1784 : : extern "C" DynamicStrings_String M2MetaError_MetaString3 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3);
1785 : : extern "C" DynamicStrings_String M2MetaError_MetaString4 (DynamicStrings_String m, unsigned int s1, unsigned int s2, unsigned int s3, unsigned int s4);
1786 : :
1787 : : /*
1788 : : InternalError - displays an internal error message together with the compiler source
1789 : : file and line number.
1790 : : This function is not buffered and is used when the compiler is about
1791 : : to give up.
1792 : : */
1793 : :
1794 : : extern "C" void M2Error_InternalError (const char *message_, unsigned int _message_high) __attribute__ ((noreturn));
1795 : :
1796 : : /*
1797 : : WriteFormat0 - displays the source module and line together
1798 : : with the encapsulated format string.
1799 : : Used for simple error messages tied to the current token.
1800 : : */
1801 : :
1802 : : extern "C" void M2Error_WriteFormat0 (const char *a_, unsigned int _a_high);
1803 : :
1804 : : /*
1805 : : WriteFormat1 - displays the source module and line together
1806 : : with the encapsulated format string.
1807 : : Used for simple error messages tied to the current token.
1808 : : */
1809 : :
1810 : : extern "C" void M2Error_WriteFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
1811 : :
1812 : : /*
1813 : : WriteFormat2 - displays the module and line together with the encapsulated
1814 : : format strings.
1815 : : Used for simple error messages tied to the current token.
1816 : : */
1817 : :
1818 : : extern "C" void M2Error_WriteFormat2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
1819 : :
1820 : : /*
1821 : : WriteFormat3 - displays the module and line together with the encapsulated
1822 : : format strings.
1823 : : Used for simple error messages tied to the current token.
1824 : : */
1825 : :
1826 : : extern "C" void M2Error_WriteFormat3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
1827 : :
1828 : : /*
1829 : : NewError - creates and returns a new error handle.
1830 : : */
1831 : :
1832 : : extern "C" M2Error_Error M2Error_NewError (unsigned int AtTokenNo);
1833 : :
1834 : : /*
1835 : : NewWarning - creates and returns a new error handle suitable for a warning.
1836 : : A warning will not stop compilation.
1837 : : */
1838 : :
1839 : : extern "C" M2Error_Error M2Error_NewWarning (unsigned int AtTokenNo);
1840 : :
1841 : : /*
1842 : : NewNote - creates and returns a new error handle suitable for a note.
1843 : : A note will not stop compilation.
1844 : : */
1845 : :
1846 : : extern "C" M2Error_Error M2Error_NewNote (unsigned int AtTokenNo);
1847 : :
1848 : : /*
1849 : : ChainError - creates and returns a new error handle, this new error
1850 : : is associated with, e, and is chained onto the end of, e.
1851 : : If, e, is NIL then the result to NewError is returned.
1852 : : */
1853 : :
1854 : : extern "C" M2Error_Error M2Error_ChainError (unsigned int AtTokenNo, M2Error_Error e);
1855 : :
1856 : : /*
1857 : : MoveError - repositions an error, e, to token, AtTokenNo, and returns, e.
1858 : : */
1859 : :
1860 : : extern "C" M2Error_Error M2Error_MoveError (M2Error_Error e, unsigned int AtTokenNo);
1861 : :
1862 : : /*
1863 : : SetColor - informs the error module that this error will have had colors
1864 : : assigned to it. If an error is issued without colors assigned
1865 : : then the default colors will be assigned to the legacy error
1866 : : messages.
1867 : : */
1868 : :
1869 : : extern "C" M2Error_Error M2Error_SetColor (M2Error_Error e);
1870 : : extern "C" void M2Error_ErrorFormat0 (M2Error_Error e, const char *a_, unsigned int _a_high);
1871 : : extern "C" void M2Error_ErrorFormat1 (M2Error_Error e, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
1872 : : extern "C" void M2Error_ErrorFormat2 (M2Error_Error e, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
1873 : : extern "C" void M2Error_ErrorFormat3 (M2Error_Error e, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
1874 : : extern "C" void M2Error_ErrorString (M2Error_Error e, DynamicStrings_String str);
1875 : :
1876 : : /*
1877 : : ErrorStringAt - given an error string, s, it places this
1878 : : string at token position, tok.
1879 : : The string is consumed.
1880 : : */
1881 : :
1882 : : extern "C" void M2Error_ErrorStringAt (DynamicStrings_String s, unsigned int tok);
1883 : :
1884 : : /*
1885 : : ErrorStringAt2 - given an error string, s, it places this
1886 : : string at token positions, tok1 and tok2, respectively.
1887 : : The string is consumed.
1888 : : */
1889 : :
1890 : : extern "C" void M2Error_ErrorStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2);
1891 : :
1892 : : /*
1893 : : ErrorStringsAt2 - given error strings, s1, and, s2, it places these
1894 : : strings at token positions, tok1 and tok2, respectively.
1895 : : Both strings are consumed.
1896 : : */
1897 : :
1898 : : extern "C" void M2Error_ErrorStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2);
1899 : :
1900 : : /*
1901 : : WarnStringAt - given an error string, s, it places this
1902 : : string at token position, tok.
1903 : : The string is consumed.
1904 : : */
1905 : :
1906 : : extern "C" void M2Error_WarnStringAt (DynamicStrings_String s, unsigned int tok);
1907 : :
1908 : : /*
1909 : : WarnStringAt2 - given an warning string, s, it places this
1910 : : string at token positions, tok1 and tok2, respectively.
1911 : : The string is consumed.
1912 : : */
1913 : :
1914 : : extern "C" void M2Error_WarnStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2);
1915 : :
1916 : : /*
1917 : : WarnStringsAt2 - given warning strings, s1, and, s2, it places these
1918 : : strings at token positions, tok1 and tok2, respectively.
1919 : : Both strings are consumed.
1920 : : */
1921 : :
1922 : : extern "C" void M2Error_WarnStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2);
1923 : :
1924 : : /*
1925 : : WarnFormat0 - displays the source module and line together
1926 : : with the encapsulated format string.
1927 : : Used for simple warning messages tied to the current token.
1928 : : */
1929 : :
1930 : : extern "C" void M2Error_WarnFormat0 (const char *a_, unsigned int _a_high);
1931 : :
1932 : : /*
1933 : : WarnFormat1 - displays the source module and line together
1934 : : with the encapsulated format string.
1935 : : Used for simple warning messages tied to the current token.
1936 : : */
1937 : :
1938 : : extern "C" void M2Error_WarnFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
1939 : :
1940 : : /*
1941 : : FlushErrors - switches the output channel to the error channel
1942 : : and then writes out all errors.
1943 : : */
1944 : :
1945 : : extern "C" void M2Error_FlushErrors (void);
1946 : :
1947 : : /*
1948 : : FlushWarnings - switches the output channel to the error channel
1949 : : and then writes out all warnings.
1950 : : If an error is present the compilation is terminated,
1951 : : if warnings only were emitted then compilation will
1952 : : continue.
1953 : : */
1954 : :
1955 : : extern "C" void M2Error_FlushWarnings (void);
1956 : :
1957 : : /*
1958 : : ErrorAbort0 - aborts compiling, it flushes all warnings and errors before aborting.
1959 : : */
1960 : :
1961 : : extern "C" void M2Error_ErrorAbort0 (const char *a_, unsigned int _a_high) __attribute__ ((noreturn));
1962 : :
1963 : : /*
1964 : : AnnounceScope - return the error string s with a scope description prepended
1965 : : assuming that scope has changed.
1966 : : */
1967 : :
1968 : : extern "C" DynamicStrings_String M2Error_AnnounceScope (M2Error_Error e, DynamicStrings_String message);
1969 : :
1970 : : /*
1971 : : EnterImplementationScope - signifies to the error routines that the front end
1972 : : has started to compile implementation module scopeName.
1973 : : */
1974 : :
1975 : : extern "C" void M2Error_EnterImplementationScope (NameKey_Name scopename);
1976 : :
1977 : : /*
1978 : : EnterProgramScope - signifies to the error routines that the front end
1979 : : has started to compile program module scopeName.
1980 : : */
1981 : :
1982 : : extern "C" void M2Error_EnterProgramScope (NameKey_Name scopename);
1983 : :
1984 : : /*
1985 : : EnterModuleScope - signifies to the error routines that the front end
1986 : : has started to compile an inner module scopeName.
1987 : : */
1988 : :
1989 : : extern "C" void M2Error_EnterModuleScope (NameKey_Name scopename);
1990 : :
1991 : : /*
1992 : : EnterDefinitionScope - signifies to the error routines that the front end
1993 : : has started to compile definition module scopeName.
1994 : : */
1995 : :
1996 : : extern "C" void M2Error_EnterDefinitionScope (NameKey_Name scopename);
1997 : :
1998 : : /*
1999 : : EnterProcedureScope - signifies to the error routines that the front end
2000 : : has started to compile definition module scopeName.
2001 : : */
2002 : :
2003 : : extern "C" void M2Error_EnterProcedureScope (NameKey_Name scopename);
2004 : :
2005 : : /*
2006 : : DepthScope - returns the depth of the scope stack.
2007 : : */
2008 : :
2009 : : extern "C" unsigned int M2Error_DepthScope (void);
2010 : :
2011 : : /*
2012 : : GetAnnounceScope - return message with the error scope attached to message.
2013 : : filename and message are treated as read only by this
2014 : : procedure function.
2015 : : */
2016 : :
2017 : : extern "C" DynamicStrings_String M2Error_GetAnnounceScope (DynamicStrings_String filename, DynamicStrings_String message);
2018 : :
2019 : : /*
2020 : : DefaultProgramModule - sets up an unnamed program scope before the Ident is seen.
2021 : : */
2022 : :
2023 : : extern "C" void M2Error_DefaultProgramModule (void);
2024 : :
2025 : : /*
2026 : : DefaultImplementationModule - sets up an unnamed implementation
2027 : : scope before the Ident is seen.
2028 : : */
2029 : :
2030 : : extern "C" void M2Error_DefaultImplementationModule (void);
2031 : :
2032 : : /*
2033 : : DefaultDefinitionModule - sets up an unnamed definition
2034 : : scope before the Ident is seen.
2035 : : */
2036 : :
2037 : : extern "C" void M2Error_DefaultDefinitionModule (void);
2038 : :
2039 : : /*
2040 : : DefaultInnerModule - sets up an unnamed inner
2041 : : scope before the Ident is seen.
2042 : : */
2043 : :
2044 : : extern "C" void M2Error_DefaultInnerModule (void);
2045 : :
2046 : : /*
2047 : : DefaultProcedure - sets up an unnamed procedure
2048 : : scope before the Ident is seen.
2049 : : */
2050 : :
2051 : : extern "C" void M2Error_DefaultProcedure (void);
2052 : :
2053 : : /*
2054 : : EnterErrorScope - pushes the currentScope and sets currentScope to scope.
2055 : : */
2056 : :
2057 : : extern "C" void M2Error_EnterErrorScope (M2Error_ErrorScope scope);
2058 : :
2059 : : /*
2060 : : LeaveErrorScope - leave the current scope and pop into the previous one.
2061 : : */
2062 : :
2063 : : extern "C" void M2Error_LeaveErrorScope (void);
2064 : :
2065 : : /*
2066 : : GetCurrentErrorScope - returns currentScope.
2067 : : */
2068 : :
2069 : : extern "C" M2Error_ErrorScope M2Error_GetCurrentErrorScope (void);
2070 : :
2071 : : /*
2072 : : ResetErrorScope - should be called at the start of each pass to
2073 : : reset the error scope index.
2074 : : */
2075 : :
2076 : : extern "C" void M2Error_ResetErrorScope (void);
2077 : : extern "C" bool M2LangDump_IsDumpRequiredTree (m2tree_Tree tree, bool default_);
2078 : : extern "C" bool M2LangDump_IsDumpRequired (unsigned int sym, bool default_);
2079 : : extern "C" DynamicStrings_String M2LangDump_MakeQuadTemplate (void);
2080 : : extern "C" DynamicStrings_String M2LangDump_MakeGimpleTemplate (unsigned int *len);
2081 : : extern "C" FIO_File M2LangDump_GetDumpFile (void);
2082 : : extern "C" void M2LangDump_CreateDumpQuad (const char *title_, unsigned int _title_high);
2083 : : extern "C" void M2LangDump_CloseDumpQuad (void);
2084 : : extern "C" void M2LangDump_CreateDumpDecl (const char *title_, unsigned int _title_high);
2085 : : extern "C" void M2LangDump_CloseDumpDecl (void);
2086 : : extern "C" void M2Printf_printf0 (const char *a_, unsigned int _a_high);
2087 : : extern "C" void M2Printf_printf1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
2088 : : extern "C" void M2Printf_printf2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
2089 : : extern "C" void M2Printf_printf3 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
2090 : : extern "C" void M2Printf_printf4 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high);
2091 : : extern "C" void M2Printf_fprintf0 (FIO_File file, const char *a_, unsigned int _a_high);
2092 : : extern "C" void M2Printf_fprintf1 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
2093 : : extern "C" void M2Printf_fprintf2 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
2094 : : extern "C" void M2Printf_fprintf3 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high);
2095 : : extern "C" void M2Printf_fprintf4 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high, const unsigned char *w3_, unsigned int _w3_high, const unsigned char *w4_, unsigned int _w4_high);
2096 : :
2097 : : /*
2098 : : InitIndexTuned - creates a dynamic array with low indice.
2099 : : The minsize is the initial number of elements the
2100 : : array is allocated and growfactor determines how
2101 : : it will be resized once it becomes full.
2102 : : */
2103 : :
2104 : : extern "C" Indexing_Index Indexing_InitIndexTuned (unsigned int low, unsigned int minsize, unsigned int growfactor);
2105 : :
2106 : : /*
2107 : : InitIndex - creates and returns an Index.
2108 : : */
2109 : :
2110 : : extern "C" Indexing_Index Indexing_InitIndex (unsigned int low);
2111 : :
2112 : : /*
2113 : : KillIndex - returns Index to free storage.
2114 : : */
2115 : :
2116 : : extern "C" Indexing_Index Indexing_KillIndex (Indexing_Index i);
2117 : :
2118 : : /*
2119 : : DebugIndex - turns on debugging within an index.
2120 : : */
2121 : :
2122 : : extern "C" Indexing_Index Indexing_DebugIndex (Indexing_Index i);
2123 : :
2124 : : /*
2125 : : InBounds - returns TRUE if indice, n, is within the bounds
2126 : : of the dynamic array.
2127 : : */
2128 : :
2129 : : extern "C" bool Indexing_InBounds (Indexing_Index i, unsigned int n);
2130 : :
2131 : : /*
2132 : : HighIndice - returns the last legally accessible indice of this array.
2133 : : */
2134 : :
2135 : : extern "C" unsigned int Indexing_HighIndice (Indexing_Index i);
2136 : :
2137 : : /*
2138 : : LowIndice - returns the first legally accessible indice of this array.
2139 : : */
2140 : :
2141 : : extern "C" unsigned int Indexing_LowIndice (Indexing_Index i);
2142 : :
2143 : : /*
2144 : : PutIndice - places, a, into the dynamic array at position i[n]
2145 : : */
2146 : :
2147 : : extern "C" void Indexing_PutIndice (Indexing_Index i, unsigned int n, void * a);
2148 : :
2149 : : /*
2150 : : GetIndice - retrieves, element i[n] from the dynamic array.
2151 : : */
2152 : :
2153 : : extern "C" void * Indexing_GetIndice (Indexing_Index i, unsigned int n);
2154 : :
2155 : : /*
2156 : : IsIndiceInIndex - returns TRUE if, a, is in the index, i.
2157 : : */
2158 : :
2159 : : extern "C" bool Indexing_IsIndiceInIndex (Indexing_Index i, void * a);
2160 : :
2161 : : /*
2162 : : RemoveIndiceFromIndex - removes, a, from Index, i.
2163 : : */
2164 : :
2165 : : extern "C" void Indexing_RemoveIndiceFromIndex (Indexing_Index i, void * a);
2166 : :
2167 : : /*
2168 : : DeleteIndice - delete i[j] from the array.
2169 : : */
2170 : :
2171 : : extern "C" void Indexing_DeleteIndice (Indexing_Index i, unsigned int j);
2172 : :
2173 : : /*
2174 : : IncludeIndiceIntoIndex - if the indice is not in the index, then
2175 : : add it at the end.
2176 : : */
2177 : :
2178 : : extern "C" void Indexing_IncludeIndiceIntoIndex (Indexing_Index i, void * a);
2179 : :
2180 : : /*
2181 : : ForeachIndiceInIndexDo - for each j indice of i, call procedure p(i[j])
2182 : : */
2183 : :
2184 : : extern "C" void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_IndexProcedure p);
2185 : :
2186 : : /*
2187 : : IsEmpty - return TRUE if the array has no entries it.
2188 : : */
2189 : :
2190 : : extern "C" bool Indexing_IsEmpty (Indexing_Index i);
2191 : :
2192 : : /*
2193 : : InitList - creates a new list, l.
2194 : : */
2195 : :
2196 : : extern "C" void Lists_InitList (Lists_List *l);
2197 : :
2198 : : /*
2199 : : KillList - deletes the complete list, l.
2200 : : */
2201 : :
2202 : : extern "C" void Lists_KillList (Lists_List *l);
2203 : :
2204 : : /*
2205 : : PutItemIntoList - places a WORD, c, into list, l.
2206 : : */
2207 : :
2208 : : extern "C" void Lists_PutItemIntoList (Lists_List l, unsigned int c);
2209 : : extern "C" unsigned int Lists_GetItemFromList (Lists_List l, unsigned int n);
2210 : :
2211 : : /*
2212 : : GetIndexOfList - returns the index for WORD, c, in list, l.
2213 : : If more than one WORD, c, exists the index
2214 : : for the first is returned.
2215 : : */
2216 : :
2217 : : extern "C" unsigned int Lists_GetIndexOfList (Lists_List l, unsigned int c);
2218 : :
2219 : : /*
2220 : : NoOfItemsInList - returns the number of items in list, l.
2221 : : (iterative algorithm of the above).
2222 : : */
2223 : :
2224 : : extern "C" unsigned int Lists_NoOfItemsInList (Lists_List l);
2225 : :
2226 : : /*
2227 : : IncludeItemIntoList - adds a WORD, c, into a list providing
2228 : : the value does not already exist.
2229 : : */
2230 : :
2231 : : extern "C" void Lists_IncludeItemIntoList (Lists_List l, unsigned int c);
2232 : :
2233 : : /*
2234 : : RemoveItemFromList - removes a WORD, c, from a list.
2235 : : It assumes that this value only appears once.
2236 : : */
2237 : :
2238 : : extern "C" void Lists_RemoveItemFromList (Lists_List l, unsigned int c);
2239 : :
2240 : : /*
2241 : : IsItemInList - returns true if a WORD, c, was found in list, l.
2242 : : */
2243 : :
2244 : : extern "C" bool Lists_IsItemInList (Lists_List l, unsigned int c);
2245 : :
2246 : : /*
2247 : : ForeachItemInListDo - calls procedure, P, foreach item in list, l.
2248 : : */
2249 : :
2250 : : extern "C" void Lists_ForeachItemInListDo (Lists_List l, SymbolKey_PerformOperation P);
2251 : :
2252 : : /*
2253 : : DuplicateList - returns a duplicate list derived from, l.
2254 : : */
2255 : :
2256 : : extern "C" Lists_List Lists_DuplicateList (Lists_List l);
2257 : :
2258 : : /*
2259 : : InitSet - initializes and returns a set. The set will
2260 : : never contain an element less than, low.
2261 : : */
2262 : :
2263 : : extern "C" Sets_Set Sets_InitSet (unsigned int low);
2264 : :
2265 : : /*
2266 : : KillSet - deallocates Set, s.
2267 : : */
2268 : :
2269 : : extern "C" Sets_Set Sets_KillSet (Sets_Set s);
2270 : :
2271 : : /*
2272 : : DuplicateSet - returns a new duplicated set.
2273 : : */
2274 : :
2275 : : extern "C" Sets_Set Sets_DuplicateSet (Sets_Set s);
2276 : :
2277 : : /*
2278 : : ForeachElementInSetDo - for each element e in, s, call, p(e).
2279 : : */
2280 : :
2281 : : extern "C" void Sets_ForeachElementInSetDo (Sets_Set s, SymbolKey_PerformOperation p);
2282 : :
2283 : : /*
2284 : : IsElementInSet - returns TRUE if element, i, is in set, s.
2285 : : */
2286 : :
2287 : : extern "C" bool Sets_IsElementInSet (Sets_Set s, unsigned int i);
2288 : :
2289 : : /*
2290 : : NoOfElementsInSet - returns the number of elements in a set, s.
2291 : : */
2292 : :
2293 : : extern "C" unsigned int Sets_NoOfElementsInSet (Sets_Set s);
2294 : :
2295 : : /*
2296 : : ExcludeElementFromSet - excludes element, i, from set, s.
2297 : : */
2298 : :
2299 : : extern "C" void Sets_ExcludeElementFromSet (Sets_Set s, unsigned int i);
2300 : :
2301 : : /*
2302 : : IncludeElementIntoSet - includes element, i, into set, s.
2303 : : */
2304 : :
2305 : : extern "C" void Sets_IncludeElementIntoSet (Sets_Set s, unsigned int i);
2306 : :
2307 : : /*
2308 : : EqualSet - return TRUE if left = right.
2309 : : */
2310 : :
2311 : : extern "C" bool Sets_EqualSet (Sets_Set left, Sets_Set right);
2312 : : extern "C" unsigned int SymbolTable_FinalSymbol (void);
2313 : : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record);
2314 : : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field);
2315 : : extern "C" bool SymbolTable_IsComponent (unsigned int sym);
2316 : : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode);
2317 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode);
2318 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode);
2319 : : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode);
2320 : : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym);
2321 : : extern "C" void SymbolTable_StartScope (unsigned int Sym);
2322 : : extern "C" void SymbolTable_EndScope (void);
2323 : : extern "C" void SymbolTable_PseudoScope (unsigned int Sym);
2324 : : extern "C" unsigned int SymbolTable_GetCurrentScope (void);
2325 : : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym);
2326 : : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym);
2327 : : extern "C" void SymbolTable_SetFileModule (unsigned int Sym);
2328 : : extern "C" void SymbolTable_SetMainModule (unsigned int Sym);
2329 : : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name);
2330 : : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym);
2331 : : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope);
2332 : : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName);
2333 : : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName);
2334 : : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName);
2335 : : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName);
2336 : : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename);
2337 : : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname);
2338 : : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym);
2339 : : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value);
2340 : : extern "C" bool SymbolTable_IsMonoName (unsigned int sym);
2341 : : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value);
2342 : : extern "C" bool SymbolTable_IsExtern (unsigned int sym);
2343 : : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value);
2344 : : extern "C" bool SymbolTable_IsPublic (unsigned int sym);
2345 : : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value);
2346 : : extern "C" bool SymbolTable_IsCtor (unsigned int sym);
2347 : : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep);
2348 : : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym);
2349 : : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external);
2350 : : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value);
2351 : : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym);
2352 : : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName);
2353 : : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName);
2354 : : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym);
2355 : : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym);
2356 : : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName);
2357 : : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName);
2358 : : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName);
2359 : : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value);
2360 : : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
2361 : : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName);
2362 : : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName);
2363 : : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known);
2364 : : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known);
2365 : : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known);
2366 : : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr);
2367 : : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym);
2368 : : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym);
2369 : : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym);
2370 : : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym);
2371 : : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym);
2372 : : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName);
2373 : : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName);
2374 : : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName);
2375 : : extern "C" void SymbolTable_PutArrayLarge (unsigned int array);
2376 : : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array);
2377 : : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority);
2378 : : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module);
2379 : : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym);
2380 : : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym);
2381 : : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address);
2382 : : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym);
2383 : : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym);
2384 : : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value);
2385 : : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym);
2386 : : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value);
2387 : : extern "C" unsigned int SymbolTable_MakeGnuAsm (void);
2388 : : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string);
2389 : : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out);
2390 : : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in);
2391 : : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash);
2392 : : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym);
2393 : : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym);
2394 : : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym);
2395 : : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym);
2396 : : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym);
2397 : : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym);
2398 : : extern "C" unsigned int SymbolTable_MakeRegInterface (void);
2399 : : extern "C" void SymbolTable_PutRegInterface (unsigned int tok, unsigned int sym, unsigned int i, NameKey_Name n, unsigned int string, unsigned int object, unsigned int read_, unsigned int write_);
2400 : : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object);
2401 : : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name);
2402 : : extern "C" unsigned int SymbolTable_GetCurrentModule (void);
2403 : : extern "C" unsigned int SymbolTable_GetFileModule (void);
2404 : : extern "C" unsigned int SymbolTable_GetBaseModule (void);
2405 : : extern "C" unsigned int SymbolTable_GetMainModule (void);
2406 : : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void);
2407 : : extern "C" unsigned int SymbolTable_GetLastModuleScope (void);
2408 : : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym);
2409 : : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym);
2410 : : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym);
2411 : : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym);
2412 : : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym);
2413 : : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym);
2414 : : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym);
2415 : : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym);
2416 : : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym);
2417 : : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name);
2418 : : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName);
2419 : : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name);
2420 : : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym);
2421 : : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod);
2422 : : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n);
2423 : : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, unsigned int ParamNo);
2424 : : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym);
2425 : : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym);
2426 : : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo);
2427 : : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym);
2428 : : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym);
2429 : : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym);
2430 : : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name);
2431 : : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym);
2432 : : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym);
2433 : : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym);
2434 : : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym);
2435 : : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym);
2436 : : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym);
2437 : : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym);
2438 : : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType);
2439 : : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType);
2440 : : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym);
2441 : : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value);
2442 : : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym);
2443 : : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value);
2444 : : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym);
2445 : : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType);
2446 : : extern "C" void SymbolTable_PutConstSet (unsigned int Sym);
2447 : : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym);
2448 : : extern "C" void SymbolTable_PutConstructor (unsigned int Sym);
2449 : : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from);
2450 : : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym);
2451 : : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym);
2452 : : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field);
2453 : : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym);
2454 : : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym);
2455 : : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym);
2456 : : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag);
2457 : : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName);
2458 : : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol);
2459 : : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed);
2460 : : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym);
2461 : : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym);
2462 : : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol);
2463 : : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol);
2464 : : extern "C" void SymbolTable_PutFunction (unsigned int Sym, unsigned int TypeSym);
2465 : : extern "C" void SymbolTable_PutOptFunction (unsigned int Sym, unsigned int TypeSym);
2466 : : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym);
2467 : : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded);
2468 : : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded);
2469 : : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, unsigned int no, NameKey_Name name);
2470 : : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym);
2471 : : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym);
2472 : : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, bool value);
2473 : : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym);
2474 : : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber);
2475 : : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber);
2476 : : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber);
2477 : : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber);
2478 : : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish);
2479 : : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, m2tree_Tree finally);
2480 : : extern "C" m2tree_Tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym);
2481 : : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber);
2482 : : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber);
2483 : : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber);
2484 : : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end);
2485 : : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2486 : : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2487 : : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
2488 : : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2489 : : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2490 : : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2491 : : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
2492 : : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2493 : : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
2494 : : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n);
2495 : : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym);
2496 : : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym);
2497 : : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym);
2498 : : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym);
2499 : : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym);
2500 : : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym);
2501 : : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin);
2502 : : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end);
2503 : : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end);
2504 : : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P);
2505 : : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P);
2506 : : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P);
2507 : : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, unsigned int ParamNo);
2508 : : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, unsigned int ParamNo);
2509 : : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym);
2510 : : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym);
2511 : : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym);
2512 : : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym);
2513 : : extern "C" bool SymbolTable_HasVarParameters (unsigned int p);
2514 : : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym);
2515 : : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym);
2516 : : extern "C" bool SymbolTable_IsModule (unsigned int Sym);
2517 : : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym);
2518 : : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym);
2519 : : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName);
2520 : : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym);
2521 : : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym);
2522 : : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName);
2523 : : extern "C" void SymbolTable_PutImported (unsigned int Sym);
2524 : : extern "C" void SymbolTable_PutIncluded (unsigned int Sym);
2525 : : extern "C" void SymbolTable_PutExported (unsigned int Sym);
2526 : : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName);
2527 : : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName);
2528 : : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym);
2529 : : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName);
2530 : : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName);
2531 : : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name);
2532 : : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym);
2533 : : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym);
2534 : : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym);
2535 : : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym);
2536 : : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym);
2537 : : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym);
2538 : : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym);
2539 : : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2540 : : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
2541 : : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym);
2542 : : extern "C" void SymbolTable_CheckForUnImplementedExports (void);
2543 : : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym);
2544 : : extern "C" void SymbolTable_CheckForUnknownInModule (void);
2545 : : extern "C" void SymbolTable_UnknownReported (unsigned int sym);
2546 : : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym);
2547 : : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void);
2548 : : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym);
2549 : : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym);
2550 : : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym);
2551 : : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym);
2552 : : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym);
2553 : : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym);
2554 : : extern "C" void SymbolTable_SanityCheckConstants (void);
2555 : : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2556 : : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
2557 : : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P);
2558 : : extern "C" bool SymbolTable_IsType (unsigned int Sym);
2559 : : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym);
2560 : : extern "C" bool SymbolTable_IsParameter (unsigned int Sym);
2561 : : extern "C" void SymbolTable_ProcedureParametersDefined (unsigned int Sym);
2562 : : extern "C" bool SymbolTable_AreProcedureParametersDefined (unsigned int Sym);
2563 : : extern "C" void SymbolTable_ParametersDefinedInDefinition (unsigned int Sym);
2564 : : extern "C" bool SymbolTable_AreParametersDefinedInDefinition (unsigned int Sym);
2565 : : extern "C" void SymbolTable_ParametersDefinedInImplementation (unsigned int Sym);
2566 : : extern "C" bool SymbolTable_AreParametersDefinedInImplementation (unsigned int Sym);
2567 : : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym);
2568 : : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym);
2569 : : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym);
2570 : : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym);
2571 : : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym);
2572 : : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym);
2573 : : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName);
2574 : : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType);
2575 : : extern "C" bool SymbolTable_IsPointer (unsigned int Sym);
2576 : : extern "C" bool SymbolTable_IsRecord (unsigned int Sym);
2577 : : extern "C" bool SymbolTable_IsVarient (unsigned int Sym);
2578 : : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym);
2579 : : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym);
2580 : : extern "C" bool SymbolTable_IsArray (unsigned int Sym);
2581 : : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym);
2582 : : extern "C" bool SymbolTable_IsSet (unsigned int Sym);
2583 : : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym);
2584 : : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym);
2585 : : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym);
2586 : : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType);
2587 : : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType);
2588 : : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p);
2589 : : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym);
2590 : : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim);
2591 : : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym);
2592 : : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym);
2593 : : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim);
2594 : : extern "C" unsigned int SymbolTable_MakeSubscript (void);
2595 : : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType);
2596 : : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim);
2597 : : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym);
2598 : : extern "C" void SymbolTable_PutArray (unsigned int Sym, unsigned int TypeSymbol);
2599 : : extern "C" void SymbolTable_ResolveImports (void);
2600 : : extern "C" void SymbolTable_ResolveConstructorTypes (void);
2601 : : extern "C" void SymbolTable_AddNameToScope (NameKey_Name n);
2602 : : extern "C" void SymbolTable_AddNameToImportList (NameKey_Name n);
2603 : : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym);
2604 : : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym);
2605 : : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym);
2606 : : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym);
2607 : : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym);
2608 : : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym);
2609 : : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName);
2610 : : extern "C" void SymbolTable_PutProcTypeParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded);
2611 : : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded);
2612 : : extern "C" bool SymbolTable_IsProcType (unsigned int Sym);
2613 : : extern "C" bool SymbolTable_IsVar (unsigned int Sym);
2614 : : extern "C" bool SymbolTable_IsVarConst (unsigned int sym);
2615 : : extern "C" bool SymbolTable_IsConst (unsigned int Sym);
2616 : : extern "C" bool SymbolTable_IsConstString (unsigned int sym);
2617 : : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym);
2618 : : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym);
2619 : : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym);
2620 : : extern "C" bool SymbolTable_IsDummy (unsigned int Sym);
2621 : : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym);
2622 : : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym);
2623 : : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym);
2624 : : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym);
2625 : : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym);
2626 : : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym);
2627 : : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym);
2628 : : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym);
2629 : : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym);
2630 : : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym);
2631 : : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym);
2632 : : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym);
2633 : : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym);
2634 : : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym);
2635 : : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym);
2636 : : extern "C" bool SymbolTable_IsComposite (unsigned int sym);
2637 : : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym);
2638 : : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align);
2639 : : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type);
2640 : : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym);
2641 : : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align);
2642 : : extern "C" void SymbolTable_PutUnused (unsigned int sym);
2643 : : extern "C" bool SymbolTable_IsUnused (unsigned int sym);
2644 : : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b);
2645 : : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym);
2646 : : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym);
2647 : : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym);
2648 : : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym);
2649 : : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym);
2650 : : extern "C" void SymbolTable_PushSize (unsigned int Sym);
2651 : : extern "C" void SymbolTable_PushOffset (unsigned int Sym);
2652 : : extern "C" void SymbolTable_PushValue (unsigned int Sym);
2653 : : extern "C" void SymbolTable_PushParamSize (unsigned int Sym, unsigned int ParamNo);
2654 : : extern "C" void SymbolTable_PushSumOfLocalVarSize (unsigned int Sym);
2655 : : extern "C" void SymbolTable_PushSumOfParamSize (unsigned int Sym);
2656 : : extern "C" void SymbolTable_PushVarSize (unsigned int Sym);
2657 : : extern "C" void SymbolTable_PopValue (unsigned int Sym);
2658 : : extern "C" void SymbolTable_PopSize (unsigned int Sym);
2659 : : extern "C" void SymbolTable_PopOffset (unsigned int Sym);
2660 : : extern "C" void SymbolTable_PopSumOfParamSize (unsigned int Sym);
2661 : : extern "C" bool SymbolTable_IsObject (unsigned int Sym);
2662 : : extern "C" bool SymbolTable_IsTuple (unsigned int Sym);
2663 : : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b);
2664 : : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name);
2665 : : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name);
2666 : : extern "C" bool SymbolTable_IsError (unsigned int Sym);
2667 : : extern "C" bool SymbolTable_IsLegal (unsigned int sym);
2668 : : extern "C" void SymbolTable_PutModuleContainsBuiltin (void);
2669 : : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym);
2670 : : extern "C" void SymbolTable_PutHiddenTypeDeclared (void);
2671 : : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym);
2672 : : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym);
2673 : : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym);
2674 : : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym);
2675 : : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified);
2676 : : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno);
2677 : : extern "C" bool SymbolTable_IsImport (unsigned int sym);
2678 : : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym);
2679 : : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym);
2680 : : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym);
2681 : : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym);
2682 : : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym);
2683 : : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym);
2684 : : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement);
2685 : : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import);
2686 : : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link);
2687 : : extern "C" bool SymbolTable_IsModLink (unsigned int sym);
2688 : : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link);
2689 : : extern "C" bool SymbolTable_IsDefLink (unsigned int sym);
2690 : : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym);
2691 : : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value);
2692 : : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value);
2693 : : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym);
2694 : : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode);
2695 : : extern "C" void SymbolTable_VarInitState (unsigned int sym);
2696 : : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode);
2697 : : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
2698 : : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
2699 : : extern "C" void SymbolTable_PrintInitialized (unsigned int sym);
2700 : : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym);
2701 : : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym);
2702 : : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure);
2703 : : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value);
2704 : : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym);
2705 : : extern "C" void M2Base_InitBase (m2linemap_location_t location, unsigned int *sym);
2706 : : extern "C" void M2Base_GetBaseTypeMinMax (unsigned int type, unsigned int *min, unsigned int *max);
2707 : : extern "C" bool M2Base_IsPseudoBaseFunction (unsigned int Sym);
2708 : : extern "C" bool M2Base_IsPseudoBaseProcedure (unsigned int Sym);
2709 : : extern "C" bool M2Base_IsNeededAtRunTime (unsigned int tok, unsigned int sym);
2710 : : extern "C" bool M2Base_IsBaseType (unsigned int Sym);
2711 : : extern "C" bool M2Base_IsOrdinalType (unsigned int Sym);
2712 : : extern "C" bool M2Base_IsOrd (unsigned int sym);
2713 : : extern "C" bool M2Base_IsTrunc (unsigned int sym);
2714 : : extern "C" bool M2Base_IsFloat (unsigned int sym);
2715 : : extern "C" bool M2Base_IsInt (unsigned int sym);
2716 : : extern "C" bool M2Base_AssignmentRequiresWarning (unsigned int t1, unsigned int t2);
2717 : : extern "C" bool M2Base_IsAssignmentCompatible (unsigned int t1, unsigned int t2);
2718 : : extern "C" bool M2Base_IsExpressionCompatible (unsigned int t1, unsigned int t2);
2719 : : extern "C" bool M2Base_IsParameterCompatible (unsigned int t1, unsigned int t2);
2720 : : extern "C" bool M2Base_IsComparisonCompatible (unsigned int t1, unsigned int t2);
2721 : : extern "C" bool M2Base_IsValidParameter (unsigned int formal, unsigned int actual);
2722 : : extern "C" void M2Base_CheckExpressionCompatible (unsigned int tok, unsigned int left, unsigned int right);
2723 : : extern "C" void M2Base_CheckAssignmentCompatible (unsigned int tok, unsigned int left, unsigned int right);
2724 : : extern "C" void M2Base_CheckParameterCompatible (unsigned int tok, unsigned int t1, unsigned int t2);
2725 : : extern "C" bool M2Base_CannotCheckTypeInPass3 (unsigned int e);
2726 : : extern "C" unsigned int M2Base_MixTypes (unsigned int t1, unsigned int t2, unsigned int NearTok);
2727 : : extern "C" unsigned int M2Base_NegateType (unsigned int type);
2728 : : extern "C" bool M2Base_IsMathType (unsigned int type);
2729 : : extern "C" bool M2Base_IsRealType (unsigned int t);
2730 : : extern "C" bool M2Base_IsComplexType (unsigned int sym);
2731 : : extern "C" unsigned int M2Base_ComplexToScalar (unsigned int sym);
2732 : : extern "C" unsigned int M2Base_ScalarToComplex (unsigned int sym);
2733 : : extern "C" unsigned int M2Base_GetCmplxReturnType (unsigned int t1, unsigned int t2);
2734 : : extern "C" void M2System_InitSystem (void);
2735 : : extern "C" void M2System_GetSystemTypeMinMax (unsigned int type, unsigned int *min, unsigned int *max);
2736 : : extern "C" bool M2System_IsPseudoSystemFunction (unsigned int sym);
2737 : : extern "C" bool M2System_IsPseudoSystemProcedure (unsigned int sym);
2738 : : extern "C" bool M2System_IsPseudoSystemFunctionConstExpression (unsigned int sym);
2739 : : extern "C" bool M2System_IsSystemType (unsigned int sym);
2740 : : extern "C" unsigned int M2System_IntegerN (unsigned int bitlength);
2741 : : extern "C" unsigned int M2System_CardinalN (unsigned int bitlength);
2742 : : extern "C" unsigned int M2System_WordN (unsigned int bitlength);
2743 : : extern "C" unsigned int M2System_SetN (unsigned int bitlength);
2744 : : extern "C" unsigned int M2System_RealN (unsigned int bitlength);
2745 : : extern "C" unsigned int M2System_ComplexN (unsigned int bitlength);
2746 : : extern "C" bool M2System_IsIntegerN (unsigned int sym);
2747 : : extern "C" bool M2System_IsCardinalN (unsigned int sym);
2748 : : extern "C" bool M2System_IsWordN (unsigned int sym);
2749 : : extern "C" bool M2System_IsSetN (unsigned int sym);
2750 : : extern "C" bool M2System_IsRealN (unsigned int sym);
2751 : : extern "C" bool M2System_IsComplexN (unsigned int sym);
2752 : : extern "C" bool M2System_IsGenericSystemType (unsigned int sym);
2753 : : extern "C" bool M2System_IsSameSizePervasiveType (unsigned int a, unsigned int b);
2754 : : extern "C" bool M2System_IsSameSize (unsigned int a, unsigned int b);
2755 : : extern "C" void M2Bitset_MakeBitset (void);
2756 : : extern "C" void M2Bitset_GetBitsetMinMax (unsigned int *min, unsigned int *max);
2757 : : extern "C" m2tree_Tree SymbolConversion_Mod2Gcc (unsigned int sym);
2758 : : extern "C" unsigned int SymbolConversion_Gcc2Mod (m2tree_Tree tree);
2759 : : extern "C" void SymbolConversion_AddModGcc (unsigned int sym, m2tree_Tree gcc);
2760 : : extern "C" void SymbolConversion_RemoveMod2Gcc (unsigned int sym);
2761 : : extern "C" bool SymbolConversion_GccKnowsAbout (unsigned int sym);
2762 : : extern "C" void SymbolConversion_AddTemporaryKnown (unsigned int sym);
2763 : : extern "C" void SymbolConversion_RemoveTemporaryKnown (unsigned int sym);
2764 : : extern "C" void SymbolConversion_Poison (unsigned int sym);
2765 : : extern "C" void M2GenGCC_ConvertQuadsToTree (unsigned int Start, unsigned int End);
2766 : : extern "C" bool M2GenGCC_ResolveConstantExpressions (M2GCCDeclare_WalkAction p, unsigned int start, unsigned int end);
2767 : : extern "C" m2tree_Tree M2GenGCC_GetHighFromUnbounded (m2linemap_location_t location, unsigned int dim, unsigned int param);
2768 : : extern "C" m2tree_Tree M2GenGCC_StringToChar (m2tree_Tree t, unsigned int type, unsigned int str);
2769 : : extern "C" m2tree_Tree M2GenGCC_LValueToGenericPtr (m2linemap_location_t location, unsigned int sym);
2770 : : extern "C" m2tree_Tree M2GenGCC_ZConstToTypedConst (m2tree_Tree t, unsigned int op1, unsigned int op2);
2771 : : extern "C" bool M2GenGCC_PrepareCopyString (unsigned int tokenno, m2tree_Tree *length, m2tree_Tree *srcTree, unsigned int src, unsigned int destStrType);
2772 : :
2773 : : /*
2774 : : InitScopeBlock -
2775 : : */
2776 : :
2777 : : extern "C" M2Scope_ScopeBlock M2Scope_InitScopeBlock (unsigned int scope);
2778 : :
2779 : : /*
2780 : : KillScopeBlock - destroys the ScopeBlock sb and assign sb to NIL.
2781 : : */
2782 : :
2783 : : extern "C" void M2Scope_KillScopeBlock (M2Scope_ScopeBlock *sb);
2784 : :
2785 : : /*
2786 : : ForeachScopeBlockDo2 - calls a procedure p for each block of contigeous quadruples
2787 : : defining an outer scope sb.
2788 : : */
2789 : :
2790 : : extern "C" void M2Scope_ForeachScopeBlockDo2 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure2 p);
2791 : :
2792 : : /*
2793 : : ForeachScopeBlockDo3 - calls a procedure p for each block of contigeous quadruples
2794 : : defining an outer scope sb.
2795 : : */
2796 : :
2797 : : extern "C" void M2Scope_ForeachScopeBlockDo3 (M2Scope_ScopeBlock sb, M2Scope_ScopeProcedure3 p);
2798 : :
2799 : : /*
2800 : : InitValue - initializes and returns a memory cell.
2801 : : */
2802 : :
2803 : : extern "C" M2ALU_PtrToValue M2ALU_InitValue (void);
2804 : :
2805 : : /*
2806 : : IsValueTypeNone - returns TRUE if the value on the top stack has no value.
2807 : : */
2808 : :
2809 : : extern "C" bool M2ALU_IsValueTypeNone (void);
2810 : :
2811 : : /*
2812 : : IsValueTypeInteger - returns TRUE if the value on the top stack is an integer.
2813 : : */
2814 : :
2815 : : extern "C" bool M2ALU_IsValueTypeInteger (void);
2816 : :
2817 : : /*
2818 : : IsValueTypeReal - returns TRUE if the value on the top stack is a real.
2819 : : */
2820 : :
2821 : : extern "C" bool M2ALU_IsValueTypeReal (void);
2822 : :
2823 : : /*
2824 : : IsValueTypeComplex - returns TRUE if the value on the top stack is a complex.
2825 : : */
2826 : :
2827 : : extern "C" bool M2ALU_IsValueTypeComplex (void);
2828 : :
2829 : : /*
2830 : : IsValueTypeSet - returns TRUE if the value on the top stack is a set.
2831 : : */
2832 : :
2833 : : extern "C" bool M2ALU_IsValueTypeSet (void);
2834 : :
2835 : : /*
2836 : : IsValueTypeConstructor - returns TRUE if the value on the top
2837 : : stack is a constructor.
2838 : : */
2839 : :
2840 : : extern "C" bool M2ALU_IsValueTypeConstructor (void);
2841 : :
2842 : : /*
2843 : : IsValueTypeArray - returns TRUE if the value on the top stack is
2844 : : an array.
2845 : : */
2846 : :
2847 : : extern "C" bool M2ALU_IsValueTypeArray (void);
2848 : :
2849 : : /*
2850 : : IsValueTypeRecord - returns TRUE if the value on the top stack is
2851 : : a record.
2852 : : */
2853 : :
2854 : : extern "C" bool M2ALU_IsValueTypeRecord (void);
2855 : :
2856 : : /*
2857 : : GetSetValueType - returns the set type on top of the ALU stack.
2858 : : */
2859 : :
2860 : : extern "C" unsigned int M2ALU_GetSetValueType (void);
2861 : :
2862 : : /*
2863 : : PushIntegerTree - pushes a gcc tree value onto the ALU stack.
2864 : : */
2865 : :
2866 : : extern "C" void M2ALU_PushIntegerTree (m2tree_Tree t);
2867 : :
2868 : : /*
2869 : : PopIntegerTree - pops a gcc tree value from the ALU stack.
2870 : : */
2871 : :
2872 : : extern "C" m2tree_Tree M2ALU_PopIntegerTree (void);
2873 : :
2874 : : /*
2875 : : PushRealTree - pushes a gcc tree value onto the ALU stack.
2876 : : */
2877 : :
2878 : : extern "C" void M2ALU_PushRealTree (m2tree_Tree t);
2879 : :
2880 : : /*
2881 : : PopRealTree - pops a gcc tree value from the ALU stack.
2882 : : */
2883 : :
2884 : : extern "C" m2tree_Tree M2ALU_PopRealTree (void);
2885 : :
2886 : : /*
2887 : : PushComplexTree - pushes a gcc tree value onto the ALU stack.
2888 : : */
2889 : :
2890 : : extern "C" void M2ALU_PushComplexTree (m2tree_Tree t);
2891 : :
2892 : : /*
2893 : : PopComplexTree - pops a gcc tree value from the ALU stack.
2894 : : */
2895 : :
2896 : : extern "C" m2tree_Tree M2ALU_PopComplexTree (void);
2897 : :
2898 : : /*
2899 : : PushSetTree - pushes a gcc tree onto the ALU stack.
2900 : : The tree, t, is expected to contain a
2901 : : word value. It is converted into a set
2902 : : type (sym). Bit 0 maps onto MIN(sym).
2903 : : */
2904 : :
2905 : : extern "C" void M2ALU_PushSetTree (unsigned int tokenno, m2tree_Tree t, unsigned int sym);
2906 : :
2907 : : /*
2908 : : PopSetTree - pops a gcc tree from the ALU stack.
2909 : : */
2910 : :
2911 : : extern "C" m2tree_Tree M2ALU_PopSetTree (unsigned int tokenno);
2912 : :
2913 : : /*
2914 : : PopConstructorTree - returns a tree containing the compound literal.
2915 : : */
2916 : :
2917 : : extern "C" m2tree_Tree M2ALU_PopConstructorTree (unsigned int tokenno);
2918 : :
2919 : : /*
2920 : : PushFrom - pushes a copy of the contents of, v, onto stack.
2921 : : */
2922 : :
2923 : : extern "C" void M2ALU_PushFrom (M2ALU_PtrToValue v);
2924 : :
2925 : : /*
2926 : : PopInto - pops the top element from the stack and places it into, v.
2927 : : */
2928 : :
2929 : : extern "C" void M2ALU_PopInto (M2ALU_PtrToValue v);
2930 : :
2931 : : /*
2932 : : PushCard - pushes a cardinal onto the stack.
2933 : : */
2934 : :
2935 : : extern "C" void M2ALU_PushCard (unsigned int c);
2936 : :
2937 : : /*
2938 : : PushInt - pushes an integer onto the stack.
2939 : : */
2940 : :
2941 : : extern "C" void M2ALU_PushInt (int i);
2942 : :
2943 : : /*
2944 : : PushChar - pushes a char onto the stack.
2945 : : */
2946 : :
2947 : : extern "C" void M2ALU_PushChar (char c);
2948 : :
2949 : : /*
2950 : : PopChar - pops a char from the stack.
2951 : : */
2952 : :
2953 : : extern "C" char M2ALU_PopChar (unsigned int tokenno);
2954 : :
2955 : : /*
2956 : : PushString - pushes the numerical value of the string onto the stack.
2957 : : */
2958 : :
2959 : : extern "C" void M2ALU_PushString (unsigned int tokenno, NameKey_Name s, bool issueError);
2960 : :
2961 : : /*
2962 : : CoerseLongRealToCard - performs a coersion between a REAL to a CARDINAL
2963 : : */
2964 : :
2965 : : extern "C" void M2ALU_CoerseLongRealToCard (void);
2966 : :
2967 : : /*
2968 : : ConvertRealToInt - converts a REAL into an INTEGER
2969 : : */
2970 : :
2971 : : extern "C" void M2ALU_ConvertRealToInt (void);
2972 : :
2973 : : /*
2974 : : ConvertToInt - converts the value into an INTEGER. This should be used
2975 : : if we are computing the number of elements in a char set to
2976 : : avoid an overflow.
2977 : : */
2978 : :
2979 : : extern "C" void M2ALU_ConvertToInt (void);
2980 : :
2981 : : /*
2982 : : ConvertToType - converts the top of stack to type, t.
2983 : : */
2984 : :
2985 : : extern "C" void M2ALU_ConvertToType (unsigned int t);
2986 : :
2987 : : /*
2988 : : IsSolved - returns true if the memory cell indicated by v
2989 : : has a known value.
2990 : : */
2991 : :
2992 : : extern "C" bool M2ALU_IsSolved (M2ALU_PtrToValue v);
2993 : :
2994 : : /*
2995 : : PutConstructorSolved - records that this constructor is solved.
2996 : : */
2997 : :
2998 : : extern "C" void M2ALU_PutConstructorSolved (unsigned int sym);
2999 : :
3000 : : /*
3001 : : EvaluateValue - attempts to evaluate the symbol, sym, value.
3002 : : */
3003 : :
3004 : : extern "C" void M2ALU_EvaluateValue (unsigned int sym);
3005 : :
3006 : : /*
3007 : : TryEvaluateValue - attempts to evaluate the symbol, sym, value.
3008 : : */
3009 : :
3010 : : extern "C" void M2ALU_TryEvaluateValue (unsigned int sym);
3011 : : extern "C" void M2ALU_Addn (void);
3012 : :
3013 : : /*
3014 : : Sub - subtracts the top two elements on the stack.
3015 : :
3016 : : The Stack:
3017 : :
3018 : : Entry Exit
3019 : :
3020 : : Ptr ->
3021 : : +------------+
3022 : : | Op1 | <- Ptr
3023 : : |------------| +------------+
3024 : : | Op2 | | Op2 - Op1 |
3025 : : |------------| |------------|
3026 : : */
3027 : :
3028 : : extern "C" void M2ALU_Sub (void);
3029 : : extern "C" void M2ALU_Multn (void);
3030 : :
3031 : : /*
3032 : : DivFloor - divides the top two elements on the stack.
3033 : :
3034 : : The Stack:
3035 : :
3036 : : Entry Exit
3037 : :
3038 : : Ptr ->
3039 : : +------------+
3040 : : | Op1 | <- Ptr
3041 : : |------------| +--------------+
3042 : : | Op2 | | Op2 DIV Op1 |
3043 : : |------------| |--------------|
3044 : : */
3045 : :
3046 : : extern "C" void M2ALU_DivFloor (void);
3047 : :
3048 : : /*
3049 : : ModFloor - modulus of the top two elements on the stack.
3050 : :
3051 : : The Stack:
3052 : :
3053 : : Entry Exit
3054 : :
3055 : : Ptr ->
3056 : : +------------+
3057 : : | Op1 | <- Ptr
3058 : : |------------| +--------------+
3059 : : | Op2 | | Op2 MOD Op1 |
3060 : : |------------| |--------------|
3061 : : */
3062 : :
3063 : : extern "C" void M2ALU_ModFloor (void);
3064 : :
3065 : : /*
3066 : : DivTrunc - divides the top two elements on the stack.
3067 : :
3068 : : The Stack:
3069 : :
3070 : : Entry Exit
3071 : :
3072 : : Ptr ->
3073 : : +------------+
3074 : : | Op1 | <- Ptr
3075 : : |------------| +--------------+
3076 : : | Op2 | | Op2 DIV Op1 |
3077 : : |------------| |--------------|
3078 : : */
3079 : :
3080 : : extern "C" void M2ALU_DivTrunc (void);
3081 : :
3082 : : /*
3083 : : ModTrunc - modulus of the top two elements on the stack.
3084 : :
3085 : : The Stack:
3086 : :
3087 : : Entry Exit
3088 : :
3089 : : Ptr ->
3090 : : +------------+
3091 : : | Op1 | <- Ptr
3092 : : |------------| +--------------+
3093 : : | Op2 | | Op2 MOD Op1 |
3094 : : |------------| |--------------|
3095 : : */
3096 : :
3097 : : extern "C" void M2ALU_ModTrunc (void);
3098 : :
3099 : : /*
3100 : : Equ - returns true if the top two elements on the stack
3101 : : are identical.
3102 : :
3103 : : The Stack:
3104 : :
3105 : : Entry Exit
3106 : :
3107 : : Ptr ->
3108 : : +------------+
3109 : : | Op1 |
3110 : : |------------|
3111 : : | Op2 |
3112 : : |------------| Empty
3113 : :
3114 : : RETURN( Op2 = Op1 )
3115 : : */
3116 : :
3117 : : extern "C" bool M2ALU_Equ (unsigned int tokenno);
3118 : :
3119 : : /*
3120 : : NotEqu - returns true if the top two elements on the stack
3121 : : are not identical.
3122 : :
3123 : : The Stack:
3124 : :
3125 : : Entry Exit
3126 : :
3127 : : Ptr ->
3128 : : +------------+
3129 : : | Op1 |
3130 : : |------------|
3131 : : | Op2 |
3132 : : |------------| Empty
3133 : :
3134 : : RETURN( Op2 # Op1 )
3135 : : */
3136 : :
3137 : : extern "C" bool M2ALU_NotEqu (unsigned int tokenno);
3138 : :
3139 : : /*
3140 : : Less - returns true if Op2 < Op1
3141 : :
3142 : : The Stack:
3143 : :
3144 : : Entry Exit
3145 : :
3146 : : Ptr ->
3147 : : +------------+
3148 : : | Op1 |
3149 : : |------------|
3150 : : | Op2 |
3151 : : |------------| Empty
3152 : :
3153 : : RETURN( Op2 < Op1 )
3154 : : */
3155 : :
3156 : : extern "C" bool M2ALU_Less (unsigned int tokenno);
3157 : :
3158 : : /*
3159 : : Gre - returns true if Op2 > Op1
3160 : :
3161 : : The Stack:
3162 : :
3163 : : Entry Exit
3164 : :
3165 : : Ptr ->
3166 : : +------------+
3167 : : | Op1 |
3168 : : |------------|
3169 : : | Op2 |
3170 : : |------------| Empty
3171 : :
3172 : : RETURN( Op2 > Op1 )
3173 : : */
3174 : :
3175 : : extern "C" bool M2ALU_Gre (unsigned int tokenno);
3176 : :
3177 : : /*
3178 : : LessEqu - returns true if Op2<Op1
3179 : :
3180 : : The Stack:
3181 : :
3182 : : Entry Exit
3183 : :
3184 : : Ptr ->
3185 : : +------------+
3186 : : | Op1 |
3187 : : |------------|
3188 : : | Op2 |
3189 : : |------------| Empty
3190 : :
3191 : : RETURN( Op2 <= Op1 )
3192 : : */
3193 : :
3194 : : extern "C" bool M2ALU_LessEqu (unsigned int tokenno);
3195 : :
3196 : : /*
3197 : : GreEqu - returns true if Op2 >= Op1
3198 : : are not identical.
3199 : :
3200 : : The Stack:
3201 : :
3202 : : Entry Exit
3203 : :
3204 : : Ptr ->
3205 : : +------------+
3206 : : | Op1 |
3207 : : |------------|
3208 : : | Op2 |
3209 : : |------------| Empty
3210 : :
3211 : : RETURN( Op2 >= Op1 )
3212 : : */
3213 : :
3214 : : extern "C" bool M2ALU_GreEqu (unsigned int tokenno);
3215 : :
3216 : : /*
3217 : : IsNulSet - returns TRUE if the top element is the nul set constant, {}.
3218 : : */
3219 : :
3220 : : extern "C" bool M2ALU_IsNulSet (void);
3221 : :
3222 : : /*
3223 : : IsGenericNulSet - returns TRUE if the top element is the generic nul set constant, {}.
3224 : : */
3225 : :
3226 : : extern "C" bool M2ALU_IsGenericNulSet (void);
3227 : :
3228 : : /*
3229 : : PushNulSet - pushes an empty set {} onto the ALU stack. The subrange type used
3230 : : to construct the set is defined by, constructorType.
3231 : : If this is NulSym then
3232 : : the set is generic and compatible with all sets.
3233 : :
3234 : : The Stack:
3235 : :
3236 : : Entry Exit
3237 : :
3238 : : <- Ptr
3239 : : +------------+
3240 : : | {} |
3241 : : Ptr -> |------------|
3242 : :
3243 : : */
3244 : :
3245 : : extern "C" void M2ALU_PushNulSet (unsigned int settype);
3246 : :
3247 : : /*
3248 : : AddBitRange - adds the range op1..op2 to the underlying set.
3249 : :
3250 : : Ptr ->
3251 : : <- Ptr
3252 : : +------------+ +------------+
3253 : : | Set | | Set |
3254 : : |------------| |------------|
3255 : :
3256 : : */
3257 : :
3258 : : extern "C" void M2ALU_AddBitRange (unsigned int tokenno, unsigned int op1, unsigned int op2);
3259 : :
3260 : : /*
3261 : : AddBit - adds the bit op1 to the underlying set. INCL(Set, op1)
3262 : :
3263 : : Ptr ->
3264 : : <- Ptr
3265 : : +------------+ +------------+
3266 : : | Set | | Set |
3267 : : |------------| |------------|
3268 : : */
3269 : :
3270 : : extern "C" void M2ALU_AddBit (unsigned int tokenno, unsigned int op1);
3271 : :
3272 : : /*
3273 : : SubBit - removes a bit op1 from the underlying set. EXCL(Set, Op1)
3274 : :
3275 : : Ptr ->
3276 : : <- Ptr
3277 : : +------------+ +------------+
3278 : : | Set | | Set |
3279 : : |------------| |------------|
3280 : : */
3281 : :
3282 : : extern "C" void M2ALU_SubBit (unsigned int tokenno, unsigned int op1);
3283 : :
3284 : : /*
3285 : : SetIn - returns true if Op2 IN Op1
3286 : :
3287 : : The Stack:
3288 : :
3289 : : Entry Exit
3290 : :
3291 : : Ptr ->
3292 : : +------------+
3293 : : | Set |
3294 : : |------------| Empty
3295 : :
3296 : : RETURN( Op1 IN Set )
3297 : : */
3298 : :
3299 : : extern "C" bool M2ALU_SetIn (unsigned int tokenno, unsigned int Op1);
3300 : :
3301 : : /*
3302 : : SetOr - performs an inclusive OR of the top two elements on the stack.
3303 : :
3304 : : The Stack:
3305 : :
3306 : : Entry Exit
3307 : :
3308 : : Ptr ->
3309 : : +------------+
3310 : : | Set1 | <- Ptr
3311 : : |------------| +------------+
3312 : : | Set2 | | Set1 + Set2|
3313 : : |------------| |------------|
3314 : :
3315 : : */
3316 : :
3317 : : extern "C" void M2ALU_SetOr (unsigned int tokenno);
3318 : :
3319 : : /*
3320 : : SetAnd - performs a set AND the top two elements on the stack.
3321 : :
3322 : : The Stack:
3323 : :
3324 : : Entry Exit
3325 : :
3326 : : Ptr ->
3327 : : +------------+
3328 : : | Op1 | <- Ptr
3329 : : |------------| +------------+
3330 : : | Op2 | | Op2 * Op1 |
3331 : : |------------| |------------|
3332 : : */
3333 : :
3334 : : extern "C" void M2ALU_SetAnd (unsigned int tokenno);
3335 : :
3336 : : /*
3337 : : SetDifference - performs a set difference of the top two elements on the stack.
3338 : : For each member in the set
3339 : : if member in Op2 and not member in Op1
3340 : :
3341 : : The Stack:
3342 : :
3343 : : Entry Exit
3344 : :
3345 : : Ptr ->
3346 : : +------------+
3347 : : | Op1 | <- Ptr
3348 : : |------------| +-------------------+
3349 : : | Op2 | | Op2 and (not Op1) |
3350 : : |------------| |-------------------|
3351 : : */
3352 : :
3353 : : extern "C" void M2ALU_SetDifference (unsigned int tokenno);
3354 : :
3355 : : /*
3356 : : SetSymmetricDifference - performs a set difference of the top two elements on the stack.
3357 : :
3358 : : The Stack:
3359 : :
3360 : : Entry Exit
3361 : :
3362 : : Ptr ->
3363 : : +------------+
3364 : : | Op1 | <- Ptr
3365 : : |------------| +-------------+
3366 : : | Op2 | | Op2 xor Op1 |
3367 : : |------------| |-------------|
3368 : : */
3369 : :
3370 : : extern "C" void M2ALU_SetSymmetricDifference (unsigned int tokenno);
3371 : :
3372 : : /*
3373 : : SetNegate - negates the top set on the stack.
3374 : :
3375 : : Ptr -> <- Ptr
3376 : : +-----------+ +------------+
3377 : : | Set | | Set |
3378 : : |-----------| |------------|
3379 : : */
3380 : :
3381 : : extern "C" void M2ALU_SetNegate (unsigned int tokenno);
3382 : :
3383 : : /*
3384 : : SetShift - if op1 is positive
3385 : : then
3386 : : result := op2 << op1
3387 : : else
3388 : : result := op2 >> op1
3389 : : fi
3390 : :
3391 : :
3392 : : The Stack:
3393 : :
3394 : : Entry Exit
3395 : :
3396 : : Ptr ->
3397 : : +------------+
3398 : : | Op1 | <- Ptr
3399 : : |------------| +------------+
3400 : : | Op2 | | result |
3401 : : |------------| |------------|
3402 : :
3403 : : */
3404 : :
3405 : : extern "C" void M2ALU_SetShift (unsigned int tokenno);
3406 : :
3407 : : /*
3408 : : SetRotate - if op1 is positive
3409 : : then
3410 : : result := ROTATERIGHT(op2, op1)
3411 : : else
3412 : : result := ROTATELEFT(op2, op1)
3413 : : fi
3414 : :
3415 : :
3416 : : The Stack:
3417 : :
3418 : : Entry Exit
3419 : :
3420 : : Ptr ->
3421 : : +------------+
3422 : : | Op1 | <- Ptr
3423 : : |------------| +------------+
3424 : : | Op2 | | result |
3425 : : |------------| |------------|
3426 : : */
3427 : :
3428 : : extern "C" void M2ALU_SetRotate (unsigned int tokenno);
3429 : :
3430 : : /*
3431 : : GetValue - returns and pops the value from the top of stack.
3432 : : */
3433 : :
3434 : : extern "C" M2ALU_PtrToValue M2ALU_GetValue (unsigned int tokenno);
3435 : :
3436 : : /*
3437 : : GetRange - returns TRUE if range number, n, exists in the value, v.
3438 : : A non empty set is defined by having 1..N ranges
3439 : : */
3440 : :
3441 : : extern "C" bool M2ALU_GetRange (M2ALU_PtrToValue v, unsigned int n, unsigned int *low, unsigned int *high);
3442 : :
3443 : : /*
3444 : : ConstructSetConstant - builds a struct of integers which represents the
3445 : : set const as defined by, v.
3446 : : */
3447 : :
3448 : : extern "C" m2tree_Tree M2ALU_ConstructSetConstant (unsigned int tokenno, M2ALU_PtrToValue v);
3449 : :
3450 : : /*
3451 : : BuildRange - returns a integer sized constant which represents the
3452 : : value {e1..e2}.
3453 : : */
3454 : :
3455 : : extern "C" m2tree_Tree M2ALU_BuildRange (unsigned int tokenno, m2tree_Tree e1, m2tree_Tree e2);
3456 : :
3457 : : /*
3458 : : IsConstructorDependants - return TRUE if all q(dependants) of,
3459 : : sym, return TRUE.
3460 : : */
3461 : :
3462 : : extern "C" bool M2ALU_IsConstructorDependants (unsigned int sym, M2GCCDeclare_IsAction q);
3463 : :
3464 : : /*
3465 : : WalkConstructorDependants - walk the constructor, sym, calling
3466 : : p for each dependant.
3467 : : */
3468 : :
3469 : : extern "C" void M2ALU_WalkConstructorDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
3470 : :
3471 : : /*
3472 : : IsValueAndTreeKnown - returns TRUE if the value is known and the gcc tree
3473 : : is defined.
3474 : :
3475 : : The Stack:
3476 : :
3477 : : Entry Exit
3478 : :
3479 : : Ptr ->
3480 : : +------------+
3481 : : | Op1 | <- Ptr
3482 : : |------------| +------------+
3483 : : */
3484 : :
3485 : : extern "C" bool M2ALU_IsValueAndTreeKnown (void);
3486 : :
3487 : : /*
3488 : : CheckOrResetOverflow - tests to see whether the tree, t, has caused
3489 : : an overflow error and if so it generates an
3490 : : error message.
3491 : : */
3492 : :
3493 : : extern "C" void M2ALU_CheckOrResetOverflow (unsigned int tokenno, m2tree_Tree t, bool check);
3494 : :
3495 : : /*
3496 : : AddElements - adds the elements, el BY, n, to the array constant.
3497 : :
3498 : : Ptr ->
3499 : : <- Ptr
3500 : : +------------+ +------------+
3501 : : | Array | | Array |
3502 : : |------------| |------------|
3503 : :
3504 : : */
3505 : :
3506 : : extern "C" void M2ALU_AddElements (unsigned int tokenno, unsigned int el, unsigned int n);
3507 : :
3508 : : /*
3509 : : AddField - adds the field op1 to the underlying constructor.
3510 : :
3511 : : Ptr ->
3512 : : <- Ptr
3513 : : +------------+ +------------+
3514 : : | const | | const |
3515 : : |------------| |------------|
3516 : :
3517 : : */
3518 : :
3519 : : extern "C" void M2ALU_AddField (unsigned int tokenno, unsigned int op1);
3520 : :
3521 : : /*
3522 : : PushEmptyConstructor - pushes an empty constructor {} onto the ALU stack.
3523 : : This is expected to be filled in by subsequent
3524 : : calls to AddElements, AddRange or AddField.
3525 : :
3526 : : The Stack:
3527 : :
3528 : : Entry Exit
3529 : :
3530 : : <- Ptr
3531 : : +------------+
3532 : : | {} |
3533 : : Ptr -> |------------|
3534 : :
3535 : : */
3536 : :
3537 : : extern "C" void M2ALU_PushEmptyConstructor (unsigned int constype);
3538 : :
3539 : : /*
3540 : : PushEmptyArray - pushes an empty array {} onto the ALU stack.
3541 : : This is expected to be filled in by subsequent
3542 : : calls to AddElements.
3543 : :
3544 : : The Stack:
3545 : :
3546 : : Entry Exit
3547 : :
3548 : : <- Ptr
3549 : : +------------+
3550 : : | {} |
3551 : : Ptr -> |------------|
3552 : :
3553 : : */
3554 : :
3555 : : extern "C" void M2ALU_PushEmptyArray (unsigned int arraytype);
3556 : :
3557 : : /*
3558 : : PushEmptyRecord - pushes an empty record {} onto the ALU stack.
3559 : : This is expected to be filled in by subsequent
3560 : : calls to AddField.
3561 : :
3562 : : The Stack:
3563 : :
3564 : : Entry Exit
3565 : :
3566 : : <- Ptr
3567 : : +------------+
3568 : : | {} |
3569 : : Ptr -> |------------|
3570 : :
3571 : : */
3572 : :
3573 : : extern "C" void M2ALU_PushEmptyRecord (unsigned int recordtype);
3574 : :
3575 : : /*
3576 : : ChangeToConstructor - change the top of stack value to a constructor, type.
3577 : : (Constructor, Set, Array or Record).
3578 : : */
3579 : :
3580 : : extern "C" void M2ALU_ChangeToConstructor (unsigned int tokenno, unsigned int constype);
3581 : :
3582 : : /*
3583 : : IsValueConst - returns true if the memory cell indicated by v
3584 : : is only defined by constants. For example
3585 : : no variables are used in the constructor.
3586 : : */
3587 : :
3588 : : extern "C" bool M2ALU_IsValueConst (M2ALU_PtrToValue v);
3589 : :
3590 : : /*
3591 : : PushTypeOfTree - pushes tree, gcc, to the stack and records the
3592 : : front end type.
3593 : : */
3594 : :
3595 : : extern "C" void M2ALU_PushTypeOfTree (unsigned int sym, m2tree_Tree gcc);
3596 : : extern "C" void m2linemap_StartFile (void * filename, unsigned int linebegin);
3597 : : extern "C" void m2linemap_EndFile (void);
3598 : : extern "C" void m2linemap_StartLine (unsigned int linenumber, unsigned int linesize);
3599 : : extern "C" m2linemap_location_t m2linemap_GetLocationColumn (unsigned int column);
3600 : : extern "C" m2linemap_location_t m2linemap_GetLocationRange (unsigned int start, unsigned int end);
3601 : : extern "C" m2linemap_location_t m2linemap_GetLocationBinary (m2linemap_location_t caret, m2linemap_location_t left, m2linemap_location_t right);
3602 : : extern "C" m2linemap_location_t m2linemap_UnknownLocation (void);
3603 : : extern "C" m2linemap_location_t m2linemap_BuiltinsLocation (void);
3604 : : extern "C" int m2linemap_GetLineNoFromLocation (m2linemap_location_t location);
3605 : : extern "C" int m2linemap_GetColumnNoFromLocation (m2linemap_location_t location);
3606 : : extern "C" void * m2linemap_GetFilenameFromLocation (m2linemap_location_t location);
3607 : : extern "C" void m2linemap_ErrorAt (m2linemap_location_t location, void * message);
3608 : : extern "C" void m2linemap_ErrorAtf (m2linemap_location_t location, void * message);
3609 : : extern "C" void m2linemap_WarningAtf (m2linemap_location_t location, void * message);
3610 : : extern "C" void m2linemap_NoteAtf (m2linemap_location_t location, void * message);
3611 : : extern "C" void m2linemap_internal_error (void * message);
3612 : : extern "C" void m2decl_BuildModuleCtor (m2tree_Tree moduleCtor);
3613 : : extern "C" m2tree_Tree m2decl_DeclareModuleCtor (m2tree_Tree decl);
3614 : : extern "C" m2tree_Tree m2decl_DeclareM2linkForcedModuleInitOrder (m2linemap_location_t location, void * RuntimeOverride);
3615 : : extern "C" m2tree_Tree m2decl_DeclareM2linkStaticInitialization (m2linemap_location_t location, int ScaffoldStatic);
3616 : : extern "C" m2tree_Tree m2decl_BuildPtrToTypeString (m2linemap_location_t location, void * string, m2tree_Tree type);
3617 : : extern "C" int m2decl_GetBitsPerBitset (void);
3618 : : extern "C" int m2decl_GetBitsPerInt (void);
3619 : : extern "C" int m2decl_GetBitsPerUnit (void);
3620 : : extern "C" int m2decl_GetBitsPerWord (void);
3621 : : extern "C" m2tree_Tree m2decl_BuildIntegerConstant (int value);
3622 : : extern "C" m2tree_Tree m2decl_BuildStringConstantType (int length, void * string, m2tree_Tree type);
3623 : : extern "C" m2tree_Tree m2decl_DeclareKnownVariable (m2linemap_location_t location, void * name, m2tree_Tree type, bool exported, bool imported, bool istemporary, bool isglobal, m2tree_Tree scope, m2tree_Tree initial);
3624 : : extern "C" m2tree_Tree m2decl_DeclareKnownConstant (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree value);
3625 : : extern "C" m2tree_Tree m2decl_BuildParameterDeclaration (m2linemap_location_t location, void * name, m2tree_Tree type, bool isreference);
3626 : : extern "C" void m2decl_BuildStartFunctionDeclaration (bool uses_varargs);
3627 : : extern "C" m2tree_Tree m2decl_BuildEndFunctionDeclaration (m2linemap_location_t location_begin, m2linemap_location_t location_end, void * name, m2tree_Tree returntype, bool isexternal, bool isnested, bool ispublic, bool isnoreturn);
3628 : : extern "C" void m2decl_RememberVariables (m2tree_Tree l);
3629 : : extern "C" m2tree_Tree m2decl_BuildConstLiteralNumber (m2linemap_location_t location, void * str, unsigned int base, bool issueError);
3630 : : extern "C" m2tree_Tree m2decl_BuildStringConstant (void * string, int length);
3631 : : extern "C" m2tree_Tree m2decl_BuildCStringConstant (void * string, int length);
3632 : : extern "C" m2tree_Tree m2decl_GetDeclContext (m2tree_Tree t);
3633 : : extern "C" bool m2type_ValueInTypeRange (m2tree_Tree type, m2tree_Tree value);
3634 : : extern "C" bool m2type_ValueOutOfTypeRange (m2tree_Tree type, m2tree_Tree value);
3635 : : extern "C" bool m2type_ExceedsTypeRange (m2tree_Tree type, m2tree_Tree low, m2tree_Tree high);
3636 : : extern "C" bool m2type_WithinTypeRange (m2tree_Tree type, m2tree_Tree low, m2tree_Tree high);
3637 : : extern "C" m2tree_Tree m2type_BuildSubrangeType (m2linemap_location_t location, void * name, m2tree_Tree type, m2tree_Tree lowval, m2tree_Tree highval);
3638 : : extern "C" m2tree_Tree m2type_BuildCharConstant (m2linemap_location_t location, void * string);
3639 : : extern "C" m2tree_Tree m2type_BuildCharConstantChar (m2linemap_location_t location, char ch);
3640 : : extern "C" void m2type_BuildArrayConstructorElement (void * p, m2tree_Tree value, m2tree_Tree indice);
3641 : : extern "C" m2tree_Tree m2type_BuildEndArrayConstructor (m2type_Constructor p);
3642 : : extern "C" m2type_Constructor m2type_BuildStartArrayConstructor (m2tree_Tree type);
3643 : : extern "C" void m2type_BuildRecordConstructorElement (m2type_Constructor p, m2tree_Tree value);
3644 : : extern "C" m2tree_Tree m2type_BuildEndRecordConstructor (m2type_Constructor p);
3645 : : extern "C" m2type_Constructor m2type_BuildStartRecordConstructor (m2tree_Tree type);
3646 : : extern "C" m2tree_Tree m2type_BuildEndSetConstructor (m2type_Constructor p);
3647 : : extern "C" void m2type_BuildSetConstructorElement (m2type_Constructor p, m2tree_Tree value);
3648 : : extern "C" m2type_Constructor m2type_BuildStartSetConstructor (m2tree_Tree type);
3649 : : extern "C" m2tree_Tree m2type_BuildSetType (m2linemap_location_t location, void * name, m2tree_Tree type, m2tree_Tree lowval, m2tree_Tree highval, bool ispacked);
3650 : : extern "C" m2tree_Tree m2type_BuildConstPointerType (m2tree_Tree totype);
3651 : : extern "C" m2tree_Tree m2type_BuildPointerType (m2tree_Tree totype);
3652 : : extern "C" m2tree_Tree m2type_BuildEnumerator (m2linemap_location_t location, void * name, m2tree_Tree value, m2tree_Tree *enumvalues);
3653 : : extern "C" m2tree_Tree m2type_BuildEndEnumeration (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree enumvalues);
3654 : : extern "C" m2tree_Tree m2type_BuildStartEnumeration (m2linemap_location_t location, void * name, bool ispacked);
3655 : : extern "C" void m2type_BuildTypeDeclaration (m2linemap_location_t location, m2tree_Tree type);
3656 : : extern "C" m2tree_Tree m2type_GetMaxFrom (m2linemap_location_t location, m2tree_Tree type);
3657 : : extern "C" m2tree_Tree m2type_GetMinFrom (m2linemap_location_t location, m2tree_Tree type);
3658 : : extern "C" m2tree_Tree m2type_GetDefaultType (m2linemap_location_t location, void * name, m2tree_Tree type);
3659 : : extern "C" m2tree_Tree m2type_BuildEndType (m2linemap_location_t location, m2tree_Tree type);
3660 : : extern "C" m2tree_Tree m2type_BuildStartType (m2linemap_location_t location, void * name, m2tree_Tree type);
3661 : : extern "C" void m2type_InitSystemTypes (m2linemap_location_t location, int loc);
3662 : : extern "C" void m2type_InitBaseTypes (m2linemap_location_t location);
3663 : : extern "C" m2tree_Tree m2type_BuildVariableArrayAndDeclare (m2linemap_location_t location, m2tree_Tree elementtype, m2tree_Tree high, void * name, m2tree_Tree scope);
3664 : : extern "C" void m2type_InitFunctionTypeParameters (void);
3665 : : extern "C" m2tree_Tree m2type_BuildProcTypeParameterDeclaration (m2linemap_location_t location, m2tree_Tree type, bool isreference);
3666 : : extern "C" m2tree_Tree m2type_BuildStartFunctionType (m2linemap_location_t location, void * name);
3667 : : extern "C" m2tree_Tree m2type_BuildEndFunctionType (m2tree_Tree func, m2tree_Tree type, bool usesvarags);
3668 : : extern "C" m2tree_Tree m2type_GetTreeType (m2tree_Tree type);
3669 : : extern "C" m2tree_Tree m2type_DeclareKnownType (m2linemap_location_t location, void * name, m2tree_Tree type);
3670 : : extern "C" m2tree_Tree m2type_GetM2ZType (void);
3671 : : extern "C" m2tree_Tree m2type_GetM2RType (void);
3672 : : extern "C" m2tree_Tree m2type_BuildSetTypeFromSubrange (m2linemap_location_t location, void * name, m2tree_Tree subrangeType, m2tree_Tree lowval, m2tree_Tree highval, bool ispacked);
3673 : : extern "C" m2tree_Tree m2type_BuildSmallestTypeRange (m2linemap_location_t location, m2tree_Tree low, m2tree_Tree high);
3674 : : extern "C" m2tree_Tree m2type_GetBooleanType (void);
3675 : : extern "C" m2tree_Tree m2type_GetBooleanFalse (void);
3676 : : extern "C" m2tree_Tree m2type_GetBooleanTrue (void);
3677 : : extern "C" m2tree_Tree m2type_GetPackedBooleanType (void);
3678 : : extern "C" m2tree_Tree m2type_GetCharType (void);
3679 : : extern "C" m2tree_Tree m2type_GetByteType (void);
3680 : : extern "C" m2tree_Tree m2type_GetVoidType (void);
3681 : : extern "C" m2tree_Tree m2type_GetBitnumType (void);
3682 : : extern "C" m2tree_Tree m2type_GetRealType (void);
3683 : : extern "C" m2tree_Tree m2type_GetLongRealType (void);
3684 : : extern "C" m2tree_Tree m2type_GetShortRealType (void);
3685 : : extern "C" m2tree_Tree m2type_GetLongIntType (void);
3686 : : extern "C" m2tree_Tree m2type_GetPointerType (void);
3687 : : extern "C" m2tree_Tree m2type_GetCardinalType (void);
3688 : : extern "C" m2tree_Tree m2type_GetIntegerType (void);
3689 : : extern "C" m2tree_Tree m2type_GetWordType (void);
3690 : : extern "C" m2tree_Tree m2type_GetM2CardinalType (void);
3691 : : extern "C" m2tree_Tree m2type_GetBitsetType (void);
3692 : : extern "C" m2tree_Tree m2type_GetM2CType (void);
3693 : : extern "C" m2tree_Tree m2type_GetProcType (void);
3694 : : extern "C" m2tree_Tree m2type_GetM2ComplexType (void);
3695 : : extern "C" m2tree_Tree m2type_GetM2LongComplexType (void);
3696 : : extern "C" m2tree_Tree m2type_GetM2ShortComplexType (void);
3697 : : extern "C" m2tree_Tree m2type_GetM2Complex128 (void);
3698 : : extern "C" m2tree_Tree m2type_GetM2Complex96 (void);
3699 : : extern "C" m2tree_Tree m2type_GetM2Complex64 (void);
3700 : : extern "C" m2tree_Tree m2type_GetM2Complex32 (void);
3701 : : extern "C" m2tree_Tree m2type_GetM2Real128 (void);
3702 : : extern "C" m2tree_Tree m2type_GetM2Real96 (void);
3703 : : extern "C" m2tree_Tree m2type_GetM2Real64 (void);
3704 : : extern "C" m2tree_Tree m2type_GetM2Real32 (void);
3705 : : extern "C" m2tree_Tree m2type_GetM2Bitset32 (void);
3706 : : extern "C" m2tree_Tree m2type_GetM2Bitset16 (void);
3707 : : extern "C" m2tree_Tree m2type_GetM2Bitset8 (void);
3708 : : extern "C" m2tree_Tree m2type_GetM2Word64 (void);
3709 : : extern "C" m2tree_Tree m2type_GetM2Word32 (void);
3710 : : extern "C" m2tree_Tree m2type_GetM2Word16 (void);
3711 : : extern "C" m2tree_Tree m2type_GetM2Cardinal64 (void);
3712 : : extern "C" m2tree_Tree m2type_GetM2Cardinal32 (void);
3713 : : extern "C" m2tree_Tree m2type_GetM2Cardinal16 (void);
3714 : : extern "C" m2tree_Tree m2type_GetM2Cardinal8 (void);
3715 : : extern "C" m2tree_Tree m2type_GetM2Integer64 (void);
3716 : : extern "C" m2tree_Tree m2type_GetM2Integer32 (void);
3717 : : extern "C" m2tree_Tree m2type_GetM2Integer16 (void);
3718 : : extern "C" m2tree_Tree m2type_GetM2Integer8 (void);
3719 : : extern "C" m2tree_Tree m2type_GetISOLocType (void);
3720 : : extern "C" m2tree_Tree m2type_GetISOByteType (void);
3721 : : extern "C" m2tree_Tree m2type_GetISOWordType (void);
3722 : : extern "C" m2tree_Tree m2type_GetShortCardType (void);
3723 : : extern "C" m2tree_Tree m2type_GetM2ShortCardType (void);
3724 : : extern "C" m2tree_Tree m2type_GetShortIntType (void);
3725 : : extern "C" m2tree_Tree m2type_GetM2ShortIntType (void);
3726 : : extern "C" m2tree_Tree m2type_GetM2LongCardType (void);
3727 : : extern "C" m2tree_Tree m2type_GetM2LongIntType (void);
3728 : : extern "C" m2tree_Tree m2type_GetM2LongRealType (void);
3729 : : extern "C" m2tree_Tree m2type_GetM2RealType (void);
3730 : : extern "C" m2tree_Tree m2type_GetM2ShortRealType (void);
3731 : : extern "C" m2tree_Tree m2type_GetM2IntegerType (void);
3732 : : extern "C" m2tree_Tree m2type_GetM2CharType (void);
3733 : : extern "C" m2tree_Tree m2type_GetCSizeTType (void);
3734 : : extern "C" m2tree_Tree m2type_GetCSSizeTType (void);
3735 : : extern "C" m2tree_Tree m2type_BuildArrayStringConstructor (m2linemap_location_t location, m2tree_Tree arrayType, m2tree_Tree str, m2tree_Tree length);
3736 : : extern "C" m2tree_Tree m2type_RealToTree (void * name);
3737 : : extern "C" m2tree_Tree m2type_BuildStartRecord (m2linemap_location_t location, void * name);
3738 : : extern "C" m2tree_Tree m2type_BuildStartUnion (m2linemap_location_t location, void * name);
3739 : : extern "C" m2tree_Tree m2type_BuildStartVarient (m2linemap_location_t location, void * name);
3740 : : extern "C" m2tree_Tree m2type_BuildEndVarient (m2linemap_location_t location, m2tree_Tree varientField, m2tree_Tree varientList, bool isPacked);
3741 : : extern "C" m2tree_Tree m2type_BuildStartFieldVarient (m2linemap_location_t location, void * name);
3742 : : extern "C" m2tree_Tree m2type_BuildEndFieldVarient (m2linemap_location_t location, m2tree_Tree varientField, m2tree_Tree varientList, bool isPacked);
3743 : : extern "C" m2tree_Tree m2type_BuildStartFieldRecord (m2linemap_location_t location, void * name, m2tree_Tree type);
3744 : : extern "C" m2tree_Tree m2type_BuildFieldRecord (m2linemap_location_t location, void * name, m2tree_Tree type);
3745 : : extern "C" m2tree_Tree m2type_ChainOn (m2tree_Tree t1, m2tree_Tree t2);
3746 : : extern "C" m2tree_Tree m2type_ChainOnParamValue (m2tree_Tree list, m2tree_Tree name, m2tree_Tree str, m2tree_Tree value);
3747 : : extern "C" m2tree_Tree m2type_AddStringToTreeList (m2tree_Tree list, m2tree_Tree string);
3748 : : extern "C" m2tree_Tree m2type_BuildEndRecord (m2linemap_location_t location, m2tree_Tree record, m2tree_Tree fieldlist, bool isPacked);
3749 : : extern "C" m2tree_Tree m2type_SetAlignment (m2tree_Tree node, m2tree_Tree align);
3750 : : extern "C" m2tree_Tree m2type_SetDeclPacked (m2tree_Tree node);
3751 : : extern "C" m2tree_Tree m2type_SetTypePacked (m2tree_Tree node);
3752 : : extern "C" m2tree_Tree m2type_SetRecordFieldOffset (m2tree_Tree field, m2tree_Tree byteOffset, m2tree_Tree bitOffset, m2tree_Tree fieldtype, m2tree_Tree nbits);
3753 : : extern "C" m2tree_Tree m2type_BuildPackedFieldRecord (m2linemap_location_t location, void * name, m2tree_Tree fieldtype);
3754 : : extern "C" m2tree_Tree m2type_BuildNumberOfArrayElements (m2linemap_location_t location, m2tree_Tree arrayType);
3755 : : extern "C" void m2type_AddStatement (m2linemap_location_t location, m2tree_Tree t);
3756 : : extern "C" void m2type_MarkFunctionReferenced (m2tree_Tree f);
3757 : : extern "C" void m2type_GarbageCollect (void);
3758 : : extern "C" m2tree_Tree m2type_BuildArrayIndexType (m2tree_Tree low, m2tree_Tree high);
3759 : : extern "C" m2tree_Tree m2type_GetArrayNoOfElements (m2linemap_location_t location, m2tree_Tree arraytype);
3760 : : extern "C" m2tree_Tree m2type_BuildEndArrayType (m2tree_Tree arraytype, m2tree_Tree elementtype, m2tree_Tree indextype, int type);
3761 : : extern "C" void m2type_PutArrayType (m2tree_Tree array, m2tree_Tree type);
3762 : : extern "C" m2tree_Tree m2type_BuildStartArrayType (m2tree_Tree index_type, m2tree_Tree elt_type, int type);
3763 : : extern "C" bool m2type_IsAddress (m2tree_Tree type);
3764 : : extern "C" bool m2type_SameRealType (m2tree_Tree a, m2tree_Tree b);
3765 : : extern "C" m2tree_Tree m2convert_ToWord (m2linemap_location_t location, m2tree_Tree expr);
3766 : : extern "C" m2tree_Tree m2convert_ToCardinal (m2linemap_location_t location, m2tree_Tree expr);
3767 : : extern "C" m2tree_Tree m2convert_ToInteger (m2linemap_location_t location, m2tree_Tree expr);
3768 : : extern "C" m2tree_Tree m2convert_ToBitset (m2linemap_location_t location, m2tree_Tree expr);
3769 : : extern "C" m2tree_Tree m2convert_ConvertToPtr (m2tree_Tree p);
3770 : : extern "C" m2tree_Tree m2convert_BuildConvert (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree value, bool checkOverflow);
3771 : : extern "C" m2tree_Tree m2convert_ConvertConstantAndCheck (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree expr);
3772 : : extern "C" m2tree_Tree m2convert_ConvertString (m2tree_Tree type, m2tree_Tree expr);
3773 : : extern "C" m2tree_Tree m2convert_GenericToType (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree expr);
3774 : : extern "C" void m2expr_init (m2linemap_location_t location);
3775 : : extern "C" void * m2expr_CSTIntToString (m2tree_Tree t);
3776 : : extern "C" char m2expr_CSTIntToChar (m2tree_Tree t);
3777 : : extern "C" bool m2expr_CheckConstStrZtypeRange (m2linemap_location_t location, void * str, unsigned int base);
3778 : : extern "C" int m2expr_CompareTrees (m2tree_Tree e1, m2tree_Tree e2);
3779 : : extern "C" m2tree_Tree m2expr_GetPointerOne (m2linemap_location_t location);
3780 : : extern "C" m2tree_Tree m2expr_GetPointerZero (m2linemap_location_t location);
3781 : : extern "C" m2tree_Tree m2expr_GetWordOne (m2linemap_location_t location);
3782 : : extern "C" m2tree_Tree m2expr_GetWordZero (m2linemap_location_t location);
3783 : : extern "C" m2tree_Tree m2expr_GetIntegerOne (m2linemap_location_t location);
3784 : : extern "C" m2tree_Tree m2expr_GetIntegerZero (m2linemap_location_t location);
3785 : : extern "C" m2tree_Tree m2expr_GetCardinalOne (m2linemap_location_t location);
3786 : : extern "C" m2tree_Tree m2expr_GetCardinalZero (m2linemap_location_t location);
3787 : : extern "C" m2tree_Tree m2expr_GetSizeOfInBits (m2tree_Tree type);
3788 : : extern "C" m2tree_Tree m2expr_GetSizeOf (m2linemap_location_t location, m2tree_Tree type);
3789 : : extern "C" void m2expr_BuildLogicalRotate (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree op3, m2tree_Tree nBits, bool needconvert);
3790 : : extern "C" m2tree_Tree m2expr_BuildLRRn (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree nBits, bool needconvert);
3791 : : extern "C" m2tree_Tree m2expr_BuildLRLn (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree nBits, bool needconvert);
3792 : : extern "C" m2tree_Tree m2expr_BuildMask (m2linemap_location_t location, m2tree_Tree nBits, bool needconvert);
3793 : : extern "C" m2tree_Tree m2expr_BuildMult (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3794 : : extern "C" m2tree_Tree m2expr_BuildMultCheck (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree lowest, m2tree_Tree min, m2tree_Tree max);
3795 : : extern "C" m2tree_Tree m2expr_BuildLRR (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3796 : : extern "C" m2tree_Tree m2expr_BuildLRL (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3797 : : extern "C" void m2expr_BuildLogicalShift (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree op3, m2tree_Tree nBits, bool needconvert);
3798 : : extern "C" m2tree_Tree m2expr_BuildLSR (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3799 : : extern "C" m2tree_Tree m2expr_BuildLSL (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3800 : : extern "C" m2tree_Tree m2expr_BuildDivM2 (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needsconvert);
3801 : : extern "C" m2tree_Tree m2expr_BuildDivM2Check (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree lowest, m2tree_Tree min, m2tree_Tree max);
3802 : : extern "C" m2tree_Tree m2expr_BuildModM2 (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needsconvert);
3803 : : extern "C" m2tree_Tree m2expr_BuildModM2Check (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree lowest, m2tree_Tree min, m2tree_Tree max);
3804 : : extern "C" m2tree_Tree m2expr_BuildModFloor (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3805 : : extern "C" m2tree_Tree m2expr_BuildDivCeil (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3806 : : extern "C" m2tree_Tree m2expr_BuildModCeil (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3807 : : extern "C" m2tree_Tree m2expr_BuildDivFloor (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3808 : : extern "C" m2tree_Tree m2expr_BuildModTrunc (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3809 : : extern "C" m2tree_Tree m2expr_BuildDivTrunc (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3810 : : extern "C" m2tree_Tree m2expr_BuildDivTruncCheck (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree lowest, m2tree_Tree min, m2tree_Tree max);
3811 : : extern "C" m2tree_Tree m2expr_BuildRDiv (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3812 : : extern "C" m2tree_Tree m2expr_BuildSubCheck (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree lowest, m2tree_Tree min, m2tree_Tree max);
3813 : : extern "C" m2tree_Tree m2expr_BuildAddCheck (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree lowest, m2tree_Tree min, m2tree_Tree max);
3814 : : extern "C" m2tree_Tree m2expr_BuildSub (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3815 : : extern "C" m2tree_Tree m2expr_BuildAdd (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3816 : : extern "C" m2tree_Tree m2expr_FoldAndStrip (m2tree_Tree t);
3817 : : extern "C" unsigned int m2expr_StringLength (m2tree_Tree string);
3818 : : extern "C" bool m2expr_TreeOverflow (m2tree_Tree t);
3819 : : extern "C" m2tree_Tree m2expr_RemoveOverflow (m2tree_Tree t);
3820 : : extern "C" m2tree_Tree m2expr_BuildCoerce (m2linemap_location_t location, m2tree_Tree des, m2tree_Tree type, m2tree_Tree expr);
3821 : : extern "C" m2tree_Tree m2expr_BuildTrunc (m2tree_Tree op1);
3822 : : extern "C" m2tree_Tree m2expr_BuildNegate (m2linemap_location_t location, m2tree_Tree op1, bool needconvert);
3823 : : extern "C" m2tree_Tree m2expr_BuildNegateCheck (m2linemap_location_t location, m2tree_Tree arg, m2tree_Tree lowest, m2tree_Tree min, m2tree_Tree max);
3824 : : extern "C" m2tree_Tree m2expr_BuildSetNegate (m2linemap_location_t location, m2tree_Tree op1, bool needconvert);
3825 : : extern "C" m2tree_Tree m2expr_BuildTBitSize (m2linemap_location_t location, m2tree_Tree type);
3826 : : extern "C" m2tree_Tree m2expr_BuildSize (m2linemap_location_t location, m2tree_Tree op1, bool needconvert);
3827 : : extern "C" m2tree_Tree m2expr_BuildAddr (m2linemap_location_t location, m2tree_Tree op1, bool needconvert);
3828 : : extern "C" m2tree_Tree m2expr_BuildOffset1 (m2linemap_location_t location, m2tree_Tree field, bool needconvert);
3829 : : extern "C" m2tree_Tree m2expr_BuildOffset (m2linemap_location_t location, m2tree_Tree record, m2tree_Tree field, bool needconvert);
3830 : : extern "C" m2tree_Tree m2expr_BuildLogicalOrAddress (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3831 : : extern "C" m2tree_Tree m2expr_BuildLogicalOr (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3832 : : extern "C" m2tree_Tree m2expr_BuildLogicalAnd (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3833 : : extern "C" m2tree_Tree m2expr_BuildSymmetricDifference (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3834 : : extern "C" m2tree_Tree m2expr_BuildLogicalDifference (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2, bool needconvert);
3835 : : extern "C" m2tree_Tree m2expr_BuildLessThan (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3836 : : extern "C" m2tree_Tree m2expr_BuildGreaterThan (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3837 : : extern "C" m2tree_Tree m2expr_BuildLessThanOrEqual (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3838 : : extern "C" m2tree_Tree m2expr_BuildGreaterThanOrEqual (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3839 : : extern "C" m2tree_Tree m2expr_BuildEqualTo (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3840 : : extern "C" m2tree_Tree m2expr_BuildNotEqualTo (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3841 : : extern "C" m2tree_Tree m2expr_BuildIsSuperset (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3842 : : extern "C" m2tree_Tree m2expr_BuildIsNotSuperset (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3843 : : extern "C" m2tree_Tree m2expr_BuildIsSubset (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3844 : : extern "C" m2tree_Tree m2expr_BuildIsNotSubset (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3845 : : extern "C" void m2expr_BuildIfConstInVar (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree varset, m2tree_Tree constel, bool is_lvalue, int fieldno, void * label);
3846 : : extern "C" void m2expr_BuildIfNotConstInVar (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree varset, m2tree_Tree constel, bool is_lvalue, int fieldno, void * label);
3847 : : extern "C" void m2expr_BuildIfVarInVar (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree varset, m2tree_Tree varel, bool is_lvalue, m2tree_Tree low, m2tree_Tree high, void * label);
3848 : : extern "C" void m2expr_BuildIfNotVarInVar (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree varset, m2tree_Tree varel, bool is_lvalue, m2tree_Tree low, m2tree_Tree high, void * label);
3849 : : extern "C" void m2expr_BuildForeachWordInSetDoIfExpr (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree op1, m2tree_Tree op2, bool is_op1lvalue, bool is_op2lvalue, bool is_op1const, bool isop2const, m2expr_BuildExprProcedure_C expr, void * label);
3850 : : extern "C" void m2expr_BuildIfInRangeGoto (m2linemap_location_t location, m2tree_Tree var, m2tree_Tree low, m2tree_Tree high, void * label);
3851 : : extern "C" void m2expr_BuildIfNotInRangeGoto (m2linemap_location_t location, m2tree_Tree var, m2tree_Tree low, m2tree_Tree high, void * label);
3852 : : extern "C" m2tree_Tree m2expr_BuildArray (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree array, m2tree_Tree index, m2tree_Tree lowIndice);
3853 : : extern "C" m2tree_Tree m2expr_BuildComponentRef (m2linemap_location_t location, m2tree_Tree record, m2tree_Tree field);
3854 : : extern "C" m2tree_Tree m2expr_BuildIndirect (m2linemap_location_t location, m2tree_Tree target, m2tree_Tree type);
3855 : : extern "C" bool m2expr_IsTrue (m2tree_Tree t);
3856 : : extern "C" bool m2expr_IsFalse (m2tree_Tree t);
3857 : : extern "C" int m2expr_GetCstInteger (m2tree_Tree cst);
3858 : : extern "C" bool m2expr_AreConstantsEqual (m2tree_Tree e1, m2tree_Tree e2);
3859 : : extern "C" bool m2expr_AreRealOrComplexConstantsEqual (m2tree_Tree e1, m2tree_Tree e2);
3860 : : extern "C" int m2expr_DetermineSign (m2tree_Tree e);
3861 : : extern "C" m2tree_Tree m2expr_BuildCap (m2linemap_location_t location, m2tree_Tree t);
3862 : : extern "C" m2tree_Tree m2expr_BuildAbs (m2linemap_location_t location, m2tree_Tree t);
3863 : : extern "C" m2tree_Tree m2expr_BuildRe (m2tree_Tree op1);
3864 : : extern "C" m2tree_Tree m2expr_BuildIm (m2tree_Tree op1);
3865 : : extern "C" m2tree_Tree m2expr_BuildCmplx (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree real, m2tree_Tree imag);
3866 : : extern "C" void m2expr_BuildBinaryForeachWordDo (m2linemap_location_t location, m2tree_Tree type, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree op3, m2expr_BuildBinProcedure_C binop, bool is_op1lvalue, bool is_op2lvalue, bool is_op3lvalue, bool is_op1_const, bool is_op2_const, bool is_op3_const);
3867 : : extern "C" void m2expr_BuildBinarySetDo (m2linemap_location_t location, m2tree_Tree settype, m2tree_Tree op1, m2tree_Tree op2, m2tree_Tree op3, m2expr_BuildSetProcedure_C binop, bool is_op1lvalue, bool is_op2lvalue, bool is_op3lvalue, m2tree_Tree nBits, m2tree_Tree unbounded, m2tree_Tree varproc, m2tree_Tree leftproc, m2tree_Tree rightproc);
3868 : : extern "C" void m2expr_ConstantExpressionWarning (m2tree_Tree value);
3869 : : extern "C" m2tree_Tree m2expr_BuildAddAddress (m2linemap_location_t location, m2tree_Tree op1, m2tree_Tree op2);
3870 : : extern "C" m2tree_Tree m2expr_calcNbits (m2linemap_location_t location, m2tree_Tree min, m2tree_Tree max);
3871 : : extern "C" bool m2expr_OverflowZType (m2linemap_location_t location, void * str, unsigned int base, bool issueError);
3872 : : extern "C" m2tree_Tree m2expr_BuildCondIfExpression (m2tree_Tree condition, m2tree_Tree type, m2tree_Tree left, m2tree_Tree right);
3873 : : extern "C" void m2block_init (void);
3874 : : extern "C" bool m2block_toplevel (void);
3875 : : extern "C" m2tree_Tree m2block_global_constant (m2tree_Tree t);
3876 : : extern "C" m2tree_Tree m2block_RememberInitModuleFunction (m2tree_Tree t);
3877 : : extern "C" m2tree_Tree m2block_DumpGlobalConstants (void);
3878 : : extern "C" m2tree_Tree m2block_RememberConstant (m2tree_Tree t);
3879 : : extern "C" m2tree_Tree m2block_RememberType (m2tree_Tree t);
3880 : : extern "C" m2tree_Tree m2block_pushDecl (m2tree_Tree decl);
3881 : : extern "C" void m2block_popGlobalScope (void);
3882 : : extern "C" void m2block_pushGlobalScope (void);
3883 : : extern "C" m2tree_Tree m2block_popFunctionScope (void);
3884 : : extern "C" void m2block_pushFunctionScope (m2tree_Tree fndecl);
3885 : : extern "C" void m2block_finishFunctionCode (m2tree_Tree fndecl);
3886 : : extern "C" void m2block_finishFunctionDecl (m2linemap_location_t location, m2tree_Tree fndecl);
3887 : : extern "C" m2tree_Tree m2block_getLabel (m2linemap_location_t location, void * name);
3888 : : extern "C" m2tree_Tree m2block_GetErrorNode (void);
3889 : : extern "C" void m2block_includeDecl (m2tree_Tree decl);
3890 : : extern "C" m2tree_Tree m2block_GetGlobals (void);
3891 : : extern "C" m2tree_Tree m2block_GetGlobalContext (void);
3892 : : extern "C" m2tree_Tree m2block_begin_statement_list (void);
3893 : : extern "C" m2tree_Tree m2block_push_statement_list (m2tree_Tree t);
3894 : : extern "C" m2tree_Tree m2block_pop_statement_list (void);
3895 : : extern "C" void m2block_addStmtNote (m2linemap_location_t location);
3896 : : extern "C" void m2block_removeStmtNote (void);
3897 : : extern "C" ssize_t libc_write (int d, void * buf, size_t nbytes);
3898 : : extern "C" ssize_t libc_read (int d, void * buf, size_t nbytes);
3899 : : extern "C" int libc_system (void * a);
3900 : : extern "C" void libc_abort (void) __attribute__ ((noreturn));
3901 : : extern "C" void * libc_malloc (size_t size);
3902 : : extern "C" void libc_free (void * ptr);
3903 : : extern "C" void * libc_realloc (void * ptr, size_t size);
3904 : : extern "C" int libc_isatty (int fd);
3905 : : extern "C" void libc_exit (int r) __attribute__ ((noreturn));
3906 : : extern "C" void * libc_getenv (void * s);
3907 : : extern "C" int libc_putenv (void * s);
3908 : : extern "C" int libc_getpid (void);
3909 : : extern "C" int libc_dup (int d);
3910 : : extern "C" int libc_close (int d);
3911 : : extern "C" int libc_open (void * filename, int oflag, ...);
3912 : : extern "C" int libc_creat (void * filename, unsigned int mode);
3913 : : extern "C" ssize_t libc_lseek (int fd, ssize_t offset, int whence);
3914 : : extern "C" void libc_perror (const char *string_, unsigned int _string_high);
3915 : : extern "C" int libc_readv (int fd, void * v, int n);
3916 : : extern "C" int libc_writev (int fd, void * v, int n);
3917 : : extern "C" void * libc_getcwd (void * buf, size_t size);
3918 : : extern "C" int libc_chown (void * filename, int uid, int gid);
3919 : : extern "C" size_t libc_strlen (void * a);
3920 : : extern "C" void * libc_strcpy (void * dest, void * src);
3921 : : extern "C" void * libc_strncpy (void * dest, void * src, unsigned int n);
3922 : : extern "C" int libc_unlink (void * file);
3923 : : extern "C" void * libc_memcpy (void * dest, void * src, size_t size);
3924 : : extern "C" void * libc_memset (void * s, int c, size_t size);
3925 : : extern "C" void * libc_memmove (void * dest, void * src, size_t size);
3926 : : extern "C" int libc_printf (const char *format_, unsigned int _format_high, ...);
3927 : : extern "C" int libc_snprintf (void * dest, size_t size, const char *format_, unsigned int _format_high, ...);
3928 : : extern "C" int libc_setenv (void * name, void * value, int overwrite);
3929 : : extern "C" void libc_srand (int seed);
3930 : : extern "C" int libc_rand (void);
3931 : : extern "C" libc_time_t libc_time (void * a);
3932 : : extern "C" void * libc_localtime (libc_time_t *t);
3933 : : extern "C" int libc_ftime (libc_timeb *t);
3934 : : extern "C" int libc_shutdown (int s, int how);
3935 : : extern "C" int libc_rename (void * oldpath, void * newpath);
3936 : : extern "C" int libc_setjmp (void * env);
3937 : : extern "C" void libc_longjmp (void * env, int val);
3938 : : extern "C" int libc_atexit (libc_exitP_C proc);
3939 : : extern "C" void * libc_ttyname (int filedes);
3940 : : extern "C" unsigned int libc_sleep (unsigned int seconds);
3941 : : extern "C" int libc_execv (void * pathname, void * argv);
3942 : : extern "C" void StrLib_StrConCat (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high, char *c, unsigned int _c_high);
3943 : : extern "C" bool StrLib_StrLess (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
3944 : : extern "C" bool StrLib_StrEqual (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
3945 : : extern "C" unsigned int StrLib_StrLen (const char *a_, unsigned int _a_high);
3946 : : extern "C" void StrLib_StrCopy (const char *src_, unsigned int _src_high, char *dest, unsigned int _dest_high);
3947 : : extern "C" bool StrLib_IsSubString (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
3948 : : extern "C" void StrLib_StrRemoveWhitePrefix (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high);
3949 : : extern "C" void Assertion_Assert (bool Condition);
3950 : : extern "C" bool M2Reserved_IsReserved (NameKey_Name n, M2Reserved_toktype *tok);
3951 : : extern "C" NameKey_Name M2Reserved_tokToTok (M2Reserved_toktype t);
3952 : : extern "C" void M2Emit_EmitError (bool error, bool note, unsigned int token, DynamicStrings_String message);
3953 : : extern "C" void M2Emit_InternalError (const char *message_, unsigned int _message_high);
3954 : : extern "C" m2linemap_location_t M2Emit_UnknownLocation (void);
3955 : : extern "C" m2linemap_location_t M2Emit_BuiltinsLocation (void);
3956 : :
3957 : : /*
3958 : : InitStackAddress - creates and returns a new stack.
3959 : : */
3960 : :
3961 : : extern "C" M2StackAddress_StackOfAddress M2StackAddress_InitStackAddress (void);
3962 : :
3963 : : /*
3964 : : KillStackAddress - destroys a stack, returning NIL.
3965 : : */
3966 : :
3967 : : extern "C" M2StackAddress_StackOfAddress M2StackAddress_KillStackAddress (M2StackAddress_StackOfAddress s);
3968 : :
3969 : : /*
3970 : : PushAddress - pushes a word, w, onto, s.
3971 : : */
3972 : :
3973 : : extern "C" void M2StackAddress_PushAddress (M2StackAddress_StackOfAddress s, void * w);
3974 : :
3975 : : /*
3976 : : PopAddress - pops an element from stack, s.
3977 : : */
3978 : :
3979 : : extern "C" void * M2StackAddress_PopAddress (M2StackAddress_StackOfAddress s);
3980 : :
3981 : : /*
3982 : : IsEmptyAddress - returns TRUE if stack, s, is empty.
3983 : : */
3984 : :
3985 : : extern "C" bool M2StackAddress_IsEmptyAddress (M2StackAddress_StackOfAddress s);
3986 : :
3987 : : /*
3988 : : PeepAddress - returns the element at, n, items below in the stack.
3989 : : Top of stack can be seen via Peep(s, 1)
3990 : : */
3991 : :
3992 : : extern "C" void * M2StackAddress_PeepAddress (M2StackAddress_StackOfAddress s, unsigned int n);
3993 : :
3994 : : /*
3995 : : ReduceAddress - reduce the stack by n elements.
3996 : : */
3997 : :
3998 : : extern "C" void M2StackAddress_ReduceAddress (M2StackAddress_StackOfAddress s, unsigned int n);
3999 : :
4000 : : /*
4001 : : NoOfItemsInStackAddress - returns the number of items held in the stack, s.
4002 : : */
4003 : :
4004 : : extern "C" unsigned int M2StackAddress_NoOfItemsInStackAddress (M2StackAddress_StackOfAddress s);
4005 : : extern "C" void M2Pass_SetPassToNoPass (void);
4006 : : extern "C" void M2Pass_SetPassToPass0 (void);
4007 : : extern "C" void M2Pass_SetPassToPass1 (void);
4008 : : extern "C" void M2Pass_SetPassToPass2 (void);
4009 : : extern "C" void M2Pass_SetPassToPassC (void);
4010 : : extern "C" void M2Pass_SetPassToPass3 (void);
4011 : : extern "C" void M2Pass_SetPassToPassHidden (void);
4012 : : extern "C" void M2Pass_SetPassToCodeGeneration (void);
4013 : : extern "C" void M2Pass_SetPassToErrorPass (void);
4014 : : extern "C" bool M2Pass_IsNoPass (void);
4015 : : extern "C" bool M2Pass_IsPass0 (void);
4016 : : extern "C" bool M2Pass_IsPass1 (void);
4017 : : extern "C" bool M2Pass_IsPass2 (void);
4018 : : extern "C" bool M2Pass_IsPassC (void);
4019 : : extern "C" bool M2Pass_IsPass3 (void);
4020 : : extern "C" bool M2Pass_IsPassHidden (void);
4021 : : extern "C" bool M2Pass_IsPassCodeGeneration (void);
4022 : : extern "C" bool M2Pass_IsErrorPass (void);
4023 : : extern "C" bool M2ColorString_SetEnableColor (bool b);
4024 : : extern "C" DynamicStrings_String M2ColorString_quoteOpen (DynamicStrings_String s);
4025 : : extern "C" DynamicStrings_String M2ColorString_quoteClose (DynamicStrings_String s);
4026 : : extern "C" DynamicStrings_String M2ColorString_endColor (DynamicStrings_String s);
4027 : : extern "C" DynamicStrings_String M2ColorString_quoteColor (DynamicStrings_String s);
4028 : : extern "C" DynamicStrings_String M2ColorString_errorColor (DynamicStrings_String s);
4029 : : extern "C" DynamicStrings_String M2ColorString_warningColor (DynamicStrings_String s);
4030 : : extern "C" DynamicStrings_String M2ColorString_noteColor (DynamicStrings_String s);
4031 : : extern "C" DynamicStrings_String M2ColorString_locusColor (DynamicStrings_String s);
4032 : : extern "C" DynamicStrings_String M2ColorString_insertColor (DynamicStrings_String s);
4033 : : extern "C" DynamicStrings_String M2ColorString_deleteColor (DynamicStrings_String s);
4034 : : extern "C" DynamicStrings_String M2ColorString_filenameColor (DynamicStrings_String s);
4035 : : extern "C" DynamicStrings_String M2ColorString_typeColor (DynamicStrings_String s);
4036 : : extern "C" DynamicStrings_String M2ColorString_range1Color (DynamicStrings_String s);
4037 : : extern "C" DynamicStrings_String M2ColorString_range2Color (DynamicStrings_String s);
4038 : : extern "C" void SymbolKey_InitTree (SymbolKey_SymbolTree *t);
4039 : : extern "C" void SymbolKey_KillTree (SymbolKey_SymbolTree *t);
4040 : :
4041 : : /*
4042 : : ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey.
4043 : : */
4044 : :
4045 : : extern "C" unsigned int SymbolKey_GetSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey);
4046 : :
4047 : : /*
4048 : : ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey.
4049 : : */
4050 : :
4051 : : extern "C" void SymbolKey_PutSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey, unsigned int SymKey);
4052 : :
4053 : : /*
4054 : : DelSymKey - deletes an entry in the binary tree.
4055 : :
4056 : : NB in order for this to work we must ensure that the InitTree sets
4057 : : both Left and Right to NIL.
4058 : : */
4059 : :
4060 : : extern "C" void SymbolKey_DelSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey);
4061 : :
4062 : : /*
4063 : : IsEmptyTree - returns true if SymbolTree, t, is empty.
4064 : : */
4065 : :
4066 : : extern "C" bool SymbolKey_IsEmptyTree (SymbolKey_SymbolTree t);
4067 : :
4068 : : /*
4069 : : DoesTreeContainAny - returns true if SymbolTree, t, contains any
4070 : : symbols which in turn return true when procedure,
4071 : : P, is called with a symbol as its parameter.
4072 : : The SymbolTree root is empty apart from the field,
4073 : : Left, hence we need two procedures.
4074 : : */
4075 : :
4076 : : extern "C" bool SymbolKey_DoesTreeContainAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P);
4077 : :
4078 : : /*
4079 : : ForeachNodeDo - for each node in SymbolTree, t, a procedure, P,
4080 : : is called with the node symbol as its parameter.
4081 : : The tree root node only contains a legal Left pointer,
4082 : : therefore we need two procedures to examine this tree.
4083 : : */
4084 : :
4085 : : extern "C" void SymbolKey_ForeachNodeDo (SymbolKey_SymbolTree t, SymbolKey_PerformOperation P);
4086 : :
4087 : : /*
4088 : : ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey.
4089 : : */
4090 : :
4091 : : extern "C" bool SymbolKey_ContainsSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey);
4092 : :
4093 : : /*
4094 : : NoOfNodes - returns the number of nodes in the tree t.
4095 : : */
4096 : :
4097 : : extern "C" unsigned int SymbolKey_NoOfNodes (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition);
4098 : :
4099 : : /*
4100 : : ForeachNodeConditionDo - traverse the tree t and for any node which satisfied
4101 : : condition call P.
4102 : : */
4103 : :
4104 : : extern "C" void SymbolKey_ForeachNodeConditionDo (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition, SymbolKey_PerformOperation P);
4105 : :
4106 : : /*
4107 : : InitStackWord - creates and returns a new stack.
4108 : : */
4109 : :
4110 : : extern "C" M2StackWord_StackOfWord M2StackWord_InitStackWord (void);
4111 : :
4112 : : /*
4113 : : KillStackWord - destroys a stack, returning NIL.
4114 : : */
4115 : :
4116 : : extern "C" M2StackWord_StackOfWord M2StackWord_KillStackWord (M2StackWord_StackOfWord s);
4117 : :
4118 : : /*
4119 : : PushWord - pushes a word, w, onto, s.
4120 : : */
4121 : :
4122 : : extern "C" void M2StackWord_PushWord (M2StackWord_StackOfWord s, unsigned int w);
4123 : :
4124 : : /*
4125 : : PopWord - pops an element from stack, s.
4126 : : */
4127 : :
4128 : : extern "C" unsigned int M2StackWord_PopWord (M2StackWord_StackOfWord s);
4129 : :
4130 : : /*
4131 : : IsEmptyWord - returns TRUE if stack, s, is empty.
4132 : : */
4133 : :
4134 : : extern "C" bool M2StackWord_IsEmptyWord (M2StackWord_StackOfWord s);
4135 : :
4136 : : /*
4137 : : PeepWord - returns the element at, n, items below in the stack.
4138 : : Top of stack can be seen via Peep(s, 1)
4139 : : */
4140 : :
4141 : : extern "C" unsigned int M2StackWord_PeepWord (M2StackWord_StackOfWord s, unsigned int n);
4142 : :
4143 : : /*
4144 : : ReduceWord - reduce the stack by n elements.
4145 : : */
4146 : :
4147 : : extern "C" void M2StackWord_ReduceWord (M2StackWord_StackOfWord s, unsigned int n);
4148 : :
4149 : : /*
4150 : : RemoveTop - throw away the top element of the stack.
4151 : : */
4152 : :
4153 : : extern "C" void M2StackWord_RemoveTop (M2StackWord_StackOfWord s);
4154 : :
4155 : : /*
4156 : : NoOfItemsInStackWord - returns the number of items held in the stack, s.
4157 : : */
4158 : :
4159 : : extern "C" unsigned int M2StackWord_NoOfItemsInStackWord (M2StackWord_StackOfWord s);
4160 : : extern "C" DynamicStrings_String StringConvert_IntegerToString (int i, unsigned int width, char padding, bool sign, unsigned int base, bool lower);
4161 : : extern "C" DynamicStrings_String StringConvert_CardinalToString (unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
4162 : : extern "C" int StringConvert_StringToInteger (DynamicStrings_String s, unsigned int base, bool *found);
4163 : : extern "C" unsigned int StringConvert_StringToCardinal (DynamicStrings_String s, unsigned int base, bool *found);
4164 : : extern "C" DynamicStrings_String StringConvert_LongIntegerToString (long int i, unsigned int width, char padding, bool sign, unsigned int base, bool lower);
4165 : : extern "C" long int StringConvert_StringToLongInteger (DynamicStrings_String s, unsigned int base, bool *found);
4166 : : extern "C" DynamicStrings_String StringConvert_LongCardinalToString (long unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
4167 : : extern "C" long unsigned int StringConvert_StringToLongCardinal (DynamicStrings_String s, unsigned int base, bool *found);
4168 : : extern "C" DynamicStrings_String StringConvert_ShortCardinalToString (short unsigned int c, unsigned int width, char padding, unsigned int base, bool lower);
4169 : : extern "C" short unsigned int StringConvert_StringToShortCardinal (DynamicStrings_String s, unsigned int base, bool *found);
4170 : : extern "C" int StringConvert_stoi (DynamicStrings_String s);
4171 : : extern "C" DynamicStrings_String StringConvert_itos (int i, unsigned int width, char padding, bool sign);
4172 : : extern "C" DynamicStrings_String StringConvert_ctos (unsigned int c, unsigned int width, char padding);
4173 : : extern "C" unsigned int StringConvert_stoc (DynamicStrings_String s);
4174 : : extern "C" int StringConvert_hstoi (DynamicStrings_String s);
4175 : : extern "C" int StringConvert_ostoi (DynamicStrings_String s);
4176 : : extern "C" int StringConvert_bstoi (DynamicStrings_String s);
4177 : : extern "C" unsigned int StringConvert_hstoc (DynamicStrings_String s);
4178 : : extern "C" unsigned int StringConvert_ostoc (DynamicStrings_String s);
4179 : : extern "C" unsigned int StringConvert_bstoc (DynamicStrings_String s);
4180 : : extern "C" long double StringConvert_StringToLongreal (DynamicStrings_String s, bool *found);
4181 : : extern "C" DynamicStrings_String StringConvert_LongrealToString (long double x, unsigned int TotalWidth, unsigned int FractionWidth);
4182 : : extern "C" double StringConvert_stor (DynamicStrings_String s);
4183 : : extern "C" long double StringConvert_stolr (DynamicStrings_String s);
4184 : : extern "C" DynamicStrings_String StringConvert_ToSigFig (DynamicStrings_String s, unsigned int n);
4185 : : extern "C" DynamicStrings_String StringConvert_ToDecimalPlaces (DynamicStrings_String s, unsigned int n);
4186 : : extern "C" void m2misc_DebugTree (m2tree_Tree t);
4187 : : extern "C" void m2misc_error (const char *message_, unsigned int _message_high);
4188 : : extern "C" void m2misc_cerror (void * message);
4189 : : extern "C" void StrIO_WriteLn (void);
4190 : : extern "C" void StrIO_ReadString (char *a, unsigned int _a_high);
4191 : : extern "C" void StrIO_WriteString (const char *a_, unsigned int _a_high);
4192 : : extern "C" void NumberIO_ReadCard (unsigned int *x);
4193 : : extern "C" void NumberIO_WriteCard (unsigned int x, unsigned int n);
4194 : : extern "C" void NumberIO_ReadHex (unsigned int *x);
4195 : : extern "C" void NumberIO_WriteHex (unsigned int x, unsigned int n);
4196 : : extern "C" void NumberIO_ReadInt (int *x);
4197 : : extern "C" void NumberIO_WriteInt (int x, unsigned int n);
4198 : : extern "C" void NumberIO_CardToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
4199 : : extern "C" void NumberIO_StrToCard (const char *a_, unsigned int _a_high, unsigned int *x);
4200 : : extern "C" void NumberIO_HexToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
4201 : : extern "C" void NumberIO_StrToHex (const char *a_, unsigned int _a_high, unsigned int *x);
4202 : : extern "C" void NumberIO_IntToStr (int x, unsigned int n, char *a, unsigned int _a_high);
4203 : : extern "C" void NumberIO_StrToInt (const char *a_, unsigned int _a_high, int *x);
4204 : : extern "C" void NumberIO_ReadOct (unsigned int *x);
4205 : : extern "C" void NumberIO_WriteOct (unsigned int x, unsigned int n);
4206 : : extern "C" void NumberIO_OctToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
4207 : : extern "C" void NumberIO_StrToOct (const char *a_, unsigned int _a_high, unsigned int *x);
4208 : : extern "C" void NumberIO_ReadBin (unsigned int *x);
4209 : : extern "C" void NumberIO_WriteBin (unsigned int x, unsigned int n);
4210 : : extern "C" void NumberIO_BinToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
4211 : : extern "C" void NumberIO_StrToBin (const char *a_, unsigned int _a_high, unsigned int *x);
4212 : : extern "C" void NumberIO_StrToBinInt (const char *a_, unsigned int _a_high, int *x);
4213 : : extern "C" void NumberIO_StrToHexInt (const char *a_, unsigned int _a_high, int *x);
4214 : : extern "C" void NumberIO_StrToOctInt (const char *a_, unsigned int _a_high, int *x);
4215 : : extern "C" void Debug_Halt (const char *Message_, unsigned int _Message_high, const char *Module_, unsigned int _Module_high, const char *Function_, unsigned int _Function_high, unsigned int LineNo);
4216 : : extern "C" void Debug_DebugString (const char *a_, unsigned int _a_high);
4217 : : static void mystop (void);
4218 : :
4219 : : /*
4220 : : PrintNum -
4221 : : */
4222 : :
4223 : : static void PrintNum (unsigned int sym);
4224 : :
4225 : : /*
4226 : : DebugSet -
4227 : : */
4228 : :
4229 : : static void DebugSet (const char *a_, unsigned int _a_high, Sets_Set l);
4230 : :
4231 : : /*
4232 : : DebugSets -
4233 : : */
4234 : :
4235 : : static void DebugSets (void);
4236 : :
4237 : : /*
4238 : : DebugNumber -
4239 : : */
4240 : :
4241 : : static void DebugNumber (const char *a_, unsigned int _a_high, Sets_Set s);
4242 : : static void DebugSetNumbers (void);
4243 : :
4244 : : /*
4245 : : AddSymToWatch - adds symbol, sym, to the list of symbols
4246 : : to watch and annotate their movement between
4247 : : lists.
4248 : : */
4249 : :
4250 : : static void AddSymToWatch (unsigned int sym);
4251 : :
4252 : : /*
4253 : : doInclude -
4254 : : */
4255 : :
4256 : : static void doInclude (Sets_Set l, const char *a_, unsigned int _a_high, unsigned int sym);
4257 : :
4258 : : /*
4259 : : WatchIncludeList - include a symbol onto the set first checking
4260 : : whether it is already on the set and
4261 : : displaying a debug message if the set is
4262 : : changed.
4263 : : */
4264 : :
4265 : : static void WatchIncludeList (unsigned int sym, M2GCCDeclare_ListType lt);
4266 : :
4267 : : /*
4268 : : doExclude -
4269 : : */
4270 : :
4271 : : static void doExclude (Sets_Set l, const char *a_, unsigned int _a_high, unsigned int sym);
4272 : :
4273 : : /*
4274 : : WatchRemoveList - remove a symbol onto the list first checking
4275 : : whether it is already on the list and
4276 : : displaying a debug message if the list is
4277 : : changed.
4278 : : */
4279 : :
4280 : : static void WatchRemoveList (unsigned int sym, M2GCCDeclare_ListType lt);
4281 : :
4282 : : /*
4283 : : NewGroup -
4284 : : */
4285 : :
4286 : : static void NewGroup (M2GCCDeclare_Group *g);
4287 : :
4288 : : /*
4289 : : DisposeGroup -
4290 : : */
4291 : :
4292 : : static void DisposeGroup (M2GCCDeclare_Group *g);
4293 : :
4294 : : /*
4295 : : InitGroup - initialize all sets in group and return the group.
4296 : : */
4297 : :
4298 : : static M2GCCDeclare_Group InitGroup (void);
4299 : :
4300 : : /*
4301 : : KillGroup - delete all sets in group and deallocate g.
4302 : : */
4303 : :
4304 : : static void KillGroup (M2GCCDeclare_Group *g);
4305 : :
4306 : : /*
4307 : : DupGroup - If g is not NIL then destroy g.
4308 : : Return a duplicate of GlobalGroup.
4309 : : */
4310 : :
4311 : : static M2GCCDeclare_Group DupGroup (M2GCCDeclare_Group g);
4312 : :
4313 : : /*
4314 : : EqualGroup - return TRUE if group left = right.
4315 : : */
4316 : :
4317 : : static bool EqualGroup (M2GCCDeclare_Group left, M2GCCDeclare_Group right);
4318 : :
4319 : : /*
4320 : : LookupSet -
4321 : : */
4322 : :
4323 : : static Sets_Set LookupSet (M2GCCDeclare_ListType listtype);
4324 : :
4325 : : /*
4326 : : GetEnumList -
4327 : : */
4328 : :
4329 : : static m2tree_Tree GetEnumList (unsigned int sym);
4330 : :
4331 : : /*
4332 : : PutEnumList -
4333 : : */
4334 : :
4335 : : static void PutEnumList (unsigned int sym, m2tree_Tree enumlist);
4336 : :
4337 : : /*
4338 : : Chained - checks to see that, sym, has not already been placed on a chain.
4339 : : It returns the symbol, sym.
4340 : : */
4341 : :
4342 : : static unsigned int Chained (unsigned int sym);
4343 : :
4344 : : /*
4345 : : DoStartDeclaration - returns a tree representing a symbol which has
4346 : : not yet been finished. Used when declaring
4347 : : recursive types.
4348 : : */
4349 : :
4350 : : static m2tree_Tree DoStartDeclaration (unsigned int sym, M2GCCDeclare_StartProcedure p);
4351 : :
4352 : : /*
4353 : : ArrayComponentsDeclared - returns TRUE if array, sym,
4354 : : subscripts and type are known.
4355 : : */
4356 : :
4357 : : static bool ArrayComponentsDeclared (unsigned int sym);
4358 : :
4359 : : /*
4360 : : GetRecordOfVarient -
4361 : : */
4362 : :
4363 : : static unsigned int GetRecordOfVarient (unsigned int sym);
4364 : :
4365 : : /*
4366 : : CanDeclareRecordKind -
4367 : : */
4368 : :
4369 : : static bool CanDeclareRecordKind (unsigned int sym);
4370 : :
4371 : : /*
4372 : : DeclareRecordKind - works out whether record, sym, is packed or not.
4373 : : */
4374 : :
4375 : : static void DeclareRecordKind (unsigned int sym);
4376 : :
4377 : : /*
4378 : : CanDeclareRecord -
4379 : : */
4380 : :
4381 : : static bool CanDeclareRecord (unsigned int sym);
4382 : :
4383 : : /*
4384 : : FinishDeclareRecord -
4385 : : */
4386 : :
4387 : : static void FinishDeclareRecord (unsigned int sym);
4388 : :
4389 : : /*
4390 : : CanDeclareTypePartially - return TRUE if we are able to make a
4391 : : gcc partially created type.
4392 : : */
4393 : :
4394 : : static bool CanDeclareTypePartially (unsigned int sym);
4395 : :
4396 : : /*
4397 : : DeclareTypePartially - create the gcc partial type symbol from, sym.
4398 : : */
4399 : :
4400 : : static void DeclareTypePartially (unsigned int sym);
4401 : :
4402 : : /*
4403 : : CanDeclareArrayAsNil -
4404 : : */
4405 : :
4406 : : static bool CanDeclareArrayAsNil (unsigned int sym);
4407 : :
4408 : : /*
4409 : : DeclareArrayAsNil -
4410 : : */
4411 : :
4412 : : static void DeclareArrayAsNil (unsigned int sym);
4413 : :
4414 : : /*
4415 : : CanDeclareArrayPartially -
4416 : : */
4417 : :
4418 : : static bool CanDeclareArrayPartially (unsigned int sym);
4419 : :
4420 : : /*
4421 : : DeclareArrayPartially -
4422 : : */
4423 : :
4424 : : static void DeclareArrayPartially (unsigned int sym);
4425 : :
4426 : : /*
4427 : : CanDeclarePointerToNilArray -
4428 : : */
4429 : :
4430 : : static bool CanDeclarePointerToNilArray (unsigned int sym);
4431 : :
4432 : : /*
4433 : : DeclarePointerToNilArray -
4434 : : */
4435 : :
4436 : : static void DeclarePointerToNilArray (unsigned int sym);
4437 : :
4438 : : /*
4439 : : CanPromotePointerFully -
4440 : : */
4441 : :
4442 : : static bool CanPromotePointerFully (unsigned int sym);
4443 : :
4444 : : /*
4445 : : PromotePointerFully -
4446 : : */
4447 : :
4448 : : static void PromotePointerFully (unsigned int sym);
4449 : :
4450 : : /*
4451 : : IsTypeQ - returns TRUE if all q(dependants) of, sym,
4452 : : return TRUE.
4453 : : */
4454 : :
4455 : : static bool IsTypeQ (unsigned int sym, M2GCCDeclare_IsAction q);
4456 : :
4457 : : /*
4458 : : IsNilTypedArrays - returns TRUE if, sym, is dependant upon a NIL typed array
4459 : : */
4460 : :
4461 : : static bool IsNilTypedArrays (unsigned int sym);
4462 : :
4463 : : /*
4464 : : IsFullyDeclared - returns TRUE if, sym, is fully declared.
4465 : : */
4466 : :
4467 : : static bool IsFullyDeclared (unsigned int sym);
4468 : :
4469 : : /*
4470 : : AllDependantsFullyDeclared - returns TRUE if all dependants of,
4471 : : sym, are declared.
4472 : : */
4473 : :
4474 : : static bool AllDependantsFullyDeclared (unsigned int sym);
4475 : :
4476 : : /*
4477 : : NotAllDependantsFullyDeclared - returns TRUE if any dependants of,
4478 : : sym, are not declared.
4479 : : */
4480 : :
4481 : : static bool NotAllDependantsFullyDeclared (unsigned int sym);
4482 : :
4483 : : /*
4484 : : IsPartiallyDeclared - returns TRUE if, sym, is partially declared.
4485 : : */
4486 : :
4487 : : static bool IsPartiallyDeclared (unsigned int sym);
4488 : :
4489 : : /*
4490 : : AllDependantsPartiallyDeclared - returns TRUE if all dependants of,
4491 : : sym, are partially declared.
4492 : : */
4493 : :
4494 : : static bool AllDependantsPartiallyDeclared (unsigned int sym);
4495 : :
4496 : : /*
4497 : : NotAllDependantsPartiallyDeclared - returns TRUE if any dependants of,
4498 : : sym, are not partially declared.
4499 : : */
4500 : :
4501 : : static bool NotAllDependantsPartiallyDeclared (unsigned int sym);
4502 : :
4503 : : /*
4504 : : IsPartiallyOrFullyDeclared - returns TRUE if, sym, is partially or fully declared.
4505 : : */
4506 : :
4507 : : static bool IsPartiallyOrFullyDeclared (unsigned int sym);
4508 : :
4509 : : /*
4510 : : AllDependantsPartiallyOrFullyDeclared - returns TRUE if all dependants of,
4511 : : sym, are partially or fully declared.
4512 : : */
4513 : :
4514 : : static bool AllDependantsPartiallyOrFullyDeclared (unsigned int sym);
4515 : :
4516 : : /*
4517 : : TypeConstDependantsFullyDeclared - returns TRUE if sym is a constant or
4518 : : type and its dependants are fully
4519 : : declared.
4520 : : */
4521 : :
4522 : : static bool TypeConstDependantsFullyDeclared (unsigned int sym);
4523 : :
4524 : : /*
4525 : : CanBeDeclaredViaPartialDependants - returns TRUE if this symbol
4526 : : can be declared by partial
4527 : : dependants. Such a symbol must
4528 : : be a record, proctype or
4529 : : an array.
4530 : : */
4531 : :
4532 : : static bool CanBeDeclaredViaPartialDependants (unsigned int sym);
4533 : :
4534 : : /*
4535 : : DeclareConstFully - will add, sym, to the fully declared list and
4536 : : also remove it from the to do list. This is
4537 : : called indirectly from M2GenGCC as it calculates
4538 : : constants during quadruple processing.
4539 : : */
4540 : :
4541 : : static void DeclareConstFully (unsigned int sym);
4542 : :
4543 : : /*
4544 : : DeclareTypeConstFully - declare the GCC type and add the double
4545 : : book keeping entry.
4546 : : */
4547 : :
4548 : : static void DeclareTypeConstFully (unsigned int sym);
4549 : :
4550 : : /*
4551 : : DeclareTypeFromPartial - declare the full GCC type from a partial type
4552 : : and add the double book keeping entry.
4553 : : */
4554 : :
4555 : : static void DeclareTypeFromPartial (unsigned int sym);
4556 : :
4557 : : /*
4558 : : CanBeDeclaredPartiallyViaPartialDependants - returns TRUE if, sym,
4559 : : can be partially declared via
4560 : : another partially declared type.
4561 : : */
4562 : :
4563 : : static bool CanBeDeclaredPartiallyViaPartialDependants (unsigned int sym);
4564 : :
4565 : : /*
4566 : : EmitCircularDependancyError - issue a dependancy error.
4567 : : */
4568 : :
4569 : : static void EmitCircularDependancyError (unsigned int sym);
4570 : :
4571 : : /*
4572 : : WriteRule - writes out the name of the rule.
4573 : : */
4574 : :
4575 : : static void WriteRule (void);
4576 : :
4577 : : /*
4578 : : Body -
4579 : : */
4580 : :
4581 : : static void Body (unsigned int sym);
4582 : :
4583 : : /*
4584 : : ForeachTryDeclare - while q (of one sym in set t) is true
4585 : : for each symbol in set t,
4586 : : if q (sym)
4587 : : then
4588 : : p (sym)
4589 : : end
4590 : : end
4591 : : end
4592 : : */
4593 : :
4594 : : static bool ForeachTryDeclare (M2GCCDeclare_ListType t, M2GCCDeclare_Rule r, M2GCCDeclare_IsAction q, M2GCCDeclare_WalkAction p);
4595 : : static bool DeclaredOutstandingTypes (bool ForceComplete);
4596 : :
4597 : : /*
4598 : : CompleteDeclarationOf - returns the GCC Tree for, sym, if it can
4599 : : be created from partially or fully declared
4600 : : dependents.
4601 : : */
4602 : :
4603 : : static m2tree_Tree CompleteDeclarationOf (unsigned int sym);
4604 : :
4605 : : /*
4606 : : DeclareType - here a type has been created via TYPE foo = bar,
4607 : : we must tell GCC about it.
4608 : : */
4609 : :
4610 : : static m2tree_Tree DeclareType (unsigned int sym);
4611 : : static void DeclareConstantFromTree (unsigned int sym, m2tree_Tree value);
4612 : :
4613 : : /*
4614 : : DeclareCharConstant - declares a character constant.
4615 : : */
4616 : :
4617 : : static void DeclareCharConstant (unsigned int tokenno, unsigned int sym);
4618 : :
4619 : : /*
4620 : : DeclareStringConstant - declares a string constant the sym will be known.
4621 : : */
4622 : :
4623 : : static void DeclareStringConstant (unsigned int tokenno, unsigned int sym);
4624 : :
4625 : : /*
4626 : : WalkConstructor - walks all dependants of, sym.
4627 : : */
4628 : :
4629 : : static void WalkConstructor (unsigned int sym, M2GCCDeclare_WalkAction p);
4630 : :
4631 : : /*
4632 : : WalkConst - walks all dependants of, sym.
4633 : : */
4634 : :
4635 : : static void WalkConst (unsigned int sym, M2GCCDeclare_WalkAction p);
4636 : :
4637 : : /*
4638 : : IsConstDependants - returns TRUE if the symbol, sym,
4639 : : q(dependants) all return TRUE.
4640 : : */
4641 : :
4642 : : static bool IsConstDependants (unsigned int sym, M2GCCDeclare_IsAction q);
4643 : :
4644 : : /*
4645 : : DeclareConstString -
4646 : : */
4647 : :
4648 : : static bool DeclareConstString (unsigned int tokenno, unsigned int sym);
4649 : :
4650 : : /*
4651 : : TryDeclareConst - try to declare a const to gcc. If it cannot
4652 : : declare the symbol it places it into the
4653 : : todolist.
4654 : : */
4655 : :
4656 : : static void TryDeclareConst (unsigned int tokenno, unsigned int sym);
4657 : :
4658 : : /*
4659 : : DeclareConst - declares a const to gcc and returns a Tree.
4660 : : */
4661 : :
4662 : : static m2tree_Tree DeclareConst (unsigned int tokenno, unsigned int sym);
4663 : :
4664 : : /*
4665 : : WalkFamilyOfUnbounded -
4666 : : */
4667 : :
4668 : : static void WalkFamilyOfUnbounded (unsigned int oaf __attribute__((unused)), unsigned int dim __attribute__((unused)), unsigned int unbounded);
4669 : :
4670 : : /*
4671 : : WalkAssociatedUnbounded -
4672 : : */
4673 : :
4674 : : static void WalkAssociatedUnbounded (unsigned int sym, M2GCCDeclare_WalkAction p);
4675 : :
4676 : : /*
4677 : : WalkDependants - walks through all dependants of, Sym,
4678 : : calling, p, for each dependant.
4679 : : */
4680 : :
4681 : : static void WalkDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
4682 : :
4683 : : /*
4684 : : TraverseDependantsInner -
4685 : : */
4686 : :
4687 : : static void TraverseDependantsInner (unsigned int sym);
4688 : :
4689 : : /*
4690 : : TraverseDependants - walks, sym, dependants. But it checks
4691 : : to see that, sym, is not on the
4692 : : FullyDeclared and not on the ToDoList.
4693 : : */
4694 : :
4695 : : static void TraverseDependants (unsigned int sym);
4696 : :
4697 : : /*
4698 : : WalkTypeInfo - walks type, sym, and its dependants.
4699 : : */
4700 : :
4701 : : static void WalkTypeInfo (unsigned int sym);
4702 : :
4703 : : /*
4704 : : DeclareUnboundedProcedureParameters -
4705 : : */
4706 : :
4707 : : static void DeclareUnboundedProcedureParameters (unsigned int sym);
4708 : :
4709 : : /*
4710 : : WalkUnboundedProcedureParameters -
4711 : : */
4712 : :
4713 : : static void WalkUnboundedProcedureParameters (unsigned int sym);
4714 : :
4715 : : /*
4716 : : WalkTypesInProcedure - walk all types in procedure, Sym.
4717 : : */
4718 : :
4719 : : static void WalkTypesInProcedure (unsigned int sym);
4720 : :
4721 : : /*
4722 : : WalkTypesInModule - declare all types in module, Sym, to GCC.
4723 : : */
4724 : :
4725 : : static void WalkTypesInModule (unsigned int sym);
4726 : :
4727 : : /*
4728 : : IsRecordFieldDependants - returns TRUE if the record field
4729 : : symbol, sym, p(dependants) all return TRUE.
4730 : : */
4731 : :
4732 : : static bool IsRecordFieldDependants (unsigned int sym, M2GCCDeclare_IsAction q);
4733 : :
4734 : : /*
4735 : : GetModuleWhereDeclared - returns the module where, Sym, was created.
4736 : : */
4737 : :
4738 : : static unsigned int GetModuleWhereDeclared (unsigned int sym);
4739 : :
4740 : : /*
4741 : : IsPseudoProcFunc - returns TRUE if Sym is a pseudo function or procedure.
4742 : : */
4743 : :
4744 : : static bool IsPseudoProcFunc (unsigned int Sym);
4745 : :
4746 : : /*
4747 : : IsExternal -
4748 : : */
4749 : :
4750 : : static bool IsExternal (unsigned int sym);
4751 : :
4752 : : /*
4753 : : IsExternalToWholeProgram - return TRUE if the symbol, sym, is external to the
4754 : : sources that we have parsed.
4755 : : */
4756 : :
4757 : : static bool IsExternalToWholeProgram (unsigned int sym);
4758 : :
4759 : : /*
4760 : : DeclareProcedureToGccWholeProgram -
4761 : : */
4762 : :
4763 : : static void DeclareProcedureToGccWholeProgram (unsigned int Sym);
4764 : :
4765 : : /*
4766 : : DeclareProcedureToGccSeparateProgram -
4767 : : */
4768 : :
4769 : : static void DeclareProcedureToGccSeparateProgram (unsigned int Sym);
4770 : :
4771 : : /*
4772 : : DeclareProcedureToGcc - traverses all parameters and interfaces to gm2gcc.
4773 : : */
4774 : :
4775 : : static void DeclareProcedureToGcc (unsigned int sym);
4776 : :
4777 : : /*
4778 : : ActivateWatch - activate a watch for any symbol (lista xor listb).
4779 : : */
4780 : :
4781 : : static void ActivateWatch (Sets_Set lista, Sets_Set listb);
4782 : :
4783 : : /*
4784 : : DeclareTypesConstantsProceduresInRange -
4785 : : */
4786 : :
4787 : : static void DeclareTypesConstantsProceduresInRange (unsigned int scope, unsigned int start, unsigned int end);
4788 : :
4789 : : /*
4790 : : SkipModuleScope - skips all module scopes for, scope.
4791 : : It returns either NulSym or a procedure sym.
4792 : : */
4793 : :
4794 : : static unsigned int SkipModuleScope (unsigned int scope);
4795 : :
4796 : : /*
4797 : : PushBinding -
4798 : : */
4799 : :
4800 : : static void PushBinding (unsigned int scope);
4801 : :
4802 : : /*
4803 : : PopBinding -
4804 : : */
4805 : :
4806 : : static void PopBinding (unsigned int scope);
4807 : :
4808 : : /*
4809 : : DeclareTypesConstantsProcedures -
4810 : : */
4811 : :
4812 : : static void DeclareTypesConstantsProcedures (unsigned int scope);
4813 : :
4814 : : /*
4815 : : AssertAllTypesDeclared - asserts that all types for variables are declared in, scope.
4816 : : */
4817 : :
4818 : : static void AssertAllTypesDeclared (unsigned int scope);
4819 : :
4820 : : /*
4821 : : DeclareModuleInit - declare all the ctor related functions within
4822 : : a module.
4823 : : */
4824 : :
4825 : : static void DeclareModuleInit (unsigned int moduleSym);
4826 : :
4827 : : /*
4828 : : StartDeclareProcedureScope -
4829 : : */
4830 : :
4831 : : static void StartDeclareProcedureScope (unsigned int scope);
4832 : :
4833 : : /*
4834 : : StartDeclareModuleScopeSeparate -
4835 : : */
4836 : :
4837 : : static void StartDeclareModuleScopeSeparate (unsigned int scope);
4838 : :
4839 : : /*
4840 : : StartDeclareModuleScopeWholeProgram -
4841 : : */
4842 : :
4843 : : static void StartDeclareModuleScopeWholeProgram (unsigned int scope);
4844 : :
4845 : : /*
4846 : : StartDeclareModuleScope -
4847 : : */
4848 : :
4849 : : static void StartDeclareModuleScope (unsigned int scope);
4850 : :
4851 : : /*
4852 : : DumpResolver - dumps the m2 representation of sym.
4853 : : */
4854 : :
4855 : : static void DumpResolver (unsigned int sym);
4856 : :
4857 : : /*
4858 : : DumpDefinitive - dumps the m2 and m2 gimple representation of sym.
4859 : : */
4860 : :
4861 : : static void DumpDefinitive (unsigned int sym);
4862 : :
4863 : : /*
4864 : : PreAddModGcc - adds a relationship between sym and tree.
4865 : : */
4866 : :
4867 : : static void PreAddModGcc (unsigned int sym, m2tree_Tree tree);
4868 : :
4869 : : /*
4870 : : DeclareDefaultType - declares a default type, sym, with, name.
4871 : : */
4872 : :
4873 : : static void DeclareDefaultType (unsigned int sym, const char *name_, unsigned int _name_high, m2tree_Tree gcctype);
4874 : :
4875 : : /*
4876 : : DeclareBoolean - declares the Boolean type together with true and false.
4877 : : */
4878 : :
4879 : : static void DeclareBoolean (void);
4880 : :
4881 : : /*
4882 : : DeclareFixedSizedType - declares the GNU Modula-2 fixed types
4883 : : (if the back end support such a type).
4884 : : */
4885 : :
4886 : : static void DeclareFixedSizedType (const char *name_, unsigned int _name_high, unsigned int type, m2tree_Tree t);
4887 : :
4888 : : /*
4889 : : DeclareDefaultSimpleTypes - declares the simple types.
4890 : : */
4891 : :
4892 : : static void DeclareDefaultSimpleTypes (void);
4893 : :
4894 : : /*
4895 : : DeclarePackedBoolean -
4896 : : */
4897 : :
4898 : : static void DeclarePackedBoolean (void);
4899 : :
4900 : : /*
4901 : : DeclarePackedDefaultSimpleTypes -
4902 : : */
4903 : :
4904 : : static void DeclarePackedDefaultSimpleTypes (void);
4905 : :
4906 : : /*
4907 : : DeclareDefaultTypes - makes default types known to GCC
4908 : : */
4909 : :
4910 : : static void DeclareDefaultTypes (void);
4911 : :
4912 : : /*
4913 : : DeclareDefaultConstants - make default constants known to GCC
4914 : : */
4915 : :
4916 : : static void DeclareDefaultConstants (void);
4917 : :
4918 : : /*
4919 : : FindContext - returns the scope where the symbol
4920 : : should be created.
4921 : :
4922 : : Symbols created in a module will
4923 : : return the global context tree, but symbols created
4924 : : in a module which is declared inside
4925 : : a procedure will return the procedure Tree.
4926 : : */
4927 : :
4928 : : static m2tree_Tree FindContext (unsigned int sym);
4929 : :
4930 : : /*
4931 : : IsEffectivelyImported - returns TRUE if symbol, Sym, was
4932 : : effectively imported into ModSym.
4933 : : */
4934 : :
4935 : : static bool IsEffectivelyImported (unsigned int ModSym, unsigned int sym);
4936 : :
4937 : : /*
4938 : : FindOuterModule - returns the out most module where, sym,
4939 : : was declared. It returns NulSym if the
4940 : : symbol or the module was declared inside
4941 : : a procedure.
4942 : : */
4943 : :
4944 : : static unsigned int FindOuterModule (unsigned int sym);
4945 : :
4946 : : /*
4947 : : DoVariableDeclaration - create a corresponding gcc variable and add the association
4948 : : between the front end symbol var and the gcc tree.
4949 : : */
4950 : :
4951 : : static void DoVariableDeclaration (unsigned int var, void * name, bool isImported, bool isExported, bool isTemporary, bool isGlobal, m2tree_Tree scope);
4952 : :
4953 : : /*
4954 : : IsGlobal - is the variable not in a procedure scope.
4955 : : */
4956 : :
4957 : : static bool IsGlobal (unsigned int sym);
4958 : :
4959 : : /*
4960 : : DeclareVariable - declares a global variable to GCC.
4961 : : */
4962 : :
4963 : : static void DeclareVariable (unsigned int ModSym, unsigned int variable);
4964 : :
4965 : : /*
4966 : : DeclareVariableWholeProgram - declares a global variable to GCC when using -fm2-whole-program.
4967 : : */
4968 : :
4969 : : static void DeclareVariableWholeProgram (unsigned int mainModule, unsigned int variable);
4970 : :
4971 : : /*
4972 : : DeclareGlobalVariablesWholeProgram -
4973 : : */
4974 : :
4975 : : static void DeclareGlobalVariablesWholeProgram (unsigned int ModSym);
4976 : :
4977 : : /*
4978 : : DeclareGlobalVariables - lists the Global variables for
4979 : : Module ModSym together with their offset.
4980 : : */
4981 : :
4982 : : static void DeclareGlobalVariables (unsigned int ModSym);
4983 : :
4984 : : /*
4985 : : DeclareImportedVariables - declares all imported variables to GM2.
4986 : : */
4987 : :
4988 : : static void DeclareImportedVariables (unsigned int sym);
4989 : :
4990 : : /*
4991 : : DeclareImportedVariablesWholeProgram - declares all imported variables.
4992 : : */
4993 : :
4994 : : static void DeclareImportedVariablesWholeProgram (unsigned int sym);
4995 : :
4996 : : /*
4997 : : DeclareFieldValue -
4998 : : */
4999 : :
5000 : : static m2tree_Tree DeclareFieldValue (unsigned int sym, m2tree_Tree value, m2tree_Tree *list);
5001 : :
5002 : : /*
5003 : : DeclareFieldEnumeration - declares an enumerator within the current enumeration type.
5004 : : */
5005 : :
5006 : : static m2tree_Tree DeclareFieldEnumeration (unsigned int sym);
5007 : :
5008 : : /*
5009 : : DeclareEnumeration - declare an enumerated type.
5010 : : */
5011 : :
5012 : : static m2tree_Tree DeclareEnumeration (unsigned int sym);
5013 : :
5014 : : /*
5015 : : DeclareSubrangeNarrow - will return cardinal, integer, or type depending on whether
5016 : : low..high fits in the C data type.
5017 : : */
5018 : :
5019 : : static m2tree_Tree DeclareSubrangeNarrow (m2linemap_location_t location, unsigned int high, unsigned int low, m2tree_Tree type);
5020 : :
5021 : : /*
5022 : : DeclareSubrange - declare a subrange type.
5023 : : */
5024 : :
5025 : : static m2tree_Tree DeclareSubrange (unsigned int sym);
5026 : :
5027 : : /*
5028 : : IncludeGetNth -
5029 : : */
5030 : :
5031 : : static void IncludeGetNth (Lists_List l, unsigned int sym);
5032 : :
5033 : : /*
5034 : : IncludeType -
5035 : : */
5036 : :
5037 : : static void IncludeType (Lists_List l, unsigned int sym);
5038 : :
5039 : : /*
5040 : : IncludeSubscript -
5041 : : */
5042 : :
5043 : : static void IncludeSubscript (Lists_List l, unsigned int sym);
5044 : :
5045 : : /*
5046 : : PrintLocalSymbol -
5047 : : */
5048 : :
5049 : : static void PrintLocalSymbol (unsigned int sym);
5050 : :
5051 : : /*
5052 : : PrintLocalSymbols -
5053 : : */
5054 : :
5055 : : static void PrintLocalSymbols (unsigned int sym);
5056 : :
5057 : : /*
5058 : : IncludeGetVarient -
5059 : : */
5060 : :
5061 : : static void IncludeGetVarient (Lists_List l, unsigned int sym);
5062 : :
5063 : : /*
5064 : : IncludeUnbounded - includes the record component of an unbounded type.
5065 : : */
5066 : :
5067 : : static void IncludeUnbounded (Lists_List l, unsigned int sym);
5068 : :
5069 : : /*
5070 : : IncludePartialUnbounded - includes the type component of a partial unbounded symbol.
5071 : : */
5072 : :
5073 : : static void IncludePartialUnbounded (Lists_List l, unsigned int sym);
5074 : :
5075 : : /*
5076 : : PrintDeclared - prints out where, sym, was declared.
5077 : : */
5078 : :
5079 : : static void PrintDeclared (unsigned int sym);
5080 : :
5081 : : /*
5082 : : PrintAlignment -
5083 : : */
5084 : :
5085 : : static void PrintAlignment (unsigned int sym);
5086 : :
5087 : : /*
5088 : : IncludeGetParent -
5089 : : */
5090 : :
5091 : : static void IncludeGetParent (Lists_List l, unsigned int sym);
5092 : :
5093 : : /*
5094 : : PrintDecl -
5095 : : */
5096 : :
5097 : : static void PrintDecl (unsigned int sym);
5098 : :
5099 : : /*
5100 : : PrintScope - displays the scope and line number of declaration of symbol, sym.
5101 : : */
5102 : :
5103 : : static void PrintScope (unsigned int sym);
5104 : :
5105 : : /*
5106 : : PrintProcedure -
5107 : : */
5108 : :
5109 : : static void PrintProcedure (unsigned int sym);
5110 : :
5111 : : /*
5112 : : PrintString -
5113 : : */
5114 : :
5115 : : static void PrintString (unsigned int sym);
5116 : :
5117 : : /*
5118 : : PrintVerboseFromList - prints the, i, th element in the list, l.
5119 : : */
5120 : :
5121 : : static void PrintVerboseFromList (Lists_List l, unsigned int i);
5122 : :
5123 : : /*
5124 : : PrintVerbose - prints limited information about a symbol.
5125 : : */
5126 : :
5127 : : static void PrintVerbose (unsigned int sym);
5128 : :
5129 : : /*
5130 : : PrintTerse -
5131 : : */
5132 : :
5133 : : static void PrintTerse (unsigned int sym);
5134 : :
5135 : : /*
5136 : : CheckAlignment -
5137 : : */
5138 : :
5139 : : static m2tree_Tree CheckAlignment (m2tree_Tree type, unsigned int sym);
5140 : :
5141 : : /*
5142 : : CheckPragma -
5143 : : */
5144 : :
5145 : : static m2tree_Tree CheckPragma (m2tree_Tree type, unsigned int sym);
5146 : :
5147 : : /*
5148 : : IsZero - returns TRUE if symbol, sym, is zero.
5149 : : */
5150 : :
5151 : : static bool IsZero (unsigned int sym);
5152 : :
5153 : : /*
5154 : : SetFieldPacked - sets Varient, VarientField and RecordField symbols
5155 : : as packed.
5156 : : */
5157 : :
5158 : : static void SetFieldPacked (unsigned int field);
5159 : :
5160 : : /*
5161 : : RecordPacked - indicates that record, sym, and its fields
5162 : : are all packed.
5163 : : */
5164 : :
5165 : : static void RecordPacked (unsigned int sym);
5166 : :
5167 : : /*
5168 : : SetFieldNotPacked - sets Varient, VarientField and RecordField symbols
5169 : : as not packed.
5170 : : */
5171 : :
5172 : : static void SetFieldNotPacked (unsigned int field);
5173 : :
5174 : : /*
5175 : : RecordNotPacked - indicates that record, sym, and its fields
5176 : : are all not packed.
5177 : : */
5178 : :
5179 : : static void RecordNotPacked (unsigned int sym);
5180 : :
5181 : : /*
5182 : : DetermineIfRecordPacked -
5183 : : */
5184 : :
5185 : : static void DetermineIfRecordPacked (unsigned int sym);
5186 : :
5187 : : /*
5188 : : DeclarePackedSubrange -
5189 : : */
5190 : :
5191 : : static void DeclarePackedSubrange (unsigned int equiv, unsigned int sym);
5192 : :
5193 : : /*
5194 : : DeclarePackedSet -
5195 : : */
5196 : :
5197 : : static void DeclarePackedSet (unsigned int equiv, unsigned int sym);
5198 : : static void DeclarePackedFieldEnumeration (unsigned int sym);
5199 : :
5200 : : /*
5201 : : DeclarePackedEnumeration -
5202 : : */
5203 : :
5204 : : static void DeclarePackedEnumeration (unsigned int equiv, unsigned int sym);
5205 : :
5206 : : /*
5207 : : DeclarePackedType -
5208 : : */
5209 : :
5210 : : static void DeclarePackedType (unsigned int equiv, unsigned int sym);
5211 : :
5212 : : /*
5213 : : doDeclareEquivalent -
5214 : : */
5215 : :
5216 : : static m2tree_Tree doDeclareEquivalent (unsigned int sym, M2GCCDeclare_doDeclareProcedure p);
5217 : :
5218 : : /*
5219 : : PossiblyPacked -
5220 : : */
5221 : :
5222 : : static m2tree_Tree PossiblyPacked (unsigned int sym, bool isPacked);
5223 : :
5224 : : /*
5225 : : GetPackedType - returns a possibly packed type for field.
5226 : : */
5227 : :
5228 : : static m2tree_Tree GetPackedType (unsigned int sym);
5229 : :
5230 : : /*
5231 : : MaybeAlignField - checks to see whether, field, is packed or aligned and it updates
5232 : : the offsets if appropriate.
5233 : : */
5234 : :
5235 : : static m2tree_Tree MaybeAlignField (unsigned int field, m2tree_Tree *byteOffset, m2tree_Tree *bitOffset);
5236 : :
5237 : : /*
5238 : : DeclareRecord - declares a record and its fields to gcc.
5239 : : The final gcc record type is returned.
5240 : : */
5241 : :
5242 : : static m2tree_Tree DeclareRecord (unsigned int Sym);
5243 : :
5244 : : /*
5245 : : DeclareRecordField -
5246 : : */
5247 : :
5248 : : static m2tree_Tree DeclareRecordField (unsigned int sym);
5249 : :
5250 : : /*
5251 : : DeclareVarient - declares a record and its fields to gcc.
5252 : : The final gcc record type is returned.
5253 : : */
5254 : :
5255 : : static m2tree_Tree DeclareVarient (unsigned int sym);
5256 : :
5257 : : /*
5258 : : DeclareFieldVarient -
5259 : : */
5260 : :
5261 : : static m2tree_Tree DeclareFieldVarient (unsigned int sym);
5262 : :
5263 : : /*
5264 : : DeclarePointer - declares a pointer type to gcc and returns the Tree.
5265 : : */
5266 : :
5267 : : static m2tree_Tree DeclarePointer (unsigned int sym);
5268 : :
5269 : : /*
5270 : : DeclareUnbounded - builds an unbounded type and returns the gcc tree.
5271 : : */
5272 : :
5273 : : static m2tree_Tree DeclareUnbounded (unsigned int sym);
5274 : :
5275 : : /*
5276 : : BuildIndex -
5277 : : */
5278 : :
5279 : : static m2tree_Tree BuildIndex (unsigned int tokenno, unsigned int array);
5280 : :
5281 : : /*
5282 : : DeclareArray - declares an array to gcc and returns the gcc tree.
5283 : : */
5284 : :
5285 : : static m2tree_Tree DeclareArray (unsigned int Sym);
5286 : :
5287 : : /*
5288 : : DeclareProcType - declares a procedure type to gcc and returns the gcc type tree.
5289 : : */
5290 : :
5291 : : static m2tree_Tree DeclareProcType (unsigned int Sym);
5292 : :
5293 : : /*
5294 : : FindMinMaxEnum - finds the minimum and maximum enumeration fields.
5295 : : */
5296 : :
5297 : : static void FindMinMaxEnum (unsigned int field);
5298 : :
5299 : : /*
5300 : : PushNoOfBits - pushes the integer value of the number of bits required
5301 : : to maintain a set of type.
5302 : : */
5303 : :
5304 : : static void PushNoOfBits (unsigned int type, unsigned int low, unsigned int high);
5305 : :
5306 : : /*
5307 : : DeclareLargeSet - n is the name of the set.
5308 : : type is the subrange type (or simple type)
5309 : : low and high are the limits of the subrange.
5310 : : */
5311 : :
5312 : : static m2tree_Tree DeclareLargeSet (NameKey_Name n, unsigned int type, unsigned int low, unsigned int high);
5313 : :
5314 : : /*
5315 : : DeclareLargeOrSmallSet - works out whether the set will exceed TSIZE(WORD). If it does
5316 : : we manufacture a set using:
5317 : :
5318 : : settype = RECORD
5319 : : w1: SET OF [...]
5320 : : w2: SET OF [...]
5321 : : END
5322 : :
5323 : : We do this as GCC and GDB (stabs) only knows about WORD sized sets.
5324 : : If the set will fit into a WORD then we call gccgm2 directly.
5325 : : */
5326 : :
5327 : : static m2tree_Tree DeclareLargeOrSmallSet (unsigned int sym, NameKey_Name n, unsigned int type, unsigned int low, unsigned int high);
5328 : :
5329 : : /*
5330 : : DeclareSet - declares a set type to gcc and returns a Tree.
5331 : : */
5332 : :
5333 : : static m2tree_Tree DeclareSet (unsigned int sym);
5334 : :
5335 : : /*
5336 : : CheckResolveSubrange - checks to see whether we can determine
5337 : : the subrange type. We are able to do
5338 : : this once low, high and the type are known.
5339 : : */
5340 : :
5341 : : static void CheckResolveSubrange (unsigned int sym);
5342 : :
5343 : : /*
5344 : : TypeConstFullyDeclared - all, sym, dependents are declared, so create and
5345 : : return the GCC Tree equivalent.
5346 : : */
5347 : :
5348 : : static m2tree_Tree TypeConstFullyDeclared (unsigned int sym);
5349 : :
5350 : : /*
5351 : : IsBaseType - returns true if a type, Sym, is a base type and
5352 : : we use predefined GDB information to represent this
5353 : : type.
5354 : : */
5355 : :
5356 : : static bool IsBaseType (unsigned int Sym);
5357 : :
5358 : : /*
5359 : : IsFieldEnumerationDependants - sets enumDeps to FALSE if action(Sym)
5360 : : is also FALSE.
5361 : : */
5362 : :
5363 : : static void IsFieldEnumerationDependants (unsigned int Sym);
5364 : :
5365 : : /*
5366 : : IsEnumerationDependants - returns true if the enumeration
5367 : : p(dependants) all return true.
5368 : : */
5369 : :
5370 : : static bool IsEnumerationDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5371 : :
5372 : : /*
5373 : : WalkEnumerationDependants - returns walks all dependants of Sym.
5374 : : */
5375 : :
5376 : : static void WalkEnumerationDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5377 : :
5378 : : /*
5379 : : WalkSubrangeDependants - calls p(dependants) for each dependant of, sym.
5380 : : */
5381 : :
5382 : : static void WalkSubrangeDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5383 : :
5384 : : /*
5385 : : IsSubrangeDependants - returns TRUE if the subrange
5386 : : q(dependants) all return TRUE.
5387 : : */
5388 : :
5389 : : static bool IsSubrangeDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5390 : :
5391 : : /*
5392 : : WalkComponentDependants -
5393 : : */
5394 : :
5395 : : static void WalkComponentDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5396 : :
5397 : : /*
5398 : : IsComponentDependants -
5399 : : */
5400 : :
5401 : : static bool IsComponentDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5402 : :
5403 : : /*
5404 : : WalkVarDependants - walks all dependants of sym.
5405 : : */
5406 : :
5407 : : static void WalkVarDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5408 : :
5409 : : /*
5410 : : IsVarDependants - returns TRUE if the pointer symbol, sym,
5411 : : p(dependants) all return TRUE.
5412 : : */
5413 : :
5414 : : static bool IsVarDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5415 : :
5416 : : /*
5417 : : WalkPointerDependants - walks all dependants of sym.
5418 : : */
5419 : :
5420 : : static void WalkPointerDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5421 : :
5422 : : /*
5423 : : IsPointerDependants - returns TRUE if the pointer symbol, sym,
5424 : : p(dependants) all return TRUE.
5425 : : */
5426 : :
5427 : : static bool IsPointerDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5428 : :
5429 : : /*
5430 : : IsRecordAlignment -
5431 : : */
5432 : :
5433 : : static bool IsRecordAlignment (unsigned int sym, M2GCCDeclare_IsAction q);
5434 : :
5435 : : /*
5436 : : IsRecordDependants - returns TRUE if the symbol, sym,
5437 : : q(dependants) all return TRUE.
5438 : : */
5439 : :
5440 : : static bool IsRecordDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5441 : :
5442 : : /*
5443 : : WalkRecordAlignment - walks the alignment constant associated with
5444 : : record, sym.
5445 : : */
5446 : :
5447 : : static void WalkRecordAlignment (unsigned int sym, M2GCCDeclare_WalkAction p);
5448 : :
5449 : : /*
5450 : : WalkRecordDependants - walks symbol, sym, dependants. It only
5451 : : walks the fields if the alignment is
5452 : : unused or fully declared.
5453 : : */
5454 : :
5455 : : static void WalkRecordDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5456 : :
5457 : : /*
5458 : : WalkRecordFieldDependants -
5459 : : */
5460 : :
5461 : : static void WalkRecordFieldDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5462 : :
5463 : : /*
5464 : : WalkRecordDependants2 - walks the fields of record, sym, calling
5465 : : p on every dependant.
5466 : : */
5467 : :
5468 : : static void WalkRecordDependants2 (unsigned int sym, M2GCCDeclare_WalkAction p);
5469 : :
5470 : : /*
5471 : : IsVarientAlignment -
5472 : : */
5473 : :
5474 : : static bool IsVarientAlignment (unsigned int sym, M2GCCDeclare_IsAction q);
5475 : :
5476 : : /*
5477 : : IsVarientDependants - returns TRUE if the symbol, sym,
5478 : : q(dependants) all return TRUE.
5479 : : */
5480 : :
5481 : : static bool IsVarientDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5482 : :
5483 : : /*
5484 : : WalkVarientAlignment -
5485 : : */
5486 : :
5487 : : static void WalkVarientAlignment (unsigned int sym, M2GCCDeclare_WalkAction p);
5488 : :
5489 : : /*
5490 : : WalkVarientDependants - walks symbol, sym, dependants.
5491 : : */
5492 : :
5493 : : static void WalkVarientDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5494 : :
5495 : : /*
5496 : : IsVarientFieldDependants - returns TRUE if the symbol, sym,
5497 : : q(dependants) all return TRUE.
5498 : : */
5499 : :
5500 : : static bool IsVarientFieldDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5501 : :
5502 : : /*
5503 : : WalkVarientFieldDependants -
5504 : : */
5505 : :
5506 : : static void WalkVarientFieldDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5507 : :
5508 : : /*
5509 : : IsArrayDependants - returns TRUE if the symbol, sym,
5510 : : q(dependants) all return TRUE.
5511 : :
5512 : : */
5513 : :
5514 : : static bool IsArrayDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5515 : :
5516 : : /*
5517 : : WalkArrayDependants - walks symbol, sym, dependants.
5518 : : */
5519 : :
5520 : : static void WalkArrayDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5521 : :
5522 : : /*
5523 : : IsSetDependants - returns TRUE if the symbol, sym,
5524 : : q(dependants) all return TRUE.
5525 : : */
5526 : :
5527 : : static bool IsSetDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5528 : :
5529 : : /*
5530 : : WalkSetDependants - walks dependants, sym.
5531 : : */
5532 : :
5533 : : static void WalkSetDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5534 : :
5535 : : /*
5536 : : IsProcTypeDependants -
5537 : : */
5538 : :
5539 : : static bool IsProcTypeDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5540 : :
5541 : : /*
5542 : : WalkProcTypeDependants - walks dependants, sym.
5543 : : */
5544 : :
5545 : : static void WalkProcTypeDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5546 : :
5547 : : /*
5548 : : IsProcedureDependants -
5549 : : */
5550 : :
5551 : : static bool IsProcedureDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5552 : :
5553 : : /*
5554 : : WalkProcedureDependants - walks dependants, sym.
5555 : : */
5556 : :
5557 : : static void WalkProcedureDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5558 : :
5559 : : /*
5560 : : IsUnboundedDependants - returns TRUE if the symbol, sym,
5561 : : q(dependants) all return TRUE.
5562 : : */
5563 : :
5564 : : static bool IsUnboundedDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5565 : :
5566 : : /*
5567 : : WalkUnboundedDependants - walks the dependants of, sym.
5568 : : */
5569 : :
5570 : : static void WalkUnboundedDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5571 : :
5572 : : /*
5573 : : IsTypeDependants - returns TRUE if all q(dependants) return
5574 : : TRUE.
5575 : : */
5576 : :
5577 : : static bool IsTypeDependants (unsigned int sym, M2GCCDeclare_IsAction q);
5578 : :
5579 : : /*
5580 : : WalkTypeDependants - walks all dependants of, sym.
5581 : : */
5582 : :
5583 : : static void WalkTypeDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
5584 : :
5585 : 0 : static void mystop (void)
5586 : : {
5587 : 0 : }
5588 : :
5589 : :
5590 : : /*
5591 : : PrintNum -
5592 : : */
5593 : :
5594 : 0 : static void PrintNum (unsigned int sym)
5595 : : {
5596 : 0 : M2Printf_printf1 ((const char *) "%d, ", 4, (const unsigned char *) &sym, (sizeof (sym)-1));
5597 : 0 : }
5598 : :
5599 : :
5600 : : /*
5601 : : DebugSet -
5602 : : */
5603 : :
5604 : 0 : static void DebugSet (const char *a_, unsigned int _a_high, Sets_Set l)
5605 : : {
5606 : 0 : char a[_a_high+1];
5607 : :
5608 : : /* make a local copy of each unbounded array. */
5609 : 0 : memcpy (a, a_, _a_high+1);
5610 : :
5611 : 0 : M2Printf_printf0 ((const char *) a, _a_high);
5612 : 0 : M2Printf_printf0 ((const char *) " {", 2);
5613 : 0 : Sets_ForeachElementInSetDo (l, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PrintNum});
5614 : 0 : M2Printf_printf0 ((const char *) "}\\n", 3);
5615 : 0 : }
5616 : :
5617 : :
5618 : : /*
5619 : : DebugSets -
5620 : : */
5621 : :
5622 : 0 : static void DebugSets (void)
5623 : : {
5624 : 0 : DebugSet ((const char *) "ToDoList", 8, GlobalGroup->ToDoList);
5625 : 0 : DebugSet ((const char *) "HeldByAlignment", 15, GlobalGroup->HeldByAlignment);
5626 : 0 : DebugSet ((const char *) "FinishedAlignment", 17, GlobalGroup->FinishedAlignment);
5627 : 0 : DebugSet ((const char *) "PartiallyDeclared", 17, GlobalGroup->PartiallyDeclared);
5628 : 0 : DebugSet ((const char *) "FullyDeclared", 13, GlobalGroup->FullyDeclared);
5629 : 0 : DebugSet ((const char *) "NilTypedArrays", 14, GlobalGroup->NilTypedArrays);
5630 : 0 : DebugSet ((const char *) "ToBeSolvedByQuads", 17, GlobalGroup->ToBeSolvedByQuads);
5631 : 0 : DebugSet ((const char *) "FinishedSetArray", 16, GlobalGroup->FinishedSetArray);
5632 : 0 : }
5633 : :
5634 : :
5635 : : /*
5636 : : DebugNumber -
5637 : : */
5638 : :
5639 : 0 : static void DebugNumber (const char *a_, unsigned int _a_high, Sets_Set s)
5640 : : {
5641 : 0 : unsigned int n;
5642 : 0 : char a[_a_high+1];
5643 : :
5644 : : /* make a local copy of each unbounded array. */
5645 : 0 : memcpy (a, a_, _a_high+1);
5646 : :
5647 : 0 : n = Sets_NoOfElementsInSet (s);
5648 : 0 : M2Printf_printf1 ((const char *) a, _a_high, (const unsigned char *) &n, (sizeof (n)-1));
5649 : 0 : FIO_FlushBuffer (FIO_StdOut);
5650 : 0 : }
5651 : :
5652 : 0 : static void DebugSetNumbers (void)
5653 : : {
5654 : : /*
5655 : : DebugSets -
5656 : : */
5657 : 0 : DebugNumber ((const char *) "ToDoList : %d\\n", 15, GlobalGroup->ToDoList);
5658 : 0 : DebugNumber ((const char *) "HeldByAlignment : %d\\n", 22, GlobalGroup->HeldByAlignment);
5659 : 0 : DebugNumber ((const char *) "PartiallyDeclared : %d\\n", 24, GlobalGroup->PartiallyDeclared);
5660 : 0 : DebugNumber ((const char *) "FullyDeclared : %d\\n", 20, GlobalGroup->FullyDeclared);
5661 : 0 : DebugNumber ((const char *) "NilTypedArrays : %d\\n", 21, GlobalGroup->NilTypedArrays);
5662 : 0 : DebugNumber ((const char *) "ToBeSolvedByQuads : %d\\n", 24, GlobalGroup->ToBeSolvedByQuads);
5663 : 0 : DebugNumber ((const char *) "FinishedSetArray : %d\\n", 23, GlobalGroup->FinishedSetArray);
5664 : 0 : }
5665 : :
5666 : :
5667 : : /*
5668 : : AddSymToWatch - adds symbol, sym, to the list of symbols
5669 : : to watch and annotate their movement between
5670 : : lists.
5671 : : */
5672 : :
5673 : 0 : static void AddSymToWatch (unsigned int sym)
5674 : : {
5675 : 0 : if ((sym != SymbolTable_NulSym) && (! (Sets_IsElementInSet (WatchList, sym))))
5676 : : {
5677 : 0 : Sets_IncludeElementIntoSet (WatchList, sym);
5678 : 0 : WalkDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) AddSymToWatch});
5679 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "%d, ", 4, (const unsigned char *) &sym, (sizeof (sym)-1));
5680 : : }
5681 : 0 : }
5682 : :
5683 : :
5684 : : /*
5685 : : doInclude -
5686 : : */
5687 : :
5688 : 0 : static void doInclude (Sets_Set l, const char *a_, unsigned int _a_high, unsigned int sym)
5689 : : {
5690 : 0 : char a[_a_high+1];
5691 : :
5692 : : /* make a local copy of each unbounded array. */
5693 : 0 : memcpy (a, a_, _a_high+1);
5694 : :
5695 : 0 : if (! (Sets_IsElementInSet (l, sym)))
5696 : : {
5697 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "rule: ", 6);
5698 : 0 : WriteRule ();
5699 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " ", 2);
5700 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) a, _a_high, (const unsigned char *) &sym, (sizeof (sym)-1));
5701 : 0 : Sets_IncludeElementIntoSet (l, sym);
5702 : : }
5703 : 0 : }
5704 : :
5705 : :
5706 : : /*
5707 : : WatchIncludeList - include a symbol onto the set first checking
5708 : : whether it is already on the set and
5709 : : displaying a debug message if the set is
5710 : : changed.
5711 : : */
5712 : :
5713 : 12411106 : static void WatchIncludeList (unsigned int sym, M2GCCDeclare_ListType lt)
5714 : : {
5715 : 12411106 : if (Sets_IsElementInSet (WatchList, sym))
5716 : : {
5717 : 0 : switch (lt)
5718 : : {
5719 : 0 : case M2GCCDeclare_tobesolvedbyquads:
5720 : 0 : doInclude (GlobalGroup->ToBeSolvedByQuads, (const char *) "symbol %d -> ToBeSolvedByQuads\\n", 32, sym);
5721 : 0 : break;
5722 : :
5723 : 0 : case M2GCCDeclare_fullydeclared:
5724 : 0 : doInclude (GlobalGroup->FullyDeclared, (const char *) "symbol %d -> FullyDeclared\\n", 28, sym);
5725 : 0 : break;
5726 : :
5727 : 0 : case M2GCCDeclare_partiallydeclared:
5728 : 0 : doInclude (GlobalGroup->PartiallyDeclared, (const char *) "symbol %d -> PartiallyDeclared\\n", 32, sym);
5729 : 0 : break;
5730 : :
5731 : 0 : case M2GCCDeclare_heldbyalignment:
5732 : 0 : doInclude (GlobalGroup->HeldByAlignment, (const char *) "symbol %d -> HeldByAlignment\\n", 30, sym);
5733 : 0 : break;
5734 : :
5735 : 0 : case M2GCCDeclare_finishedalignment:
5736 : 0 : doInclude (GlobalGroup->FinishedAlignment, (const char *) "symbol %d -> FinishedAlignment\\n", 32, sym);
5737 : 0 : break;
5738 : :
5739 : 0 : case M2GCCDeclare_todolist:
5740 : 0 : doInclude (GlobalGroup->ToDoList, (const char *) "symbol %d -> ToDoList\\n", 23, sym);
5741 : 0 : break;
5742 : :
5743 : 0 : case M2GCCDeclare_niltypedarrays:
5744 : 0 : doInclude (GlobalGroup->NilTypedArrays, (const char *) "symbol %d -> NilTypedArrays\\n", 29, sym);
5745 : 0 : break;
5746 : :
5747 : 0 : case M2GCCDeclare_finishedsetarray:
5748 : 0 : doInclude (GlobalGroup->FinishedSetArray, (const char *) "symbol %d -> FinishedSetArray\\n", 31, sym);
5749 : 0 : break;
5750 : :
5751 : :
5752 : 0 : default:
5753 : 0 : M2Error_InternalError ((const char *) "unknown list", 12);
5754 : : break;
5755 : : }
5756 : : }
5757 : : else
5758 : : {
5759 : 12411106 : switch (lt)
5760 : : {
5761 : 277058 : case M2GCCDeclare_tobesolvedbyquads:
5762 : 277058 : Sets_IncludeElementIntoSet (GlobalGroup->ToBeSolvedByQuads, sym);
5763 : 277058 : break;
5764 : :
5765 : 8943785 : case M2GCCDeclare_fullydeclared:
5766 : 8943785 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, sym);
5767 : 8943785 : break;
5768 : :
5769 : 126568 : case M2GCCDeclare_partiallydeclared:
5770 : 126568 : Sets_IncludeElementIntoSet (GlobalGroup->PartiallyDeclared, sym);
5771 : 126568 : break;
5772 : :
5773 : 74853 : case M2GCCDeclare_heldbyalignment:
5774 : 74853 : Sets_IncludeElementIntoSet (GlobalGroup->HeldByAlignment, sym);
5775 : 74853 : break;
5776 : :
5777 : 554976 : case M2GCCDeclare_finishedalignment:
5778 : 554976 : Sets_IncludeElementIntoSet (GlobalGroup->FinishedAlignment, sym);
5779 : 554976 : break;
5780 : :
5781 : 2429767 : case M2GCCDeclare_todolist:
5782 : 2429767 : Sets_IncludeElementIntoSet (GlobalGroup->ToDoList, sym);
5783 : 2429767 : break;
5784 : :
5785 : 4099 : case M2GCCDeclare_niltypedarrays:
5786 : 4099 : Sets_IncludeElementIntoSet (GlobalGroup->NilTypedArrays, sym);
5787 : 4099 : break;
5788 : :
5789 : 0 : case M2GCCDeclare_finishedsetarray:
5790 : 0 : Sets_IncludeElementIntoSet (GlobalGroup->FinishedSetArray, sym);
5791 : 0 : break;
5792 : :
5793 : :
5794 : 0 : default:
5795 : 0 : M2Error_InternalError ((const char *) "unknown list", 12);
5796 : 12411106 : break;
5797 : : }
5798 : : }
5799 : 12411106 : }
5800 : :
5801 : :
5802 : : /*
5803 : : doExclude -
5804 : : */
5805 : :
5806 : 0 : static void doExclude (Sets_Set l, const char *a_, unsigned int _a_high, unsigned int sym)
5807 : : {
5808 : 0 : char a[_a_high+1];
5809 : :
5810 : : /* make a local copy of each unbounded array. */
5811 : 0 : memcpy (a, a_, _a_high+1);
5812 : :
5813 : 0 : if (Sets_IsElementInSet (l, sym))
5814 : : {
5815 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "rule: ", 6);
5816 : 0 : WriteRule ();
5817 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " ", 2);
5818 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) a, _a_high, (const unsigned char *) &sym, (sizeof (sym)-1));
5819 : 0 : Sets_ExcludeElementFromSet (l, sym);
5820 : : }
5821 : 0 : }
5822 : :
5823 : :
5824 : : /*
5825 : : WatchRemoveList - remove a symbol onto the list first checking
5826 : : whether it is already on the list and
5827 : : displaying a debug message if the list is
5828 : : changed.
5829 : : */
5830 : :
5831 : 14585412 : static void WatchRemoveList (unsigned int sym, M2GCCDeclare_ListType lt)
5832 : : {
5833 : 14585412 : if (Sets_IsElementInSet (WatchList, sym))
5834 : : {
5835 : 0 : switch (lt)
5836 : : {
5837 : 0 : case M2GCCDeclare_tobesolvedbyquads:
5838 : 0 : doExclude (GlobalGroup->ToBeSolvedByQuads, (const char *) "symbol %d off ToBeSolvedByQuads\\n", 33, sym);
5839 : 0 : break;
5840 : :
5841 : 0 : case M2GCCDeclare_fullydeclared:
5842 : 0 : doExclude (GlobalGroup->FullyDeclared, (const char *) "symbol %d off FullyDeclared\\n", 29, sym);
5843 : 0 : break;
5844 : :
5845 : 0 : case M2GCCDeclare_partiallydeclared:
5846 : 0 : doExclude (GlobalGroup->PartiallyDeclared, (const char *) "symbol %d off PartiallyDeclared\\n", 33, sym);
5847 : 0 : break;
5848 : :
5849 : 0 : case M2GCCDeclare_heldbyalignment:
5850 : 0 : doExclude (GlobalGroup->HeldByAlignment, (const char *) "symbol %d -> HeldByAlignment\\n", 30, sym);
5851 : 0 : break;
5852 : :
5853 : 0 : case M2GCCDeclare_finishedalignment:
5854 : 0 : doExclude (GlobalGroup->FinishedAlignment, (const char *) "symbol %d -> FinishedAlignment\\n", 32, sym);
5855 : 0 : break;
5856 : :
5857 : 0 : case M2GCCDeclare_todolist:
5858 : 0 : doExclude (GlobalGroup->ToDoList, (const char *) "symbol %d off ToDoList\\n", 24, sym);
5859 : 0 : break;
5860 : :
5861 : 0 : case M2GCCDeclare_niltypedarrays:
5862 : 0 : doExclude (GlobalGroup->NilTypedArrays, (const char *) "symbol %d off NilTypedArrays\\n", 30, sym);
5863 : 0 : break;
5864 : :
5865 : 0 : case M2GCCDeclare_finishedsetarray:
5866 : 0 : doExclude (GlobalGroup->FinishedSetArray, (const char *) "symbol %d off FinishedSetArray\\n", 32, sym);
5867 : 0 : break;
5868 : :
5869 : :
5870 : 0 : default:
5871 : 0 : M2Error_InternalError ((const char *) "unknown list", 12);
5872 : : break;
5873 : : }
5874 : : }
5875 : : else
5876 : : {
5877 : 14585412 : switch (lt)
5878 : : {
5879 : 348819 : case M2GCCDeclare_tobesolvedbyquads:
5880 : 348819 : Sets_ExcludeElementFromSet (GlobalGroup->ToBeSolvedByQuads, sym);
5881 : 348819 : break;
5882 : :
5883 : 0 : case M2GCCDeclare_fullydeclared:
5884 : 0 : Sets_ExcludeElementFromSet (GlobalGroup->FullyDeclared, sym);
5885 : 0 : break;
5886 : :
5887 : 1519560 : case M2GCCDeclare_partiallydeclared:
5888 : 1519560 : Sets_ExcludeElementFromSet (GlobalGroup->PartiallyDeclared, sym);
5889 : 1519560 : break;
5890 : :
5891 : 1364252 : case M2GCCDeclare_heldbyalignment:
5892 : 1364252 : Sets_ExcludeElementFromSet (GlobalGroup->HeldByAlignment, sym);
5893 : 1364252 : break;
5894 : :
5895 : 1288583 : case M2GCCDeclare_finishedalignment:
5896 : 1288583 : Sets_ExcludeElementFromSet (GlobalGroup->FinishedAlignment, sym);
5897 : 1288583 : break;
5898 : :
5899 : 10060939 : case M2GCCDeclare_todolist:
5900 : 10060939 : Sets_ExcludeElementFromSet (GlobalGroup->ToDoList, sym);
5901 : 10060939 : break;
5902 : :
5903 : 3259 : case M2GCCDeclare_niltypedarrays:
5904 : 3259 : Sets_ExcludeElementFromSet (GlobalGroup->NilTypedArrays, sym);
5905 : 3259 : break;
5906 : :
5907 : 0 : case M2GCCDeclare_finishedsetarray:
5908 : 0 : Sets_ExcludeElementFromSet (GlobalGroup->FinishedSetArray, sym);
5909 : 0 : break;
5910 : :
5911 : :
5912 : 0 : default:
5913 : 0 : M2Error_InternalError ((const char *) "unknown list", 12);
5914 : 14585412 : break;
5915 : : }
5916 : : }
5917 : 14585412 : }
5918 : :
5919 : :
5920 : : /*
5921 : : NewGroup -
5922 : : */
5923 : :
5924 : 1663181 : static void NewGroup (M2GCCDeclare_Group *g)
5925 : : {
5926 : 1663181 : if (FreeGroup == NULL)
5927 : : {
5928 : 50325 : Storage_ALLOCATE ((void **) &(*g), sizeof (M2GCCDeclare__T15));
5929 : : }
5930 : : else
5931 : : {
5932 : 1612856 : (*g) = FreeGroup;
5933 : 1612856 : FreeGroup = FreeGroup->Next;
5934 : : }
5935 : 1663181 : }
5936 : :
5937 : :
5938 : : /*
5939 : : DisposeGroup -
5940 : : */
5941 : :
5942 : 1650110 : static void DisposeGroup (M2GCCDeclare_Group *g)
5943 : : {
5944 : 1650110 : (*g)->Next = FreeGroup;
5945 : 1650110 : FreeGroup = (*g);
5946 : 1650110 : (*g) = NULL;
5947 : 1650110 : }
5948 : :
5949 : :
5950 : : /*
5951 : : InitGroup - initialize all sets in group and return the group.
5952 : : */
5953 : :
5954 : 12963 : static M2GCCDeclare_Group InitGroup (void)
5955 : : {
5956 : 12963 : M2GCCDeclare_Group g;
5957 : :
5958 : 12963 : NewGroup (&g);
5959 : : /* Initialize all sets in group. */
5960 : 12963 : g->FinishedSetArray = Sets_InitSet (1);
5961 : 12963 : g->ToDoList = Sets_InitSet (1);
5962 : 12963 : g->FullyDeclared = Sets_InitSet (1);
5963 : 12963 : g->PartiallyDeclared = Sets_InitSet (1);
5964 : 12963 : g->NilTypedArrays = Sets_InitSet (1);
5965 : 12963 : g->HeldByAlignment = Sets_InitSet (1);
5966 : 12963 : g->FinishedAlignment = Sets_InitSet (1);
5967 : 12963 : g->ToBeSolvedByQuads = Sets_InitSet (1);
5968 : 12963 : g->Next = NULL;
5969 : 12963 : return g;
5970 : : /* static analysis guarentees a RETURN statement will be used before here. */
5971 : : __builtin_unreachable ();
5972 : : }
5973 : :
5974 : :
5975 : : /*
5976 : : KillGroup - delete all sets in group and deallocate g.
5977 : : */
5978 : :
5979 : 1650110 : static void KillGroup (M2GCCDeclare_Group *g)
5980 : : {
5981 : : /* Delete all sets in group. */
5982 : 1650110 : if ((*g) != NULL)
5983 : : {
5984 : 1650110 : (*g)->FinishedSetArray = Sets_KillSet ((*g)->FinishedSetArray);
5985 : 1650110 : (*g)->ToDoList = Sets_KillSet ((*g)->ToDoList);
5986 : 1650110 : (*g)->FullyDeclared = Sets_KillSet ((*g)->FullyDeclared);
5987 : 1650110 : (*g)->PartiallyDeclared = Sets_KillSet ((*g)->PartiallyDeclared);
5988 : 1650110 : (*g)->NilTypedArrays = Sets_KillSet ((*g)->NilTypedArrays);
5989 : 1650110 : (*g)->HeldByAlignment = Sets_KillSet ((*g)->HeldByAlignment);
5990 : 1650110 : (*g)->FinishedAlignment = Sets_KillSet ((*g)->FinishedAlignment);
5991 : 1650110 : (*g)->ToBeSolvedByQuads = Sets_KillSet ((*g)->ToBeSolvedByQuads);
5992 : 1650110 : (*g)->Next = NULL;
5993 : 1650110 : DisposeGroup (g);
5994 : : }
5995 : 1650110 : }
5996 : :
5997 : :
5998 : : /*
5999 : : DupGroup - If g is not NIL then destroy g.
6000 : : Return a duplicate of GlobalGroup.
6001 : : */
6002 : :
6003 : 1650218 : static M2GCCDeclare_Group DupGroup (M2GCCDeclare_Group g)
6004 : : {
6005 : 1650218 : if (g != NULL)
6006 : : {
6007 : : /* Kill old group. */
6008 : 204576 : KillGroup (&g);
6009 : : }
6010 : 1650218 : NewGroup (&g);
6011 : : /* Copy all sets. */
6012 : 1650218 : g->FinishedSetArray = Sets_DuplicateSet (GlobalGroup->FinishedSetArray);
6013 : 1650218 : g->ToDoList = Sets_DuplicateSet (GlobalGroup->ToDoList);
6014 : 1650218 : g->FullyDeclared = Sets_DuplicateSet (GlobalGroup->FullyDeclared);
6015 : 1650218 : g->PartiallyDeclared = Sets_DuplicateSet (GlobalGroup->PartiallyDeclared);
6016 : 1650218 : g->NilTypedArrays = Sets_DuplicateSet (GlobalGroup->NilTypedArrays);
6017 : 1650218 : g->HeldByAlignment = Sets_DuplicateSet (GlobalGroup->HeldByAlignment);
6018 : 1650218 : g->FinishedAlignment = Sets_DuplicateSet (GlobalGroup->FinishedAlignment);
6019 : 1650218 : g->ToBeSolvedByQuads = Sets_DuplicateSet (GlobalGroup->ToBeSolvedByQuads);
6020 : 1650218 : g->Next = NULL;
6021 : 1650218 : return g;
6022 : : /* static analysis guarentees a RETURN statement will be used before here. */
6023 : : __builtin_unreachable ();
6024 : : }
6025 : :
6026 : :
6027 : : /*
6028 : : EqualGroup - return TRUE if group left = right.
6029 : : */
6030 : :
6031 : 826419 : static bool EqualGroup (M2GCCDeclare_Group left, M2GCCDeclare_Group right)
6032 : : {
6033 : 826419 : return (left == right) || ((((((((Sets_EqualSet (left->FullyDeclared, right->FullyDeclared)) && (Sets_EqualSet (left->PartiallyDeclared, right->PartiallyDeclared))) && (Sets_EqualSet (left->NilTypedArrays, right->NilTypedArrays))) && (Sets_EqualSet (left->HeldByAlignment, right->HeldByAlignment))) && (Sets_EqualSet (left->FinishedAlignment, right->FinishedAlignment))) && (Sets_EqualSet (left->ToDoList, right->ToDoList))) && (Sets_EqualSet (left->ToBeSolvedByQuads, right->ToBeSolvedByQuads))) && (Sets_EqualSet (left->FinishedSetArray, right->FinishedSetArray)));
6034 : : /* static analysis guarentees a RETURN statement will be used before here. */
6035 : : __builtin_unreachable ();
6036 : : }
6037 : :
6038 : :
6039 : : /*
6040 : : LookupSet -
6041 : : */
6042 : :
6043 : 10116042 : static Sets_Set LookupSet (M2GCCDeclare_ListType listtype)
6044 : : {
6045 : 10116042 : switch (listtype)
6046 : : {
6047 : 0 : case M2GCCDeclare_fullydeclared:
6048 : 0 : return GlobalGroup->FullyDeclared;
6049 : 1462796 : break;
6050 : :
6051 : 1462796 : case M2GCCDeclare_partiallydeclared:
6052 : 1462796 : return GlobalGroup->PartiallyDeclared;
6053 : 1643269 : break;
6054 : :
6055 : 1643269 : case M2GCCDeclare_niltypedarrays:
6056 : 1643269 : return GlobalGroup->NilTypedArrays;
6057 : 904186 : break;
6058 : :
6059 : 904186 : case M2GCCDeclare_heldbyalignment:
6060 : 904186 : return GlobalGroup->HeldByAlignment;
6061 : 900513 : break;
6062 : :
6063 : 900513 : case M2GCCDeclare_finishedalignment:
6064 : 900513 : return GlobalGroup->FinishedAlignment;
6065 : 5205278 : break;
6066 : :
6067 : 5205278 : case M2GCCDeclare_todolist:
6068 : 5205278 : return GlobalGroup->ToDoList;
6069 : 0 : break;
6070 : :
6071 : 0 : case M2GCCDeclare_tobesolvedbyquads:
6072 : 0 : return GlobalGroup->ToBeSolvedByQuads;
6073 : 0 : break;
6074 : :
6075 : 0 : case M2GCCDeclare_finishedsetarray:
6076 : 0 : return GlobalGroup->FinishedSetArray;
6077 : 0 : break;
6078 : :
6079 : :
6080 : 0 : default:
6081 : 0 : M2Error_InternalError ((const char *) "unknown ListType", 16);
6082 : : break;
6083 : : }
6084 : : return NULL;
6085 : : /* static analysis guarentees a RETURN statement will be used before here. */
6086 : : __builtin_unreachable ();
6087 : : }
6088 : :
6089 : :
6090 : : /*
6091 : : GetEnumList -
6092 : : */
6093 : :
6094 : 411840 : static m2tree_Tree GetEnumList (unsigned int sym)
6095 : : {
6096 : 411840 : if (Indexing_InBounds (EnumerationIndex, sym))
6097 : : {
6098 : 393736 : return Indexing_GetIndice (EnumerationIndex, sym);
6099 : : }
6100 : : else
6101 : : {
6102 : : return NULL;
6103 : : }
6104 : : /* static analysis guarentees a RETURN statement will be used before here. */
6105 : : __builtin_unreachable ();
6106 : : }
6107 : :
6108 : :
6109 : : /*
6110 : : PutEnumList -
6111 : : */
6112 : :
6113 : 390413 : static void PutEnumList (unsigned int sym, m2tree_Tree enumlist)
6114 : : {
6115 : 0 : Indexing_PutIndice (EnumerationIndex, sym, enumlist);
6116 : 0 : }
6117 : :
6118 : :
6119 : : /*
6120 : : Chained - checks to see that, sym, has not already been placed on a chain.
6121 : : It returns the symbol, sym.
6122 : : */
6123 : :
6124 : 297090 : static unsigned int Chained (unsigned int sym)
6125 : : {
6126 : 297090 : if (Sets_IsElementInSet (ChainedList, sym))
6127 : : {
6128 : 0 : M2Error_InternalError ((const char *) "symbol has already been chained onto a previous list", 52);
6129 : : }
6130 : 297090 : Sets_IncludeElementIntoSet (ChainedList, sym);
6131 : 297090 : return sym;
6132 : : /* static analysis guarentees a RETURN statement will be used before here. */
6133 : : __builtin_unreachable ();
6134 : : }
6135 : :
6136 : :
6137 : : /*
6138 : : DoStartDeclaration - returns a tree representing a symbol which has
6139 : : not yet been finished. Used when declaring
6140 : : recursive types.
6141 : : */
6142 : :
6143 : 246774 : static m2tree_Tree DoStartDeclaration (unsigned int sym, M2GCCDeclare_StartProcedure p)
6144 : : {
6145 : 246774 : m2linemap_location_t location;
6146 : :
6147 : 246774 : if (! (SymbolConversion_GccKnowsAbout (sym)))
6148 : : {
6149 : 123387 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
6150 : 123387 : PreAddModGcc (sym, reinterpret_cast<m2tree_Tree> ((*p.proc) (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)))));
6151 : : }
6152 : 246774 : return SymbolConversion_Mod2Gcc (sym);
6153 : : /* static analysis guarentees a RETURN statement will be used before here. */
6154 : : __builtin_unreachable ();
6155 : : }
6156 : :
6157 : :
6158 : : /*
6159 : : ArrayComponentsDeclared - returns TRUE if array, sym,
6160 : : subscripts and type are known.
6161 : : */
6162 : :
6163 : 900066 : static bool ArrayComponentsDeclared (unsigned int sym)
6164 : : {
6165 : 900066 : unsigned int Subscript;
6166 : 900066 : unsigned int Type;
6167 : 900066 : unsigned int High;
6168 : 900066 : unsigned int Low;
6169 : :
6170 : 900066 : Subscript = SymbolTable_GetArraySubscript (sym);
6171 : 900066 : M2Debug_Assert (SymbolTable_IsSubscript (Subscript));
6172 : 900066 : Type = SymbolTable_GetDType (Subscript);
6173 : 900066 : Low = M2GCCDeclare_GetTypeMin (Type);
6174 : 900066 : High = M2GCCDeclare_GetTypeMax (Type);
6175 : 908138 : return ((IsFullyDeclared (Type)) && (IsFullyDeclared (Low))) && (IsFullyDeclared (High));
6176 : : /* static analysis guarentees a RETURN statement will be used before here. */
6177 : : __builtin_unreachable ();
6178 : : }
6179 : :
6180 : :
6181 : : /*
6182 : : GetRecordOfVarient -
6183 : : */
6184 : :
6185 : 140733 : static unsigned int GetRecordOfVarient (unsigned int sym)
6186 : : {
6187 : 140733 : if ((SymbolTable_IsVarient (sym)) || (SymbolTable_IsFieldVarient (sym)))
6188 : : {
6189 : 67536 : do {
6190 : 67536 : sym = SymbolTable_GetParent (sym);
6191 : 67536 : } while (! (SymbolTable_IsRecord (sym)));
6192 : : }
6193 : 140733 : return sym;
6194 : : /* static analysis guarentees a RETURN statement will be used before here. */
6195 : : __builtin_unreachable ();
6196 : : }
6197 : :
6198 : :
6199 : : /*
6200 : : CanDeclareRecordKind -
6201 : : */
6202 : :
6203 : 75519 : static bool CanDeclareRecordKind (unsigned int sym)
6204 : : {
6205 : 75519 : sym = GetRecordOfVarient (sym);
6206 : 76221 : return (SymbolTable_IsRecord (sym)) && (((SymbolTable_GetDefaultRecordFieldAlignment (sym)) == SymbolTable_NulSym) || (IsFullyDeclared (SymbolTable_GetDefaultRecordFieldAlignment (sym))));
6207 : : /* static analysis guarentees a RETURN statement will be used before here. */
6208 : : __builtin_unreachable ();
6209 : : }
6210 : :
6211 : :
6212 : : /*
6213 : : DeclareRecordKind - works out whether record, sym, is packed or not.
6214 : : */
6215 : :
6216 : 74853 : static void DeclareRecordKind (unsigned int sym)
6217 : : {
6218 : 74853 : if (SymbolTable_IsRecord (sym))
6219 : : {
6220 : 73911 : DetermineIfRecordPacked (sym);
6221 : : }
6222 : 74853 : WatchIncludeList (sym, M2GCCDeclare_todolist);
6223 : 74853 : WatchRemoveList (sym, M2GCCDeclare_heldbyalignment);
6224 : 74853 : WatchIncludeList (sym, M2GCCDeclare_finishedalignment);
6225 : 149706 : if (AllDependantsFullyDeclared (sym))
6226 : : {} /* empty. */
6227 : : /* All good and ready to be solved. */
6228 : 74853 : }
6229 : :
6230 : :
6231 : : /*
6232 : : CanDeclareRecord -
6233 : : */
6234 : :
6235 : 554160 : static bool CanDeclareRecord (unsigned int sym)
6236 : : {
6237 : 554160 : TraverseDependants (sym);
6238 : 554160 : if (AllDependantsFullyDeclared (sym))
6239 : : {
6240 : : return true;
6241 : : }
6242 : : else
6243 : : {
6244 : 480123 : WatchIncludeList (sym, M2GCCDeclare_finishedalignment);
6245 : 480123 : return false;
6246 : : }
6247 : : /* static analysis guarentees a RETURN statement will be used before here. */
6248 : : __builtin_unreachable ();
6249 : : }
6250 : :
6251 : :
6252 : : /*
6253 : : FinishDeclareRecord -
6254 : : */
6255 : :
6256 : 74037 : static void FinishDeclareRecord (unsigned int sym)
6257 : : {
6258 : 74037 : DeclareTypeConstFully (sym);
6259 : 74037 : WatchRemoveList (sym, M2GCCDeclare_heldbyalignment);
6260 : 74037 : WatchRemoveList (sym, M2GCCDeclare_finishedalignment);
6261 : 74037 : WatchRemoveList (sym, M2GCCDeclare_todolist);
6262 : 74037 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
6263 : 74037 : }
6264 : :
6265 : :
6266 : : /*
6267 : : CanDeclareTypePartially - return TRUE if we are able to make a
6268 : : gcc partially created type.
6269 : : */
6270 : :
6271 : 15188215 : static bool CanDeclareTypePartially (unsigned int sym)
6272 : : {
6273 : 15188215 : unsigned int type;
6274 : :
6275 : 15188215 : if (Sets_IsElementInSet (GlobalGroup->PartiallyDeclared, sym))
6276 : : {
6277 : : return false;
6278 : : }
6279 : 14528101 : else if ((((SymbolTable_IsProcType (sym)) || (SymbolTable_IsRecord (sym))) || (SymbolTable_IsVarient (sym))) || (SymbolTable_IsFieldVarient (sym)))
6280 : : {
6281 : : /* avoid dangling else. */
6282 : 123387 : return true;
6283 : : }
6284 : 14404714 : else if (SymbolTable_IsType (sym))
6285 : : {
6286 : : /* avoid dangling else. */
6287 : 54618 : type = SymbolTable_GetSType (sym);
6288 : 109236 : if ((type != SymbolTable_NulSym) && (IsNilTypedArrays (type)))
6289 : : {
6290 : : return true;
6291 : : }
6292 : : }
6293 : : return false;
6294 : : /* static analysis guarentees a RETURN statement will be used before here. */
6295 : : __builtin_unreachable ();
6296 : : }
6297 : :
6298 : :
6299 : : /*
6300 : : DeclareTypePartially - create the gcc partial type symbol from, sym.
6301 : : */
6302 : :
6303 : 123393 : static void DeclareTypePartially (unsigned int sym)
6304 : : {
6305 : 123393 : m2linemap_location_t location;
6306 : :
6307 : : /* check to see if we have already partially declared the symbol */
6308 : 123393 : if (! (Sets_IsElementInSet (GlobalGroup->PartiallyDeclared, sym)))
6309 : : {
6310 : 123393 : if (SymbolTable_IsRecord (sym))
6311 : : {
6312 : 73911 : M2Debug_Assert (! (Sets_IsElementInSet (GlobalGroup->HeldByAlignment, sym)));
6313 : 73911 : M2Debug_Assert ((DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartRecord})) != NULL);
6314 : 73911 : WatchIncludeList (sym, M2GCCDeclare_heldbyalignment);
6315 : : }
6316 : 49482 : else if (SymbolTable_IsVarient (sym))
6317 : : {
6318 : : /* avoid dangling else. */
6319 : 276 : M2Debug_Assert (! (Sets_IsElementInSet (GlobalGroup->HeldByAlignment, sym)));
6320 : 276 : M2Debug_Assert ((DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartVarient})) != NULL);
6321 : 276 : WatchIncludeList (sym, M2GCCDeclare_heldbyalignment);
6322 : : }
6323 : 49206 : else if (SymbolTable_IsFieldVarient (sym))
6324 : : {
6325 : : /* avoid dangling else. */
6326 : 666 : M2Debug_Assert (! (Sets_IsElementInSet (GlobalGroup->HeldByAlignment, sym)));
6327 : 666 : M2Debug_Assert ((DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartFieldVarient})) != NULL);
6328 : 666 : WatchIncludeList (sym, M2GCCDeclare_heldbyalignment);
6329 : : }
6330 : 48540 : else if (SymbolTable_IsProcType (sym))
6331 : : {
6332 : : /* avoid dangling else. */
6333 : 48534 : M2Debug_Assert ((DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartFunctionType})) != NULL);
6334 : : }
6335 : 6 : else if (SymbolTable_IsType (sym))
6336 : : {
6337 : : /* avoid dangling else. */
6338 : 6 : if (! (SymbolConversion_GccKnowsAbout (sym)))
6339 : : {
6340 : 6 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
6341 : 6 : PreAddModGcc (sym, m2type_BuildStartType (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)), SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym))));
6342 : : }
6343 : : }
6344 : : else
6345 : : {
6346 : : /* avoid dangling else. */
6347 : 0 : M2Error_InternalError ((const char *) "do not know how to create a partial type from this symbol", 57);
6348 : : }
6349 : 123393 : WatchIncludeList (sym, M2GCCDeclare_partiallydeclared);
6350 : 123393 : TraverseDependants (sym);
6351 : : }
6352 : 123393 : }
6353 : :
6354 : :
6355 : : /*
6356 : : CanDeclareArrayAsNil -
6357 : : */
6358 : :
6359 : 15382992 : static bool CanDeclareArrayAsNil (unsigned int sym)
6360 : : {
6361 : 15382992 : return (SymbolTable_IsArray (sym)) && (ArrayComponentsDeclared (sym));
6362 : : /* static analysis guarentees a RETURN statement will be used before here. */
6363 : : __builtin_unreachable ();
6364 : : }
6365 : :
6366 : :
6367 : : /*
6368 : : DeclareArrayAsNil -
6369 : : */
6370 : :
6371 : 4009 : static void DeclareArrayAsNil (unsigned int sym)
6372 : : {
6373 : 4009 : PreAddModGcc (sym, m2type_BuildStartArrayType (BuildIndex (SymbolTable_GetDeclaredMod (sym), sym), NULL, static_cast<int> (SymbolTable_GetDType (sym))));
6374 : 4009 : WatchIncludeList (sym, M2GCCDeclare_niltypedarrays);
6375 : 4009 : }
6376 : :
6377 : :
6378 : : /*
6379 : : CanDeclareArrayPartially -
6380 : : */
6381 : :
6382 : 12997 : static bool CanDeclareArrayPartially (unsigned int sym)
6383 : : {
6384 : 12997 : unsigned int type;
6385 : :
6386 : 12997 : if (SymbolTable_IsArray (sym))
6387 : : {
6388 : 12703 : type = SymbolTable_GetSType (sym);
6389 : 20419 : if ((IsPartiallyOrFullyDeclared (type)) || ((SymbolTable_IsPointer (type)) && (IsNilTypedArrays (type))))
6390 : : {
6391 : 3175 : return true;
6392 : : }
6393 : : }
6394 : : return false;
6395 : : /* static analysis guarentees a RETURN statement will be used before here. */
6396 : : __builtin_unreachable ();
6397 : : }
6398 : :
6399 : :
6400 : : /*
6401 : : DeclareArrayPartially -
6402 : : */
6403 : :
6404 : 3175 : static void DeclareArrayPartially (unsigned int sym)
6405 : : {
6406 : 3175 : M2Debug_Assert ((SymbolTable_IsArray (sym)) && (SymbolConversion_GccKnowsAbout (sym)));
6407 : 3175 : m2type_PutArrayType (SymbolConversion_Mod2Gcc (sym), SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym)));
6408 : 3175 : WatchIncludeList (sym, M2GCCDeclare_partiallydeclared);
6409 : 3175 : }
6410 : :
6411 : :
6412 : : /*
6413 : : CanDeclarePointerToNilArray -
6414 : : */
6415 : :
6416 : 14989933 : static bool CanDeclarePointerToNilArray (unsigned int sym)
6417 : : {
6418 : 15466366 : return (SymbolTable_IsPointer (sym)) && (IsNilTypedArrays (SymbolTable_GetSType (sym)));
6419 : : /* static analysis guarentees a RETURN statement will be used before here. */
6420 : : __builtin_unreachable ();
6421 : : }
6422 : :
6423 : :
6424 : : /*
6425 : : DeclarePointerToNilArray -
6426 : : */
6427 : :
6428 : 90 : static void DeclarePointerToNilArray (unsigned int sym)
6429 : : {
6430 : 90 : PreAddModGcc (sym, m2type_BuildPointerType (SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym))));
6431 : 90 : WatchIncludeList (sym, M2GCCDeclare_niltypedarrays);
6432 : 90 : }
6433 : :
6434 : :
6435 : : /*
6436 : : CanPromotePointerFully -
6437 : : */
6438 : :
6439 : 9276 : static bool CanPromotePointerFully (unsigned int sym)
6440 : : {
6441 : 9276 : return (SymbolTable_IsPointer (sym)) && (IsPartiallyOrFullyDeclared (SymbolTable_GetSType (sym)));
6442 : : /* static analysis guarentees a RETURN statement will be used before here. */
6443 : : __builtin_unreachable ();
6444 : : }
6445 : :
6446 : :
6447 : : /*
6448 : : PromotePointerFully -
6449 : : */
6450 : :
6451 : 84 : static void PromotePointerFully (unsigned int sym)
6452 : : {
6453 : 84 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
6454 : 84 : }
6455 : :
6456 : :
6457 : : /*
6458 : : IsTypeQ - returns TRUE if all q(dependants) of, sym,
6459 : : return TRUE.
6460 : : */
6461 : :
6462 : 7773964 : static bool IsTypeQ (unsigned int sym, M2GCCDeclare_IsAction q)
6463 : : {
6464 : 7773964 : if (SymbolTable_IsVar (sym))
6465 : : {
6466 : 520291 : return IsVarDependants (sym, q);
6467 : : }
6468 : 7253673 : else if (SymbolTable_IsEnumeration (sym))
6469 : : {
6470 : : /* avoid dangling else. */
6471 : 110858 : return IsEnumerationDependants (sym, q);
6472 : : }
6473 : 7142815 : else if (SymbolTable_IsFieldEnumeration (sym))
6474 : : {
6475 : : /* avoid dangling else. */
6476 : : return true;
6477 : : }
6478 : 6752522 : else if (SymbolTable_IsSubrange (sym))
6479 : : {
6480 : : /* avoid dangling else. */
6481 : 932995 : return IsSubrangeDependants (sym, q);
6482 : : }
6483 : 5819527 : else if (SymbolTable_IsPointer (sym))
6484 : : {
6485 : : /* avoid dangling else. */
6486 : 1272505 : return IsPointerDependants (sym, q);
6487 : : }
6488 : 4547022 : else if (SymbolTable_IsRecord (sym))
6489 : : {
6490 : : /* avoid dangling else. */
6491 : 727401 : return IsRecordDependants (sym, q);
6492 : : }
6493 : 3819621 : else if (SymbolTable_IsRecordField (sym))
6494 : : {
6495 : : /* avoid dangling else. */
6496 : 989020 : return IsRecordFieldDependants (sym, q);
6497 : : }
6498 : 2830601 : else if (SymbolTable_IsVarient (sym))
6499 : : {
6500 : : /* avoid dangling else. */
6501 : 2178 : return IsVarientDependants (sym, q);
6502 : : }
6503 : 2828423 : else if (SymbolTable_IsFieldVarient (sym))
6504 : : {
6505 : : /* avoid dangling else. */
6506 : 3630 : return IsVarientFieldDependants (sym, q);
6507 : : }
6508 : 2824793 : else if (SymbolTable_IsArray (sym))
6509 : : {
6510 : : /* avoid dangling else. */
6511 : 974613 : return IsArrayDependants (sym, q);
6512 : : }
6513 : 1850180 : else if (SymbolTable_IsProcType (sym))
6514 : : {
6515 : : /* avoid dangling else. */
6516 : 185230 : return IsProcTypeDependants (sym, q);
6517 : : }
6518 : 1664950 : else if (SymbolTable_IsUnbounded (sym))
6519 : : {
6520 : : /* avoid dangling else. */
6521 : 200897 : return IsUnboundedDependants (sym, q);
6522 : : }
6523 : 1464053 : else if (SymbolTable_IsPartialUnbounded (sym))
6524 : : {
6525 : : /* avoid dangling else. */
6526 : 0 : M2Error_InternalError ((const char *) "should not be declaring a partial unbounded symbol", 50);
6527 : : }
6528 : 1464053 : else if (SymbolTable_IsSet (sym))
6529 : : {
6530 : : /* avoid dangling else. */
6531 : 31263 : return IsSetDependants (sym, q);
6532 : : }
6533 : 1432790 : else if (SymbolTable_IsType (sym))
6534 : : {
6535 : : /* avoid dangling else. */
6536 : 601682 : return IsTypeDependants (sym, q);
6537 : : }
6538 : 831108 : else if (SymbolTable_IsConst (sym))
6539 : : {
6540 : : /* avoid dangling else. */
6541 : 830538 : return IsConstDependants (sym, q);
6542 : : }
6543 : 570 : else if ((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym)))
6544 : : {
6545 : : /* avoid dangling else. */
6546 : : /* sym can be a constructor, but at present we have not resolved whether
6547 : : all dependants are constants.
6548 : : */
6549 : 0 : return M2ALU_IsConstructorDependants (sym, q);
6550 : : }
6551 : 570 : else if (SymbolTable_IsProcedure (sym))
6552 : : {
6553 : : /* avoid dangling else. */
6554 : 426 : return IsProcedureDependants (sym, q);
6555 : : }
6556 : : else
6557 : : {
6558 : : /* avoid dangling else. */
6559 : : return true;
6560 : : }
6561 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2GCCDeclare.def", 20, 1);
6562 : : __builtin_unreachable ();
6563 : : }
6564 : :
6565 : :
6566 : : /*
6567 : : IsNilTypedArrays - returns TRUE if, sym, is dependant upon a NIL typed array
6568 : : */
6569 : :
6570 : 538767 : static bool IsNilTypedArrays (unsigned int sym)
6571 : : {
6572 : 538767 : return Sets_IsElementInSet (GlobalGroup->NilTypedArrays, sym);
6573 : : /* static analysis guarentees a RETURN statement will be used before here. */
6574 : : __builtin_unreachable ();
6575 : : }
6576 : :
6577 : :
6578 : : /*
6579 : : IsFullyDeclared - returns TRUE if, sym, is fully declared.
6580 : : */
6581 : :
6582 : 16200280 : static bool IsFullyDeclared (unsigned int sym)
6583 : : {
6584 : 16186190 : return Sets_IsElementInSet (GlobalGroup->FullyDeclared, sym);
6585 : : /* static analysis guarentees a RETURN statement will be used before here. */
6586 : : __builtin_unreachable ();
6587 : : }
6588 : :
6589 : :
6590 : : /*
6591 : : AllDependantsFullyDeclared - returns TRUE if all dependants of,
6592 : : sym, are declared.
6593 : : */
6594 : :
6595 : 7575809 : static bool AllDependantsFullyDeclared (unsigned int sym)
6596 : : {
6597 : 5478598 : return IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared});
6598 : : /* static analysis guarentees a RETURN statement will be used before here. */
6599 : : __builtin_unreachable ();
6600 : : }
6601 : :
6602 : :
6603 : : /*
6604 : : NotAllDependantsFullyDeclared - returns TRUE if any dependants of,
6605 : : sym, are not declared.
6606 : : */
6607 : :
6608 : 0 : static bool NotAllDependantsFullyDeclared (unsigned int sym)
6609 : : {
6610 : 0 : return ! (IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared}));
6611 : : /* static analysis guarentees a RETURN statement will be used before here. */
6612 : : __builtin_unreachable ();
6613 : : }
6614 : :
6615 : :
6616 : : /*
6617 : : IsPartiallyDeclared - returns TRUE if, sym, is partially declared.
6618 : : */
6619 : :
6620 : 0 : static bool IsPartiallyDeclared (unsigned int sym)
6621 : : {
6622 : 0 : return Sets_IsElementInSet (GlobalGroup->PartiallyDeclared, sym);
6623 : : /* static analysis guarentees a RETURN statement will be used before here. */
6624 : : __builtin_unreachable ();
6625 : : }
6626 : :
6627 : :
6628 : : /*
6629 : : AllDependantsPartiallyDeclared - returns TRUE if all dependants of,
6630 : : sym, are partially declared.
6631 : : */
6632 : :
6633 : 0 : static bool AllDependantsPartiallyDeclared (unsigned int sym)
6634 : : {
6635 : 0 : return IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsPartiallyDeclared});
6636 : : /* static analysis guarentees a RETURN statement will be used before here. */
6637 : : __builtin_unreachable ();
6638 : : }
6639 : :
6640 : :
6641 : : /*
6642 : : NotAllDependantsPartiallyDeclared - returns TRUE if any dependants of,
6643 : : sym, are not partially declared.
6644 : : */
6645 : :
6646 : 0 : static bool NotAllDependantsPartiallyDeclared (unsigned int sym)
6647 : : {
6648 : 0 : return ! (IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsPartiallyDeclared}));
6649 : : /* static analysis guarentees a RETURN statement will be used before here. */
6650 : : __builtin_unreachable ();
6651 : : }
6652 : :
6653 : :
6654 : : /*
6655 : : IsPartiallyOrFullyDeclared - returns TRUE if, sym, is partially or fully declared.
6656 : : */
6657 : :
6658 : 220478 : static bool IsPartiallyOrFullyDeclared (unsigned int sym)
6659 : : {
6660 : 220478 : return (Sets_IsElementInSet (GlobalGroup->PartiallyDeclared, sym)) || (Sets_IsElementInSet (GlobalGroup->FullyDeclared, sym));
6661 : : /* static analysis guarentees a RETURN statement will be used before here. */
6662 : : __builtin_unreachable ();
6663 : : }
6664 : :
6665 : :
6666 : : /*
6667 : : AllDependantsPartiallyOrFullyDeclared - returns TRUE if all dependants of,
6668 : : sym, are partially or fully declared.
6669 : : */
6670 : :
6671 : 198155 : static bool AllDependantsPartiallyOrFullyDeclared (unsigned int sym)
6672 : : {
6673 : 198155 : return IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsPartiallyOrFullyDeclared});
6674 : : /* static analysis guarentees a RETURN statement will be used before here. */
6675 : : __builtin_unreachable ();
6676 : : }
6677 : :
6678 : :
6679 : : /*
6680 : : TypeConstDependantsFullyDeclared - returns TRUE if sym is a constant or
6681 : : type and its dependants are fully
6682 : : declared.
6683 : : */
6684 : :
6685 : 16801871 : static bool TypeConstDependantsFullyDeclared (unsigned int sym)
6686 : : {
6687 : 21651456 : return (((! (SymbolTable_IsVar (sym))) && (! (SymbolTable_IsRecord (sym)))) && (! (SymbolTable_IsParameter (sym)))) && (AllDependantsFullyDeclared (sym));
6688 : : /* static analysis guarentees a RETURN statement will be used before here. */
6689 : : __builtin_unreachable ();
6690 : : }
6691 : :
6692 : :
6693 : : /*
6694 : : CanBeDeclaredViaPartialDependants - returns TRUE if this symbol
6695 : : can be declared by partial
6696 : : dependants. Such a symbol must
6697 : : be a record, proctype or
6698 : : an array.
6699 : : */
6700 : :
6701 : 10551587 : static bool CanBeDeclaredViaPartialDependants (unsigned int sym)
6702 : : {
6703 : 10749742 : return ((SymbolTable_IsPointer (sym)) || (SymbolTable_IsProcType (sym))) && (AllDependantsPartiallyOrFullyDeclared (sym));
6704 : : /* static analysis guarentees a RETURN statement will be used before here. */
6705 : : __builtin_unreachable ();
6706 : : }
6707 : :
6708 : :
6709 : : /*
6710 : : DeclareConstFully - will add, sym, to the fully declared list and
6711 : : also remove it from the to do list. This is
6712 : : called indirectly from M2GenGCC as it calculates
6713 : : constants during quadruple processing.
6714 : : */
6715 : :
6716 : 348819 : static void DeclareConstFully (unsigned int sym)
6717 : : {
6718 : 348819 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
6719 : 348819 : WatchRemoveList (sym, M2GCCDeclare_todolist);
6720 : 348819 : WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
6721 : 348819 : WatchRemoveList (sym, M2GCCDeclare_tobesolvedbyquads);
6722 : 348819 : }
6723 : :
6724 : :
6725 : : /*
6726 : : DeclareTypeConstFully - declare the GCC type and add the double
6727 : : book keeping entry.
6728 : : */
6729 : :
6730 : 1066874 : static void DeclareTypeConstFully (unsigned int sym)
6731 : : {
6732 : 1066874 : m2tree_Tree t;
6733 : :
6734 : 1066874 : if (! (Sets_IsElementInSet (GlobalGroup->ToBeSolvedByQuads, sym)))
6735 : : {
6736 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
6737 : 1066874 : if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
6738 : : {
6739 : 144 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
6740 : 144 : WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
6741 : 144 : WatchRemoveList (sym, M2GCCDeclare_todolist);
6742 : : }
6743 : 1066730 : else if (SymbolTable_IsProcedure (sym))
6744 : : {
6745 : : /* avoid dangling else. */
6746 : 408 : DeclareProcedureToGcc (sym);
6747 : 408 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
6748 : 408 : WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
6749 : 408 : WatchRemoveList (sym, M2GCCDeclare_todolist);
6750 : : }
6751 : : else
6752 : : {
6753 : : /* avoid dangling else. */
6754 : 1066322 : t = TypeConstFullyDeclared (sym);
6755 : 1066322 : if (t != NULL)
6756 : : {
6757 : : /* add relationship between gccsym and sym */
6758 : 2132644 : PreAddModGcc (sym, t);
6759 : 1066322 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
6760 : 1066322 : WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
6761 : 1066322 : WatchRemoveList (sym, M2GCCDeclare_heldbyalignment);
6762 : 1066322 : WatchRemoveList (sym, M2GCCDeclare_finishedalignment);
6763 : 1066322 : WatchRemoveList (sym, M2GCCDeclare_todolist);
6764 : : }
6765 : : }
6766 : : }
6767 : 1066874 : }
6768 : :
6769 : :
6770 : : /*
6771 : : DeclareTypeFromPartial - declare the full GCC type from a partial type
6772 : : and add the double book keeping entry.
6773 : : */
6774 : :
6775 : 25923 : static void DeclareTypeFromPartial (unsigned int sym)
6776 : : {
6777 : 25923 : m2tree_Tree t;
6778 : :
6779 : 25923 : t = CompleteDeclarationOf (sym);
6780 : 25923 : if (t == NULL)
6781 : : {
6782 : 0 : M2Error_InternalError ((const char *) "expecting to be able to create a gcc type", 41);
6783 : : }
6784 : : else
6785 : : {
6786 : 25923 : SymbolConversion_AddModGcc (sym, t);
6787 : 25923 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
6788 : 25923 : WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
6789 : : }
6790 : 25923 : }
6791 : :
6792 : :
6793 : : /*
6794 : : CanBeDeclaredPartiallyViaPartialDependants - returns TRUE if, sym,
6795 : : can be partially declared via
6796 : : another partially declared type.
6797 : : */
6798 : :
6799 : 246431 : static bool CanBeDeclaredPartiallyViaPartialDependants (unsigned int sym)
6800 : : {
6801 : 246431 : return (SymbolTable_IsType (sym)) && (AllDependantsPartiallyDeclared (sym));
6802 : : /* static analysis guarentees a RETURN statement will be used before here. */
6803 : : __builtin_unreachable ();
6804 : : }
6805 : :
6806 : :
6807 : : /*
6808 : : EmitCircularDependancyError - issue a dependancy error.
6809 : : */
6810 : :
6811 : 6 : static void EmitCircularDependancyError (unsigned int sym)
6812 : : {
6813 : 0 : M2MetaError_MetaError1 ((const char *) "circular dependancy error found when trying to resolve {%1Uad}", 62, sym);
6814 : 0 : }
6815 : :
6816 : :
6817 : : /*
6818 : : WriteRule - writes out the name of the rule.
6819 : : */
6820 : :
6821 : 0 : static void WriteRule (void)
6822 : : {
6823 : 0 : if (Debugging)
6824 : : {
6825 : : switch (bodyr)
6826 : : {
6827 : : case M2GCCDeclare_norule:
6828 : : M2Printf_printf0 ((const char *) "norule", 6);
6829 : : break;
6830 : :
6831 : : case M2GCCDeclare_partialtype:
6832 : : M2Printf_printf0 ((const char *) "partialtype", 11);
6833 : : break;
6834 : :
6835 : : case M2GCCDeclare_arraynil:
6836 : : M2Printf_printf0 ((const char *) "arraynil", 8);
6837 : : break;
6838 : :
6839 : : case M2GCCDeclare_pointernilarray:
6840 : : M2Printf_printf0 ((const char *) "pointernilarray", 15);
6841 : : break;
6842 : :
6843 : : case M2GCCDeclare_arraypartial:
6844 : : M2Printf_printf0 ((const char *) "arraypartial", 12);
6845 : : break;
6846 : :
6847 : : case M2GCCDeclare_pointerfully:
6848 : : M2Printf_printf0 ((const char *) "pointerfully", 12);
6849 : : break;
6850 : :
6851 : : case M2GCCDeclare_recordkind:
6852 : : M2Printf_printf0 ((const char *) "recordkind", 10);
6853 : : break;
6854 : :
6855 : : case M2GCCDeclare_recordfully:
6856 : : M2Printf_printf0 ((const char *) "recordfully", 11);
6857 : : break;
6858 : :
6859 : : case M2GCCDeclare_typeconstfully:
6860 : : M2Printf_printf0 ((const char *) "typeconstfully", 14);
6861 : : break;
6862 : :
6863 : : case M2GCCDeclare_pointerfrompartial:
6864 : : M2Printf_printf0 ((const char *) "pointerfrompartial", 18);
6865 : : break;
6866 : :
6867 : : case M2GCCDeclare_typefrompartial:
6868 : : M2Printf_printf0 ((const char *) "typefrompartial", 15);
6869 : : break;
6870 : :
6871 : : case M2GCCDeclare_partialfrompartial:
6872 : : M2Printf_printf0 ((const char *) "partialfrompartial", 18);
6873 : : break;
6874 : :
6875 : : case M2GCCDeclare_partialtofully:
6876 : : M2Printf_printf0 ((const char *) "partialtofully", 14);
6877 : : break;
6878 : :
6879 : : case M2GCCDeclare_circulartodo:
6880 : : M2Printf_printf0 ((const char *) "circulartodo", 12);
6881 : : break;
6882 : :
6883 : : case M2GCCDeclare_circularpartial:
6884 : : M2Printf_printf0 ((const char *) "circularpartial", 15);
6885 : : break;
6886 : :
6887 : : case M2GCCDeclare_circularniltyped:
6888 : : M2Printf_printf0 ((const char *) "circularniltyped", 16);
6889 : : break;
6890 : :
6891 : :
6892 : : default:
6893 : : M2Error_InternalError ((const char *) "unknown rule", 12);
6894 : : break;
6895 : : }
6896 : : }
6897 : 0 : }
6898 : :
6899 : :
6900 : : /*
6901 : : Body -
6902 : : */
6903 : :
6904 : 73812981 : static void Body (unsigned int sym)
6905 : : {
6906 : 73812981 : if ((*bodyq.proc) (sym))
6907 : : {
6908 : 1298401 : WatchRemoveList (sym, bodyt);
6909 : 1298401 : (*bodyp.proc) (sym);
6910 : : /* The bodyp (sym) procedure function might have replaced sym into the set. */
6911 : 1298401 : if (! (Sets_IsElementInSet (LookupSet (bodyt), sym)))
6912 : : {
6913 : 1175008 : noMoreWritten = false;
6914 : 1175008 : oneResolved = true;
6915 : : }
6916 : : }
6917 : 73812981 : }
6918 : :
6919 : :
6920 : : /*
6921 : : ForeachTryDeclare - while q (of one sym in set t) is true
6922 : : for each symbol in set t,
6923 : : if q (sym)
6924 : : then
6925 : : p (sym)
6926 : : end
6927 : : end
6928 : : end
6929 : : */
6930 : :
6931 : 8695301 : static bool ForeachTryDeclare (M2GCCDeclare_ListType t, M2GCCDeclare_Rule r, M2GCCDeclare_IsAction q, M2GCCDeclare_WalkAction p)
6932 : : {
6933 : 8695301 : if (recursionCaught)
6934 : : {
6935 : 0 : M2Error_InternalError ((const char *) "caught recursive cycle in ForeachTryDeclare", 43);
6936 : : }
6937 : 8695301 : bodyt = t;
6938 : 8695301 : bodyq = q;
6939 : 8695301 : bodyp = p;
6940 : 8695301 : bodyr = r;
6941 : 8695301 : recursionCaught = true;
6942 : 8695301 : oneResolved = false;
6943 : 8817641 : do {
6944 : 8817641 : noMoreWritten = true;
6945 : 8817641 : Sets_ForeachElementInSetDo (LookupSet (t), (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) Body});
6946 : 8817641 : } while (! (noMoreWritten));
6947 : 8695301 : bodyr = M2GCCDeclare_norule;
6948 : 8695301 : recursionCaught = false;
6949 : 8695301 : return oneResolved;
6950 : : /* static analysis guarentees a RETURN statement will be used before here. */
6951 : : __builtin_unreachable ();
6952 : : }
6953 : :
6954 : 725480 : static bool DeclaredOutstandingTypes (bool ForceComplete)
6955 : : {
6956 : 725480 : bool finished;
6957 : 725480 : M2GCCDeclare_Group copy;
6958 : :
6959 : : /*
6960 : : DeclaredOutandingTypes - writes out any types that have their
6961 : : dependants solved. It returns TRUE if
6962 : : all outstanding types have been written.
6963 : : */
6964 : 725480 : copy = NULL;
6965 : 725480 : finished = false;
6966 : 823381 : do {
6967 : 823381 : if (Progress && (copy != NULL))
6968 : : {
6969 : : if (! (EqualGroup (copy, GlobalGroup)))
6970 : : {
6971 : : DebugSetNumbers ();
6972 : : DebugSets ();
6973 : : }
6974 : : }
6975 : 823381 : copy = DupGroup (copy);
6976 : 823381 : if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_partialtype, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareTypePartially}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypePartially}))
6977 : : {} /* empty. */
6978 : : /* Continue looping. */
6979 : 823381 : else if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_arraynil, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareArrayAsNil}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareArrayAsNil}))
6980 : : {
6981 : : /* avoid dangling else. */
6982 : : }
6983 : 820020 : else if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_pointernilarray, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclarePointerToNilArray}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclarePointerToNilArray}))
6984 : : {
6985 : : /* avoid dangling else. */
6986 : : }
6987 : 819948 : else if (ForeachTryDeclare (M2GCCDeclare_niltypedarrays, M2GCCDeclare_arraypartial, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareArrayPartially}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareArrayPartially}))
6988 : : {
6989 : : /* avoid dangling else. */
6990 : : }
6991 : 816911 : else if (ForeachTryDeclare (M2GCCDeclare_niltypedarrays, M2GCCDeclare_pointerfully, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanPromotePointerFully}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) PromotePointerFully}))
6992 : : {
6993 : : /* avoid dangling else. */
6994 : : }
6995 : 816845 : else if (ForeachTryDeclare (M2GCCDeclare_heldbyalignment, M2GCCDeclare_recordkind, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareRecordKind}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareRecordKind}))
6996 : : {
6997 : : /* avoid dangling else. */
6998 : : }
6999 : 804357 : else if (ForeachTryDeclare (M2GCCDeclare_finishedalignment, M2GCCDeclare_recordfully, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareRecord}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) FinishDeclareRecord}))
7000 : : {
7001 : : /* avoid dangling else. */
7002 : : }
7003 : 782238 : else if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_typeconstfully, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) TypeConstDependantsFullyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypeConstFully}))
7004 : : {
7005 : : /* avoid dangling else. */
7006 : : }
7007 : 731462 : else if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_typefrompartial, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanBeDeclaredViaPartialDependants}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypeFromPartial}))
7008 : : {
7009 : : /* avoid dangling else. */
7010 : : }
7011 : 728379 : else if (ForeachTryDeclare (M2GCCDeclare_partiallydeclared, M2GCCDeclare_partialfrompartial, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanBeDeclaredPartiallyViaPartialDependants}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypePartially}))
7012 : : {
7013 : : /* avoid dangling else. */
7014 : : }
7015 : 728379 : else if (ForeachTryDeclare (M2GCCDeclare_partiallydeclared, M2GCCDeclare_partialtofully, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) TypeConstDependantsFullyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypeConstFully}))
7016 : : {
7017 : : /* avoid dangling else. */
7018 : : }
7019 : : else
7020 : : {
7021 : : /* avoid dangling else. */
7022 : : /* Nothing left to do (and constants are resolved elsewhere). */
7023 : 823381 : finished = true;
7024 : : }
7025 : 823381 : } while (! (finished));
7026 : 725480 : KillGroup (©);
7027 : 725480 : if (ForceComplete)
7028 : : {
7029 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7030 : 0 : if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_circulartodo, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) NotAllDependantsFullyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) EmitCircularDependancyError}))
7031 : : {} /* empty. */
7032 : 0 : else if (ForeachTryDeclare (M2GCCDeclare_partiallydeclared, M2GCCDeclare_circularpartial, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) NotAllDependantsPartiallyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) EmitCircularDependancyError}))
7033 : : {
7034 : : /* avoid dangling else. */
7035 : : }
7036 : 0 : else if (ForeachTryDeclare (M2GCCDeclare_niltypedarrays, M2GCCDeclare_circularniltyped, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) NotAllDependantsPartiallyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) EmitCircularDependancyError}))
7037 : : {
7038 : : /* avoid dangling else. */
7039 : : }
7040 : : }
7041 : 725480 : return (Sets_NoOfElementsInSet (GlobalGroup->ToDoList)) == 0;
7042 : : /* static analysis guarentees a RETURN statement will be used before here. */
7043 : : __builtin_unreachable ();
7044 : : }
7045 : :
7046 : :
7047 : : /*
7048 : : CompleteDeclarationOf - returns the GCC Tree for, sym, if it can
7049 : : be created from partially or fully declared
7050 : : dependents.
7051 : : */
7052 : :
7053 : 25923 : static m2tree_Tree CompleteDeclarationOf (unsigned int sym)
7054 : : {
7055 : 25923 : if (SymbolTable_IsArray (sym))
7056 : : {
7057 : 0 : return DeclareArray (sym);
7058 : : }
7059 : 25923 : else if (SymbolTable_IsProcType (sym))
7060 : : {
7061 : : /* avoid dangling else. */
7062 : 5316 : return DeclareProcType (sym);
7063 : : }
7064 : 20607 : else if (SymbolTable_IsRecordField (sym))
7065 : : {
7066 : : /* avoid dangling else. */
7067 : 0 : return DeclareRecordField (sym);
7068 : : }
7069 : 20607 : else if (SymbolTable_IsPointer (sym))
7070 : : {
7071 : : /* avoid dangling else. */
7072 : 20607 : return DeclarePointer (sym);
7073 : : }
7074 : : else
7075 : : {
7076 : : /* avoid dangling else. */
7077 : : return NULL;
7078 : : }
7079 : : /* static analysis guarentees a RETURN statement will be used before here. */
7080 : : __builtin_unreachable ();
7081 : : }
7082 : :
7083 : :
7084 : : /*
7085 : : DeclareType - here a type has been created via TYPE foo = bar,
7086 : : we must tell GCC about it.
7087 : : */
7088 : :
7089 : 25325 : static m2tree_Tree DeclareType (unsigned int sym)
7090 : : {
7091 : 25325 : m2tree_Tree t;
7092 : 25325 : m2linemap_location_t location;
7093 : :
7094 : 25325 : if ((SymbolTable_GetSType (sym)) == SymbolTable_NulSym)
7095 : : {
7096 : 0 : M2MetaError_MetaError1 ((const char *) "base type {%1Ua} not understood", 31, sym);
7097 : 0 : M2Error_InternalError ((const char *) "base type should have been declared", 35);
7098 : : }
7099 : : else
7100 : : {
7101 : 25325 : if ((SymbolTable_GetSymName (sym)) == NameKey_NulName)
7102 : : {
7103 : 0 : return (m2tree_Tree) (SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym)));
7104 : : }
7105 : : else
7106 : : {
7107 : 25325 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
7108 : 25325 : if (SymbolConversion_GccKnowsAbout (sym))
7109 : : {
7110 : 6 : t = SymbolConversion_Mod2Gcc (sym);
7111 : : }
7112 : : else
7113 : : {
7114 : : /* not partially declared therefore start it */
7115 : 25319 : t = m2type_BuildStartType (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)), SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym)));
7116 : : }
7117 : 25325 : t = m2type_BuildEndType (location, t); /* now finish it */
7118 : 25325 : return t; /* now finish it */
7119 : : }
7120 : : }
7121 : : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2GCCDeclare.def", 20, 1);
7122 : : __builtin_unreachable ();
7123 : : }
7124 : :
7125 : 442597 : static void DeclareConstantFromTree (unsigned int sym, m2tree_Tree value)
7126 : : {
7127 : : /*
7128 : : DeclareIntegerFromTree - declares an integer constant from a Tree, value.
7129 : : */
7130 : 885194 : PreAddModGcc (sym, value);
7131 : 442597 : WatchRemoveList (sym, M2GCCDeclare_todolist);
7132 : 442597 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
7133 : 442597 : }
7134 : :
7135 : :
7136 : : /*
7137 : : DeclareCharConstant - declares a character constant.
7138 : : */
7139 : :
7140 : 12161 : static void DeclareCharConstant (unsigned int tokenno, unsigned int sym)
7141 : : {
7142 : 12161 : m2linemap_location_t location;
7143 : :
7144 : 12161 : M2Debug_Assert (SymbolTable_IsConstStringKnown (sym));
7145 : 12161 : location = M2LexBuf_TokenToLocation (tokenno);
7146 : 12161 : PreAddModGcc (sym, m2type_BuildCharConstant (location, NameKey_KeyToCharStar (SymbolTable_GetString (sym))));
7147 : 12161 : WatchRemoveList (sym, M2GCCDeclare_todolist);
7148 : 12161 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
7149 : 12161 : }
7150 : :
7151 : :
7152 : : /*
7153 : : DeclareStringConstant - declares a string constant the sym will be known.
7154 : : */
7155 : :
7156 : 200403 : static void DeclareStringConstant (unsigned int tokenno, unsigned int sym)
7157 : : {
7158 : 200403 : m2tree_Tree symtree;
7159 : :
7160 : 200403 : M2Debug_Assert (SymbolTable_IsConstStringKnown (sym));
7161 : 200403 : if ((SymbolTable_IsConstStringM2nul (sym)) || (SymbolTable_IsConstStringCnul (sym)))
7162 : : {
7163 : : /* in either case the string needs a nul terminator. If the string
7164 : : is a C variant it will already have had any escape characters applied.
7165 : : The BuildCStringConstant only adds the nul terminator. */
7166 : 200391 : symtree = m2decl_BuildCStringConstant (NameKey_KeyToCharStar (SymbolTable_GetString (sym)), static_cast<int> (SymbolTable_GetStringLength (tokenno, sym)));
7167 : : }
7168 : : else
7169 : : {
7170 : 12 : symtree = m2decl_BuildStringConstant (NameKey_KeyToCharStar (SymbolTable_GetString (sym)), static_cast<int> (SymbolTable_GetStringLength (tokenno, sym)));
7171 : : }
7172 : 400806 : PreAddModGcc (sym, symtree);
7173 : 200403 : WatchRemoveList (sym, M2GCCDeclare_todolist);
7174 : 200403 : WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
7175 : 200403 : }
7176 : :
7177 : :
7178 : : /*
7179 : : WalkConstructor - walks all dependants of, sym.
7180 : : */
7181 : :
7182 : 183871 : static void WalkConstructor (unsigned int sym, M2GCCDeclare_WalkAction p)
7183 : : {
7184 : 183871 : unsigned int type;
7185 : :
7186 : 183871 : type = SymbolTable_GetSType (sym);
7187 : 183871 : if (type != SymbolTable_NulSym)
7188 : : {
7189 : 182611 : WalkDependants (type, p);
7190 : 182611 : M2ALU_WalkConstructorDependants (sym, p);
7191 : : }
7192 : 183871 : }
7193 : :
7194 : :
7195 : : /*
7196 : : WalkConst - walks all dependants of, sym.
7197 : : */
7198 : :
7199 : 15994215 : static void WalkConst (unsigned int sym, M2GCCDeclare_WalkAction p)
7200 : : {
7201 : 15994215 : unsigned int type;
7202 : :
7203 : 15994215 : M2Debug_Assert (SymbolTable_IsConst (sym));
7204 : 15994215 : type = SymbolTable_GetSType (sym);
7205 : 15994215 : if (type != SymbolTable_NulSym)
7206 : : {
7207 : 15005385 : (*p.proc) (type);
7208 : : }
7209 : 15994215 : if ((SymbolTable_IsConstSet (sym)) || (SymbolTable_IsConstructor (sym)))
7210 : : {
7211 : 170670 : WalkConstructor (sym, p);
7212 : : }
7213 : 15994215 : }
7214 : :
7215 : :
7216 : : /*
7217 : : IsConstDependants - returns TRUE if the symbol, sym,
7218 : : q(dependants) all return TRUE.
7219 : : */
7220 : :
7221 : 830538 : static bool IsConstDependants (unsigned int sym, M2GCCDeclare_IsAction q)
7222 : : {
7223 : 830538 : unsigned int type;
7224 : :
7225 : 830538 : M2Debug_Assert (SymbolTable_IsConst (sym));
7226 : 830538 : type = SymbolTable_GetSType (sym);
7227 : 830538 : if (type != SymbolTable_NulSym)
7228 : : {
7229 : 822666 : if (! ((*q.proc) (type)))
7230 : : {
7231 : : return false;
7232 : : }
7233 : : }
7234 : 825218 : if ((SymbolTable_IsConstSet (sym)) || (SymbolTable_IsConstructor (sym)))
7235 : : {
7236 : 10629 : return M2ALU_IsConstructorDependants (sym, q);
7237 : : }
7238 : 814589 : return SymbolTable_IsValueSolved (sym);
7239 : : /* static analysis guarentees a RETURN statement will be used before here. */
7240 : : __builtin_unreachable ();
7241 : : }
7242 : :
7243 : :
7244 : : /*
7245 : : DeclareConstString -
7246 : : */
7247 : :
7248 : 212564 : static bool DeclareConstString (unsigned int tokenno, unsigned int sym)
7249 : : {
7250 : 212564 : unsigned int size;
7251 : :
7252 : 212564 : if (SymbolTable_IsConstStringKnown (sym))
7253 : : {
7254 : 212564 : size = SymbolTable_GetStringLength (tokenno, sym);
7255 : 212564 : if (size == 1)
7256 : : {
7257 : 12161 : DeclareCharConstant (tokenno, sym);
7258 : : }
7259 : : else
7260 : : {
7261 : 200403 : DeclareStringConstant (tokenno, sym);
7262 : : }
7263 : 212564 : return true;
7264 : : }
7265 : : return false;
7266 : : /* static analysis guarentees a RETURN statement will be used before here. */
7267 : : __builtin_unreachable ();
7268 : : }
7269 : :
7270 : :
7271 : : /*
7272 : : TryDeclareConst - try to declare a const to gcc. If it cannot
7273 : : declare the symbol it places it into the
7274 : : todolist.
7275 : : */
7276 : :
7277 : 2921891 : static void TryDeclareConst (unsigned int tokenno, unsigned int sym)
7278 : : {
7279 : 2921891 : unsigned int type;
7280 : :
7281 : 2921891 : if (! (SymbolConversion_GccKnowsAbout (sym)))
7282 : : {
7283 : 401357 : if ((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym)))
7284 : : {
7285 : 706 : M2ALU_WalkConstructorDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
7286 : 706 : M2ALU_TryEvaluateValue (sym);
7287 : 706 : if (! (M2ALU_IsConstructorDependants (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared})))
7288 : : {
7289 : : /*
7290 : : WatchIncludeList(sym, todolist) ;
7291 : : */
7292 : 694 : TraverseDependants (sym);
7293 : 694 : return ;
7294 : : }
7295 : 12 : if (! (SymbolTable_IsConstructorConstant (sym)))
7296 : : {
7297 : : return ;
7298 : : }
7299 : : }
7300 : 400663 : if ((SymbolTable_IsConstString (sym)) && (SymbolTable_IsConstStringKnown (sym)))
7301 : : {
7302 : : /* avoid dangling else. */
7303 : 72498 : if (DeclareConstString (tokenno, sym))
7304 : : {} /* empty. */
7305 : : }
7306 : 328165 : else if (SymbolTable_IsValueSolved (sym))
7307 : : {
7308 : : /* avoid dangling else. */
7309 : 326893 : SymbolTable_PushValue (sym);
7310 : 326893 : if (SymbolTable_IsConstSet (sym))
7311 : : {
7312 : 12 : DeclareConstantFromTree (sym, M2ALU_PopSetTree (tokenno));
7313 : : }
7314 : 326881 : else if (SymbolTable_IsConstructor (sym))
7315 : : {
7316 : : /* avoid dangling else. */
7317 : 0 : DeclareConstantFromTree (sym, M2ALU_PopConstructorTree (tokenno));
7318 : : }
7319 : 326881 : else if (M2Base_IsRealType (SymbolTable_GetDType (sym)))
7320 : : {
7321 : : /* avoid dangling else. */
7322 : 4756 : type = SymbolTable_GetDType (sym);
7323 : 4756 : DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopRealTree (), true));
7324 : : }
7325 : 322125 : else if (M2Base_IsComplexType (SymbolTable_GetDType (sym)))
7326 : : {
7327 : : /* avoid dangling else. */
7328 : 330 : type = SymbolTable_GetDType (sym);
7329 : 330 : DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopComplexTree (), true));
7330 : : }
7331 : : else
7332 : : {
7333 : : /* avoid dangling else. */
7334 : 321795 : if ((SymbolTable_GetSType (sym)) == SymbolTable_NulSym)
7335 : : {
7336 : 0 : type = M2Base_ZType;
7337 : : }
7338 : : else
7339 : : {
7340 : 321795 : type = SymbolTable_GetDType (sym);
7341 : : }
7342 : 321795 : DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopIntegerTree (), true));
7343 : : }
7344 : : }
7345 : : else
7346 : : {
7347 : : /* avoid dangling else. */
7348 : 1272 : TraverseDependants (sym);
7349 : : }
7350 : : }
7351 : : }
7352 : :
7353 : :
7354 : : /*
7355 : : DeclareConst - declares a const to gcc and returns a Tree.
7356 : : */
7357 : :
7358 : 720565 : static m2tree_Tree DeclareConst (unsigned int tokenno, unsigned int sym)
7359 : : {
7360 : 720565 : unsigned int type;
7361 : :
7362 : 720565 : if (SymbolConversion_GccKnowsAbout (sym))
7363 : : {
7364 : 472422 : return SymbolConversion_Mod2Gcc (sym);
7365 : : }
7366 : 248143 : if ((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym)))
7367 : : {
7368 : 2589 : M2ALU_EvaluateValue (sym);
7369 : : }
7370 : 248143 : if (SymbolTable_IsConstString (sym))
7371 : : {
7372 : : /* avoid dangling else. */
7373 : 140066 : if (DeclareConstString (tokenno, sym))
7374 : : {} /* empty. */
7375 : : }
7376 : 108077 : else if (SymbolTable_IsValueSolved (sym))
7377 : : {
7378 : : /* avoid dangling else. */
7379 : 108077 : SymbolTable_PushValue (sym);
7380 : 108077 : if (SymbolTable_IsConstSet (sym))
7381 : : {
7382 : 377 : DeclareConstantFromTree (sym, M2ALU_PopSetTree (tokenno));
7383 : : }
7384 : 107700 : else if (SymbolTable_IsConstructor (sym))
7385 : : {
7386 : : /* avoid dangling else. */
7387 : 2212 : DeclareConstantFromTree (sym, M2ALU_PopConstructorTree (tokenno));
7388 : : }
7389 : 105488 : else if (M2Base_IsRealType (SymbolTable_GetDType (sym)))
7390 : : {
7391 : : /* avoid dangling else. */
7392 : 1566 : type = SymbolTable_GetDType (sym);
7393 : 1566 : DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopRealTree (), true));
7394 : : }
7395 : 103922 : else if (M2Base_IsComplexType (SymbolTable_GetDType (sym)))
7396 : : {
7397 : : /* avoid dangling else. */
7398 : 0 : type = SymbolTable_GetDType (sym);
7399 : 0 : DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopComplexTree (), true));
7400 : : }
7401 : : else
7402 : : {
7403 : : /* avoid dangling else. */
7404 : 103922 : if ((SymbolTable_GetSType (sym)) == SymbolTable_NulSym)
7405 : : {
7406 : 12454 : type = M2Base_ZType;
7407 : : }
7408 : : else
7409 : : {
7410 : 91468 : type = SymbolTable_GetDType (sym);
7411 : : }
7412 : 103922 : DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopIntegerTree (), true));
7413 : : }
7414 : : }
7415 : 248143 : if (SymbolConversion_GccKnowsAbout (sym))
7416 : : {
7417 : 248143 : return SymbolConversion_Mod2Gcc (sym);
7418 : : }
7419 : : else
7420 : : {
7421 : : return NULL;
7422 : : }
7423 : : /* static analysis guarentees a RETURN statement will be used before here. */
7424 : : __builtin_unreachable ();
7425 : : }
7426 : :
7427 : :
7428 : : /*
7429 : : WalkFamilyOfUnbounded -
7430 : : */
7431 : :
7432 : 3797547 : static void WalkFamilyOfUnbounded (unsigned int oaf __attribute__((unused)), unsigned int dim __attribute__((unused)), unsigned int unbounded)
7433 : : {
7434 : 3797547 : if (unbounded != SymbolTable_NulSym)
7435 : : {
7436 : 3772173 : (*unboundedp.proc) (unbounded);
7437 : : }
7438 : 3797547 : }
7439 : :
7440 : :
7441 : : /*
7442 : : WalkAssociatedUnbounded -
7443 : : */
7444 : :
7445 : 78414267 : static void WalkAssociatedUnbounded (unsigned int sym, M2GCCDeclare_WalkAction p)
7446 : : {
7447 : 78414267 : unsigned int oaf;
7448 : 78414267 : M2GCCDeclare_WalkAction o;
7449 : :
7450 : 78414267 : oaf = SymbolTable_GetOAFamily (sym);
7451 : 78414267 : o = unboundedp;
7452 : 78414267 : unboundedp = p;
7453 : 78414267 : SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) WalkFamilyOfUnbounded});
7454 : 78414267 : unboundedp = o;
7455 : 78414267 : }
7456 : :
7457 : :
7458 : : /*
7459 : : WalkDependants - walks through all dependants of, Sym,
7460 : : calling, p, for each dependant.
7461 : : */
7462 : :
7463 : 77841383 : static void WalkDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
7464 : : {
7465 : 77841383 : WalkAssociatedUnbounded (sym, p);
7466 : 77841383 : if (SymbolTable_IsComponent (sym))
7467 : : {
7468 : 91403 : WalkComponentDependants (sym, p);
7469 : : }
7470 : 77749980 : else if (SymbolTable_IsEnumeration (sym))
7471 : : {
7472 : : /* avoid dangling else. */
7473 : 2043791 : WalkEnumerationDependants (sym, p);
7474 : : }
7475 : 75706189 : else if (SymbolTable_IsSubrange (sym))
7476 : : {
7477 : : /* avoid dangling else. */
7478 : 1086284 : WalkSubrangeDependants (sym, p);
7479 : : }
7480 : 74619905 : else if (SymbolTable_IsPointer (sym))
7481 : : {
7482 : : /* avoid dangling else. */
7483 : 9408819 : WalkPointerDependants (sym, p);
7484 : : }
7485 : 65211086 : else if (SymbolTable_IsRecord (sym))
7486 : : {
7487 : : /* avoid dangling else. */
7488 : 5960254 : WalkRecordDependants (sym, p);
7489 : : }
7490 : 59250832 : else if (SymbolTable_IsVarient (sym))
7491 : : {
7492 : : /* avoid dangling else. */
7493 : 7344 : WalkVarientDependants (sym, p);
7494 : : }
7495 : 59243488 : else if (SymbolTable_IsRecordField (sym))
7496 : : {
7497 : : /* avoid dangling else. */
7498 : 18693032 : WalkRecordFieldDependants (sym, p);
7499 : : }
7500 : 40550456 : else if (SymbolTable_IsFieldVarient (sym))
7501 : : {
7502 : : /* avoid dangling else. */
7503 : 18828 : WalkVarientFieldDependants (sym, p);
7504 : : }
7505 : 40531628 : else if (SymbolTable_IsArray (sym))
7506 : : {
7507 : : /* avoid dangling else. */
7508 : 664767 : WalkArrayDependants (sym, p);
7509 : : }
7510 : 39866861 : else if (SymbolTable_IsProcType (sym))
7511 : : {
7512 : : /* avoid dangling else. */
7513 : 2038948 : WalkProcTypeDependants (sym, p);
7514 : : }
7515 : 37827913 : else if (SymbolTable_IsUnbounded (sym))
7516 : : {
7517 : : /* avoid dangling else. */
7518 : 3728034 : WalkUnboundedDependants (sym, p);
7519 : : }
7520 : 34099879 : else if (SymbolTable_IsSet (sym))
7521 : : {
7522 : : /* avoid dangling else. */
7523 : 564161 : WalkSetDependants (sym, p);
7524 : : }
7525 : 33535718 : else if (SymbolTable_IsType (sym))
7526 : : {
7527 : : /* avoid dangling else. */
7528 : 17039085 : WalkTypeDependants (sym, p);
7529 : : }
7530 : 16496633 : else if (SymbolTable_IsConst (sym))
7531 : : {
7532 : : /* avoid dangling else. */
7533 : 15994215 : WalkConst (sym, p);
7534 : : }
7535 : 502418 : else if (SymbolTable_IsVar (sym))
7536 : : {
7537 : : /* avoid dangling else. */
7538 : 501854 : WalkVarDependants (sym, p);
7539 : : }
7540 : 564 : else if (SymbolTable_IsProcedure (sym))
7541 : : {
7542 : : /* avoid dangling else. */
7543 : 408 : WalkProcedureDependants (sym, p);
7544 : : }
7545 : 77841383 : }
7546 : :
7547 : :
7548 : : /*
7549 : : TraverseDependantsInner -
7550 : : */
7551 : :
7552 : 132711813 : static void TraverseDependantsInner (unsigned int sym)
7553 : : {
7554 : 132711813 : if ((! (Sets_IsElementInSet (GlobalGroup->FullyDeclared, sym))) && (! (Sets_IsElementInSet (GlobalGroup->ToDoList, sym))))
7555 : : {
7556 : 2354914 : WatchIncludeList (sym, M2GCCDeclare_todolist);
7557 : : }
7558 : 132711813 : if (! (Sets_IsElementInSet (VisitedList, sym)))
7559 : : {
7560 : 77658772 : Sets_IncludeElementIntoSet (VisitedList, sym);
7561 : 77658772 : WalkDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependantsInner});
7562 : : }
7563 : 132711813 : }
7564 : :
7565 : :
7566 : : /*
7567 : : TraverseDependants - walks, sym, dependants. But it checks
7568 : : to see that, sym, is not on the
7569 : : FullyDeclared and not on the ToDoList.
7570 : : */
7571 : :
7572 : 13047749 : static void TraverseDependants (unsigned int sym)
7573 : : {
7574 : 13047749 : if (VisitedList == NULL)
7575 : : {
7576 : 13047749 : VisitedList = Sets_InitSet (1);
7577 : 13047749 : TraverseDependantsInner (sym);
7578 : 13047749 : VisitedList = Sets_KillSet (VisitedList);
7579 : : }
7580 : : else
7581 : : {
7582 : 0 : M2Error_InternalError ((const char *) "recursive call to TraverseDependants caught", 43);
7583 : : }
7584 : 13047749 : }
7585 : :
7586 : :
7587 : : /*
7588 : : WalkTypeInfo - walks type, sym, and its dependants.
7589 : : */
7590 : :
7591 : 12324959 : static void WalkTypeInfo (unsigned int sym)
7592 : : {
7593 : 12327923 : if (SymbolTable_IsVarient (sym))
7594 : : {
7595 : 0 : M2Error_InternalError ((const char *) "why have we reached here?", 25);
7596 : : }
7597 : 12327923 : else if (SymbolTable_IsVar (sym))
7598 : : {
7599 : : /* avoid dangling else. */
7600 : 225576 : WalkTypeInfo (SymbolTable_GetSType (sym));
7601 : 225576 : if ((SymbolTable_GetVarBackEndType (sym)) != SymbolTable_NulSym)
7602 : : {
7603 : 2964 : WalkTypeInfo (SymbolTable_GetVarBackEndType (sym));
7604 : : }
7605 : : }
7606 : 12102347 : else if (SymbolTable_IsAModula2Type (sym))
7607 : : {
7608 : : /* avoid dangling else. */
7609 : 7506822 : TraverseDependants (sym);
7610 : : }
7611 : 12324959 : }
7612 : :
7613 : :
7614 : : /*
7615 : : DeclareUnboundedProcedureParameters -
7616 : : */
7617 : :
7618 : 165212 : static void DeclareUnboundedProcedureParameters (unsigned int sym)
7619 : : {
7620 : 165212 : unsigned int param;
7621 : 165212 : unsigned int type;
7622 : 165212 : unsigned int p;
7623 : 165212 : unsigned int i;
7624 : 165212 : m2linemap_location_t location;
7625 : :
7626 : 165212 : if (SymbolTable_IsProcedure (sym))
7627 : : {
7628 : 164540 : p = SymbolTable_NoOfParam (sym);
7629 : 164540 : i = p;
7630 : 752971 : while (i > 0)
7631 : : {
7632 : 423891 : if (SymbolTable_IsUnboundedParam (sym, i))
7633 : : {
7634 : : /* avoid dangling else. */
7635 : 38972 : param = SymbolTable_GetNthParam (sym, i);
7636 : 38972 : type = SymbolTable_GetSType (param);
7637 : 38972 : TraverseDependants (type);
7638 : 38972 : if (SymbolConversion_GccKnowsAbout (type))
7639 : : {
7640 : 38972 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (type));
7641 : 38972 : m2type_BuildTypeDeclaration (location, SymbolConversion_Mod2Gcc (type));
7642 : : }
7643 : : }
7644 : : else
7645 : : {
7646 : 384919 : param = SymbolTable_GetNth (sym, i);
7647 : 384919 : type = SymbolTable_GetSType (param);
7648 : 384919 : TraverseDependants (type);
7649 : : }
7650 : 423891 : i -= 1;
7651 : : }
7652 : : }
7653 : 165212 : }
7654 : :
7655 : :
7656 : : /*
7657 : : WalkUnboundedProcedureParameters -
7658 : : */
7659 : :
7660 : 5736360 : static void WalkUnboundedProcedureParameters (unsigned int sym)
7661 : : {
7662 : 5736360 : unsigned int param;
7663 : 5736360 : unsigned int type;
7664 : 5736360 : unsigned int p;
7665 : 5736360 : unsigned int i;
7666 : :
7667 : 5736360 : if (SymbolTable_IsProcedure (sym))
7668 : : {
7669 : 3585206 : p = SymbolTable_NoOfParam (sym);
7670 : 3585206 : i = p;
7671 : 13533435 : while (i > 0)
7672 : : {
7673 : 6363023 : if (SymbolTable_IsUnboundedParam (sym, i))
7674 : : {
7675 : 620744 : param = SymbolTable_GetNthParam (sym, i);
7676 : : }
7677 : : else
7678 : : {
7679 : 5742279 : param = SymbolTable_GetNth (sym, i);
7680 : : }
7681 : 6363023 : type = SymbolTable_GetSType (param);
7682 : 6363023 : WalkTypeInfo (type);
7683 : 6363023 : i -= 1;
7684 : : }
7685 : : }
7686 : 5736360 : }
7687 : :
7688 : :
7689 : : /*
7690 : : WalkTypesInProcedure - walk all types in procedure, Sym.
7691 : : */
7692 : :
7693 : 62471 : static void WalkTypesInProcedure (unsigned int sym)
7694 : : {
7695 : 0 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) TraverseDependants});
7696 : 0 : }
7697 : :
7698 : :
7699 : : /*
7700 : : WalkTypesInModule - declare all types in module, Sym, to GCC.
7701 : : */
7702 : :
7703 : 137857 : static void WalkTypesInModule (unsigned int sym)
7704 : : {
7705 : 137857 : NameKey_Name n;
7706 : :
7707 : 137857 : if (Debugging)
7708 : : {
7709 : : n = SymbolTable_GetSymName (sym);
7710 : : M2Printf_printf1 ((const char *) "Declaring types in MODULE %a\\n", 30, (const unsigned char *) &n, (sizeof (n)-1));
7711 : : }
7712 : 137857 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypeInfo});
7713 : 137857 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkUnboundedProcedureParameters});
7714 : 137857 : SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});
7715 : 137857 : }
7716 : :
7717 : :
7718 : : /*
7719 : : IsRecordFieldDependants - returns TRUE if the record field
7720 : : symbol, sym, p(dependants) all return TRUE.
7721 : : */
7722 : :
7723 : 989020 : static bool IsRecordFieldDependants (unsigned int sym, M2GCCDeclare_IsAction q)
7724 : : {
7725 : 989020 : unsigned int align;
7726 : 989020 : bool final;
7727 : :
7728 : 989020 : final = true;
7729 : 989020 : if (! ((*q.proc) (SymbolTable_GetSType (sym))))
7730 : : {
7731 : : final = false;
7732 : : }
7733 : 989020 : align = SymbolTable_GetAlignment (sym);
7734 : 989020 : if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
7735 : : {
7736 : : final = false;
7737 : : }
7738 : 989020 : return final;
7739 : : /* static analysis guarentees a RETURN statement will be used before here. */
7740 : : __builtin_unreachable ();
7741 : : }
7742 : :
7743 : :
7744 : : /*
7745 : : GetModuleWhereDeclared - returns the module where, Sym, was created.
7746 : : */
7747 : :
7748 : 9450359 : static unsigned int GetModuleWhereDeclared (unsigned int sym)
7749 : : {
7750 : 9456665 : unsigned int s;
7751 : :
7752 : 9456665 : s = SymbolTable_GetScope (sym);
7753 : 9456665 : if (((s == SymbolTable_NulSym) || (SymbolTable_IsDefImp (s))) || ((SymbolTable_IsModule (s)) && ((SymbolTable_GetScope (s)) == SymbolTable_NulSym)))
7754 : : {
7755 : 9450359 : return s;
7756 : : }
7757 : : else
7758 : : {
7759 : 6306 : return GetModuleWhereDeclared (s);
7760 : : }
7761 : : /* static analysis guarentees a RETURN statement will be used before here. */
7762 : : __builtin_unreachable ();
7763 : : }
7764 : :
7765 : :
7766 : : /*
7767 : : IsPseudoProcFunc - returns TRUE if Sym is a pseudo function or procedure.
7768 : : */
7769 : :
7770 : 2914430 : static bool IsPseudoProcFunc (unsigned int Sym)
7771 : : {
7772 : 2914430 : return ((M2Base_IsPseudoBaseProcedure (Sym)) || (M2Base_IsPseudoBaseFunction (Sym))) || (M2System_IsPseudoSystemFunction (Sym));
7773 : : /* static analysis guarentees a RETURN statement will be used before here. */
7774 : : __builtin_unreachable ();
7775 : : }
7776 : :
7777 : :
7778 : : /*
7779 : : IsExternal -
7780 : : */
7781 : :
7782 : 1968486 : static bool IsExternal (unsigned int sym)
7783 : : {
7784 : 1968486 : unsigned int mod;
7785 : :
7786 : 1968486 : M2Debug_Assert (! (SymbolTable_IsDefImp (sym)));
7787 : 1968486 : if ((SymbolTable_IsProcedure (sym)) && (SymbolTable_IsExtern (sym)))
7788 : : {
7789 : : return true;
7790 : : }
7791 : 1749014 : mod = SymbolTable_GetScope (sym);
7792 : 1751018 : do {
7793 : 1751018 : if (mod == SymbolTable_NulSym)
7794 : : {
7795 : : return false;
7796 : : }
7797 : 1751018 : else if (SymbolTable_IsDefImp (mod))
7798 : : {
7799 : : /* avoid dangling else. */
7800 : 1668842 : return mod != (SymbolTable_GetMainModule ());
7801 : : }
7802 : 82176 : mod = SymbolTable_GetScope (mod);
7803 : 82176 : } while (! (mod == SymbolTable_NulSym));
7804 : : return false;
7805 : : /* static analysis guarentees a RETURN statement will be used before here. */
7806 : : __builtin_unreachable ();
7807 : : }
7808 : :
7809 : :
7810 : : /*
7811 : : IsExternalToWholeProgram - return TRUE if the symbol, sym, is external to the
7812 : : sources that we have parsed.
7813 : : */
7814 : :
7815 : 11136 : static bool IsExternalToWholeProgram (unsigned int sym)
7816 : : {
7817 : 11136 : unsigned int mod;
7818 : :
7819 : 11136 : mod = SymbolTable_GetScope (sym);
7820 : 11136 : do {
7821 : 11136 : if (mod == SymbolTable_NulSym)
7822 : : {
7823 : : return false;
7824 : : }
7825 : 11136 : else if (SymbolTable_IsDefImp (mod))
7826 : : {
7827 : : /* avoid dangling else. */
7828 : : /* return TRUE if we have no source file. */
7829 : 10872 : return (M2Batch_GetModuleFile (mod)) == NULL;
7830 : : }
7831 : 264 : mod = SymbolTable_GetScope (mod);
7832 : 264 : } while (! (mod == SymbolTable_NulSym));
7833 : : return false;
7834 : : /* static analysis guarentees a RETURN statement will be used before here. */
7835 : : __builtin_unreachable ();
7836 : : }
7837 : :
7838 : :
7839 : : /*
7840 : : DeclareProcedureToGccWholeProgram -
7841 : : */
7842 : :
7843 : 248328 : static void DeclareProcedureToGccWholeProgram (unsigned int Sym)
7844 : : {
7845 : 248328 : m2tree_Tree returnType;
7846 : 248328 : m2tree_Tree GccParam;
7847 : 248328 : unsigned int scope;
7848 : 248328 : unsigned int Son;
7849 : 248328 : unsigned int p;
7850 : 248328 : unsigned int i;
7851 : 248328 : unsigned int b;
7852 : 248328 : unsigned int e;
7853 : 248328 : m2linemap_location_t begin;
7854 : 248328 : m2linemap_location_t end;
7855 : 248328 : m2linemap_location_t location;
7856 : :
7857 : 248328 : if ((! (SymbolConversion_GccKnowsAbout (Sym))) && (! (IsPseudoProcFunc (Sym))))
7858 : : {
7859 : 11136 : m2decl_BuildStartFunctionDeclaration (SymbolTable_UsesVarArgs (Sym));
7860 : 11136 : p = SymbolTable_NoOfParam (Sym);
7861 : 11136 : i = p;
7862 : : /* note we dont use GetNthParam as we want the parameter that is seen by the procedure block
7863 : : remember that this is treated exactly the same as a variable, just its position on
7864 : : the activation record is special (ie a parameter)
7865 : : */
7866 : 42672 : while (i > 0)
7867 : : {
7868 : 20400 : Son = SymbolTable_GetNth (Sym, i);
7869 : 20400 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Son));
7870 : 20400 : if (SymbolTable_IsUnboundedParam (Sym, i))
7871 : : {
7872 : 2088 : GccParam = m2decl_BuildParameterDeclaration (location, NameKey_KeyToCharStar (SymbolTable_GetSymName (Son)), SymbolConversion_Mod2Gcc (SymbolTable_GetLType (Son)), false);
7873 : : }
7874 : : else
7875 : : {
7876 : 18312 : GccParam = m2decl_BuildParameterDeclaration (location, NameKey_KeyToCharStar (SymbolTable_GetSymName (Son)), SymbolConversion_Mod2Gcc (SymbolTable_GetLType (Son)), SymbolTable_IsVarParam (Sym, i));
7877 : : }
7878 : 40800 : PreAddModGcc (Son, GccParam);
7879 : 20400 : WatchRemoveList (Son, M2GCCDeclare_todolist);
7880 : 20400 : WatchIncludeList (Son, M2GCCDeclare_fullydeclared);
7881 : 20400 : i -= 1;
7882 : : }
7883 : 11136 : SymbolTable_GetProcedureBeginEnd (Sym, &b, &e);
7884 : 11136 : begin = M2LexBuf_TokenToLocation (b);
7885 : 11136 : end = M2LexBuf_TokenToLocation (e);
7886 : 11136 : scope = SymbolTable_GetScope (Sym);
7887 : 11136 : PushBinding (scope);
7888 : 11136 : if ((SymbolTable_GetSType (Sym)) == SymbolTable_NulSym)
7889 : : {
7890 : : returnType = NULL;
7891 : : }
7892 : : else
7893 : : {
7894 : 4344 : returnType = SymbolConversion_Mod2Gcc (SymbolTable_GetSType (Sym));
7895 : : }
7896 : 11136 : PreAddModGcc (Sym, m2decl_BuildEndFunctionDeclaration (begin, end, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (Sym)), returnType, IsExternalToWholeProgram (Sym), M2GCCDeclare_IsProcedureGccNested (Sym), SymbolTable_IsExported (GetModuleWhereDeclared (Sym), Sym), SymbolTable_IsProcedureNoReturn (Sym)));
7897 : 11136 : PopBinding (scope);
7898 : 11136 : WatchRemoveList (Sym, M2GCCDeclare_todolist);
7899 : 11136 : WatchIncludeList (Sym, M2GCCDeclare_fullydeclared);
7900 : : }
7901 : 248328 : }
7902 : :
7903 : :
7904 : : /*
7905 : : DeclareProcedureToGccSeparateProgram -
7906 : : */
7907 : :
7908 : 3146910 : static void DeclareProcedureToGccSeparateProgram (unsigned int Sym)
7909 : : {
7910 : 3146910 : m2tree_Tree returnType;
7911 : 3146910 : m2tree_Tree GccParam;
7912 : 3146910 : unsigned int scope;
7913 : 3146910 : unsigned int Son;
7914 : 3146910 : unsigned int p;
7915 : 3146910 : unsigned int i;
7916 : 3146910 : unsigned int b;
7917 : 3146910 : unsigned int e;
7918 : 3146910 : m2linemap_location_t begin;
7919 : 3146910 : m2linemap_location_t end;
7920 : 3146910 : m2linemap_location_t location;
7921 : 3146910 : unsigned int tok;
7922 : :
7923 : 3146910 : tok = SymbolTable_GetDeclaredMod (Sym);
7924 : 3146910 : if (((! (SymbolConversion_GccKnowsAbout (Sym))) && (! (IsPseudoProcFunc (Sym)))) && ((((((IsEffectivelyImported (SymbolTable_GetMainModule (), Sym)) || ((GetModuleWhereDeclared (Sym)) == (SymbolTable_GetMainModule ()))) || (M2Base_IsNeededAtRunTime (tok, Sym))) || (SymbolTable_IsImported (SymbolTable_GetBaseModule (), Sym))) || (SymbolTable_IsExported (GetModuleWhereDeclared (Sym), Sym))) || (SymbolTable_IsExtern (Sym))))
7925 : : {
7926 : 1968486 : m2decl_BuildStartFunctionDeclaration (SymbolTable_UsesVarArgs (Sym));
7927 : 1968486 : p = SymbolTable_NoOfParam (Sym);
7928 : 1968486 : i = p;
7929 : : /* Note we dont use GetNthParam as we want the parameter that is seen by
7930 : : the procedure block remember that this is treated exactly the same as
7931 : : a variable, just its position on the activation record is special (ie
7932 : : a parameter). */
7933 : 8208411 : while (i > 0)
7934 : : {
7935 : 4271439 : Son = SymbolTable_GetNth (Sym, i);
7936 : 4271439 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Son));
7937 : 4271439 : if (SymbolTable_IsUnboundedParam (Sym, i))
7938 : : {
7939 : 280043 : GccParam = m2decl_BuildParameterDeclaration (location, NameKey_KeyToCharStar (SymbolTable_GetSymName (Son)), SymbolConversion_Mod2Gcc (SymbolTable_GetLType (Son)), false);
7940 : : }
7941 : : else
7942 : : {
7943 : 3991396 : GccParam = m2decl_BuildParameterDeclaration (location, NameKey_KeyToCharStar (SymbolTable_GetSymName (Son)), SymbolConversion_Mod2Gcc (SymbolTable_GetLType (Son)), SymbolTable_IsVarParam (Sym, i));
7944 : : }
7945 : 8542878 : PreAddModGcc (Son, GccParam);
7946 : 4271439 : WatchRemoveList (Son, M2GCCDeclare_todolist);
7947 : 4271439 : WatchIncludeList (Son, M2GCCDeclare_fullydeclared);
7948 : 4271439 : i -= 1;
7949 : : }
7950 : 1968486 : SymbolTable_GetProcedureBeginEnd (Sym, &b, &e);
7951 : 1968486 : begin = M2LexBuf_TokenToLocation (b);
7952 : 1968486 : end = M2LexBuf_TokenToLocation (e);
7953 : 1968486 : scope = SymbolTable_GetScope (Sym);
7954 : 1968486 : PushBinding (scope);
7955 : 1968486 : if ((SymbolTable_GetSType (Sym)) == SymbolTable_NulSym)
7956 : : {
7957 : : returnType = NULL;
7958 : : }
7959 : : else
7960 : : {
7961 : 800255 : returnType = SymbolConversion_Mod2Gcc (SymbolTable_GetSType (Sym));
7962 : : }
7963 : : /* Exported from the module where it was declared. */
7964 : 3834147 : PreAddModGcc (Sym, m2decl_BuildEndFunctionDeclaration (begin, end, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (Sym)), returnType, IsExternal (Sym), M2GCCDeclare_IsProcedureGccNested (Sym), (SymbolTable_IsExported (GetModuleWhereDeclared (Sym), Sym)) || (SymbolTable_IsExtern (Sym)), SymbolTable_IsProcedureNoReturn (Sym)));
7965 : 1968486 : PopBinding (scope);
7966 : 1968486 : WatchRemoveList (Sym, M2GCCDeclare_todolist);
7967 : 1968486 : WatchIncludeList (Sym, M2GCCDeclare_fullydeclared);
7968 : : }
7969 : 3146910 : }
7970 : :
7971 : :
7972 : : /*
7973 : : DeclareProcedureToGcc - traverses all parameters and interfaces to gm2gcc.
7974 : : */
7975 : :
7976 : 3407562 : static void DeclareProcedureToGcc (unsigned int sym)
7977 : : {
7978 : 3407562 : if (sym != SymbolTable_NulSym)
7979 : : {
7980 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
7981 : 3395238 : if (M2Options_WholeProgram)
7982 : : {
7983 : 248328 : DeclareProcedureToGccWholeProgram (sym);
7984 : : }
7985 : : else
7986 : : {
7987 : 3146910 : DeclareProcedureToGccSeparateProgram (sym);
7988 : : }
7989 : : }
7990 : 3407562 : }
7991 : :
7992 : :
7993 : : /*
7994 : : ActivateWatch - activate a watch for any symbol (lista xor listb).
7995 : : */
7996 : :
7997 : 0 : static void ActivateWatch (Sets_Set lista, Sets_Set listb)
7998 : : {
7999 : 0 : Sets_Set smallest;
8000 : 0 : Sets_Set largest;
8001 : 0 : unsigned int n;
8002 : 0 : unsigned int sym;
8003 : :
8004 : 0 : if ((Sets_NoOfElementsInSet (lista)) != (Sets_NoOfElementsInSet (listb)))
8005 : : {
8006 : 0 : if ((Sets_NoOfElementsInSet (lista)) > (Sets_NoOfElementsInSet (listb)))
8007 : : {
8008 : : largest = lista;
8009 : : smallest = listb;
8010 : : }
8011 : : else
8012 : : {
8013 : 0 : largest = listb;
8014 : 0 : smallest = lista;
8015 : : }
8016 : 0 : M2Printf_printf0 ((const char *) "adding the following symbols to the watch list as the declarator has detected an internal bug: ", 95);
8017 : 0 : sym = 1;
8018 : 0 : n = SymbolTable_FinalSymbol ();
8019 : 0 : while (sym <= n)
8020 : : {
8021 : 0 : if (((Sets_IsElementInSet (largest, sym)) && (! (Sets_IsElementInSet (smallest, sym)))) || ((! (Sets_IsElementInSet (largest, sym))) && (Sets_IsElementInSet (smallest, sym))))
8022 : : {
8023 : 0 : AddSymToWatch (sym);
8024 : 0 : M2Printf_printf1 ((const char *) "%d ", 3, (const unsigned char *) &sym, (sizeof (sym)-1));
8025 : : }
8026 : 0 : sym += 1;
8027 : : }
8028 : 0 : M2Printf_printf0 ((const char *) "\\n", 2);
8029 : : }
8030 : 0 : }
8031 : :
8032 : :
8033 : : /*
8034 : : DeclareTypesConstantsProceduresInRange -
8035 : : */
8036 : :
8037 : 644079 : static void DeclareTypesConstantsProceduresInRange (unsigned int scope, unsigned int start, unsigned int end)
8038 : : {
8039 : 644079 : M2GCCDeclare_Group copy;
8040 : 644079 : unsigned int loop;
8041 : :
8042 : 644079 : if (TraceQuadruples)
8043 : : {
8044 : : M2Quads_DisplayQuadRange (scope, start, end);
8045 : : }
8046 : 644079 : loop = 0;
8047 : 644079 : copy = NULL;
8048 : 725534 : do {
8049 : 725534 : copy = DupGroup (copy);
8050 : 790632 : while (M2GenGCC_ResolveConstantExpressions ((M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareConstFully}, start, end))
8051 : : {} /* empty. */
8052 : : /* we need to evaluate some constant expressions to resolve these types */
8053 : 725480 : if (DeclaredOutstandingTypes (false))
8054 : : {} /* empty. */
8055 : 725480 : if (loop == DebugLoop)
8056 : : {
8057 : 0 : if (TraceQuadruples)
8058 : : {
8059 : : M2Quads_DisplayQuadRange (scope, start, end);
8060 : : }
8061 : 0 : ActivateWatch (copy->ToDoList, GlobalGroup->ToDoList);
8062 : 0 : loop = 0;
8063 : : }
8064 : 725480 : loop += 1;
8065 : 806935 : } while (! ((! (M2GenGCC_ResolveConstantExpressions ((M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareConstFully}, start, end))) && (EqualGroup (copy, GlobalGroup))));
8066 : 644025 : KillGroup (©);
8067 : 644025 : }
8068 : :
8069 : :
8070 : : /*
8071 : : SkipModuleScope - skips all module scopes for, scope.
8072 : : It returns either NulSym or a procedure sym.
8073 : : */
8074 : :
8075 : 4310532 : static unsigned int SkipModuleScope (unsigned int scope)
8076 : : {
8077 : 8498018 : if ((scope == SymbolTable_NulSym) || (SymbolTable_IsProcedure (scope)))
8078 : : {
8079 : 4310532 : return scope;
8080 : : }
8081 : : else
8082 : : {
8083 : 4187486 : return SkipModuleScope (SymbolTable_GetScope (scope));
8084 : : }
8085 : : /* static analysis guarentees a RETURN statement will be used before here. */
8086 : : __builtin_unreachable ();
8087 : : }
8088 : :
8089 : :
8090 : : /*
8091 : : PushBinding -
8092 : : */
8093 : :
8094 : 2155293 : static void PushBinding (unsigned int scope)
8095 : : {
8096 : 2155293 : scope = SkipModuleScope (scope);
8097 : 2155293 : if (scope == SymbolTable_NulSym)
8098 : : {
8099 : 2091778 : m2block_pushGlobalScope ();
8100 : : }
8101 : : else
8102 : : {
8103 : 63515 : m2block_pushFunctionScope (SymbolConversion_Mod2Gcc (scope));
8104 : : }
8105 : 2155293 : }
8106 : :
8107 : :
8108 : : /*
8109 : : PopBinding -
8110 : : */
8111 : :
8112 : 2155239 : static void PopBinding (unsigned int scope)
8113 : : {
8114 : 2155239 : scope = SkipModuleScope (scope);
8115 : 2155239 : if (scope == SymbolTable_NulSym)
8116 : : {
8117 : 2091724 : m2block_popGlobalScope ();
8118 : : }
8119 : : else
8120 : : {
8121 : 63515 : M2Debug_Assert (SymbolTable_IsProcedure (scope));
8122 : 63515 : m2block_finishFunctionDecl (M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (scope)), SymbolConversion_Mod2Gcc (scope));
8123 : 63515 : M2Debug_Assert ((m2block_popFunctionScope ()) != NULL);
8124 : : }
8125 : 2155239 : }
8126 : :
8127 : :
8128 : : /*
8129 : : DeclareTypesConstantsProcedures -
8130 : : */
8131 : :
8132 : 76083 : static void DeclareTypesConstantsProcedures (unsigned int scope)
8133 : : {
8134 : 76083 : M2GCCDeclare_Group copy;
8135 : 76083 : M2Scope_ScopeBlock sb;
8136 : :
8137 : 76083 : if (Debugging)
8138 : : {
8139 : : M2Printf_printf0 ((const char *) "declaring types constants in: ", 30);
8140 : : PrintTerse (scope);
8141 : : }
8142 : 76083 : copy = NULL;
8143 : 76083 : sb = M2Scope_InitScopeBlock (scope);
8144 : 76083 : PushBinding (scope);
8145 : 101303 : do {
8146 : 101303 : copy = DupGroup (copy);
8147 : 101303 : M2Scope_ForeachScopeBlockDo3 (sb, (M2Scope_ScopeProcedure3) {(M2Scope_ScopeProcedure3_t) DeclareTypesConstantsProceduresInRange});
8148 : 101249 : } while (! (EqualGroup (copy, GlobalGroup)));
8149 : 76029 : KillGroup (©);
8150 : 76029 : PopBinding (scope);
8151 : 76029 : M2Scope_KillScopeBlock (&sb);
8152 : 76029 : }
8153 : :
8154 : :
8155 : : /*
8156 : : AssertAllTypesDeclared - asserts that all types for variables are declared in, scope.
8157 : : */
8158 : :
8159 : 75663 : static void AssertAllTypesDeclared (unsigned int scope)
8160 : : {
8161 : 75663 : unsigned int n;
8162 : 75663 : unsigned int Var;
8163 : 75663 : bool failed;
8164 : :
8165 : 75663 : failed = false;
8166 : 75663 : n = 1;
8167 : 75663 : Var = SymbolTable_GetNth (scope, n);
8168 : 840666 : while (Var != SymbolTable_NulSym)
8169 : : {
8170 : 689340 : if (! (AllDependantsFullyDeclared (SymbolTable_GetSType (Var))))
8171 : : {
8172 : 689340 : mystop ();
8173 : : }
8174 : 689340 : if (! (AllDependantsFullyDeclared (SymbolTable_GetSType (Var))))
8175 : : {
8176 : 6 : EmitCircularDependancyError (SymbolTable_GetSType (Var));
8177 : 6 : failed = true;
8178 : : }
8179 : 689340 : n += 1;
8180 : 689340 : Var = SymbolTable_GetNth (scope, n);
8181 : : }
8182 : 75663 : if (failed)
8183 : : {
8184 : 6 : M2Error_FlushErrors ();
8185 : : }
8186 : 75657 : }
8187 : :
8188 : :
8189 : : /*
8190 : : DeclareModuleInit - declare all the ctor related functions within
8191 : : a module.
8192 : : */
8193 : :
8194 : 22978 : static void DeclareModuleInit (unsigned int moduleSym)
8195 : : {
8196 : 22978 : unsigned int ctor;
8197 : 22978 : unsigned int init;
8198 : 22978 : unsigned int fini;
8199 : 22978 : unsigned int dep;
8200 : :
8201 : 22978 : SymbolTable_GetModuleCtors (moduleSym, &ctor, &init, &fini, &dep);
8202 : 22978 : DeclareProcedureToGcc (ctor);
8203 : 22978 : DeclareProcedureToGcc (init);
8204 : 22978 : DeclareProcedureToGcc (fini);
8205 : 22978 : DeclareProcedureToGcc (dep);
8206 : 22978 : }
8207 : :
8208 : :
8209 : : /*
8210 : : StartDeclareProcedureScope -
8211 : : */
8212 : :
8213 : 62471 : static void StartDeclareProcedureScope (unsigned int scope)
8214 : : {
8215 : 62471 : WalkTypesInProcedure (scope);
8216 : 62471 : M2GCCDeclare_DeclareProcedure (scope);
8217 : 62471 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});
8218 : 62471 : DeclareTypesConstantsProcedures (scope);
8219 : 62471 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareTypesConstantsProcedures});
8220 : 62471 : M2GCCDeclare_DeclareLocalVariables (scope);
8221 : 62471 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareModuleVariables});
8222 : 62471 : AssertAllTypesDeclared (scope);
8223 : 62471 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
8224 : 62471 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
8225 : 62471 : }
8226 : :
8227 : :
8228 : : /*
8229 : : StartDeclareModuleScopeSeparate -
8230 : : */
8231 : :
8232 : 12838 : static void StartDeclareModuleScopeSeparate (unsigned int scope)
8233 : : {
8234 : 12838 : if (scope == (SymbolTable_GetMainModule ()))
8235 : : {
8236 : 12430 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule}); /* will populate the TYPE and CONST ToDo list */
8237 : 12430 : DeclareTypesConstantsProcedures (scope); /* will resolved TYPEs and CONSTs on the ToDo */
8238 : : /* lists. */
8239 : 12376 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
8240 : : /*
8241 : : now that all types have been resolved it is safe to declare
8242 : : variables
8243 : : */
8244 : 12376 : AssertAllTypesDeclared (scope);
8245 : 12370 : DeclareGlobalVariables (scope);
8246 : 12370 : SymbolTable_ForeachImportedDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareImportedVariables});
8247 : : /* now it is safe to declare all procedures */
8248 : 12370 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
8249 : 12370 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});
8250 : 12370 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareTypesConstantsProcedures});
8251 : 12370 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
8252 : 12370 : DeclareModuleInit (scope);
8253 : : }
8254 : : else
8255 : : {
8256 : 408 : DeclareTypesConstantsProcedures (scope);
8257 : 408 : AssertAllTypesDeclared (scope);
8258 : 408 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
8259 : 408 : DeclareModuleInit (scope);
8260 : 408 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
8261 : : }
8262 : 12778 : }
8263 : :
8264 : :
8265 : : /*
8266 : : StartDeclareModuleScopeWholeProgram -
8267 : : */
8268 : :
8269 : 408 : static void StartDeclareModuleScopeWholeProgram (unsigned int scope)
8270 : : {
8271 : 408 : if (M2Batch_IsSourceSeen (scope))
8272 : : {
8273 : 408 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule}); /* will populate the TYPE and CONST ToDo list */
8274 : 408 : DeclareTypesConstantsProcedures (scope); /* will resolved TYPEs and CONSTs on the ToDo */
8275 : : /* lists. */
8276 : 408 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
8277 : 408 : SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareModuleInit});
8278 : : /*
8279 : : now that all types have been resolved it is safe to declare
8280 : : variables
8281 : : */
8282 : 408 : AssertAllTypesDeclared (scope);
8283 : 408 : DeclareGlobalVariablesWholeProgram (scope);
8284 : 408 : SymbolTable_ForeachImportedDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareImportedVariablesWholeProgram});
8285 : : /* now it is safe to declare all procedures */
8286 : 408 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
8287 : 408 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});
8288 : 408 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareTypesConstantsProcedures});
8289 : 408 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
8290 : 408 : DeclareModuleInit (scope);
8291 : : }
8292 : : else
8293 : : {
8294 : 0 : DeclareTypesConstantsProcedures (scope);
8295 : 0 : AssertAllTypesDeclared (scope);
8296 : 0 : SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
8297 : 0 : DeclareModuleInit (scope);
8298 : 0 : SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
8299 : : }
8300 : 408 : }
8301 : :
8302 : :
8303 : : /*
8304 : : StartDeclareModuleScope -
8305 : : */
8306 : :
8307 : 13246 : static void StartDeclareModuleScope (unsigned int scope)
8308 : : {
8309 : 13246 : if (M2Options_WholeProgram)
8310 : : {
8311 : 408 : StartDeclareModuleScopeWholeProgram (scope);
8312 : : }
8313 : : else
8314 : : {
8315 : 12838 : StartDeclareModuleScopeSeparate (scope);
8316 : : }
8317 : 13186 : }
8318 : :
8319 : :
8320 : : /*
8321 : : DumpResolver - dumps the m2 representation of sym.
8322 : : */
8323 : :
8324 : 0 : static void DumpResolver (unsigned int sym)
8325 : : {
8326 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "dump filtered symbol %d and dependants\\n", 40, (const unsigned char *) &sym, (sizeof (sym)-1));
8327 : 0 : PrintVerbose (sym);
8328 : 0 : }
8329 : :
8330 : :
8331 : : /*
8332 : : DumpDefinitive - dumps the m2 and m2 gimple representation of sym.
8333 : : */
8334 : :
8335 : 0 : static void DumpDefinitive (unsigned int sym)
8336 : : {
8337 : 0 : int fd;
8338 : :
8339 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "\\nm2 symbol synopsis: %d\\n", 26, (const unsigned char *) &sym, (sizeof (sym)-1));
8340 : 0 : PrintVerbose (sym);
8341 : 0 : if (SymbolConversion_GccKnowsAbout (sym))
8342 : : {
8343 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "\\nm2 gimple: %d", 15, (const unsigned char *) &sym, (sizeof (sym)-1));
8344 : 0 : FIO_FlushBuffer (M2LangDump_GetDumpFile ());
8345 : 0 : fd = FIO_GetUnixFileDescriptor (M2LangDump_GetDumpFile ());
8346 : 0 : m2pp_DumpGimpleFd (fd, SymbolConversion_Mod2Gcc (sym));
8347 : : }
8348 : : else
8349 : : {
8350 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "\\nno m2 gimple for %d\\n", 23, (const unsigned char *) &sym, (sizeof (sym)-1));
8351 : : }
8352 : 0 : }
8353 : :
8354 : :
8355 : : /*
8356 : : PreAddModGcc - adds a relationship between sym and tree.
8357 : : */
8358 : :
8359 : 8771567 : static void PreAddModGcc (unsigned int sym, m2tree_Tree tree)
8360 : : {
8361 : 8120436 : SymbolConversion_AddModGcc (sym, tree);
8362 : 143628 : }
8363 : :
8364 : :
8365 : : /*
8366 : : DeclareDefaultType - declares a default type, sym, with, name.
8367 : : */
8368 : :
8369 : 523068 : static void DeclareDefaultType (unsigned int sym, const char *name_, unsigned int _name_high, m2tree_Tree gcctype)
8370 : : {
8371 : 523068 : m2tree_Tree t;
8372 : 523068 : unsigned int high;
8373 : 523068 : unsigned int low;
8374 : 523068 : m2linemap_location_t location;
8375 : 523068 : char name[_name_high+1];
8376 : :
8377 : : /* make a local copy of each unbounded array. */
8378 : 523068 : memcpy (name, name_, _name_high+1);
8379 : :
8380 : : /* DeclareDefaultType will declare a new identifier as a type of, gcctype, if it has not already been
8381 : : declared by gccgm2.c */
8382 : 1046136 : location = m2linemap_BuiltinsLocation ();
8383 : 523068 : t = m2type_GetDefaultType (location, NameKey_KeyToCharStar (NameKey_MakeKey ((const char *) name, _name_high)), gcctype);
8384 : 523068 : SymbolConversion_AddModGcc (sym, t);
8385 : 523068 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, sym);
8386 : 523068 : WalkAssociatedUnbounded (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
8387 : : /*
8388 : : this is very simplistic and assumes that the caller only uses Subranges, Sets and GCC types.
8389 : : We need to declare any constants with the types so that AllDependantsFullyDeclared works.
8390 : : */
8391 : 523068 : if (SymbolTable_IsSubrange (sym))
8392 : : {
8393 : 12454 : SymbolTable_GetSubrange (sym, &high, &low);
8394 : 12454 : M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), high);
8395 : 12454 : M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), low);
8396 : : }
8397 : 510614 : else if (SymbolTable_IsSet (sym))
8398 : : {
8399 : : /* avoid dangling else. */
8400 : 49816 : if (SymbolTable_IsSubrange (SymbolTable_GetSType (sym)))
8401 : : {
8402 : 49816 : if (! (SymbolConversion_GccKnowsAbout (SymbolTable_GetSType (sym))))
8403 : : {
8404 : : /* only true for internal types of course */
8405 : 0 : M2Error_InternalError ((const char *) "subrange type within the set type must be declared before the set type", 70);
8406 : : }
8407 : 49816 : SymbolTable_GetSubrange (SymbolTable_GetSType (sym), &high, &low);
8408 : 49816 : M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), high);
8409 : 49816 : M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), low);
8410 : : }
8411 : 0 : else if (SymbolTable_IsEnumeration (SymbolTable_GetSType (sym)))
8412 : : {
8413 : : /* avoid dangling else. */
8414 : 0 : if (! (SymbolConversion_GccKnowsAbout (SymbolTable_GetSType (sym))))
8415 : : {
8416 : : /* only true for internal types of course */
8417 : 0 : M2Error_InternalError ((const char *) "enumeration type within the set type must be declared before the set type", 73);
8418 : : }
8419 : : }
8420 : : }
8421 : 523068 : }
8422 : :
8423 : :
8424 : : /*
8425 : : DeclareBoolean - declares the Boolean type together with true and false.
8426 : : */
8427 : :
8428 : 12454 : static void DeclareBoolean (void)
8429 : : {
8430 : 12454 : SymbolConversion_AddModGcc (M2Base_Boolean, m2type_GetBooleanType ());
8431 : 12454 : SymbolConversion_AddModGcc (M2Base_True, m2type_GetBooleanTrue ());
8432 : 12454 : SymbolConversion_AddModGcc (M2Base_False, m2type_GetBooleanFalse ());
8433 : 12454 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_Boolean);
8434 : 12454 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_True);
8435 : 12454 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_False);
8436 : 12454 : WalkAssociatedUnbounded (M2Base_Boolean, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
8437 : 12454 : }
8438 : :
8439 : :
8440 : : /*
8441 : : DeclareFixedSizedType - declares the GNU Modula-2 fixed types
8442 : : (if the back end support such a type).
8443 : : */
8444 : :
8445 : 273988 : static void DeclareFixedSizedType (const char *name_, unsigned int _name_high, unsigned int type, m2tree_Tree t)
8446 : : {
8447 : 273988 : m2linemap_location_t location;
8448 : 273988 : unsigned int typetype;
8449 : 273988 : unsigned int low;
8450 : 273988 : unsigned int high;
8451 : 273988 : char name[_name_high+1];
8452 : :
8453 : : /* make a local copy of each unbounded array. */
8454 : 273988 : memcpy (name, name_, _name_high+1);
8455 : :
8456 : 273988 : if (type != SymbolTable_NulSym)
8457 : : {
8458 : 249080 : if ((SymbolTable_IsSet (type)) && (! (SymbolConversion_GccKnowsAbout (SymbolTable_GetSType (type)))))
8459 : : {
8460 : 37362 : typetype = SymbolTable_GetSType (type);
8461 : 37362 : SymbolTable_GetSubrange (typetype, &high, &low);
8462 : 37362 : M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (type), high);
8463 : 37362 : M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (type), low);
8464 : 37362 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (typetype));
8465 : 37362 : PreAddModGcc (typetype, m2type_BuildSubrangeType (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (typetype)), SymbolConversion_Mod2Gcc (SymbolTable_GetSType (typetype)), SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high)));
8466 : 37362 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, typetype);
8467 : 37362 : WalkAssociatedUnbounded (typetype, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
8468 : : }
8469 : : /* gcc back end supports, type */
8470 : 249080 : DeclareDefaultType (type, (const char *) name, _name_high, t);
8471 : : }
8472 : 273988 : }
8473 : :
8474 : :
8475 : : /*
8476 : : DeclareDefaultSimpleTypes - declares the simple types.
8477 : : */
8478 : :
8479 : 12454 : static void DeclareDefaultSimpleTypes (void)
8480 : : {
8481 : 12454 : SymbolConversion_AddModGcc (M2Base_ZType, m2type_GetM2ZType ());
8482 : 12454 : SymbolConversion_AddModGcc (M2Base_RType, m2type_GetM2RType ());
8483 : 12454 : SymbolConversion_AddModGcc (M2Base_CType, m2type_GetM2CType ());
8484 : 12454 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_ZType);
8485 : 12454 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_RType);
8486 : 12454 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_CType);
8487 : 12454 : DeclareDefaultType (M2Base_Cardinal, (const char *) "CARDINAL", 8, m2type_GetM2CardinalType ());
8488 : 12454 : DeclareDefaultType (M2Base_Integer, (const char *) "INTEGER", 7, m2type_GetM2IntegerType ());
8489 : 12454 : DeclareDefaultType (M2Base_Char, (const char *) "CHAR", 4, m2type_GetM2CharType ());
8490 : 12454 : DeclareDefaultType (M2System_Loc, (const char *) "LOC", 3, m2type_GetISOLocType ());
8491 : 12454 : if (M2Options_Iso)
8492 : : {
8493 : 3060 : DeclareDefaultType (M2System_Byte, (const char *) "BYTE", 4, m2type_GetISOByteType ());
8494 : 3060 : DeclareDefaultType (M2System_Word, (const char *) "WORD", 4, m2type_GetISOWordType ());
8495 : : }
8496 : : else
8497 : : {
8498 : 9394 : DeclareDefaultType (M2System_Byte, (const char *) "BYTE", 4, m2type_GetByteType ());
8499 : 9394 : DeclareDefaultType (M2System_Word, (const char *) "WORD", 4, m2type_GetWordType ());
8500 : : }
8501 : 12454 : DeclareDefaultType (M2Base_Proc, (const char *) "PROC", 4, m2type_GetProcType ());
8502 : 12454 : DeclareDefaultType (M2System_Address, (const char *) "ADDRESS", 7, m2type_GetPointerType ());
8503 : 12454 : DeclareDefaultType (M2Base_LongInt, (const char *) "LONGINT", 7, m2type_GetM2LongIntType ());
8504 : 12454 : DeclareDefaultType (M2Base_LongCard, (const char *) "LONGCARD", 8, m2type_GetM2LongCardType ());
8505 : 12454 : DeclareDefaultType (M2Base_ShortInt, (const char *) "SHORTINT", 8, m2type_GetM2ShortIntType ());
8506 : 12454 : DeclareDefaultType (M2Base_ShortCard, (const char *) "SHORTCARD", 9, m2type_GetM2ShortCardType ());
8507 : 12454 : DeclareDefaultType (M2Base_ShortReal, (const char *) "SHORTREAL", 9, m2type_GetM2ShortRealType ());
8508 : 12454 : DeclareDefaultType (M2Base_Real, (const char *) "REAL", 4, m2type_GetM2RealType ());
8509 : 12454 : DeclareDefaultType (M2Base_LongReal, (const char *) "LONGREAL", 8, m2type_GetM2LongRealType ());
8510 : 12454 : DeclareDefaultType (M2Bitset_Bitnum, (const char *) "BITNUM", 6, m2type_GetBitnumType ());
8511 : 12454 : DeclareDefaultType (M2Bitset_Bitset, (const char *) "BITSET", 6, m2type_GetBitsetType ());
8512 : 12454 : DeclareDefaultType (M2Base_Complex, (const char *) "COMPLEX", 7, m2type_GetM2ComplexType ());
8513 : 12454 : DeclareDefaultType (M2Base_LongComplex, (const char *) "LONGCOMPLEX", 11, m2type_GetM2LongComplexType ());
8514 : 12454 : DeclareDefaultType (M2Base_ShortComplex, (const char *) "SHORTCOMPLEX", 12, m2type_GetM2ShortComplexType ());
8515 : 12454 : DeclareDefaultType (M2System_CSizeT, (const char *) "CSIZE_T", 7, m2type_GetCSizeTType ());
8516 : 12454 : DeclareDefaultType (M2System_CSSizeT, (const char *) "CSSIZE_T", 8, m2type_GetCSSizeTType ());
8517 : 12454 : DeclareBoolean ();
8518 : 12454 : DeclareFixedSizedType ((const char *) "INTEGER8", 8, M2System_IntegerN (8), m2type_GetM2Integer8 ());
8519 : 12454 : DeclareFixedSizedType ((const char *) "INTEGER16", 9, M2System_IntegerN (16), m2type_GetM2Integer16 ());
8520 : 12454 : DeclareFixedSizedType ((const char *) "INTEGER32", 9, M2System_IntegerN (32), m2type_GetM2Integer32 ());
8521 : 12454 : DeclareFixedSizedType ((const char *) "INTEGER64", 9, M2System_IntegerN (64), m2type_GetM2Integer64 ());
8522 : 12454 : DeclareFixedSizedType ((const char *) "CARDINAL8", 9, M2System_CardinalN (8), m2type_GetM2Cardinal8 ());
8523 : 12454 : DeclareFixedSizedType ((const char *) "CARDINAL16", 10, M2System_CardinalN (16), m2type_GetM2Cardinal16 ());
8524 : 12454 : DeclareFixedSizedType ((const char *) "CARDINAL32", 10, M2System_CardinalN (32), m2type_GetM2Cardinal32 ());
8525 : 12454 : DeclareFixedSizedType ((const char *) "CARDINAL64", 10, M2System_CardinalN (64), m2type_GetM2Cardinal64 ());
8526 : 12454 : DeclareFixedSizedType ((const char *) "WORD16", 6, M2System_WordN (16), m2type_GetM2Word16 ());
8527 : 12454 : DeclareFixedSizedType ((const char *) "WORD32", 6, M2System_WordN (32), m2type_GetM2Word32 ());
8528 : 12454 : DeclareFixedSizedType ((const char *) "WORD64", 6, M2System_WordN (64), m2type_GetM2Word64 ());
8529 : 12454 : DeclareFixedSizedType ((const char *) "BITSET8", 7, M2System_SetN (8), m2type_GetM2Bitset8 ());
8530 : 12454 : DeclareFixedSizedType ((const char *) "BITSET16", 8, M2System_SetN (16), m2type_GetM2Bitset16 ());
8531 : 12454 : DeclareFixedSizedType ((const char *) "BITSET32", 8, M2System_SetN (32), m2type_GetM2Bitset32 ());
8532 : 12454 : DeclareFixedSizedType ((const char *) "REAL32", 6, M2System_RealN (32), m2type_GetM2Real32 ());
8533 : 12454 : DeclareFixedSizedType ((const char *) "REAL64", 6, M2System_RealN (64), m2type_GetM2Real64 ());
8534 : 12454 : DeclareFixedSizedType ((const char *) "REAL96", 6, M2System_RealN (96), m2type_GetM2Real96 ());
8535 : 12454 : DeclareFixedSizedType ((const char *) "REAL128", 7, M2System_RealN (128), m2type_GetM2Real128 ());
8536 : 12454 : DeclareFixedSizedType ((const char *) "COMPLEX32", 9, M2System_ComplexN (32), m2type_GetM2Complex32 ());
8537 : 12454 : DeclareFixedSizedType ((const char *) "COMPLEX64", 9, M2System_ComplexN (64), m2type_GetM2Complex64 ());
8538 : 12454 : DeclareFixedSizedType ((const char *) "COMPLEX96", 9, M2System_ComplexN (96), m2type_GetM2Complex96 ());
8539 : 12454 : DeclareFixedSizedType ((const char *) "COMPLEX128", 10, M2System_ComplexN (128), m2type_GetM2Complex128 ());
8540 : 12454 : }
8541 : :
8542 : :
8543 : : /*
8544 : : DeclarePackedBoolean -
8545 : : */
8546 : :
8547 : 12454 : static void DeclarePackedBoolean (void)
8548 : : {
8549 : 12454 : unsigned int e;
8550 : :
8551 : 12454 : e = SymbolTable_GetPackedEquivalent (M2Base_Boolean);
8552 : 12454 : SymbolConversion_AddModGcc (e, m2type_GetPackedBooleanType ());
8553 : 12454 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, e);
8554 : 12454 : }
8555 : :
8556 : :
8557 : : /*
8558 : : DeclarePackedDefaultSimpleTypes -
8559 : : */
8560 : :
8561 : 12454 : static void DeclarePackedDefaultSimpleTypes (void)
8562 : : {
8563 : 0 : DeclarePackedBoolean ();
8564 : 0 : }
8565 : :
8566 : :
8567 : : /*
8568 : : DeclareDefaultTypes - makes default types known to GCC
8569 : : */
8570 : :
8571 : 12454 : static void DeclareDefaultTypes (void)
8572 : : {
8573 : 12454 : if (! HaveInitDefaultTypes)
8574 : : {
8575 : 12454 : HaveInitDefaultTypes = true;
8576 : 12454 : m2block_pushGlobalScope ();
8577 : 12454 : DeclareDefaultSimpleTypes ();
8578 : 12454 : DeclarePackedDefaultSimpleTypes ();
8579 : 12454 : m2block_popGlobalScope ();
8580 : : }
8581 : 12454 : }
8582 : :
8583 : :
8584 : : /*
8585 : : DeclareDefaultConstants - make default constants known to GCC
8586 : : */
8587 : :
8588 : 12454 : static void DeclareDefaultConstants (void)
8589 : : {
8590 : 12454 : SymbolConversion_AddModGcc (M2Base_Nil, m2expr_GetPointerZero (m2linemap_BuiltinsLocation ()));
8591 : 12454 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_Nil);
8592 : 12454 : }
8593 : :
8594 : :
8595 : : /*
8596 : : FindContext - returns the scope where the symbol
8597 : : should be created.
8598 : :
8599 : : Symbols created in a module will
8600 : : return the global context tree, but symbols created
8601 : : in a module which is declared inside
8602 : : a procedure will return the procedure Tree.
8603 : : */
8604 : :
8605 : 99588 : static m2tree_Tree FindContext (unsigned int sym)
8606 : : {
8607 : 99588 : sym = SymbolTable_GetProcedureScope (sym);
8608 : 99588 : if (sym == SymbolTable_NulSym)
8609 : : {
8610 : 99588 : return m2block_GetGlobalContext ();
8611 : : }
8612 : : else
8613 : : {
8614 : 0 : return SymbolConversion_Mod2Gcc (sym);
8615 : : }
8616 : : /* static analysis guarentees a RETURN statement will be used before here. */
8617 : : __builtin_unreachable ();
8618 : : }
8619 : :
8620 : :
8621 : : /*
8622 : : IsEffectivelyImported - returns TRUE if symbol, Sym, was
8623 : : effectively imported into ModSym.
8624 : : */
8625 : :
8626 : 2555800 : static bool IsEffectivelyImported (unsigned int ModSym, unsigned int sym)
8627 : : {
8628 : 2555800 : return (SymbolTable_IsImported (ModSym, sym)) || ((SymbolTable_IsImported (ModSym, GetModuleWhereDeclared (sym))) && (SymbolTable_IsExported (GetModuleWhereDeclared (sym), sym)));
8629 : : /* static analysis guarentees a RETURN statement will be used before here. */
8630 : : __builtin_unreachable ();
8631 : : }
8632 : :
8633 : :
8634 : : /*
8635 : : FindOuterModule - returns the out most module where, sym,
8636 : : was declared. It returns NulSym if the
8637 : : symbol or the module was declared inside
8638 : : a procedure.
8639 : : */
8640 : :
8641 : 99666 : static unsigned int FindOuterModule (unsigned int sym)
8642 : : {
8643 : 99666 : sym = SymbolTable_GetScope (sym);
8644 : 199434 : while (! (SymbolTable_IsDefImp (sym)))
8645 : : {
8646 : 95870 : if (SymbolTable_IsModule (sym))
8647 : : {
8648 : 95870 : if ((SymbolTable_GetScope (sym)) == SymbolTable_NulSym)
8649 : : {
8650 : 95768 : return sym;
8651 : : }
8652 : : else
8653 : : {
8654 : 102 : sym = SymbolTable_GetScope (sym);
8655 : : }
8656 : : }
8657 : 0 : else if (SymbolTable_IsProcedure (sym))
8658 : : {
8659 : : /* avoid dangling else. */
8660 : 0 : sym = SymbolTable_GetScope (sym);
8661 : : }
8662 : : }
8663 : : return sym;
8664 : : /* static analysis guarentees a RETURN statement will be used before here. */
8665 : : __builtin_unreachable ();
8666 : : }
8667 : :
8668 : :
8669 : : /*
8670 : : DoVariableDeclaration - create a corresponding gcc variable and add the association
8671 : : between the front end symbol var and the gcc tree.
8672 : : */
8673 : :
8674 : 619957 : static void DoVariableDeclaration (unsigned int var, void * name, bool isImported, bool isExported, bool isTemporary, bool isGlobal, m2tree_Tree scope)
8675 : : {
8676 : 619957 : m2tree_Tree type;
8677 : 619957 : unsigned int varType;
8678 : 619957 : m2linemap_location_t location;
8679 : :
8680 : 619957 : if ((SymbolTable_IsComponent (var)) || (SymbolTable_IsVarHeap (var)))
8681 : : {
8682 : 118531 : return ;
8683 : : }
8684 : 501426 : if ((SymbolTable_GetMode (var)) == SymbolTable_LeftValue)
8685 : : {
8686 : : /*
8687 : : There are two issues to deal with:
8688 : :
8689 : : (i) LeftValue is really a pointer to GetSType (var), which is built
8690 : : here.
8691 : : (ii) Front end might have specified the back end use a particular
8692 : : data type, in which case we use the specified type.
8693 : : We do not add an extra pointer if this is the case.
8694 : : */
8695 : 70667 : varType = SymbolTable_SkipType (SymbolTable_GetVarBackEndType (var));
8696 : 70667 : if (varType == SymbolTable_NulSym)
8697 : : {
8698 : : /* We have not explicity told back end the type, so build it. */
8699 : 25695 : varType = SymbolTable_GetSType (var);
8700 : 25695 : if (SymbolTable_IsVariableAtAddress (var))
8701 : : {
8702 : 54 : type = m2type_BuildConstPointerType (SymbolConversion_Mod2Gcc (varType));
8703 : : }
8704 : : else
8705 : : {
8706 : 25641 : type = m2type_BuildPointerType (SymbolConversion_Mod2Gcc (varType));
8707 : : }
8708 : : }
8709 : : else
8710 : : {
8711 : : /* We have been requested to use varType. */
8712 : 44972 : type = SymbolConversion_Mod2Gcc (varType);
8713 : : }
8714 : 70667 : M2Debug_Assert (AllDependantsFullyDeclared (varType));
8715 : : }
8716 : : else
8717 : : {
8718 : 430759 : type = SymbolConversion_Mod2Gcc (SymbolTable_GetDType (var));
8719 : : }
8720 : 501426 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (var));
8721 : 501426 : PreAddModGcc (var, m2decl_DeclareKnownVariable (location, name, type, isExported, isImported, isTemporary, isGlobal, scope, NULL));
8722 : 501426 : WatchRemoveList (var, M2GCCDeclare_todolist);
8723 : 501426 : WatchIncludeList (var, M2GCCDeclare_fullydeclared);
8724 : : }
8725 : :
8726 : :
8727 : : /*
8728 : : IsGlobal - is the variable not in a procedure scope.
8729 : : */
8730 : :
8731 : 99588 : static bool IsGlobal (unsigned int sym)
8732 : : {
8733 : 99588 : unsigned int s;
8734 : :
8735 : 99588 : s = SymbolTable_GetScope (sym);
8736 : 199176 : while (((s != SymbolTable_NulSym) && (! (SymbolTable_IsDefImp (s)))) && (! (SymbolTable_IsModule (s))))
8737 : : {
8738 : 0 : if (SymbolTable_IsProcedure (s))
8739 : : {
8740 : : return false;
8741 : : }
8742 : 0 : s = SymbolTable_GetScope (s);
8743 : : }
8744 : : return true;
8745 : : /* static analysis guarentees a RETURN statement will be used before here. */
8746 : : __builtin_unreachable ();
8747 : : }
8748 : :
8749 : :
8750 : : /*
8751 : : DeclareVariable - declares a global variable to GCC.
8752 : : */
8753 : :
8754 : 98610 : static void DeclareVariable (unsigned int ModSym, unsigned int variable)
8755 : : {
8756 : 98610 : m2tree_Tree scope;
8757 : 98610 : unsigned int decl;
8758 : :
8759 : 98610 : if (! (SymbolConversion_GccKnowsAbout (variable)))
8760 : : {
8761 : 98592 : scope = FindContext (ModSym);
8762 : 98592 : decl = FindOuterModule (variable);
8763 : 98592 : M2Debug_Assert (AllDependantsFullyDeclared (SymbolTable_GetSType (variable)));
8764 : 98592 : PushBinding (ModSym);
8765 : : /* in Modula-2 we are allowed to import from ourselves, but we do not present this to GCC */
8766 : 196343 : DoVariableDeclaration (variable, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (variable)), (IsEffectivelyImported (ModSym, variable)) && ((SymbolTable_GetMainModule ()) != decl), SymbolTable_IsExported (ModSym, variable), SymbolTable_IsTemporary (variable), IsGlobal (variable), scope);
8767 : 98592 : PopBinding (ModSym);
8768 : : }
8769 : 98610 : }
8770 : :
8771 : :
8772 : : /*
8773 : : DeclareVariableWholeProgram - declares a global variable to GCC when using -fm2-whole-program.
8774 : : */
8775 : :
8776 : 996 : static void DeclareVariableWholeProgram (unsigned int mainModule, unsigned int variable)
8777 : : {
8778 : 996 : m2tree_Tree scope;
8779 : 996 : unsigned int decl;
8780 : :
8781 : 996 : if (! (SymbolConversion_GccKnowsAbout (variable)))
8782 : : {
8783 : 996 : scope = FindContext (mainModule);
8784 : 996 : decl = FindOuterModule (variable);
8785 : 996 : M2Debug_Assert (AllDependantsFullyDeclared (SymbolTable_GetSType (variable)));
8786 : 996 : PushBinding (mainModule);
8787 : 1992 : DoVariableDeclaration (variable, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (variable)), ((! (M2Batch_IsSourceSeen (decl))) && (IsEffectivelyImported (mainModule, variable))) && ((SymbolTable_GetMainModule ()) != decl), SymbolTable_IsExported (mainModule, variable), SymbolTable_IsTemporary (variable), IsGlobal (variable), scope);
8788 : 996 : PopBinding (mainModule);
8789 : : }
8790 : 996 : }
8791 : :
8792 : :
8793 : : /*
8794 : : DeclareGlobalVariablesWholeProgram -
8795 : : */
8796 : :
8797 : 408 : static void DeclareGlobalVariablesWholeProgram (unsigned int ModSym)
8798 : : {
8799 : 408 : unsigned int n;
8800 : 408 : unsigned int Son;
8801 : :
8802 : 408 : n = 1;
8803 : 408 : Son = SymbolTable_GetNth (ModSym, n);
8804 : 1812 : while (Son != SymbolTable_NulSym)
8805 : : {
8806 : 996 : DeclareVariableWholeProgram (ModSym, Son);
8807 : 996 : n += 1;
8808 : 996 : Son = SymbolTable_GetNth (ModSym, n);
8809 : : }
8810 : 408 : SymbolTable_ForeachInnerModuleDo (ModSym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareGlobalVariablesWholeProgram});
8811 : 408 : }
8812 : :
8813 : :
8814 : : /*
8815 : : DeclareGlobalVariables - lists the Global variables for
8816 : : Module ModSym together with their offset.
8817 : : */
8818 : :
8819 : 12622 : static void DeclareGlobalVariables (unsigned int ModSym)
8820 : : {
8821 : 12622 : unsigned int n;
8822 : 12622 : unsigned int variable;
8823 : :
8824 : 12622 : n = 1;
8825 : 12622 : variable = SymbolTable_GetNth (ModSym, n);
8826 : 123001 : while (variable != SymbolTable_NulSym)
8827 : : {
8828 : 97757 : DeclareVariable (ModSym, variable);
8829 : 97757 : n += 1;
8830 : 97757 : variable = SymbolTable_GetNth (ModSym, n);
8831 : : }
8832 : 12622 : SymbolTable_ForeachInnerModuleDo (ModSym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareGlobalVariables});
8833 : 12622 : }
8834 : :
8835 : :
8836 : : /*
8837 : : DeclareImportedVariables - declares all imported variables to GM2.
8838 : : */
8839 : :
8840 : 71854 : static void DeclareImportedVariables (unsigned int sym)
8841 : : {
8842 : 71854 : if (SymbolTable_IsVar (sym))
8843 : : {
8844 : 853 : DeclareVariable (SymbolTable_GetMainModule (), sym);
8845 : : }
8846 : 71001 : else if (SymbolTable_IsDefImp (sym))
8847 : : {
8848 : : /* avoid dangling else. */
8849 : 1713 : SymbolTable_ForeachExportedDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareImportedVariables});
8850 : : }
8851 : 71854 : }
8852 : :
8853 : :
8854 : : /*
8855 : : DeclareImportedVariablesWholeProgram - declares all imported variables.
8856 : : */
8857 : :
8858 : 6708 : static void DeclareImportedVariablesWholeProgram (unsigned int sym)
8859 : : {
8860 : 6708 : if (SymbolTable_IsVar (sym))
8861 : : {
8862 : : /* avoid dangling else. */
8863 : 78 : if (! (M2Batch_IsSourceSeen (FindOuterModule (sym))))
8864 : : {
8865 : : /* import is necessary, even for -fm2-whole-program as we
8866 : : cannot see the source. */
8867 : 0 : DeclareVariableWholeProgram (SymbolTable_GetMainModule (), sym);
8868 : : }
8869 : : }
8870 : 6630 : else if (SymbolTable_IsDefImp (sym))
8871 : : {
8872 : : /* avoid dangling else. */
8873 : 144 : SymbolTable_ForeachExportedDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareImportedVariablesWholeProgram});
8874 : : }
8875 : 6708 : }
8876 : :
8877 : :
8878 : : /*
8879 : : DeclareFieldValue -
8880 : : */
8881 : :
8882 : 390413 : static m2tree_Tree DeclareFieldValue (unsigned int sym, m2tree_Tree value, m2tree_Tree *list)
8883 : : {
8884 : 390413 : m2linemap_location_t location;
8885 : :
8886 : 390413 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
8887 : 390413 : if (((GetModuleWhereDeclared (sym)) == SymbolTable_NulSym) || ((GetModuleWhereDeclared (sym)) == (SymbolTable_GetMainModule ())))
8888 : : {
8889 : 9636 : return m2type_BuildEnumerator (location, NameKey_KeyToCharStar (SymbolTable_GetSymName (sym)), value, list);
8890 : : }
8891 : : else
8892 : : {
8893 : 380777 : return m2type_BuildEnumerator (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullScopeAsmName (sym)), value, list);
8894 : : }
8895 : : /* static analysis guarentees a RETURN statement will be used before here. */
8896 : : __builtin_unreachable ();
8897 : : }
8898 : :
8899 : :
8900 : : /*
8901 : : DeclareFieldEnumeration - declares an enumerator within the current enumeration type.
8902 : : */
8903 : :
8904 : 390293 : static m2tree_Tree DeclareFieldEnumeration (unsigned int sym)
8905 : : {
8906 : 390293 : unsigned int type;
8907 : 390293 : m2tree_Tree field;
8908 : 390293 : m2tree_Tree enumlist;
8909 : :
8910 : : /* add relationship between gccSym and sym */
8911 : 390293 : type = SymbolTable_GetSType (sym);
8912 : 390293 : enumlist = GetEnumList (type);
8913 : 390293 : SymbolTable_PushValue (sym);
8914 : 390293 : field = DeclareFieldValue (sym, M2ALU_PopIntegerTree (), &enumlist);
8915 : 390293 : PutEnumList (type, enumlist);
8916 : 390293 : return field;
8917 : : /* static analysis guarentees a RETURN statement will be used before here. */
8918 : : __builtin_unreachable ();
8919 : : }
8920 : :
8921 : :
8922 : : /*
8923 : : DeclareEnumeration - declare an enumerated type.
8924 : : */
8925 : :
8926 : 21391 : static m2tree_Tree DeclareEnumeration (unsigned int sym)
8927 : : {
8928 : 21391 : m2tree_Tree enumlist;
8929 : 21391 : m2tree_Tree gccenum;
8930 : 21391 : m2linemap_location_t location;
8931 : :
8932 : 21391 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
8933 : 21391 : gccenum = m2type_BuildStartEnumeration (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)), false);
8934 : 21391 : enumlist = GetEnumList (sym);
8935 : 21391 : return m2type_BuildEndEnumeration (location, gccenum, enumlist);
8936 : : /* static analysis guarentees a RETURN statement will be used before here. */
8937 : : __builtin_unreachable ();
8938 : : }
8939 : :
8940 : :
8941 : : /*
8942 : : DeclareSubrangeNarrow - will return cardinal, integer, or type depending on whether
8943 : : low..high fits in the C data type.
8944 : : */
8945 : :
8946 : 19327 : static m2tree_Tree DeclareSubrangeNarrow (m2linemap_location_t location, unsigned int high, unsigned int low, m2tree_Tree type)
8947 : : {
8948 : 19327 : m2tree_Tree m2low;
8949 : 19327 : m2tree_Tree m2high;
8950 : 19327 : m2tree_Tree lowtree;
8951 : 19327 : m2tree_Tree hightree;
8952 : :
8953 : : /* No zero alignment, therefore the front end will prioritize subranges to match
8954 : : unsigned int, int, or ZTYPE assuming the low..high range fits. */
8955 : 19327 : lowtree = SymbolConversion_Mod2Gcc (low);
8956 : 19327 : hightree = SymbolConversion_Mod2Gcc (high);
8957 : 19327 : if ((m2expr_CompareTrees (lowtree, m2expr_GetIntegerZero (location))) >= 0)
8958 : : {
8959 : : /* avoid dangling else. */
8960 : : /* low..high is always positive, can we use unsigned int? */
8961 : 19071 : m2high = m2type_GetMaxFrom (location, m2type_GetM2CardinalType ());
8962 : 19071 : if ((m2expr_CompareTrees (hightree, m2high)) <= 0)
8963 : : {
8964 : 19071 : return m2type_GetM2CardinalType ();
8965 : : }
8966 : : }
8967 : : else
8968 : : {
8969 : : /* Must be a signed subrange base, can we use int? */
8970 : 256 : m2high = m2type_GetMaxFrom (location, m2type_GetM2IntegerType ());
8971 : 256 : m2low = m2type_GetMinFrom (location, m2type_GetM2IntegerType ());
8972 : 256 : if (((m2expr_CompareTrees (lowtree, m2low)) >= 0) && ((m2expr_CompareTrees (hightree, m2high)) <= 0))
8973 : : {
8974 : 256 : return m2type_GetM2IntegerType ();
8975 : : }
8976 : : }
8977 : : /* Fall back to the ZType. */
8978 : : return type;
8979 : : /* static analysis guarentees a RETURN statement will be used before here. */
8980 : : __builtin_unreachable ();
8981 : : }
8982 : :
8983 : :
8984 : : /*
8985 : : DeclareSubrange - declare a subrange type.
8986 : : */
8987 : :
8988 : 22569 : static m2tree_Tree DeclareSubrange (unsigned int sym)
8989 : : {
8990 : 22569 : m2tree_Tree type;
8991 : 22569 : m2tree_Tree gccsym;
8992 : 22569 : unsigned int align;
8993 : 22569 : unsigned int high;
8994 : 22569 : unsigned int low;
8995 : 22569 : m2linemap_location_t location;
8996 : :
8997 : 22569 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
8998 : 22569 : SymbolTable_GetSubrange (sym, &high, &low);
8999 : 22569 : align = SymbolTable_GetAlignment (sym);
9000 : 22569 : type = SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym));
9001 : 22569 : if (align != SymbolTable_NulSym)
9002 : : {
9003 : 12 : if (m2expr_AreConstantsEqual (m2expr_GetIntegerZero (location), SymbolConversion_Mod2Gcc (align)))
9004 : : {
9005 : 12 : type = m2type_BuildSmallestTypeRange (location, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
9006 : : }
9007 : : else
9008 : : {
9009 : 0 : M2MetaError_MetaError1 ((const char *) "a non-zero alignment in a subrange type {%1Wa} is currently not implemented and will be ignored", 95, sym);
9010 : : }
9011 : : }
9012 : 22557 : else if ((SymbolTable_GetSType (sym)) == M2Base_ZType)
9013 : : {
9014 : : /* avoid dangling else. */
9015 : : /* Can we narrow the ZType subrange to CARDINAL or INTEGER? */
9016 : 19327 : type = DeclareSubrangeNarrow (location, high, low, type);
9017 : : }
9018 : 22569 : gccsym = m2type_BuildSubrangeType (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)), type, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
9019 : 22569 : return gccsym;
9020 : : /* static analysis guarentees a RETURN statement will be used before here. */
9021 : : __builtin_unreachable ();
9022 : : }
9023 : :
9024 : :
9025 : : /*
9026 : : IncludeGetNth -
9027 : : */
9028 : :
9029 : 0 : static void IncludeGetNth (Lists_List l, unsigned int sym)
9030 : : {
9031 : 0 : unsigned int i;
9032 : :
9033 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " ListOfSons [", 13);
9034 : 0 : i = 1;
9035 : 0 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
9036 : : {
9037 : 0 : if (i > 1)
9038 : : {
9039 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) ", ", 2);
9040 : : }
9041 : 0 : Lists_IncludeItemIntoList (l, SymbolTable_GetNth (sym, i));
9042 : 0 : PrintTerse (SymbolTable_GetNth (sym, i));
9043 : 0 : i += 1;
9044 : : }
9045 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
9046 : 0 : }
9047 : :
9048 : :
9049 : : /*
9050 : : IncludeType -
9051 : : */
9052 : :
9053 : 0 : static void IncludeType (Lists_List l, unsigned int sym)
9054 : : {
9055 : 0 : unsigned int t;
9056 : :
9057 : 0 : t = SymbolTable_GetSType (sym);
9058 : 0 : if (t != SymbolTable_NulSym)
9059 : : {
9060 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " type [", 7);
9061 : 0 : PrintTerse (t);
9062 : 0 : Lists_IncludeItemIntoList (l, t);
9063 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
9064 : 0 : t = SymbolTable_GetVarBackEndType (sym);
9065 : 0 : if (t != SymbolTable_NulSym)
9066 : : {
9067 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " gcc type [", 11);
9068 : 0 : PrintTerse (t);
9069 : 0 : Lists_IncludeItemIntoList (l, t);
9070 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
9071 : : }
9072 : : }
9073 : 0 : }
9074 : :
9075 : :
9076 : : /*
9077 : : IncludeSubscript -
9078 : : */
9079 : :
9080 : 0 : static void IncludeSubscript (Lists_List l, unsigned int sym)
9081 : : {
9082 : 0 : unsigned int t;
9083 : :
9084 : 0 : t = SymbolTable_GetArraySubscript (sym);
9085 : 0 : if (t != SymbolTable_NulSym)
9086 : : {
9087 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " subrange [", 11);
9088 : 0 : PrintTerse (t);
9089 : 0 : Lists_IncludeItemIntoList (l, t);
9090 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
9091 : : }
9092 : 0 : }
9093 : :
9094 : :
9095 : : /*
9096 : : PrintLocalSymbol -
9097 : : */
9098 : :
9099 : 0 : static void PrintLocalSymbol (unsigned int sym)
9100 : : {
9101 : 0 : PrintTerse (sym);
9102 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) ", ", 2);
9103 : 0 : }
9104 : :
9105 : :
9106 : : /*
9107 : : PrintLocalSymbols -
9108 : : */
9109 : :
9110 : 0 : static void PrintLocalSymbols (unsigned int sym)
9111 : : {
9112 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "Local Symbols {", 15);
9113 : 0 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PrintLocalSymbol});
9114 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "}", 1);
9115 : 0 : }
9116 : :
9117 : :
9118 : : /*
9119 : : IncludeGetVarient -
9120 : : */
9121 : :
9122 : 0 : static void IncludeGetVarient (Lists_List l, unsigned int sym)
9123 : : {
9124 : 0 : if ((SymbolTable_GetVarient (sym)) != SymbolTable_NulSym)
9125 : : {
9126 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " Varient [", 10);
9127 : 0 : PrintTerse (SymbolTable_GetVarient (sym));
9128 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
9129 : 0 : Lists_IncludeItemIntoList (l, SymbolTable_GetVarient (sym));
9130 : : }
9131 : 0 : }
9132 : :
9133 : :
9134 : : /*
9135 : : IncludeUnbounded - includes the record component of an unbounded type.
9136 : : */
9137 : :
9138 : 0 : static void IncludeUnbounded (Lists_List l, unsigned int sym)
9139 : : {
9140 : 0 : if ((SymbolTable_GetUnboundedRecordType (sym)) != SymbolTable_NulSym)
9141 : : {
9142 : 0 : Lists_IncludeItemIntoList (l, SymbolTable_GetUnboundedRecordType (sym));
9143 : : }
9144 : 0 : }
9145 : :
9146 : :
9147 : : /*
9148 : : IncludePartialUnbounded - includes the type component of a partial unbounded symbol.
9149 : : */
9150 : :
9151 : 0 : static void IncludePartialUnbounded (Lists_List l, unsigned int sym)
9152 : : {
9153 : 0 : if ((SymbolTable_GetSType (sym)) != SymbolTable_NulSym)
9154 : : {
9155 : 0 : Lists_IncludeItemIntoList (l, SymbolTable_GetSType (sym));
9156 : : }
9157 : 0 : }
9158 : :
9159 : :
9160 : : /*
9161 : : PrintDeclared - prints out where, sym, was declared.
9162 : : */
9163 : :
9164 : 0 : static void PrintDeclared (unsigned int sym)
9165 : : {
9166 : 0 : DynamicStrings_String filename;
9167 : 0 : unsigned int lineno;
9168 : 0 : unsigned int tokenno;
9169 : :
9170 : 0 : tokenno = SymbolTable_GetDeclaredMod (sym);
9171 : 0 : filename = M2LexBuf_FindFileNameFromToken (tokenno, 0);
9172 : 0 : lineno = M2LexBuf_TokenToLineNo (tokenno, 0);
9173 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) " declared in %s:%d", 18, (const unsigned char *) &filename, (sizeof (filename)-1), (const unsigned char *) &lineno, (sizeof (lineno)-1));
9174 : 0 : }
9175 : :
9176 : :
9177 : : /*
9178 : : PrintAlignment -
9179 : : */
9180 : :
9181 : 0 : static void PrintAlignment (unsigned int sym)
9182 : : {
9183 : 0 : unsigned int align;
9184 : :
9185 : 0 : if (((((SymbolTable_IsRecord (sym)) || (SymbolTable_IsType (sym))) || (SymbolTable_IsRecordField (sym))) || (SymbolTable_IsPointer (sym))) || (SymbolTable_IsArray (sym)))
9186 : : {
9187 : 0 : align = SymbolTable_GetAlignment (sym);
9188 : 0 : if (align != SymbolTable_NulSym)
9189 : : {
9190 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) " aligned [%d]", 13, (const unsigned char *) &align, (sizeof (align)-1));
9191 : : }
9192 : : }
9193 : 0 : }
9194 : :
9195 : :
9196 : : /*
9197 : : IncludeGetParent -
9198 : : */
9199 : :
9200 : 0 : static void IncludeGetParent (Lists_List l, unsigned int sym)
9201 : : {
9202 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " Parent [", 9);
9203 : 0 : Lists_IncludeItemIntoList (l, SymbolTable_GetParent (sym));
9204 : 0 : PrintTerse (SymbolTable_GetParent (sym));
9205 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
9206 : 0 : }
9207 : :
9208 : :
9209 : : /*
9210 : : PrintDecl -
9211 : : */
9212 : :
9213 : 0 : static void PrintDecl (unsigned int sym)
9214 : : {
9215 : 0 : if (SymbolTable_IsDeclaredPackedResolved (sym))
9216 : : {
9217 : 0 : if (SymbolTable_IsDeclaredPacked (sym))
9218 : : {
9219 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " packed", 7);
9220 : : }
9221 : : else
9222 : : {
9223 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " unpacked", 9);
9224 : : }
9225 : : }
9226 : : else
9227 : : {
9228 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " unknown if packed", 18);
9229 : : }
9230 : 0 : }
9231 : :
9232 : :
9233 : : /*
9234 : : PrintScope - displays the scope and line number of declaration of symbol, sym.
9235 : : */
9236 : :
9237 : 0 : static void PrintScope (unsigned int sym)
9238 : : {
9239 : 0 : NameKey_Name name;
9240 : 0 : unsigned int scope;
9241 : 0 : unsigned int line;
9242 : :
9243 : 0 : line = M2LexBuf_TokenToLineNo (SymbolTable_GetDeclaredMod (sym), 0);
9244 : 0 : scope = SymbolTable_GetScope (sym);
9245 : 0 : name = SymbolTable_GetSymName (scope);
9246 : 0 : M2Printf_fprintf3 (M2LangDump_GetDumpFile (), (const char *) " scope %a:%d %d", 15, (const unsigned char *) &name, (sizeof (name)-1), (const unsigned char *) &line, (sizeof (line)-1), (const unsigned char *) &scope, (sizeof (scope)-1));
9247 : 0 : }
9248 : :
9249 : :
9250 : : /*
9251 : : PrintProcedure -
9252 : : */
9253 : :
9254 : 0 : static void PrintProcedure (unsigned int sym)
9255 : : {
9256 : 0 : NameKey_Name n;
9257 : :
9258 : 0 : n = SymbolTable_GetSymName (sym);
9259 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedure (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9260 : 0 : if (SymbolTable_IsProcedureReachable (sym))
9261 : : {
9262 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsProcedureReachable", 21);
9263 : : }
9264 : 0 : PrintScope (sym);
9265 : 0 : if (SymbolTable_IsExtern (sym))
9266 : : {
9267 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " extern", 7);
9268 : : }
9269 : 0 : if (SymbolTable_IsPublic (sym))
9270 : : {
9271 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " public", 7);
9272 : : }
9273 : 0 : if (SymbolTable_IsCtor (sym))
9274 : : {
9275 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " ctor", 5);
9276 : : }
9277 : 0 : PrintDeclared (sym);
9278 : 0 : }
9279 : :
9280 : :
9281 : : /*
9282 : : PrintString -
9283 : : */
9284 : :
9285 : 0 : static void PrintString (unsigned int sym)
9286 : : {
9287 : 0 : unsigned int len;
9288 : 0 : unsigned int tokenno;
9289 : :
9290 : 0 : if (SymbolTable_IsConstStringKnown (sym))
9291 : : {
9292 : 0 : if (SymbolTable_IsConstStringM2 (sym))
9293 : : {
9294 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "a Modula-2 string", 17);
9295 : : }
9296 : 0 : else if (SymbolTable_IsConstStringC (sym))
9297 : : {
9298 : : /* avoid dangling else. */
9299 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " a C string", 11);
9300 : : }
9301 : 0 : else if (SymbolTable_IsConstStringM2nul (sym))
9302 : : {
9303 : : /* avoid dangling else. */
9304 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " a nul terminated Modula-2 string", 33);
9305 : : }
9306 : 0 : else if (SymbolTable_IsConstStringCnul (sym))
9307 : : {
9308 : : /* avoid dangling else. */
9309 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " a nul terminated C string", 26);
9310 : : }
9311 : 0 : tokenno = SymbolTable_GetDeclaredMod (sym);
9312 : 0 : len = SymbolTable_GetStringLength (tokenno, sym);
9313 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) " length %d", 10, (const unsigned char *) &len, (sizeof (len)-1));
9314 : : }
9315 : : else
9316 : : {
9317 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "is not currently known", 22);
9318 : : }
9319 : 0 : }
9320 : :
9321 : :
9322 : : /*
9323 : : PrintVerboseFromList - prints the, i, th element in the list, l.
9324 : : */
9325 : :
9326 : 0 : static void PrintVerboseFromList (Lists_List l, unsigned int i)
9327 : : {
9328 : 0 : unsigned int type;
9329 : 0 : unsigned int low;
9330 : 0 : unsigned int high;
9331 : 0 : unsigned int sym;
9332 : 0 : NameKey_Name n;
9333 : 0 : NameKey_Name n2;
9334 : :
9335 : 0 : sym = static_cast<unsigned int> (Lists_GetItemFromList (l, i));
9336 : 0 : n = SymbolTable_GetSymName (sym);
9337 : 0 : if (SymbolTable_IsError (sym))
9338 : : {
9339 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsError (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9340 : : }
9341 : 0 : else if (SymbolTable_IsDefImp (sym))
9342 : : {
9343 : : /* avoid dangling else. */
9344 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsDefImp (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9345 : 0 : if (SymbolTable_IsDefinitionForC (sym))
9346 : : {
9347 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "and IsDefinitionForC", 20);
9348 : : }
9349 : 0 : if (SymbolTable_IsHiddenTypeDeclared (sym))
9350 : : {
9351 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsHiddenTypeDeclared", 21);
9352 : : }
9353 : 0 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PrintProcedure});
9354 : : }
9355 : 0 : else if (SymbolTable_IsModule (sym))
9356 : : {
9357 : : /* avoid dangling else. */
9358 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsModule (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9359 : 0 : if (SymbolTable_IsModuleWithinProcedure (sym))
9360 : : {
9361 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " and IsModuleWithinProcedure", 28);
9362 : : }
9363 : : }
9364 : 0 : else if (SymbolTable_IsInnerModule (sym))
9365 : : {
9366 : : /* avoid dangling else. */
9367 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsInnerModule (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9368 : : }
9369 : 0 : else if (SymbolTable_IsUnknown (sym))
9370 : : {
9371 : : /* avoid dangling else. */
9372 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsUnknown (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9373 : : }
9374 : 0 : else if (SymbolTable_IsType (sym))
9375 : : {
9376 : : /* avoid dangling else. */
9377 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsType (%a)", 18, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9378 : 0 : IncludeType (l, sym);
9379 : 0 : PrintAlignment (sym);
9380 : : }
9381 : 0 : else if (SymbolTable_IsProcedure (sym))
9382 : : {
9383 : : /* avoid dangling else. */
9384 : 0 : PrintProcedure (sym);
9385 : : }
9386 : 0 : else if (SymbolTable_IsParameter (sym))
9387 : : {
9388 : : /* avoid dangling else. */
9389 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsParameter (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9390 : 0 : if ((SymbolTable_GetParameterShadowVar (sym)) == SymbolTable_NulSym)
9391 : : {
9392 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " no shadow local variable", 25);
9393 : : }
9394 : : else
9395 : : {
9396 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " shadow ", 8);
9397 : : /* PrintVerboseFromList(l, GetParameterShadowVar(sym)) */
9398 : 0 : IncludeType (l, SymbolTable_GetParameterShadowVar (sym));
9399 : : }
9400 : 0 : IncludeType (l, sym);
9401 : : }
9402 : 0 : else if (SymbolTable_IsPointer (sym))
9403 : : {
9404 : : /* avoid dangling else. */
9405 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsPointer (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9406 : 0 : IncludeType (l, sym);
9407 : 0 : PrintAlignment (sym);
9408 : : }
9409 : 0 : else if (SymbolTable_IsRecord (sym))
9410 : : {
9411 : : /* avoid dangling else. */
9412 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsRecord (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9413 : 0 : PrintLocalSymbols (sym);
9414 : 0 : IncludeGetNth (l, sym);
9415 : 0 : PrintAlignment (sym);
9416 : 0 : PrintDecl (sym);
9417 : : }
9418 : 0 : else if (SymbolTable_IsVarient (sym))
9419 : : {
9420 : : /* avoid dangling else. */
9421 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVarient (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9422 : 0 : PrintDecl (sym);
9423 : 0 : IncludeGetNth (l, sym);
9424 : 0 : IncludeGetVarient (l, sym);
9425 : 0 : IncludeGetParent (l, sym);
9426 : : }
9427 : 0 : else if (SymbolTable_IsFieldVarient (sym))
9428 : : {
9429 : : /* avoid dangling else. */
9430 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsFieldVarient (%a)", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9431 : 0 : PrintDecl (sym);
9432 : 0 : IncludeGetNth (l, sym);
9433 : 0 : IncludeGetVarient (l, sym);
9434 : 0 : IncludeGetParent (l, sym);
9435 : : }
9436 : 0 : else if (SymbolTable_IsFieldEnumeration (sym))
9437 : : {
9438 : : /* avoid dangling else. */
9439 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsFieldEnumeration (%a)", 30, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9440 : : }
9441 : 0 : else if (SymbolTable_IsArray (sym))
9442 : : {
9443 : : /* avoid dangling else. */
9444 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsArray (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9445 : 0 : IncludeSubscript (l, sym);
9446 : 0 : IncludeType (l, sym);
9447 : 0 : PrintAlignment (sym);
9448 : : }
9449 : 0 : else if (SymbolTable_IsEnumeration (sym))
9450 : : {
9451 : : /* avoid dangling else. */
9452 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsEnumeration (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9453 : : }
9454 : 0 : else if (SymbolTable_IsSet (sym))
9455 : : {
9456 : : /* avoid dangling else. */
9457 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSet (%a)", 17, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9458 : 0 : IncludeType (l, sym);
9459 : : }
9460 : 0 : else if (SymbolTable_IsUnbounded (sym))
9461 : : {
9462 : : /* avoid dangling else. */
9463 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsUnbounded (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9464 : 0 : IncludeUnbounded (l, sym);
9465 : : }
9466 : 0 : else if (SymbolTable_IsPartialUnbounded (sym))
9467 : : {
9468 : : /* avoid dangling else. */
9469 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsPartialUnbounded (%a)", 30, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9470 : 0 : IncludePartialUnbounded (l, sym);
9471 : : }
9472 : 0 : else if (SymbolTable_IsRecordField (sym))
9473 : : {
9474 : : /* avoid dangling else. */
9475 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsRecordField (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9476 : 0 : if (SymbolTable_IsRecordFieldAVarientTag (sym))
9477 : : {
9478 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " variant tag", 12);
9479 : : }
9480 : 0 : IncludeType (l, sym);
9481 : 0 : IncludeGetVarient (l, sym);
9482 : 0 : IncludeGetParent (l, sym);
9483 : 0 : PrintAlignment (sym);
9484 : 0 : PrintDecl (sym);
9485 : : }
9486 : 0 : else if (SymbolTable_IsProcType (sym))
9487 : : {
9488 : : /* avoid dangling else. */
9489 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcType (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9490 : : }
9491 : 0 : else if (SymbolTable_IsVar (sym))
9492 : : {
9493 : : /* avoid dangling else. */
9494 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVar (%a) declared in ", 30, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9495 : 0 : PrintScope (sym);
9496 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "mode ", 5);
9497 : 0 : switch (SymbolTable_GetMode (sym))
9498 : : {
9499 : 0 : case SymbolTable_LeftValue:
9500 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "l ", 2);
9501 : 0 : break;
9502 : :
9503 : 0 : case SymbolTable_RightValue:
9504 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "r ", 2);
9505 : 0 : break;
9506 : :
9507 : 0 : case SymbolTable_ImmediateValue:
9508 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "i ", 2);
9509 : 0 : break;
9510 : :
9511 : 0 : case SymbolTable_NoValue:
9512 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "n ", 2);
9513 : 0 : break;
9514 : :
9515 : :
9516 : 0 : default:
9517 : 0 : CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2GCCDeclare.def", 20, 1);
9518 : 0 : __builtin_unreachable ();
9519 : : }
9520 : 0 : if (SymbolTable_IsTemporary (sym))
9521 : : {
9522 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "temporary ", 10);
9523 : : }
9524 : 0 : if (SymbolTable_IsComponent (sym))
9525 : : {
9526 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "component ", 10);
9527 : : }
9528 : 0 : if (SymbolTable_IsVarHeap (sym))
9529 : : {
9530 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "heap ", 5);
9531 : : }
9532 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "\\n", 2);
9533 : 0 : SymbolTable_PrintInitialized (sym);
9534 : 0 : IncludeType (l, sym);
9535 : : }
9536 : 0 : else if (SymbolTable_IsConst (sym))
9537 : : {
9538 : : /* avoid dangling else. */
9539 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConst (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9540 : 0 : if (SymbolTable_IsConstString (sym))
9541 : : {
9542 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) " also IsConstString (%a)", 25, (const unsigned char *) &n, (sizeof (n)-1));
9543 : 0 : PrintString (sym);
9544 : : }
9545 : 0 : else if (SymbolTable_IsConstructor (sym))
9546 : : {
9547 : : /* avoid dangling else. */
9548 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " constant constructor ", 22);
9549 : 0 : IncludeType (l, sym);
9550 : : }
9551 : 0 : else if (SymbolTable_IsConstSet (sym))
9552 : : {
9553 : : /* avoid dangling else. */
9554 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " constant constructor set ", 26);
9555 : 0 : IncludeType (l, sym);
9556 : : }
9557 : : else
9558 : : {
9559 : : /* avoid dangling else. */
9560 : 0 : IncludeType (l, sym);
9561 : : }
9562 : : }
9563 : 0 : else if (SymbolTable_IsConstructor (sym))
9564 : : {
9565 : : /* avoid dangling else. */
9566 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConstructor (non constant) (%a)", 40, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9567 : 0 : IncludeType (l, sym);
9568 : : }
9569 : 0 : else if (SymbolTable_IsConstLit (sym))
9570 : : {
9571 : : /* avoid dangling else. */
9572 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConstLit (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9573 : : }
9574 : 0 : else if (SymbolTable_IsDummy (sym))
9575 : : {
9576 : : /* avoid dangling else. */
9577 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsDummy (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9578 : : }
9579 : 0 : else if (SymbolTable_IsTemporary (sym))
9580 : : {
9581 : : /* avoid dangling else. */
9582 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsTemporary (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9583 : : }
9584 : 0 : else if (SymbolTable_IsVarAParam (sym))
9585 : : {
9586 : : /* avoid dangling else. */
9587 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVarAParam (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9588 : : }
9589 : 0 : else if (SymbolTable_IsSubscript (sym))
9590 : : {
9591 : : /* avoid dangling else. */
9592 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSubscript (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9593 : : }
9594 : 0 : else if (SymbolTable_IsSubrange (sym))
9595 : : {
9596 : : /* avoid dangling else. */
9597 : 0 : SymbolTable_GetSubrange (sym, &high, &low);
9598 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSubrange (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9599 : 0 : if ((low != SymbolTable_NulSym) && (high != SymbolTable_NulSym))
9600 : : {
9601 : 0 : type = SymbolTable_GetSType (sym);
9602 : 0 : if (type != SymbolTable_NulSym)
9603 : : {
9604 : 0 : IncludeType (l, sym);
9605 : 0 : n = SymbolTable_GetSymName (type);
9606 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) " %a", 3, (const unsigned char *) &n, (sizeof (n)-1));
9607 : : }
9608 : 0 : n = SymbolTable_GetSymName (low);
9609 : 0 : n2 = SymbolTable_GetSymName (high);
9610 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "[%a..%a]", 8, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
9611 : : }
9612 : : }
9613 : 0 : else if (SymbolTable_IsProcedureVariable (sym))
9614 : : {
9615 : : /* avoid dangling else. */
9616 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedureVariable (%a)", 31, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9617 : : }
9618 : 0 : else if (SymbolTable_IsProcedureNested (sym))
9619 : : {
9620 : : /* avoid dangling else. */
9621 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedureNested (%a)", 29, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9622 : : }
9623 : 0 : else if (SymbolTable_IsAModula2Type (sym))
9624 : : {
9625 : : /* avoid dangling else. */
9626 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsAModula2Type (%a)", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9627 : : }
9628 : 0 : else if (SymbolTable_IsObject (sym))
9629 : : {
9630 : : /* avoid dangling else. */
9631 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsObject (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9632 : : }
9633 : 0 : else if (SymbolTable_IsTuple (sym))
9634 : : {
9635 : : /* avoid dangling else. */
9636 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsTuple (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9637 : 0 : low = SymbolTable_GetNth (sym, 1);
9638 : 0 : high = SymbolTable_GetNth (sym, 2);
9639 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "%d, %d\\n", 8, (const unsigned char *) &low, (sizeof (low)-1), (const unsigned char *) &high, (sizeof (high)-1));
9640 : : }
9641 : 0 : else if (SymbolTable_IsGnuAsm (sym))
9642 : : {
9643 : : /* avoid dangling else. */
9644 : 0 : if (SymbolTable_IsGnuAsmVolatile (sym))
9645 : : {
9646 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsGnuAsmVolatile (%a)", 28, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9647 : : }
9648 : : else
9649 : : {
9650 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsGnuAsm (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9651 : : }
9652 : : }
9653 : 0 : else if (SymbolTable_IsComponent (sym))
9654 : : {
9655 : : /* avoid dangling else. */
9656 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsComponent (%a) ", 24, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9657 : 0 : i = 1;
9658 : 0 : do {
9659 : 0 : type = SymbolTable_GetNth (sym, i);
9660 : 0 : if (type != SymbolTable_NulSym)
9661 : : {
9662 : 0 : Lists_IncludeItemIntoList (l, type);
9663 : 0 : n = SymbolTable_GetSymName (type);
9664 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "[%a %d] ", 8, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &type, (sizeof (type)-1));
9665 : 0 : i += 1;
9666 : : }
9667 : 0 : } while (! (type == SymbolTable_NulSym));
9668 : : }
9669 : 0 : if (SymbolTable_IsHiddenType (sym))
9670 : : {
9671 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsHiddenType", 13);
9672 : : }
9673 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "\\n", 2);
9674 : 0 : }
9675 : :
9676 : :
9677 : : /*
9678 : : PrintVerbose - prints limited information about a symbol.
9679 : : */
9680 : :
9681 : 0 : static void PrintVerbose (unsigned int sym)
9682 : : {
9683 : 0 : Lists_List l;
9684 : 0 : unsigned int i;
9685 : :
9686 : 0 : Lists_InitList (&l);
9687 : 0 : Lists_IncludeItemIntoList (l, sym);
9688 : 0 : i = 1;
9689 : 0 : while (i <= (Lists_NoOfItemsInList (l)))
9690 : : {
9691 : 0 : PrintVerboseFromList (l, i);
9692 : 0 : i += 1;
9693 : : }
9694 : 0 : Lists_KillList (&l);
9695 : 0 : }
9696 : :
9697 : :
9698 : : /*
9699 : : PrintTerse -
9700 : : */
9701 : :
9702 : 0 : static void PrintTerse (unsigned int sym)
9703 : : {
9704 : 0 : NameKey_Name n;
9705 : :
9706 : 0 : n = SymbolTable_GetSymName (sym);
9707 : 0 : if (SymbolTable_IsError (sym))
9708 : : {
9709 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsError (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9710 : : }
9711 : 0 : else if (SymbolTable_IsDefImp (sym))
9712 : : {
9713 : : /* avoid dangling else. */
9714 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsDefImp (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9715 : 0 : if (SymbolTable_IsDefinitionForC (sym))
9716 : : {
9717 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "and IsDefinitionForC", 20);
9718 : : }
9719 : 0 : if (SymbolTable_IsHiddenTypeDeclared (sym))
9720 : : {
9721 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsHiddenTypeDeclared", 21);
9722 : : }
9723 : : }
9724 : 0 : else if (SymbolTable_IsModule (sym))
9725 : : {
9726 : : /* avoid dangling else. */
9727 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsModule (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9728 : 0 : if (SymbolTable_IsModuleWithinProcedure (sym))
9729 : : {
9730 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " and IsModuleWithinProcedure", 28);
9731 : : }
9732 : : }
9733 : 0 : else if (SymbolTable_IsInnerModule (sym))
9734 : : {
9735 : : /* avoid dangling else. */
9736 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsInnerModule (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9737 : : }
9738 : 0 : else if (SymbolTable_IsUnknown (sym))
9739 : : {
9740 : : /* avoid dangling else. */
9741 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsUnknown (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9742 : : }
9743 : 0 : else if (SymbolTable_IsType (sym))
9744 : : {
9745 : : /* avoid dangling else. */
9746 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsType (%a)", 18, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9747 : : }
9748 : 0 : else if (SymbolTable_IsProcedure (sym))
9749 : : {
9750 : : /* avoid dangling else. */
9751 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedure (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9752 : 0 : if (SymbolTable_IsProcedureReachable (sym))
9753 : : {
9754 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " and IsProcedureReachable", 25);
9755 : : }
9756 : : }
9757 : 0 : else if (SymbolTable_IsParameter (sym))
9758 : : {
9759 : : /* avoid dangling else. */
9760 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsParameter (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9761 : : }
9762 : 0 : else if (SymbolTable_IsPointer (sym))
9763 : : {
9764 : : /* avoid dangling else. */
9765 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsPointer (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9766 : : }
9767 : 0 : else if (SymbolTable_IsRecord (sym))
9768 : : {
9769 : : /* avoid dangling else. */
9770 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsRecord (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9771 : : }
9772 : 0 : else if (SymbolTable_IsVarient (sym))
9773 : : {
9774 : : /* avoid dangling else. */
9775 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVarient (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9776 : : }
9777 : 0 : else if (SymbolTable_IsFieldVarient (sym))
9778 : : {
9779 : : /* avoid dangling else. */
9780 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsFieldVarient (%a)", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9781 : : }
9782 : 0 : else if (SymbolTable_IsFieldEnumeration (sym))
9783 : : {
9784 : : /* avoid dangling else. */
9785 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsFieldEnumeration (%a)", 30, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9786 : : }
9787 : 0 : else if (SymbolTable_IsArray (sym))
9788 : : {
9789 : : /* avoid dangling else. */
9790 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsArray (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9791 : : }
9792 : 0 : else if (SymbolTable_IsEnumeration (sym))
9793 : : {
9794 : : /* avoid dangling else. */
9795 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsEnumeration (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9796 : : }
9797 : 0 : else if (SymbolTable_IsSet (sym))
9798 : : {
9799 : : /* avoid dangling else. */
9800 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSet (%a)", 17, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9801 : : }
9802 : 0 : else if (SymbolTable_IsUnbounded (sym))
9803 : : {
9804 : : /* avoid dangling else. */
9805 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsUnbounded (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9806 : : }
9807 : 0 : else if (SymbolTable_IsRecordField (sym))
9808 : : {
9809 : : /* avoid dangling else. */
9810 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsRecordField (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9811 : : }
9812 : 0 : else if (SymbolTable_IsProcType (sym))
9813 : : {
9814 : : /* avoid dangling else. */
9815 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcType (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9816 : : }
9817 : 0 : else if (SymbolTable_IsVar (sym))
9818 : : {
9819 : : /* avoid dangling else. */
9820 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVar (%a)", 17, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9821 : : }
9822 : 0 : else if (SymbolTable_IsConstString (sym))
9823 : : {
9824 : : /* avoid dangling else. */
9825 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConstString (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9826 : : }
9827 : 0 : else if (SymbolTable_IsConst (sym))
9828 : : {
9829 : : /* avoid dangling else. */
9830 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConst (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9831 : : }
9832 : 0 : else if (SymbolTable_IsConstLit (sym))
9833 : : {
9834 : : /* avoid dangling else. */
9835 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConstLit (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9836 : : }
9837 : 0 : else if (SymbolTable_IsDummy (sym))
9838 : : {
9839 : : /* avoid dangling else. */
9840 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsDummy (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9841 : : }
9842 : 0 : else if (SymbolTable_IsTemporary (sym))
9843 : : {
9844 : : /* avoid dangling else. */
9845 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsTemporary (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9846 : : }
9847 : 0 : else if (SymbolTable_IsVarAParam (sym))
9848 : : {
9849 : : /* avoid dangling else. */
9850 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVarAParam (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9851 : : }
9852 : 0 : else if (SymbolTable_IsSubscript (sym))
9853 : : {
9854 : : /* avoid dangling else. */
9855 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSubscript (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9856 : : }
9857 : 0 : else if (SymbolTable_IsSubrange (sym))
9858 : : {
9859 : : /* avoid dangling else. */
9860 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSubrange (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9861 : : }
9862 : 0 : else if (SymbolTable_IsProcedureVariable (sym))
9863 : : {
9864 : : /* avoid dangling else. */
9865 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedureVariable (%a)", 31, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9866 : : }
9867 : 0 : else if (SymbolTable_IsProcedureNested (sym))
9868 : : {
9869 : : /* avoid dangling else. */
9870 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedureNested (%a)", 29, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9871 : : }
9872 : 0 : else if (SymbolTable_IsAModula2Type (sym))
9873 : : {
9874 : : /* avoid dangling else. */
9875 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsAModula2Type (%a)", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9876 : : }
9877 : 0 : else if (SymbolTable_IsGnuAsm (sym))
9878 : : {
9879 : : /* avoid dangling else. */
9880 : 0 : M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsGnuAsm (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
9881 : : }
9882 : 0 : else if (SymbolTable_IsImport (sym))
9883 : : {
9884 : : /* avoid dangling else. */
9885 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsImport", 15, (const unsigned char *) &sym, (sizeof (sym)-1));
9886 : : }
9887 : 0 : else if (SymbolTable_IsImportStatement (sym))
9888 : : {
9889 : : /* avoid dangling else. */
9890 : 0 : M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsImportStatement", 24, (const unsigned char *) &sym, (sizeof (sym)-1));
9891 : : }
9892 : 0 : if (SymbolTable_IsHiddenType (sym))
9893 : : {
9894 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsHiddenType", 13);
9895 : : }
9896 : 0 : }
9897 : :
9898 : :
9899 : : /*
9900 : : CheckAlignment -
9901 : : */
9902 : :
9903 : 814849 : static m2tree_Tree CheckAlignment (m2tree_Tree type, unsigned int sym)
9904 : : {
9905 : 814849 : unsigned int align;
9906 : :
9907 : 814849 : align = SymbolTable_GetAlignment (sym);
9908 : 814849 : if (align != SymbolTable_NulSym)
9909 : : {
9910 : 192 : M2ALU_PushInt (0);
9911 : 192 : SymbolTable_PushValue (align);
9912 : 192 : if (! (M2ALU_Equ (SymbolTable_GetDeclaredMod (sym))))
9913 : : {
9914 : 84 : return m2type_SetAlignment (type, SymbolConversion_Mod2Gcc (SymbolTable_GetAlignment (sym)));
9915 : : }
9916 : : }
9917 : : return type;
9918 : : /* static analysis guarentees a RETURN statement will be used before here. */
9919 : : __builtin_unreachable ();
9920 : : }
9921 : :
9922 : :
9923 : : /*
9924 : : CheckPragma -
9925 : : */
9926 : :
9927 : 370089 : static m2tree_Tree CheckPragma (m2tree_Tree type, unsigned int sym)
9928 : : {
9929 : 370089 : if (SymbolTable_IsDeclaredPacked (sym))
9930 : : {
9931 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
9932 : 144 : if ((SymbolTable_IsRecordField (sym)) || (SymbolTable_IsFieldVarient (sym)))
9933 : : {
9934 : 108 : type = m2type_SetDeclPacked (type);
9935 : : }
9936 : 36 : else if ((SymbolTable_IsRecord (sym)) || (SymbolTable_IsVarient (sym)))
9937 : : {
9938 : : /* avoid dangling else. */
9939 : 36 : type = m2type_SetTypePacked (type);
9940 : : }
9941 : : }
9942 : 370089 : return CheckAlignment (type, sym);
9943 : : /* static analysis guarentees a RETURN statement will be used before here. */
9944 : : __builtin_unreachable ();
9945 : : }
9946 : :
9947 : :
9948 : : /*
9949 : : IsZero - returns TRUE if symbol, sym, is zero.
9950 : : */
9951 : :
9952 : 36 : static bool IsZero (unsigned int sym)
9953 : : {
9954 : 36 : M2ALU_PushIntegerTree (SymbolConversion_Mod2Gcc (sym));
9955 : 36 : M2ALU_PushInt (0);
9956 : 36 : return M2ALU_Equ (SymbolTable_GetDeclaredMod (sym));
9957 : : /* static analysis guarentees a RETURN statement will be used before here. */
9958 : : __builtin_unreachable ();
9959 : : }
9960 : :
9961 : :
9962 : : /*
9963 : : SetFieldPacked - sets Varient, VarientField and RecordField symbols
9964 : : as packed.
9965 : : */
9966 : :
9967 : 360 : static void SetFieldPacked (unsigned int field)
9968 : : {
9969 : 360 : if (((SymbolTable_IsVarient (field)) || (SymbolTable_IsFieldVarient (field))) || (SymbolTable_IsRecordField (field)))
9970 : : {
9971 : 108 : SymbolTable_PutDeclaredPacked (field, true);
9972 : : }
9973 : 360 : }
9974 : :
9975 : :
9976 : : /*
9977 : : RecordPacked - indicates that record, sym, and its fields
9978 : : are all packed.
9979 : : */
9980 : :
9981 : 36 : static void RecordPacked (unsigned int sym)
9982 : : {
9983 : 36 : SymbolTable_PutDeclaredPacked (sym, true);
9984 : 36 : WalkRecordDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) SetFieldPacked});
9985 : 36 : }
9986 : :
9987 : :
9988 : : /*
9989 : : SetFieldNotPacked - sets Varient, VarientField and RecordField symbols
9990 : : as not packed.
9991 : : */
9992 : :
9993 : 593088 : static void SetFieldNotPacked (unsigned int field)
9994 : : {
9995 : 593088 : if (((SymbolTable_IsVarient (field)) || (SymbolTable_IsFieldVarient (field))) || (SymbolTable_IsRecordField (field)))
9996 : : {
9997 : 297090 : SymbolTable_PutDeclaredPacked (field, false);
9998 : : }
9999 : 593088 : }
10000 : :
10001 : :
10002 : : /*
10003 : : RecordNotPacked - indicates that record, sym, and its fields
10004 : : are all not packed.
10005 : : */
10006 : :
10007 : 73875 : static void RecordNotPacked (unsigned int sym)
10008 : : {
10009 : 73875 : SymbolTable_PutDeclaredPacked (sym, false);
10010 : 73875 : WalkRecordDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) SetFieldNotPacked});
10011 : 73875 : }
10012 : :
10013 : :
10014 : : /*
10015 : : DetermineIfRecordPacked -
10016 : : */
10017 : :
10018 : 73911 : static void DetermineIfRecordPacked (unsigned int sym)
10019 : : {
10020 : 73911 : unsigned int defaultAlignment;
10021 : :
10022 : 73911 : defaultAlignment = SymbolTable_GetDefaultRecordFieldAlignment (sym);
10023 : 73911 : if ((defaultAlignment != SymbolTable_NulSym) && (IsZero (defaultAlignment)))
10024 : : {
10025 : 36 : RecordPacked (sym);
10026 : : }
10027 : : else
10028 : : {
10029 : 73875 : RecordNotPacked (sym);
10030 : : }
10031 : 73911 : }
10032 : :
10033 : :
10034 : : /*
10035 : : DeclarePackedSubrange -
10036 : : */
10037 : :
10038 : 60 : static void DeclarePackedSubrange (unsigned int equiv, unsigned int sym)
10039 : : {
10040 : 60 : m2tree_Tree type;
10041 : 60 : m2tree_Tree gccsym;
10042 : 60 : unsigned int high;
10043 : 60 : unsigned int low;
10044 : 60 : m2linemap_location_t location;
10045 : :
10046 : 60 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
10047 : 60 : SymbolTable_GetSubrange (sym, &high, &low);
10048 : 60 : type = m2type_BuildSmallestTypeRange (location, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
10049 : 60 : gccsym = m2type_BuildSubrangeType (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)), type, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
10050 : 60 : SymbolConversion_AddModGcc (equiv, gccsym);
10051 : 60 : }
10052 : :
10053 : :
10054 : : /*
10055 : : DeclarePackedSet -
10056 : : */
10057 : :
10058 : 0 : static void DeclarePackedSet (unsigned int equiv, unsigned int sym)
10059 : : {
10060 : 0 : m2tree_Tree highLimit;
10061 : 0 : m2tree_Tree range;
10062 : 0 : m2tree_Tree gccsym;
10063 : 0 : unsigned int type;
10064 : 0 : unsigned int high;
10065 : 0 : unsigned int low;
10066 : 0 : m2linemap_location_t location;
10067 : :
10068 : 0 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
10069 : 0 : M2Debug_Assert (SymbolTable_IsSet (sym));
10070 : 0 : type = SymbolTable_GetDType (sym);
10071 : 0 : low = M2GCCDeclare_GetTypeMin (type);
10072 : 0 : high = M2GCCDeclare_GetTypeMax (type);
10073 : 0 : highLimit = m2expr_BuildSub (location, SymbolConversion_Mod2Gcc (high), SymbolConversion_Mod2Gcc (low), false);
10074 : : /* --fixme-- we need to check that low <= WORDLENGTH. */
10075 : 0 : highLimit = m2expr_BuildLSL (location, m2expr_GetIntegerOne (location), highLimit, false);
10076 : 0 : range = m2type_BuildSmallestTypeRange (location, m2expr_GetIntegerZero (location), highLimit);
10077 : 0 : gccsym = m2type_BuildSubrangeType (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)), range, m2expr_GetIntegerZero (location), highLimit);
10078 : 0 : SymbolConversion_AddModGcc (equiv, gccsym);
10079 : 0 : }
10080 : :
10081 : 120 : static void DeclarePackedFieldEnumeration (unsigned int sym)
10082 : : {
10083 : 120 : unsigned int equiv;
10084 : 120 : unsigned int type;
10085 : 120 : m2tree_Tree field;
10086 : 120 : m2tree_Tree enumlist;
10087 : :
10088 : : /* add relationship between gccSym and sym */
10089 : 120 : type = SymbolTable_GetSType (sym);
10090 : 120 : equiv = SymbolTable_GetPackedEquivalent (type);
10091 : 120 : enumlist = GetEnumList (equiv);
10092 : 120 : SymbolTable_PushValue (sym);
10093 : 120 : field = DeclareFieldValue (sym, M2ALU_PopIntegerTree (), &enumlist);
10094 : 120 : M2Debug_Assert (field != NULL);
10095 : 120 : PutEnumList (equiv, enumlist);
10096 : 120 : }
10097 : :
10098 : :
10099 : : /*
10100 : : DeclarePackedEnumeration -
10101 : : */
10102 : :
10103 : 36 : static void DeclarePackedEnumeration (unsigned int equiv, unsigned int sym)
10104 : : {
10105 : 36 : m2tree_Tree enumlist;
10106 : 36 : m2tree_Tree gccenum;
10107 : 36 : m2linemap_location_t location;
10108 : :
10109 : 36 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
10110 : 36 : gccenum = m2type_BuildStartEnumeration (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)), true);
10111 : 36 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclarePackedFieldEnumeration});
10112 : 36 : enumlist = GetEnumList (equiv);
10113 : 36 : gccenum = m2type_BuildEndEnumeration (location, gccenum, enumlist);
10114 : 36 : SymbolConversion_AddModGcc (equiv, gccenum);
10115 : 36 : }
10116 : :
10117 : :
10118 : : /*
10119 : : DeclarePackedType -
10120 : : */
10121 : :
10122 : 0 : static void DeclarePackedType (unsigned int equiv, unsigned int sym)
10123 : : {
10124 : 0 : unsigned int type;
10125 : :
10126 : 0 : type = SymbolTable_GetSType (sym);
10127 : 0 : if (type == SymbolTable_NulSym)
10128 : : {
10129 : 0 : if (sym == M2Base_Boolean)
10130 : : {
10131 : 0 : SymbolConversion_AddModGcc (equiv, m2type_GetPackedBooleanType ());
10132 : : }
10133 : : else
10134 : : {
10135 : 0 : SymbolConversion_AddModGcc (equiv, SymbolConversion_Mod2Gcc (sym));
10136 : : }
10137 : : }
10138 : : else
10139 : : {
10140 : 0 : DeclarePackedType (SymbolTable_GetPackedEquivalent (type), type);
10141 : 0 : SymbolConversion_AddModGcc (equiv, SymbolConversion_Mod2Gcc (SymbolTable_GetPackedEquivalent (type)));
10142 : : }
10143 : 0 : }
10144 : :
10145 : :
10146 : : /*
10147 : : doDeclareEquivalent -
10148 : : */
10149 : :
10150 : 216 : static m2tree_Tree doDeclareEquivalent (unsigned int sym, M2GCCDeclare_doDeclareProcedure p)
10151 : : {
10152 : 216 : unsigned int equiv;
10153 : :
10154 : 216 : equiv = SymbolTable_GetPackedEquivalent (sym);
10155 : 216 : if (! (SymbolConversion_GccKnowsAbout (equiv)))
10156 : : {
10157 : 96 : (*p.proc) (equiv, sym);
10158 : 96 : Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, equiv);
10159 : : }
10160 : 216 : return SymbolConversion_Mod2Gcc (equiv);
10161 : : /* static analysis guarentees a RETURN statement will be used before here. */
10162 : : __builtin_unreachable ();
10163 : : }
10164 : :
10165 : :
10166 : : /*
10167 : : PossiblyPacked -
10168 : : */
10169 : :
10170 : 296178 : static m2tree_Tree PossiblyPacked (unsigned int sym, bool isPacked)
10171 : : {
10172 : 296178 : if (isPacked)
10173 : : {
10174 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
10175 : 108 : if (SymbolTable_IsSubrange (sym))
10176 : : {
10177 : 60 : return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedSubrange});
10178 : : }
10179 : 48 : else if (SymbolTable_IsType (sym))
10180 : : {
10181 : : /* avoid dangling else. */
10182 : 0 : return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedType});
10183 : : }
10184 : 48 : else if (SymbolTable_IsEnumeration (sym))
10185 : : {
10186 : : /* avoid dangling else. */
10187 : 48 : return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedEnumeration});
10188 : : }
10189 : 0 : else if (SymbolTable_IsSet (sym))
10190 : : {
10191 : : /* avoid dangling else. */
10192 : 0 : return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedSet});
10193 : : }
10194 : : }
10195 : 296070 : return SymbolConversion_Mod2Gcc (sym);
10196 : : /* static analysis guarentees a RETURN statement will be used before here. */
10197 : : __builtin_unreachable ();
10198 : : }
10199 : :
10200 : :
10201 : : /*
10202 : : GetPackedType - returns a possibly packed type for field.
10203 : : */
10204 : :
10205 : 108 : static m2tree_Tree GetPackedType (unsigned int sym)
10206 : : {
10207 : 108 : if (SymbolTable_IsSubrange (sym))
10208 : : {
10209 : 60 : return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedSubrange});
10210 : : }
10211 : 48 : else if (SymbolTable_IsType (sym))
10212 : : {
10213 : : /* avoid dangling else. */
10214 : 0 : return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedType});
10215 : : }
10216 : 48 : else if (SymbolTable_IsEnumeration (sym))
10217 : : {
10218 : : /* avoid dangling else. */
10219 : 48 : return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedEnumeration});
10220 : : }
10221 : 0 : return SymbolConversion_Mod2Gcc (sym);
10222 : : /* static analysis guarentees a RETURN statement will be used before here. */
10223 : : __builtin_unreachable ();
10224 : : }
10225 : :
10226 : :
10227 : : /*
10228 : : MaybeAlignField - checks to see whether, field, is packed or aligned and it updates
10229 : : the offsets if appropriate.
10230 : : */
10231 : :
10232 : 296850 : static m2tree_Tree MaybeAlignField (unsigned int field, m2tree_Tree *byteOffset, m2tree_Tree *bitOffset)
10233 : : {
10234 : 296850 : m2tree_Tree f;
10235 : 296850 : m2tree_Tree ftype;
10236 : 296850 : m2tree_Tree nbits;
10237 : 296850 : m2linemap_location_t location;
10238 : :
10239 : 296850 : f = SymbolConversion_Mod2Gcc (field);
10240 : 296850 : if (SymbolTable_IsDeclaredPacked (field))
10241 : : {
10242 : 108 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (field));
10243 : 108 : f = m2type_SetDeclPacked (f);
10244 : 108 : ftype = GetPackedType (SymbolTable_GetSType (field));
10245 : 108 : nbits = m2expr_BuildTBitSize (location, ftype);
10246 : 108 : f = m2type_SetRecordFieldOffset (f, (*byteOffset), (*bitOffset), ftype, nbits);
10247 : 108 : (*bitOffset) = m2expr_BuildAdd (location, (*bitOffset), nbits, false);
10248 : 108 : return f;
10249 : : }
10250 : : else
10251 : : {
10252 : 296742 : return CheckAlignment (f, field);
10253 : : }
10254 : : /* static analysis guarentees a RETURN statement will be used before here. */
10255 : : __builtin_unreachable ();
10256 : : }
10257 : :
10258 : :
10259 : : /*
10260 : : DeclareRecord - declares a record and its fields to gcc.
10261 : : The final gcc record type is returned.
10262 : : */
10263 : :
10264 : 73911 : static m2tree_Tree DeclareRecord (unsigned int Sym)
10265 : : {
10266 : 73911 : unsigned int Field;
10267 : 73911 : unsigned int i;
10268 : 73911 : m2tree_Tree nbits;
10269 : 73911 : m2tree_Tree ftype;
10270 : 73911 : m2tree_Tree field;
10271 : 73911 : m2tree_Tree byteOffset;
10272 : 73911 : m2tree_Tree bitOffset;
10273 : 73911 : m2tree_Tree FieldList;
10274 : 73911 : m2tree_Tree RecordType;
10275 : 73911 : m2linemap_location_t location;
10276 : :
10277 : 73911 : i = 1;
10278 : 73911 : FieldList = (m2tree_Tree) (NULL);
10279 : 73911 : RecordType = DoStartDeclaration (Sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartRecord});
10280 : 73911 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Sym));
10281 : 73911 : byteOffset = m2expr_GetIntegerZero (location);
10282 : 73911 : bitOffset = m2expr_GetIntegerZero (location);
10283 : 369663 : do {
10284 : 369663 : Field = SymbolTable_GetNth (Sym, i);
10285 : 369663 : if (Field != SymbolTable_NulSym)
10286 : : {
10287 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
10288 : 295752 : if (((SymbolTable_IsRecordField (Field)) && (SymbolTable_IsRecordFieldAVarientTag (Field))) && ((SymbolTable_GetSymName (Field)) == NameKey_NulName))
10289 : : {} /* empty. */
10290 : : /* do not include a nameless tag into the C struct */
10291 : 295722 : else if (SymbolTable_IsVarient (Field))
10292 : : {
10293 : : /* avoid dangling else. */
10294 : 240 : Field = Chained (Field);
10295 : 240 : field = SymbolConversion_Mod2Gcc (Field);
10296 : 240 : if (SymbolTable_IsDeclaredPacked (Field))
10297 : : {
10298 : 0 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Field));
10299 : 0 : field = m2type_SetDeclPacked (field);
10300 : 0 : ftype = GetPackedType (SymbolTable_GetSType (Field));
10301 : 0 : nbits = m2expr_BuildTBitSize (location, ftype);
10302 : 0 : field = m2type_SetRecordFieldOffset (field, byteOffset, bitOffset, ftype, nbits);
10303 : 0 : bitOffset = m2expr_BuildAdd (location, bitOffset, nbits, false);
10304 : 0 : byteOffset = m2expr_BuildAdd (location, byteOffset, m2expr_BuildDivTrunc (location, bitOffset, m2decl_BuildIntegerConstant (8), false), false);
10305 : 0 : bitOffset = m2expr_BuildModTrunc (location, bitOffset, m2decl_BuildIntegerConstant (8), false);
10306 : : }
10307 : 240 : FieldList = m2type_ChainOn (FieldList, field);
10308 : : }
10309 : : else
10310 : : {
10311 : : /* avoid dangling else. */
10312 : 295482 : if (Debugging)
10313 : : {
10314 : : M2Printf_printf0 ((const char *) "chaining ", 9);
10315 : : PrintTerse (Field);
10316 : : M2Printf_printf0 ((const char *) "\\n", 2);
10317 : : }
10318 : 295482 : FieldList = m2type_ChainOn (FieldList, MaybeAlignField (Chained (Field), &byteOffset, &bitOffset));
10319 : : }
10320 : : }
10321 : 369663 : i += 1;
10322 : 369663 : } while (! (Field == SymbolTable_NulSym));
10323 : 73911 : WatchRemoveList (Sym, M2GCCDeclare_partiallydeclared);
10324 : 73911 : WatchRemoveList (Sym, M2GCCDeclare_heldbyalignment);
10325 : 73911 : WatchRemoveList (Sym, M2GCCDeclare_finishedalignment);
10326 : 73911 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Sym));
10327 : 73911 : return m2type_BuildEndRecord (location, RecordType, FieldList, SymbolTable_IsDeclaredPacked (Sym));
10328 : : /* static analysis guarentees a RETURN statement will be used before here. */
10329 : : __builtin_unreachable ();
10330 : : }
10331 : :
10332 : :
10333 : : /*
10334 : : DeclareRecordField -
10335 : : */
10336 : :
10337 : 296178 : static m2tree_Tree DeclareRecordField (unsigned int sym)
10338 : : {
10339 : 296178 : m2tree_Tree field;
10340 : 296178 : m2tree_Tree GccFieldType;
10341 : 296178 : m2linemap_location_t location;
10342 : :
10343 : 296178 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
10344 : 296178 : GccFieldType = PossiblyPacked (SymbolTable_GetSType (sym), SymbolTable_IsDeclaredPacked (sym));
10345 : 296178 : field = m2type_BuildFieldRecord (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)), GccFieldType);
10346 : 296178 : return field;
10347 : : /* static analysis guarentees a RETURN statement will be used before here. */
10348 : : __builtin_unreachable ();
10349 : : }
10350 : :
10351 : :
10352 : : /*
10353 : : DeclareVarient - declares a record and its fields to gcc.
10354 : : The final gcc record type is returned.
10355 : : */
10356 : :
10357 : 276 : static m2tree_Tree DeclareVarient (unsigned int sym)
10358 : : {
10359 : 276 : unsigned int Field;
10360 : 276 : unsigned int i;
10361 : 276 : m2tree_Tree byteOffset;
10362 : 276 : m2tree_Tree bitOffset;
10363 : 276 : m2tree_Tree FieldList;
10364 : 276 : m2tree_Tree VarientType;
10365 : 276 : m2linemap_location_t location;
10366 : :
10367 : 276 : i = 1;
10368 : 276 : FieldList = (m2tree_Tree) (NULL);
10369 : 276 : VarientType = DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartVarient});
10370 : 276 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
10371 : 276 : byteOffset = m2expr_GetIntegerZero (location);
10372 : 276 : bitOffset = m2expr_GetIntegerZero (location);
10373 : 942 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
10374 : : {
10375 : 666 : Field = SymbolTable_GetNth (sym, i);
10376 : 666 : if (((SymbolTable_IsRecordField (Field)) && (SymbolTable_IsRecordFieldAVarientTag (Field))) && ((SymbolTable_GetSymName (Field)) == NameKey_NulName))
10377 : : {} /* empty. */
10378 : : else
10379 : : {
10380 : : /* do not include a nameless tag into the C struct */
10381 : 666 : if (Debugging)
10382 : : {
10383 : : M2Printf_printf0 ((const char *) "chaining ", 9);
10384 : : PrintTerse (Field);
10385 : : M2Printf_printf0 ((const char *) "\\n", 2);
10386 : : }
10387 : 666 : FieldList = m2type_ChainOn (FieldList, MaybeAlignField (Chained (Field), &byteOffset, &bitOffset));
10388 : : }
10389 : 666 : i += 1;
10390 : : }
10391 : 276 : WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
10392 : 276 : WatchRemoveList (sym, M2GCCDeclare_heldbyalignment);
10393 : 276 : WatchRemoveList (sym, M2GCCDeclare_finishedalignment);
10394 : 276 : VarientType = m2type_BuildEndVarient (location, VarientType, FieldList, SymbolTable_IsDeclaredPacked (sym));
10395 : 276 : return VarientType;
10396 : : /* static analysis guarentees a RETURN statement will be used before here. */
10397 : : __builtin_unreachable ();
10398 : : }
10399 : :
10400 : :
10401 : : /*
10402 : : DeclareFieldVarient -
10403 : : */
10404 : :
10405 : 666 : static m2tree_Tree DeclareFieldVarient (unsigned int sym)
10406 : : {
10407 : 666 : unsigned int i;
10408 : 666 : unsigned int f;
10409 : 666 : m2tree_Tree VarientList;
10410 : 666 : m2tree_Tree VarientType;
10411 : 666 : m2tree_Tree byteOffset;
10412 : 666 : m2tree_Tree bitOffset;
10413 : 666 : m2tree_Tree GccFieldType;
10414 : 666 : m2linemap_location_t location;
10415 : :
10416 : 666 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
10417 : 666 : i = 1;
10418 : 666 : VarientList = (m2tree_Tree) (NULL);
10419 : 666 : VarientType = DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartFieldVarient});
10420 : : /* no need to store the [sym, RecordType] tuple as it is stored by DeclareRecord which calls us */
10421 : 666 : byteOffset = m2expr_GetIntegerZero (location);
10422 : 666 : bitOffset = m2expr_GetIntegerZero (location);
10423 : 1368 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
10424 : : {
10425 : 702 : f = SymbolTable_GetNth (sym, i);
10426 : 702 : if ((SymbolTable_IsFieldVarient (f)) && (SymbolTable_IsEmptyFieldVarient (f)))
10427 : : {} /* empty. */
10428 : : else
10429 : : {
10430 : : /* do not include empty varient fields (created via 'else end' in variant records */
10431 : 702 : if (Debugging)
10432 : : {
10433 : : M2Printf_printf0 ((const char *) "chaining ", 9);
10434 : : PrintTerse (f);
10435 : : M2Printf_printf0 ((const char *) "\\n", 2);
10436 : : }
10437 : 702 : VarientList = m2type_ChainOn (VarientList, MaybeAlignField (Chained (f), &byteOffset, &bitOffset));
10438 : : }
10439 : 702 : i += 1;
10440 : : }
10441 : 666 : WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
10442 : 666 : GccFieldType = m2type_BuildEndFieldVarient (location, VarientType, VarientList, SymbolTable_IsDeclaredPacked (sym));
10443 : 666 : return GccFieldType;
10444 : : /* static analysis guarentees a RETURN statement will be used before here. */
10445 : : __builtin_unreachable ();
10446 : : }
10447 : :
10448 : :
10449 : : /*
10450 : : DeclarePointer - declares a pointer type to gcc and returns the Tree.
10451 : : */
10452 : :
10453 : 119890 : static m2tree_Tree DeclarePointer (unsigned int sym)
10454 : : {
10455 : 119890 : return m2type_BuildPointerType (SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym)));
10456 : : /* static analysis guarentees a RETURN statement will be used before here. */
10457 : : __builtin_unreachable ();
10458 : : }
10459 : :
10460 : :
10461 : : /*
10462 : : DeclareUnbounded - builds an unbounded type and returns the gcc tree.
10463 : : */
10464 : :
10465 : 27907 : static m2tree_Tree DeclareUnbounded (unsigned int sym)
10466 : : {
10467 : 27907 : unsigned int record;
10468 : :
10469 : 27907 : M2Debug_Assert (SymbolTable_IsUnbounded (sym));
10470 : 27907 : if (SymbolConversion_GccKnowsAbout (sym))
10471 : : {
10472 : 0 : return SymbolConversion_Mod2Gcc (sym);
10473 : : }
10474 : : else
10475 : : {
10476 : 27907 : record = SymbolTable_GetUnboundedRecordType (sym);
10477 : 27907 : M2Debug_Assert (SymbolTable_IsRecord (record));
10478 : 27907 : M2Debug_Assert (AllDependantsFullyDeclared (record));
10479 : 27907 : if (! (SymbolConversion_GccKnowsAbout (record)))
10480 : : {
10481 : 0 : DeclareTypeConstFully (record);
10482 : 0 : WatchRemoveList (record, M2GCCDeclare_todolist);
10483 : : }
10484 : 27907 : return SymbolConversion_Mod2Gcc (record);
10485 : : }
10486 : : /* static analysis guarentees a RETURN statement will be used before here. */
10487 : : __builtin_unreachable ();
10488 : : }
10489 : :
10490 : :
10491 : : /*
10492 : : BuildIndex -
10493 : : */
10494 : :
10495 : 27419 : static m2tree_Tree BuildIndex (unsigned int tokenno, unsigned int array)
10496 : : {
10497 : 27419 : unsigned int Subscript;
10498 : 27419 : unsigned int Type;
10499 : 27419 : unsigned int High;
10500 : 27419 : unsigned int Low;
10501 : 27419 : m2tree_Tree n;
10502 : 27419 : m2tree_Tree low;
10503 : 27419 : m2tree_Tree high;
10504 : 27419 : m2linemap_location_t location;
10505 : :
10506 : 27419 : location = M2LexBuf_TokenToLocation (tokenno);
10507 : 27419 : Subscript = SymbolTable_GetArraySubscript (array);
10508 : 27419 : M2Debug_Assert (SymbolTable_IsSubscript (Subscript));
10509 : 27419 : Type = SymbolTable_GetDType (Subscript);
10510 : 27419 : Low = M2GCCDeclare_GetTypeMin (Type);
10511 : 27419 : High = M2GCCDeclare_GetTypeMax (Type);
10512 : 27419 : M2GCCDeclare_DeclareConstant (tokenno, Low);
10513 : 27419 : M2GCCDeclare_DeclareConstant (tokenno, High);
10514 : 27419 : low = SymbolConversion_Mod2Gcc (Low);
10515 : 27419 : high = SymbolConversion_Mod2Gcc (High);
10516 : 27419 : if (m2type_ExceedsTypeRange (m2type_GetIntegerType (), low, high))
10517 : : {
10518 : 24 : location = M2LexBuf_TokenToLocation (tokenno);
10519 : 24 : n = m2convert_BuildConvert (location, m2type_GetIntegerType (), m2expr_BuildSub (location, high, low, false), false);
10520 : 24 : if ((m2expr_TreeOverflow (n)) || (m2type_ValueOutOfTypeRange (m2type_GetIntegerType (), n)))
10521 : : {
10522 : 0 : M2MetaError_MetaError3 ((const char *) "implementation restriction, array is too large {%1EDM}, the range {%2ad}..{%3ad} exceeds the integer range", 106, array, Low, High);
10523 : 0 : return m2type_BuildArrayIndexType (m2expr_GetIntegerZero (location), m2expr_GetIntegerZero (location));
10524 : : }
10525 : : else
10526 : : {
10527 : 24 : SymbolTable_PutArrayLarge (array);
10528 : 24 : return m2type_BuildArrayIndexType (m2expr_GetIntegerZero (location), n);
10529 : : }
10530 : : }
10531 : : else
10532 : : {
10533 : 27395 : low = m2convert_BuildConvert (location, m2type_GetIntegerType (), low, false);
10534 : 27395 : high = m2convert_BuildConvert (location, m2type_GetIntegerType (), high, false);
10535 : 27395 : return m2type_BuildArrayIndexType (low, high);
10536 : : }
10537 : : /* static analysis guarentees a RETURN statement will be used before here. */
10538 : : __builtin_unreachable ();
10539 : : }
10540 : :
10541 : :
10542 : : /*
10543 : : DeclareArray - declares an array to gcc and returns the gcc tree.
10544 : : */
10545 : :
10546 : 23410 : static m2tree_Tree DeclareArray (unsigned int Sym)
10547 : : {
10548 : 23410 : unsigned int typeOfArray;
10549 : 23410 : m2tree_Tree ArrayType;
10550 : 23410 : m2tree_Tree GccArray;
10551 : 23410 : m2tree_Tree GccIndex;
10552 : 23410 : unsigned int Subscript;
10553 : 23410 : unsigned int tokenno;
10554 : 23410 : m2linemap_location_t location;
10555 : :
10556 : 23410 : M2Debug_Assert (SymbolTable_IsArray (Sym));
10557 : 23410 : tokenno = SymbolTable_GetDeclaredMod (Sym);
10558 : 23410 : location = M2LexBuf_TokenToLocation (tokenno);
10559 : 23410 : Subscript = SymbolTable_GetArraySubscript (Sym);
10560 : 23410 : typeOfArray = SymbolTable_GetDType (Sym);
10561 : 23410 : GccArray = SymbolConversion_Mod2Gcc (typeOfArray);
10562 : 23410 : GccIndex = BuildIndex (tokenno, Sym);
10563 : 23410 : if (SymbolConversion_GccKnowsAbout (Sym))
10564 : : {
10565 : 3175 : ArrayType = SymbolConversion_Mod2Gcc (Sym);
10566 : : }
10567 : : else
10568 : : {
10569 : 20235 : ArrayType = m2type_BuildStartArrayType (GccIndex, GccArray, static_cast<int> (typeOfArray));
10570 : 20235 : PreAddModGcc (Sym, ArrayType);
10571 : : }
10572 : 23410 : PreAddModGcc (Subscript, GccArray); /* we save the type of this array as the subscript */
10573 : 23410 : M2ALU_PushIntegerTree (m2expr_BuildSize (location, GccArray, false)); /* and the size of this array so far */
10574 : 23410 : SymbolTable_PopSize (Subscript); /* and the size of this array so far */
10575 : 23410 : GccArray = m2type_BuildEndArrayType (ArrayType, GccArray, GccIndex, static_cast<int> (typeOfArray));
10576 : 23410 : M2Debug_Assert (GccArray == ArrayType);
10577 : 23410 : return GccArray;
10578 : : /* static analysis guarentees a RETURN statement will be used before here. */
10579 : : __builtin_unreachable ();
10580 : : }
10581 : :
10582 : :
10583 : : /*
10584 : : DeclareProcType - declares a procedure type to gcc and returns the gcc type tree.
10585 : : */
10586 : :
10587 : 48534 : static m2tree_Tree DeclareProcType (unsigned int Sym)
10588 : : {
10589 : 48534 : unsigned int i;
10590 : 48534 : unsigned int p;
10591 : 48534 : unsigned int Son;
10592 : 48534 : unsigned int ReturnType;
10593 : 48534 : m2tree_Tree func;
10594 : 48534 : m2tree_Tree GccParam;
10595 : 48534 : m2linemap_location_t location;
10596 : :
10597 : 48534 : ReturnType = SymbolTable_GetSType (Sym);
10598 : 48534 : func = DoStartDeclaration (Sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartFunctionType});
10599 : 48534 : m2type_InitFunctionTypeParameters ();
10600 : 48534 : p = SymbolTable_NoOfParam (Sym);
10601 : 48534 : i = p;
10602 : 165766 : while (i > 0)
10603 : : {
10604 : 68698 : Son = SymbolTable_GetNthParam (Sym, i);
10605 : 68698 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Son));
10606 : 68698 : GccParam = m2type_BuildProcTypeParameterDeclaration (location, SymbolConversion_Mod2Gcc (SymbolTable_GetSType (Son)), SymbolTable_IsVarParam (Sym, i));
10607 : 68698 : PreAddModGcc (Son, GccParam);
10608 : 68698 : i -= 1;
10609 : : }
10610 : 48534 : if (ReturnType == SymbolTable_NulSym)
10611 : : {
10612 : 41744 : return m2type_BuildEndFunctionType (func, NULL, SymbolTable_UsesVarArgs (Sym));
10613 : : }
10614 : : else
10615 : : {
10616 : 6790 : return m2type_BuildEndFunctionType (func, SymbolConversion_Mod2Gcc (ReturnType), SymbolTable_UsesVarArgs (Sym));
10617 : : }
10618 : : /* static analysis guarentees a RETURN statement will be used before here. */
10619 : : __builtin_unreachable ();
10620 : : }
10621 : :
10622 : :
10623 : : /*
10624 : : FindMinMaxEnum - finds the minimum and maximum enumeration fields.
10625 : : */
10626 : :
10627 : 2207746 : static void FindMinMaxEnum (unsigned int field)
10628 : : {
10629 : 2207746 : if (MaxEnumerationField == SymbolTable_NulSym)
10630 : : {
10631 : 318058 : MaxEnumerationField = static_cast<unsigned int> (field);
10632 : : }
10633 : : else
10634 : : {
10635 : 1889688 : SymbolTable_PushValue (field);
10636 : 1889688 : SymbolTable_PushValue (MaxEnumerationField);
10637 : 1889688 : if (M2ALU_Gre (SymbolTable_GetDeclaredMod (field)))
10638 : : {
10639 : 197284 : MaxEnumerationField = static_cast<unsigned int> (field);
10640 : : }
10641 : : }
10642 : 2207746 : if (MinEnumerationField == SymbolTable_NulSym)
10643 : : {
10644 : 318058 : MinEnumerationField = static_cast<unsigned int> (field);
10645 : : }
10646 : : else
10647 : : {
10648 : 1889688 : SymbolTable_PushValue (field);
10649 : 1889688 : SymbolTable_PushValue (MinEnumerationField);
10650 : 1889688 : if (M2ALU_Less (SymbolTable_GetDeclaredMod (field)))
10651 : : {
10652 : 1392260 : MinEnumerationField = static_cast<unsigned int> (field);
10653 : : }
10654 : : }
10655 : 2207746 : }
10656 : :
10657 : :
10658 : : /*
10659 : : PushNoOfBits - pushes the integer value of the number of bits required
10660 : : to maintain a set of type.
10661 : : */
10662 : :
10663 : 2379 : static void PushNoOfBits (unsigned int type, unsigned int low, unsigned int high)
10664 : : {
10665 : 2379 : SymbolTable_PushValue (high);
10666 : 2379 : M2ALU_ConvertToType (type);
10667 : 2379 : SymbolTable_PushValue (low);
10668 : 2379 : M2ALU_ConvertToType (type);
10669 : 2379 : M2ALU_Sub ();
10670 : 2379 : M2ALU_ConvertToType (M2Base_Cardinal);
10671 : 2379 : }
10672 : :
10673 : :
10674 : : /*
10675 : : DeclareLargeSet - n is the name of the set.
10676 : : type is the subrange type (or simple type)
10677 : : low and high are the limits of the subrange.
10678 : : */
10679 : :
10680 : 702 : static m2tree_Tree DeclareLargeSet (NameKey_Name n, unsigned int type, unsigned int low, unsigned int high)
10681 : : {
10682 : 702 : m2tree_Tree lowtree;
10683 : 702 : m2tree_Tree hightree;
10684 : 702 : m2tree_Tree BitsInSet;
10685 : 702 : m2tree_Tree RecordType;
10686 : 702 : m2tree_Tree GccField;
10687 : 702 : m2tree_Tree FieldList;
10688 : 702 : unsigned int bpw;
10689 : 702 : m2linemap_location_t location;
10690 : :
10691 : 702 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (type));
10692 : 702 : bpw = m2decl_GetBitsPerBitset ();
10693 : 702 : SymbolTable_PushValue (low);
10694 : 702 : lowtree = M2ALU_PopIntegerTree ();
10695 : 702 : SymbolTable_PushValue (high);
10696 : 702 : hightree = M2ALU_PopIntegerTree ();
10697 : 702 : FieldList = (m2tree_Tree) (NULL);
10698 : 702 : RecordType = m2type_BuildStartRecord (location, NameKey_KeyToCharStar (n)); /* no problem with recursive types here */
10699 : 702 : PushNoOfBits (type, low, high); /* no problem with recursive types here */
10700 : 702 : M2ALU_PushCard (1);
10701 : 702 : M2ALU_Addn ();
10702 : 702 : BitsInSet = M2ALU_PopIntegerTree ();
10703 : 702 : M2ALU_PushIntegerTree (BitsInSet);
10704 : 702 : M2ALU_PushCard (0);
10705 : 26734 : while (M2ALU_Gre (SymbolTable_GetDeclaredMod (type)))
10706 : : {
10707 : 25330 : M2ALU_PushIntegerTree (BitsInSet);
10708 : 25330 : M2ALU_PushCard (bpw-1);
10709 : 25330 : if (M2ALU_GreEqu (SymbolTable_GetDeclaredMod (type)))
10710 : : {
10711 : 25196 : M2ALU_PushIntegerTree (lowtree);
10712 : 25196 : M2ALU_PushCard (bpw-1);
10713 : 25196 : M2ALU_Addn ();
10714 : 25196 : GccField = m2type_BuildFieldRecord (location, NULL, m2type_BuildSetType (location, NULL, SymbolConversion_Mod2Gcc (type), lowtree, M2ALU_PopIntegerTree (), false));
10715 : 25196 : M2ALU_PushIntegerTree (lowtree);
10716 : 25196 : M2ALU_PushCard (bpw);
10717 : 25196 : M2ALU_Addn ();
10718 : 25196 : lowtree = M2ALU_PopIntegerTree ();
10719 : 25196 : M2ALU_PushIntegerTree (BitsInSet);
10720 : 25196 : M2ALU_PushCard (bpw);
10721 : 25196 : M2ALU_Sub ();
10722 : 25196 : BitsInSet = M2ALU_PopIntegerTree ();
10723 : : }
10724 : : else
10725 : : {
10726 : : /* printf2('range is %a..%a
10727 : : ', GetSymName(low), GetSymName(high)) ; */
10728 : 134 : GccField = m2type_BuildFieldRecord (location, NULL, m2type_BuildSetType (location, NULL, SymbolConversion_Mod2Gcc (type), lowtree, hightree, false));
10729 : 134 : M2ALU_PushCard (0);
10730 : 134 : BitsInSet = M2ALU_PopIntegerTree ();
10731 : : }
10732 : 25330 : FieldList = m2type_ChainOn (FieldList, GccField);
10733 : 25330 : M2ALU_PushIntegerTree (BitsInSet);
10734 : 25330 : M2ALU_PushCard (0);
10735 : : }
10736 : 702 : return m2type_BuildEndRecord (location, RecordType, FieldList, false);
10737 : : /* static analysis guarentees a RETURN statement will be used before here. */
10738 : : __builtin_unreachable ();
10739 : : }
10740 : :
10741 : :
10742 : : /*
10743 : : DeclareLargeOrSmallSet - works out whether the set will exceed TSIZE(WORD). If it does
10744 : : we manufacture a set using:
10745 : :
10746 : : settype = RECORD
10747 : : w1: SET OF [...]
10748 : : w2: SET OF [...]
10749 : : END
10750 : :
10751 : : We do this as GCC and GDB (stabs) only knows about WORD sized sets.
10752 : : If the set will fit into a WORD then we call gccgm2 directly.
10753 : : */
10754 : :
10755 : 1677 : static m2tree_Tree DeclareLargeOrSmallSet (unsigned int sym, NameKey_Name n, unsigned int type, unsigned int low, unsigned int high)
10756 : : {
10757 : 1677 : m2linemap_location_t location;
10758 : 1677 : bool packed;
10759 : :
10760 : 1677 : PushNoOfBits (type, low, high);
10761 : 1677 : M2ALU_PushCard (static_cast<unsigned int> (m2decl_GetBitsPerBitset ()));
10762 : 1677 : packed = SymbolTable_IsSetPacked (sym);
10763 : 1677 : if (M2ALU_Less (SymbolTable_GetDeclaredMod (type)))
10764 : : {
10765 : 975 : location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
10766 : : /* PutSetSmall(sym) ; */
10767 : 975 : return m2type_BuildSetType (location, NameKey_KeyToCharStar (n), SymbolConversion_Mod2Gcc (type), SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high), packed);
10768 : : }
10769 : : else
10770 : : {
10771 : 702 : return DeclareLargeSet (n, type, low, high); /* --fixme-- finish packed here as well. */
10772 : : }
10773 : : /* static analysis guarentees a RETURN statement will be used before here. */
10774 : : __builtin_unreachable ();
10775 : : }
10776 : :
10777 : :
10778 : : /*
10779 : : DeclareSet - declares a set type to gcc and returns a Tree.
10780 : : */
10781 : :
10782 : 1677 : static m2tree_Tree DeclareSet (unsigned int sym)
10783 : : {
10784 : 1677 : m2tree_Tree gccsym;
10785 : 1677 : unsigned int type;
10786 : 1677 : unsigned int high;
10787 : 1677 : unsigned int low;
10788 : :
10789 : 1677 : type = SymbolTable_GetDType (sym);
10790 : 1677 : if (SymbolTable_IsSubrange (type))
10791 : : {
10792 : 944 : SymbolTable_GetSubrange (type, &high, &low);
10793 : 944 : gccsym = DeclareLargeOrSmallSet (sym, M2AsmUtil_GetFullSymName (sym), SymbolTable_GetSType (type), low, high);
10794 : : }
10795 : : else
10796 : : {
10797 : 733 : gccsym = DeclareLargeOrSmallSet (sym, M2AsmUtil_GetFullSymName (sym), type, M2GCCDeclare_GetTypeMin (type), M2GCCDeclare_GetTypeMax (type));
10798 : : }
10799 : 1677 : return gccsym;
10800 : : /* static analysis guarentees a RETURN statement will be used before here. */
10801 : : __builtin_unreachable ();
10802 : : }
10803 : :
10804 : :
10805 : : /*
10806 : : CheckResolveSubrange - checks to see whether we can determine
10807 : : the subrange type. We are able to do
10808 : : this once low, high and the type are known.
10809 : : */
10810 : :
10811 : 2019279 : static void CheckResolveSubrange (unsigned int sym)
10812 : : {
10813 : 2019279 : unsigned int tokenno;
10814 : 2019279 : unsigned int size;
10815 : 2019279 : unsigned int high;
10816 : 2019279 : unsigned int low;
10817 : 2019279 : unsigned int type;
10818 : :
10819 : 2019279 : SymbolTable_GetSubrange (sym, &high, &low);
10820 : 2019279 : tokenno = SymbolTable_GetDeclaredMod (sym);
10821 : 2019279 : type = SymbolTable_GetSType (sym);
10822 : 2019279 : if (type == SymbolTable_NulSym)
10823 : : {
10824 : 1438834 : if ((SymbolConversion_GccKnowsAbout (low)) && (SymbolConversion_GccKnowsAbout (high)))
10825 : : {
10826 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
10827 : 20161 : if ((SymbolTable_IsConstString (low)) && (SymbolTable_IsConstStringKnown (low)))
10828 : : {
10829 : 72 : size = SymbolTable_GetStringLength (tokenno, low);
10830 : 72 : if (size == 1)
10831 : : {
10832 : 72 : SymbolTable_PutSubrange (sym, low, high, M2Base_Char);
10833 : : }
10834 : : else
10835 : : {
10836 : 0 : M2MetaError_MetaError1 ((const char *) "cannot have a subrange of a string type {%1Uad}", 47, sym);
10837 : : }
10838 : : }
10839 : 20089 : else if (SymbolTable_IsFieldEnumeration (low))
10840 : : {
10841 : : /* avoid dangling else. */
10842 : 338 : if ((SymbolTable_GetSType (low)) == (SymbolTable_GetSType (high)))
10843 : : {
10844 : 338 : SymbolTable_PutSubrange (sym, low, high, SymbolTable_GetSType (low));
10845 : : }
10846 : : else
10847 : : {
10848 : 0 : M2MetaError_MetaError1 ((const char *) "subrange limits must be of the same type {%1Uad}", 48, sym);
10849 : : }
10850 : : }
10851 : 19751 : else if (SymbolTable_IsValueSolved (low))
10852 : : {
10853 : : /* avoid dangling else. */
10854 : 19751 : if ((SymbolTable_GetSType (low)) == M2Base_LongReal)
10855 : : {
10856 : 0 : M2MetaError_MetaError1 ((const char *) "cannot have a subrange of a SHORTREAL, REAL or LONGREAL type {%1Uad}", 68, sym);
10857 : : }
10858 : : else
10859 : : {
10860 : 19751 : SymbolTable_PutSubrange (sym, low, high, M2Base_MixTypes (SymbolTable_GetSType (low), SymbolTable_GetSType (high), SymbolTable_GetDeclaredMod (sym)));
10861 : : }
10862 : : }
10863 : : }
10864 : : }
10865 : 2019279 : }
10866 : :
10867 : :
10868 : : /*
10869 : : TypeConstFullyDeclared - all, sym, dependents are declared, so create and
10870 : : return the GCC Tree equivalent.
10871 : : */
10872 : :
10873 : 1066322 : static m2tree_Tree TypeConstFullyDeclared (unsigned int sym)
10874 : : {
10875 : 1066322 : m2tree_Tree t;
10876 : :
10877 : 1066322 : if (SymbolTable_IsEnumeration (sym))
10878 : : {
10879 : 21391 : t = DeclareEnumeration (sym);
10880 : : }
10881 : 1044931 : else if (SymbolTable_IsFieldEnumeration (sym))
10882 : : {
10883 : : /* avoid dangling else. */
10884 : 390293 : t = DeclareFieldEnumeration (sym);
10885 : : }
10886 : 654638 : else if (SymbolTable_IsSubrange (sym))
10887 : : {
10888 : : /* avoid dangling else. */
10889 : 22569 : t = DeclareSubrange (sym);
10890 : : }
10891 : 632069 : else if (SymbolTable_IsRecord (sym))
10892 : : {
10893 : : /* avoid dangling else. */
10894 : 73911 : t = CheckPragma (DeclareRecord (sym), sym);
10895 : : }
10896 : 558158 : else if (SymbolTable_IsRecordField (sym))
10897 : : {
10898 : : /* avoid dangling else. */
10899 : 296178 : t = CheckPragma (DeclareRecordField (sym), sym);
10900 : : }
10901 : 261980 : else if (SymbolTable_IsFieldVarient (sym))
10902 : : {
10903 : : /* avoid dangling else. */
10904 : 666 : t = DeclareFieldVarient (sym);
10905 : : }
10906 : 261314 : else if (SymbolTable_IsVarient (sym))
10907 : : {
10908 : : /* avoid dangling else. */
10909 : 276 : t = DeclareVarient (sym);
10910 : : }
10911 : 261038 : else if (SymbolTable_IsPointer (sym))
10912 : : {
10913 : : /* avoid dangling else. */
10914 : 99283 : t = CheckAlignment (DeclarePointer (sym), sym);
10915 : : }
10916 : 161755 : else if (SymbolTable_IsUnbounded (sym))
10917 : : {
10918 : : /* avoid dangling else. */
10919 : 27907 : t = DeclareUnbounded (sym);
10920 : : }
10921 : 133848 : else if (SymbolTable_IsArray (sym))
10922 : : {
10923 : : /* avoid dangling else. */
10924 : 23410 : t = CheckAlignment (DeclareArray (sym), sym);
10925 : : }
10926 : 110438 : else if (SymbolTable_IsProcType (sym))
10927 : : {
10928 : : /* avoid dangling else. */
10929 : 43218 : t = DeclareProcType (sym);
10930 : : }
10931 : 67220 : else if (SymbolTable_IsSet (sym))
10932 : : {
10933 : : /* avoid dangling else. */
10934 : 1677 : t = DeclareSet (sym);
10935 : : }
10936 : 65543 : else if (SymbolTable_IsConst (sym))
10937 : : {
10938 : : /* avoid dangling else. */
10939 : 40218 : if (SymbolTable_IsConstructor (sym))
10940 : : {
10941 : 2517 : SymbolTable_PushValue (sym);
10942 : 2517 : M2ALU_ChangeToConstructor (SymbolTable_GetDeclaredMod (sym), SymbolTable_GetSType (sym));
10943 : 2517 : SymbolTable_PopValue (sym);
10944 : 2517 : M2ALU_EvaluateValue (sym);
10945 : 2517 : M2ALU_PutConstructorSolved (sym);
10946 : : }
10947 : 37701 : else if (SymbolTable_IsConstSet (sym))
10948 : : {
10949 : : /* avoid dangling else. */
10950 : 0 : M2ALU_EvaluateValue (sym);
10951 : : }
10952 : 40218 : if (! (SymbolTable_IsValueSolved (sym)))
10953 : : {
10954 : : return NULL;
10955 : : }
10956 : 40218 : t = DeclareConst (SymbolTable_GetDeclaredMod (sym), sym);
10957 : 40218 : M2Debug_Assert (t != NULL);
10958 : : }
10959 : 25325 : else if (SymbolTable_IsConstructor (sym))
10960 : : {
10961 : : /* avoid dangling else. */
10962 : : /* not yet known as a constant */
10963 : : return NULL;
10964 : : }
10965 : : else
10966 : : {
10967 : : /* avoid dangling else. */
10968 : 25325 : t = DeclareType (sym);
10969 : 25325 : if (SymbolTable_IsType (sym))
10970 : : {
10971 : 25325 : t = CheckAlignment (t, sym);
10972 : : }
10973 : : }
10974 : 1066322 : return m2block_RememberType (t);
10975 : : /* static analysis guarentees a RETURN statement will be used before here. */
10976 : : __builtin_unreachable ();
10977 : : }
10978 : :
10979 : :
10980 : : /*
10981 : : IsBaseType - returns true if a type, Sym, is a base type and
10982 : : we use predefined GDB information to represent this
10983 : : type.
10984 : : */
10985 : :
10986 : 13190 : static bool IsBaseType (unsigned int Sym)
10987 : : {
10988 : 13190 : return (((Sym == M2Base_Cardinal) || (Sym == M2Base_Integer)) || (Sym == M2Base_Char)) || (Sym == M2Base_Proc);
10989 : : /* static analysis guarentees a RETURN statement will be used before here. */
10990 : : __builtin_unreachable ();
10991 : : }
10992 : :
10993 : :
10994 : : /*
10995 : : IsFieldEnumerationDependants - sets enumDeps to FALSE if action(Sym)
10996 : : is also FALSE.
10997 : : */
10998 : :
10999 : 994751 : static void IsFieldEnumerationDependants (unsigned int Sym)
11000 : : {
11001 : 994751 : if (! ((*action.proc) (Sym)))
11002 : : {
11003 : 390141 : enumDeps = false;
11004 : : }
11005 : 994751 : }
11006 : :
11007 : :
11008 : : /*
11009 : : IsEnumerationDependants - returns true if the enumeration
11010 : : p(dependants) all return true.
11011 : : */
11012 : :
11013 : 110858 : static bool IsEnumerationDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11014 : : {
11015 : 110858 : action = q;
11016 : 110858 : enumDeps = true;
11017 : 110858 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) IsFieldEnumerationDependants});
11018 : 110858 : return enumDeps;
11019 : : /* static analysis guarentees a RETURN statement will be used before here. */
11020 : : __builtin_unreachable ();
11021 : : }
11022 : :
11023 : :
11024 : : /*
11025 : : WalkEnumerationDependants - returns walks all dependants of Sym.
11026 : : */
11027 : :
11028 : 2043791 : static void WalkEnumerationDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11029 : : {
11030 : 2043791 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) p.proc});
11031 : 0 : }
11032 : :
11033 : :
11034 : : /*
11035 : : WalkSubrangeDependants - calls p(dependants) for each dependant of, sym.
11036 : : */
11037 : :
11038 : 1086284 : static void WalkSubrangeDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11039 : : {
11040 : 1086284 : unsigned int type;
11041 : 1086284 : unsigned int align;
11042 : 1086284 : unsigned int high;
11043 : 1086284 : unsigned int low;
11044 : :
11045 : 1086284 : SymbolTable_GetSubrange (sym, &high, &low);
11046 : 1086284 : CheckResolveSubrange (sym);
11047 : 1086284 : type = SymbolTable_GetSType (sym);
11048 : 1086284 : if (type != SymbolTable_NulSym)
11049 : : {
11050 : 570303 : (*p.proc) (type);
11051 : : }
11052 : : /* low and high are not types but constants and they are resolved by M2GenGCC */
11053 : 1086284 : (*p.proc) (low);
11054 : 1086284 : (*p.proc) (high);
11055 : 1086284 : align = SymbolTable_GetAlignment (sym);
11056 : 1086284 : if (align != SymbolTable_NulSym)
11057 : : {
11058 : 1368 : (*p.proc) (align);
11059 : : }
11060 : 1086284 : }
11061 : :
11062 : :
11063 : : /*
11064 : : IsSubrangeDependants - returns TRUE if the subrange
11065 : : q(dependants) all return TRUE.
11066 : : */
11067 : :
11068 : 932995 : static bool IsSubrangeDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11069 : : {
11070 : 932995 : bool result;
11071 : 932995 : unsigned int align;
11072 : 932995 : unsigned int type;
11073 : 932995 : unsigned int high;
11074 : 932995 : unsigned int low;
11075 : :
11076 : 932995 : SymbolTable_GetSubrange (sym, &high, &low);
11077 : : /* low and high are not types but constants and they are resolved by M2GenGCC */
11078 : 932995 : CheckResolveSubrange (sym);
11079 : 932995 : result = true;
11080 : 932995 : type = SymbolTable_GetSType (sym);
11081 : 932995 : if ((type == SymbolTable_NulSym) || (! ((*q.proc) (type))))
11082 : : {
11083 : : result = false;
11084 : : }
11085 : 932995 : if (! ((*q.proc) (low)))
11086 : : {
11087 : 37718 : result = false;
11088 : : }
11089 : 932995 : if (! ((*q.proc) (high)))
11090 : : {
11091 : 895477 : result = false;
11092 : : }
11093 : 932995 : align = SymbolTable_GetAlignment (sym);
11094 : 932995 : if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
11095 : : {
11096 : : result = false;
11097 : : }
11098 : 932995 : return result;
11099 : : /* static analysis guarentees a RETURN statement will be used before here. */
11100 : : __builtin_unreachable ();
11101 : : }
11102 : :
11103 : :
11104 : : /*
11105 : : WalkComponentDependants -
11106 : : */
11107 : :
11108 : 91403 : static void WalkComponentDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11109 : : {
11110 : 91403 : unsigned int i;
11111 : 91403 : unsigned int type;
11112 : :
11113 : : /* need to walk record and field */
11114 : 91403 : i = 1;
11115 : 274209 : do {
11116 : 274209 : type = SymbolTable_GetNth (sym, i);
11117 : 274209 : if (type != SymbolTable_NulSym)
11118 : : {
11119 : 182806 : if (SymbolTable_IsVar (type))
11120 : : {
11121 : 91403 : (*p.proc) (SymbolTable_GetSType (type));
11122 : : }
11123 : : else
11124 : : {
11125 : 91403 : (*p.proc) (type);
11126 : : }
11127 : 182806 : i += 1;
11128 : : }
11129 : 274209 : } while (! (type == SymbolTable_NulSym));
11130 : 91403 : }
11131 : :
11132 : :
11133 : : /*
11134 : : IsComponentDependants -
11135 : : */
11136 : :
11137 : 91403 : static bool IsComponentDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11138 : : {
11139 : 91403 : unsigned int type;
11140 : 91403 : unsigned int i;
11141 : 91403 : bool result;
11142 : :
11143 : : /* need to check record is completely resolved */
11144 : 91403 : result = true;
11145 : 91403 : i = 1;
11146 : 274209 : do {
11147 : 274209 : type = SymbolTable_GetNth (sym, i);
11148 : 274209 : if (type != SymbolTable_NulSym)
11149 : : {
11150 : 182806 : if (SymbolTable_IsVar (type))
11151 : : {
11152 : 91403 : type = SymbolTable_GetSType (type);
11153 : : }
11154 : 182806 : if (! ((*q.proc) (type)))
11155 : : {
11156 : 0 : result = false;
11157 : : }
11158 : 182806 : i += 1;
11159 : : }
11160 : 274209 : } while (! (type == SymbolTable_NulSym));
11161 : 91403 : return result;
11162 : : /* static analysis guarentees a RETURN statement will be used before here. */
11163 : : __builtin_unreachable ();
11164 : : }
11165 : :
11166 : :
11167 : : /*
11168 : : WalkVarDependants - walks all dependants of sym.
11169 : : */
11170 : :
11171 : 501854 : static void WalkVarDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11172 : : {
11173 : 501854 : unsigned int type;
11174 : :
11175 : 501854 : (*p.proc) (SymbolTable_GetSType (sym));
11176 : 501854 : if (SymbolTable_IsComponent (sym))
11177 : : {
11178 : 0 : WalkComponentDependants (sym, p);
11179 : : }
11180 : 501854 : type = SymbolTable_GetVarBackEndType (sym);
11181 : 501854 : if (type != SymbolTable_NulSym)
11182 : : {
11183 : 42008 : (*p.proc) (type);
11184 : : }
11185 : 501854 : }
11186 : :
11187 : :
11188 : : /*
11189 : : IsVarDependants - returns TRUE if the pointer symbol, sym,
11190 : : p(dependants) all return TRUE.
11191 : : */
11192 : :
11193 : 520291 : static bool IsVarDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11194 : : {
11195 : 520291 : unsigned int type;
11196 : 520291 : bool result;
11197 : :
11198 : 520291 : result = true;
11199 : 520291 : if (! ((*q.proc) (SymbolTable_GetSType (sym))))
11200 : : {
11201 : : result = false;
11202 : : }
11203 : 520291 : if (SymbolTable_IsComponent (sym))
11204 : : {
11205 : 91403 : if (! (IsComponentDependants (sym, q)))
11206 : : {
11207 : 520291 : result = false;
11208 : : }
11209 : : }
11210 : 520291 : type = SymbolTable_GetVarBackEndType (sym);
11211 : 520291 : if (type != SymbolTable_NulSym)
11212 : : {
11213 : 42008 : if (! ((*q.proc) (type)))
11214 : : {
11215 : 520291 : result = false;
11216 : : }
11217 : : }
11218 : 520291 : return result;
11219 : : /* static analysis guarentees a RETURN statement will be used before here. */
11220 : : __builtin_unreachable ();
11221 : : }
11222 : :
11223 : :
11224 : : /*
11225 : : WalkPointerDependants - walks all dependants of sym.
11226 : : */
11227 : :
11228 : 9408819 : static void WalkPointerDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11229 : : {
11230 : 9408819 : unsigned int align;
11231 : :
11232 : 9408819 : (*p.proc) (SymbolTable_GetSType (sym));
11233 : 9408819 : align = SymbolTable_GetAlignment (sym);
11234 : 9408819 : if (align != SymbolTable_NulSym)
11235 : : {
11236 : 24 : (*p.proc) (align);
11237 : : }
11238 : 9408819 : }
11239 : :
11240 : :
11241 : : /*
11242 : : IsPointerDependants - returns TRUE if the pointer symbol, sym,
11243 : : p(dependants) all return TRUE.
11244 : : */
11245 : :
11246 : 1272505 : static bool IsPointerDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11247 : : {
11248 : 1272505 : unsigned int align;
11249 : 1272505 : bool final;
11250 : :
11251 : 1272505 : final = true;
11252 : 1272505 : if (! ((*q.proc) (SymbolTable_GetSType (sym))))
11253 : : {
11254 : : final = false;
11255 : : }
11256 : 1272505 : align = SymbolTable_GetAlignment (sym);
11257 : 1272505 : if (final && (align != SymbolTable_NulSym))
11258 : : {
11259 : 420 : if (! ((*q.proc) (align)))
11260 : : {
11261 : : final = false;
11262 : : }
11263 : : }
11264 : 1272505 : return final;
11265 : : /* static analysis guarentees a RETURN statement will be used before here. */
11266 : : __builtin_unreachable ();
11267 : : }
11268 : :
11269 : :
11270 : : /*
11271 : : IsRecordAlignment -
11272 : : */
11273 : :
11274 : 727401 : static bool IsRecordAlignment (unsigned int sym, M2GCCDeclare_IsAction q)
11275 : : {
11276 : 727401 : if ((SymbolTable_GetDefaultRecordFieldAlignment (sym)) != SymbolTable_NulSym)
11277 : : {
11278 : 216 : if (! ((*q.proc) (SymbolTable_GetDefaultRecordFieldAlignment (sym))))
11279 : : {
11280 : : return false;
11281 : : }
11282 : : }
11283 : : return true;
11284 : : /* static analysis guarentees a RETURN statement will be used before here. */
11285 : : __builtin_unreachable ();
11286 : : }
11287 : :
11288 : :
11289 : : /*
11290 : : IsRecordDependants - returns TRUE if the symbol, sym,
11291 : : q(dependants) all return TRUE.
11292 : : */
11293 : :
11294 : 727401 : static bool IsRecordDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11295 : : {
11296 : 727401 : bool result;
11297 : 727401 : unsigned int i;
11298 : 727401 : unsigned int field;
11299 : :
11300 : 727401 : result = IsRecordAlignment (sym, q);
11301 : 727401 : i = 1;
11302 : 4493282 : do {
11303 : 4493282 : field = SymbolTable_GetNth (sym, i);
11304 : 4493282 : if (field != SymbolTable_NulSym)
11305 : : {
11306 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
11307 : 3765881 : if (SymbolTable_IsRecordField (field))
11308 : : {
11309 : : /* avoid dangling else. */
11310 : 3763781 : if ((! (SymbolTable_IsRecordFieldAVarientTag (field))) || ((SymbolTable_GetSymName (field)) != NameKey_NulName))
11311 : : {
11312 : 3763583 : if (! ((*q.proc) (field)))
11313 : : {
11314 : 1161108 : result = false;
11315 : : }
11316 : : }
11317 : : }
11318 : 2100 : else if (SymbolTable_IsVarient (field))
11319 : : {
11320 : : /* avoid dangling else. */
11321 : 2100 : if (! ((*q.proc) (field)))
11322 : : {
11323 : 1161108 : result = false;
11324 : : }
11325 : : }
11326 : 0 : else if (SymbolTable_IsFieldVarient (field))
11327 : : {
11328 : : /* avoid dangling else. */
11329 : 0 : M2Error_InternalError ((const char *) "should not see a field varient", 30);
11330 : : }
11331 : : else
11332 : : {
11333 : : /* avoid dangling else. */
11334 : 0 : M2Error_InternalError ((const char *) "unknown symbol in record", 24);
11335 : : }
11336 : : }
11337 : 4493282 : i += 1;
11338 : 4493282 : } while (! (field == SymbolTable_NulSym));
11339 : 727401 : return result;
11340 : : /* static analysis guarentees a RETURN statement will be used before here. */
11341 : : __builtin_unreachable ();
11342 : : }
11343 : :
11344 : :
11345 : : /*
11346 : : WalkRecordAlignment - walks the alignment constant associated with
11347 : : record, sym.
11348 : : */
11349 : :
11350 : 6034165 : static void WalkRecordAlignment (unsigned int sym, M2GCCDeclare_WalkAction p)
11351 : : {
11352 : 6034165 : if ((SymbolTable_GetDefaultRecordFieldAlignment (sym)) != SymbolTable_NulSym)
11353 : : {
11354 : 216 : (*p.proc) (SymbolTable_GetDefaultRecordFieldAlignment (sym));
11355 : : }
11356 : 6034165 : }
11357 : :
11358 : :
11359 : : /*
11360 : : WalkRecordDependants - walks symbol, sym, dependants. It only
11361 : : walks the fields if the alignment is
11362 : : unused or fully declared.
11363 : : */
11364 : :
11365 : 6034165 : static void WalkRecordDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11366 : : {
11367 : 6034165 : WalkRecordAlignment (sym, p);
11368 : 6034165 : WalkRecordDependants2 (sym, p);
11369 : 6034165 : }
11370 : :
11371 : :
11372 : : /*
11373 : : WalkRecordFieldDependants -
11374 : : */
11375 : :
11376 : 38100076 : static void WalkRecordFieldDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11377 : : {
11378 : 38100076 : unsigned int v;
11379 : 38100076 : unsigned int align;
11380 : :
11381 : 38100076 : M2Debug_Assert (SymbolTable_IsRecordField (sym));
11382 : 38100076 : (*p.proc) (SymbolTable_GetSType (sym));
11383 : 38100076 : v = SymbolTable_GetVarient (sym);
11384 : 38100076 : if (v != SymbolTable_NulSym)
11385 : : {
11386 : 25944 : (*p.proc) (v);
11387 : : }
11388 : 38100076 : align = SymbolTable_GetAlignment (sym);
11389 : 38100076 : if (align != SymbolTable_NulSym)
11390 : : {
11391 : 1764 : (*p.proc) (align);
11392 : : }
11393 : 38100076 : }
11394 : :
11395 : :
11396 : : /*
11397 : : WalkRecordDependants2 - walks the fields of record, sym, calling
11398 : : p on every dependant.
11399 : : */
11400 : :
11401 : 6034165 : static void WalkRecordDependants2 (unsigned int sym, M2GCCDeclare_WalkAction p)
11402 : : {
11403 : 6034165 : unsigned int i;
11404 : 6034165 : unsigned int Field;
11405 : :
11406 : 6034165 : i = 1;
11407 : 25445277 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
11408 : : {
11409 : 19411112 : Field = SymbolTable_GetNth (sym, i);
11410 : 19411112 : (*p.proc) (Field);
11411 : 19411112 : if (SymbolTable_IsRecordField (Field))
11412 : : {
11413 : 19407044 : WalkRecordFieldDependants (Field, p);
11414 : : }
11415 : 4068 : else if (SymbolTable_IsVarient (Field))
11416 : : {
11417 : : /* avoid dangling else. */
11418 : 4068 : WalkVarientDependants (Field, p);
11419 : : }
11420 : 0 : else if (SymbolTable_IsFieldVarient (Field))
11421 : : {
11422 : : /* avoid dangling else. */
11423 : 0 : M2Error_InternalError ((const char *) "should not see a field varient", 30);
11424 : : }
11425 : : else
11426 : : {
11427 : : /* avoid dangling else. */
11428 : 0 : M2Error_InternalError ((const char *) "unknown symbol in record", 24);
11429 : : }
11430 : 19411112 : i += 1;
11431 : : }
11432 : 6034165 : }
11433 : :
11434 : :
11435 : : /*
11436 : : IsVarientAlignment -
11437 : : */
11438 : :
11439 : 5808 : static bool IsVarientAlignment (unsigned int sym, M2GCCDeclare_IsAction q)
11440 : : {
11441 : 5808 : unsigned int align;
11442 : :
11443 : 5808 : sym = GetRecordOfVarient (sym);
11444 : 5808 : align = SymbolTable_GetDefaultRecordFieldAlignment (sym);
11445 : 5808 : if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
11446 : : {
11447 : : return false;
11448 : : }
11449 : : return true;
11450 : : /* static analysis guarentees a RETURN statement will be used before here. */
11451 : : __builtin_unreachable ();
11452 : : }
11453 : :
11454 : :
11455 : : /*
11456 : : IsVarientDependants - returns TRUE if the symbol, sym,
11457 : : q(dependants) all return TRUE.
11458 : : */
11459 : :
11460 : 2178 : static bool IsVarientDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11461 : : {
11462 : 2178 : bool result;
11463 : 2178 : unsigned int i;
11464 : 2178 : unsigned int Field;
11465 : :
11466 : 2178 : result = IsVarientAlignment (sym, q);
11467 : 2178 : i = 1;
11468 : 9558 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
11469 : : {
11470 : 5202 : Field = SymbolTable_GetNth (sym, i);
11471 : 5202 : M2Debug_Assert (SymbolTable_IsFieldVarient (Field));
11472 : 5202 : if (! ((*q.proc) (Field)))
11473 : : {
11474 : 3630 : result = false;
11475 : : }
11476 : 5202 : i += 1;
11477 : : }
11478 : 2178 : return result;
11479 : : /* static analysis guarentees a RETURN statement will be used before here. */
11480 : : __builtin_unreachable ();
11481 : : }
11482 : :
11483 : :
11484 : : /*
11485 : : WalkVarientAlignment -
11486 : : */
11487 : :
11488 : 59406 : static void WalkVarientAlignment (unsigned int sym, M2GCCDeclare_WalkAction p)
11489 : : {
11490 : 59406 : unsigned int align;
11491 : :
11492 : 59406 : sym = GetRecordOfVarient (sym);
11493 : 59406 : align = SymbolTable_GetDefaultRecordFieldAlignment (sym);
11494 : 59406 : if (align != SymbolTable_NulSym)
11495 : : {
11496 : 0 : (*p.proc) (align);
11497 : : }
11498 : 59406 : }
11499 : :
11500 : :
11501 : : /*
11502 : : WalkVarientDependants - walks symbol, sym, dependants.
11503 : : */
11504 : :
11505 : 11412 : static void WalkVarientDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11506 : : {
11507 : 11412 : unsigned int i;
11508 : 11412 : unsigned int v;
11509 : 11412 : unsigned int Field;
11510 : :
11511 : 11412 : WalkVarientAlignment (sym, p);
11512 : 11412 : if ((SymbolTable_GetSType (sym)) != SymbolTable_NulSym)
11513 : : {
11514 : 0 : (*p.proc) (SymbolTable_GetSType (sym));
11515 : : }
11516 : 11412 : v = SymbolTable_GetVarient (sym);
11517 : 11412 : if (v != SymbolTable_NulSym)
11518 : : {
11519 : 1104 : (*p.proc) (v);
11520 : : }
11521 : : i = 1;
11522 : 40578 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
11523 : : {
11524 : 29166 : Field = SymbolTable_GetNth (sym, i);
11525 : 29166 : M2Debug_Assert (SymbolTable_IsFieldVarient (Field)); /* field varients do _not_ have a type */
11526 : 29166 : (*p.proc) (Field); /* field varients do _not_ have a type */
11527 : 29166 : WalkVarientFieldDependants (Field, p);
11528 : 29166 : i += 1;
11529 : : }
11530 : 11412 : }
11531 : :
11532 : :
11533 : : /*
11534 : : IsVarientFieldDependants - returns TRUE if the symbol, sym,
11535 : : q(dependants) all return TRUE.
11536 : : */
11537 : :
11538 : 3630 : static bool IsVarientFieldDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11539 : : {
11540 : 3630 : unsigned int i;
11541 : 3630 : unsigned int type;
11542 : 3630 : unsigned int Field;
11543 : 3630 : bool result;
11544 : :
11545 : 3630 : i = 1;
11546 : 3630 : result = IsVarientAlignment (sym, q);
11547 : 11694 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
11548 : : {
11549 : 4434 : Field = SymbolTable_GetNth (sym, i);
11550 : 4434 : if (! ((*q.proc) (Field)))
11551 : : {
11552 : 3522 : result = false;
11553 : : }
11554 : 4434 : type = SymbolTable_GetSType (Field);
11555 : 4434 : if (type != SymbolTable_NulSym)
11556 : : {
11557 : 4158 : if (! ((*q.proc) (type)))
11558 : : {
11559 : 4434 : result = false;
11560 : : }
11561 : : }
11562 : 4434 : i += 1;
11563 : : }
11564 : 3630 : return result;
11565 : : /* static analysis guarentees a RETURN statement will be used before here. */
11566 : : __builtin_unreachable ();
11567 : : }
11568 : :
11569 : :
11570 : : /*
11571 : : WalkVarientFieldDependants -
11572 : : */
11573 : :
11574 : 47994 : static void WalkVarientFieldDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11575 : : {
11576 : 47994 : unsigned int i;
11577 : 47994 : unsigned int type;
11578 : 47994 : unsigned int Field;
11579 : :
11580 : 47994 : WalkVarientAlignment (sym, p);
11581 : 47994 : i = 1;
11582 : 145500 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
11583 : : {
11584 : 49512 : Field = SymbolTable_GetNth (sym, i);
11585 : 49512 : (*p.proc) (Field);
11586 : 49512 : type = SymbolTable_GetSType (Field);
11587 : 49512 : if (type != SymbolTable_NulSym)
11588 : : {
11589 : 46836 : (*p.proc) (type);
11590 : : }
11591 : 49512 : i += 1;
11592 : : }
11593 : 47994 : }
11594 : :
11595 : :
11596 : : /*
11597 : : IsArrayDependants - returns TRUE if the symbol, sym,
11598 : : q(dependants) all return TRUE.
11599 : :
11600 : : */
11601 : :
11602 : 974613 : static bool IsArrayDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11603 : : {
11604 : 974613 : bool result;
11605 : 974613 : unsigned int align;
11606 : 974613 : unsigned int subscript;
11607 : 974613 : unsigned int high;
11608 : 974613 : unsigned int low;
11609 : 974613 : unsigned int type;
11610 : :
11611 : 974613 : result = true;
11612 : 974613 : M2Debug_Assert (SymbolTable_IsArray (sym));
11613 : 974613 : type = SymbolTable_GetSType (sym);
11614 : 974613 : if (! ((*q.proc) (type)))
11615 : : {
11616 : : result = false;
11617 : : }
11618 : 974613 : subscript = SymbolTable_GetArraySubscript (sym);
11619 : 974613 : if (subscript != SymbolTable_NulSym)
11620 : : {
11621 : 974613 : M2Debug_Assert (SymbolTable_IsSubscript (subscript));
11622 : 974613 : type = SymbolTable_GetSType (subscript);
11623 : 974613 : if (! ((*q.proc) (type)))
11624 : : {
11625 : 909118 : result = false;
11626 : : }
11627 : 974613 : type = SymbolTable_SkipType (type);
11628 : : /* the array might be declared as ARRAY type OF foo */
11629 : 974613 : low = M2GCCDeclare_GetTypeMin (type);
11630 : 974613 : high = M2GCCDeclare_GetTypeMax (type);
11631 : 974613 : if (! ((*q.proc) (low)))
11632 : : {
11633 : 25370 : result = false;
11634 : : }
11635 : 974613 : if (! ((*q.proc) (high)))
11636 : : {
11637 : 884412 : result = false;
11638 : : }
11639 : 974613 : align = SymbolTable_GetAlignment (sym);
11640 : 974613 : if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
11641 : : {
11642 : : result = false;
11643 : : }
11644 : : }
11645 : 974613 : return result;
11646 : : /* static analysis guarentees a RETURN statement will be used before here. */
11647 : : __builtin_unreachable ();
11648 : : }
11649 : :
11650 : :
11651 : : /*
11652 : : WalkArrayDependants - walks symbol, sym, dependants.
11653 : : */
11654 : :
11655 : 664767 : static void WalkArrayDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11656 : : {
11657 : 664767 : unsigned int align;
11658 : 664767 : unsigned int subscript;
11659 : 664767 : unsigned int high;
11660 : 664767 : unsigned int low;
11661 : 664767 : unsigned int type;
11662 : :
11663 : 664767 : M2Debug_Assert (SymbolTable_IsArray (sym));
11664 : 664767 : type = SymbolTable_GetSType (sym);
11665 : 664767 : (*p.proc) (type);
11666 : 664767 : subscript = SymbolTable_GetArraySubscript (sym);
11667 : 664767 : if (subscript != SymbolTable_NulSym)
11668 : : {
11669 : 664767 : M2Debug_Assert (SymbolTable_IsSubscript (subscript));
11670 : 664767 : type = SymbolTable_GetSType (subscript);
11671 : 664767 : (*p.proc) (type);
11672 : 664767 : type = SymbolTable_SkipType (type);
11673 : : /* the array might be declared as ARRAY type OF foo */
11674 : 664767 : low = M2GCCDeclare_GetTypeMin (type);
11675 : 664767 : high = M2GCCDeclare_GetTypeMax (type);
11676 : 664767 : (*p.proc) (low);
11677 : 664767 : (*p.proc) (high);
11678 : 664767 : align = SymbolTable_GetAlignment (sym);
11679 : 664767 : if (align != SymbolTable_NulSym)
11680 : : {
11681 : 42 : (*p.proc) (align);
11682 : : }
11683 : : }
11684 : 664767 : }
11685 : :
11686 : :
11687 : : /*
11688 : : IsSetDependants - returns TRUE if the symbol, sym,
11689 : : q(dependants) all return TRUE.
11690 : : */
11691 : :
11692 : 31263 : static bool IsSetDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11693 : : {
11694 : 31263 : bool result;
11695 : 31263 : unsigned int type;
11696 : 31263 : unsigned int low;
11697 : 31263 : unsigned int high;
11698 : :
11699 : 31263 : result = true;
11700 : 31263 : M2Debug_Assert (SymbolTable_IsSet (sym));
11701 : 31263 : type = SymbolTable_GetDType (sym);
11702 : 31263 : if (! ((*q.proc) (type)))
11703 : : {
11704 : : result = false;
11705 : : }
11706 : 31263 : low = M2GCCDeclare_GetTypeMin (type);
11707 : 31263 : high = M2GCCDeclare_GetTypeMax (type);
11708 : 31263 : if (! ((*q.proc) (low)))
11709 : : {
11710 : 1262 : result = false;
11711 : : }
11712 : 31263 : if (! ((*q.proc) (high)))
11713 : : {
11714 : 7414 : result = false;
11715 : : }
11716 : 31263 : return result;
11717 : : /* static analysis guarentees a RETURN statement will be used before here. */
11718 : : __builtin_unreachable ();
11719 : : }
11720 : :
11721 : :
11722 : : /*
11723 : : WalkSetDependants - walks dependants, sym.
11724 : : */
11725 : :
11726 : 564161 : static void WalkSetDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11727 : : {
11728 : 564161 : unsigned int type;
11729 : 564161 : unsigned int low;
11730 : 564161 : unsigned int high;
11731 : :
11732 : 564161 : M2Debug_Assert (SymbolTable_IsSet (sym));
11733 : 564161 : type = SymbolTable_GetDType (sym);
11734 : 564161 : (*p.proc) (type);
11735 : 564161 : low = M2GCCDeclare_GetTypeMin (type);
11736 : 564161 : (*p.proc) (low);
11737 : 564161 : high = M2GCCDeclare_GetTypeMax (type);
11738 : 564161 : (*p.proc) (high);
11739 : 564161 : }
11740 : :
11741 : :
11742 : : /*
11743 : : IsProcTypeDependants -
11744 : : */
11745 : :
11746 : 185230 : static bool IsProcTypeDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11747 : : {
11748 : 185230 : unsigned int i;
11749 : 185230 : unsigned int p;
11750 : 185230 : unsigned int son;
11751 : 185230 : unsigned int ParamType;
11752 : 185230 : unsigned int ReturnType;
11753 : 185230 : bool result;
11754 : :
11755 : 185230 : result = true;
11756 : 185230 : M2Debug_Assert (SymbolTable_IsProcType (sym));
11757 : 185230 : i = 1;
11758 : 185230 : ReturnType = SymbolTable_GetSType (sym);
11759 : 185230 : p = SymbolTable_NoOfParam (sym);
11760 : 540638 : while (i <= p)
11761 : : {
11762 : 170178 : son = SymbolTable_GetNthParam (sym, i);
11763 : 170178 : ParamType = SymbolTable_GetSType (son);
11764 : 170178 : if (! ((*q.proc) (ParamType)))
11765 : : {
11766 : 50316 : result = false;
11767 : : }
11768 : 170178 : i += 1;
11769 : : }
11770 : 185230 : if ((ReturnType == SymbolTable_NulSym) || ((*q.proc) (ReturnType)))
11771 : : {
11772 : 185230 : return result;
11773 : : }
11774 : : else
11775 : : {
11776 : : return false;
11777 : : }
11778 : : /* static analysis guarentees a RETURN statement will be used before here. */
11779 : : __builtin_unreachable ();
11780 : : }
11781 : :
11782 : :
11783 : : /*
11784 : : WalkProcTypeDependants - walks dependants, sym.
11785 : : */
11786 : :
11787 : 2038948 : static void WalkProcTypeDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11788 : : {
11789 : 2038948 : unsigned int i;
11790 : 2038948 : unsigned int n;
11791 : 2038948 : unsigned int son;
11792 : 2038948 : unsigned int ParamType;
11793 : 2038948 : unsigned int ReturnType;
11794 : :
11795 : 2038948 : M2Debug_Assert (SymbolTable_IsProcType (sym));
11796 : 2038948 : i = 1;
11797 : 2038948 : ReturnType = SymbolTable_GetSType (sym);
11798 : 2038948 : n = SymbolTable_NoOfParam (sym);
11799 : 7537954 : while (i <= n)
11800 : : {
11801 : 3460058 : son = SymbolTable_GetNthParam (sym, i);
11802 : 3460058 : ParamType = SymbolTable_GetSType (son);
11803 : 3460058 : (*p.proc) (ParamType);
11804 : 3460058 : i += 1;
11805 : : }
11806 : 2038948 : if (ReturnType != SymbolTable_NulSym)
11807 : : {
11808 : 253004 : (*p.proc) (ReturnType);
11809 : : }
11810 : 2038948 : }
11811 : :
11812 : :
11813 : : /*
11814 : : IsProcedureDependants -
11815 : : */
11816 : :
11817 : 426 : static bool IsProcedureDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11818 : : {
11819 : 426 : unsigned int i;
11820 : 426 : unsigned int son;
11821 : 426 : unsigned int type;
11822 : 426 : unsigned int ReturnType;
11823 : 426 : bool result;
11824 : :
11825 : 426 : result = true;
11826 : 426 : M2Debug_Assert (SymbolTable_IsProcedure (sym));
11827 : 426 : i = 1;
11828 : 426 : ReturnType = SymbolTable_GetSType (sym);
11829 : 1482 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
11830 : : {
11831 : 630 : son = SymbolTable_GetNth (sym, i);
11832 : 630 : type = SymbolTable_GetSType (son);
11833 : 630 : if (! ((*q.proc) (type)))
11834 : : {
11835 : 36 : result = false;
11836 : : }
11837 : 630 : i += 1;
11838 : : }
11839 : 426 : if ((ReturnType == SymbolTable_NulSym) || ((*q.proc) (ReturnType)))
11840 : : {
11841 : 426 : return result;
11842 : : }
11843 : : else
11844 : : {
11845 : : return false;
11846 : : }
11847 : : /* static analysis guarentees a RETURN statement will be used before here. */
11848 : : __builtin_unreachable ();
11849 : : }
11850 : :
11851 : :
11852 : : /*
11853 : : WalkProcedureDependants - walks dependants, sym.
11854 : : */
11855 : :
11856 : 408 : static void WalkProcedureDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11857 : : {
11858 : 408 : unsigned int i;
11859 : 408 : unsigned int son;
11860 : 408 : unsigned int type;
11861 : 408 : unsigned int ReturnType;
11862 : :
11863 : 408 : M2Debug_Assert (SymbolTable_IsProcedure (sym));
11864 : 408 : i = 1;
11865 : 408 : ReturnType = SymbolTable_GetSType (sym);
11866 : 1410 : while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
11867 : : {
11868 : 594 : son = SymbolTable_GetNth (sym, i);
11869 : 594 : type = SymbolTable_GetSType (son);
11870 : 594 : (*p.proc) (type);
11871 : 594 : i += 1;
11872 : : }
11873 : 408 : if (ReturnType != SymbolTable_NulSym)
11874 : : {
11875 : 42 : (*p.proc) (ReturnType);
11876 : : }
11877 : 408 : }
11878 : :
11879 : :
11880 : : /*
11881 : : IsUnboundedDependants - returns TRUE if the symbol, sym,
11882 : : q(dependants) all return TRUE.
11883 : : */
11884 : :
11885 : 200897 : static bool IsUnboundedDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11886 : : {
11887 : 200897 : bool result;
11888 : :
11889 : 200897 : result = true;
11890 : 200897 : if (! ((*q.proc) (SymbolTable_GetUnboundedRecordType (sym))))
11891 : : {
11892 : : result = false;
11893 : : }
11894 : 200897 : if (! ((*q.proc) (M2Base_Cardinal)))
11895 : : {
11896 : 0 : result = false;
11897 : : }
11898 : 200897 : if (! ((*q.proc) (SymbolTable_GetSType (sym))))
11899 : : {
11900 : 54 : result = false;
11901 : : }
11902 : 200897 : return result;
11903 : : /* static analysis guarentees a RETURN statement will be used before here. */
11904 : : __builtin_unreachable ();
11905 : : }
11906 : :
11907 : :
11908 : : /*
11909 : : WalkUnboundedDependants - walks the dependants of, sym.
11910 : : */
11911 : :
11912 : 3728034 : static void WalkUnboundedDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11913 : : {
11914 : 3728034 : (*p.proc) (SymbolTable_GetUnboundedRecordType (sym));
11915 : 3728034 : (*p.proc) (M2Base_Cardinal);
11916 : 3728034 : (*p.proc) (SymbolTable_GetSType (sym));
11917 : 3728034 : }
11918 : :
11919 : :
11920 : : /*
11921 : : IsTypeDependants - returns TRUE if all q(dependants) return
11922 : : TRUE.
11923 : : */
11924 : :
11925 : 601682 : static bool IsTypeDependants (unsigned int sym, M2GCCDeclare_IsAction q)
11926 : : {
11927 : 601682 : unsigned int align;
11928 : 601682 : unsigned int type;
11929 : 601682 : bool final;
11930 : :
11931 : 601682 : type = SymbolTable_GetSType (sym);
11932 : 601682 : final = true;
11933 : 601682 : if ((type != SymbolTable_NulSym) && (! ((*q.proc) (type))))
11934 : : {
11935 : : final = false;
11936 : : }
11937 : 601682 : align = SymbolTable_GetAlignment (sym);
11938 : 601682 : if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
11939 : : {
11940 : : final = false;
11941 : : }
11942 : 601682 : return final;
11943 : : /* static analysis guarentees a RETURN statement will be used before here. */
11944 : : __builtin_unreachable ();
11945 : : }
11946 : :
11947 : :
11948 : : /*
11949 : : WalkTypeDependants - walks all dependants of, sym.
11950 : : */
11951 : :
11952 : 17039085 : static void WalkTypeDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
11953 : : {
11954 : 17039085 : unsigned int align;
11955 : 17039085 : unsigned int type;
11956 : :
11957 : 17039085 : type = SymbolTable_GetSType (sym);
11958 : 17039085 : if (type != SymbolTable_NulSym)
11959 : : {
11960 : 763044 : (*p.proc) (type);
11961 : : }
11962 : 17039085 : align = SymbolTable_GetAlignment (sym);
11963 : 17039085 : if (align != SymbolTable_NulSym)
11964 : : {
11965 : 36 : (*p.proc) (align);
11966 : : }
11967 : 17039085 : }
11968 : :
11969 : :
11970 : : /*
11971 : : FoldConstants - a wrapper for ResolveConstantExpressions.
11972 : : */
11973 : :
11974 : 539457 : extern "C" void M2GCCDeclare_FoldConstants (unsigned int start, unsigned int end)
11975 : : {
11976 : 539457 : if (M2GenGCC_ResolveConstantExpressions ((M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareConstFully}, start, end))
11977 : : {} /* empty. */
11978 : 539451 : }
11979 : :
11980 : :
11981 : : /*
11982 : : StartDeclareScope - declares types, variables associated with this scope.
11983 : : */
11984 : :
11985 : 75717 : extern "C" void M2GCCDeclare_StartDeclareScope (unsigned int scope)
11986 : : {
11987 : 75717 : NameKey_Name n;
11988 : :
11989 : 75717 : if (Debugging)
11990 : : {
11991 : : n = SymbolTable_GetSymName (scope);
11992 : : M2Printf_printf1 ((const char *) "declaring symbols in BLOCK %a\\n", 31, (const unsigned char *) &n, (sizeof (n)-1));
11993 : : }
11994 : 75717 : if (SymbolTable_IsProcedure (scope))
11995 : : {
11996 : 62471 : StartDeclareProcedureScope (scope);
11997 : : }
11998 : : else
11999 : : {
12000 : 13246 : StartDeclareModuleScope (scope);
12001 : : }
12002 : 75657 : if (Debugging)
12003 : : {
12004 : : n = SymbolTable_GetSymName (scope);
12005 : : M2Printf_printf1 ((const char *) "\\nEND declaring symbols in BLOCK %a\\n", 37, (const unsigned char *) &n, (sizeof (n)-1));
12006 : : }
12007 : 75657 : }
12008 : :
12009 : :
12010 : : /*
12011 : : EndDeclareScope -
12012 : : */
12013 : :
12014 : 0 : extern "C" void M2GCCDeclare_EndDeclareScope (void)
12015 : : {
12016 : 0 : }
12017 : :
12018 : :
12019 : : /*
12020 : : DeclareParameters -
12021 : : */
12022 : :
12023 : 165212 : extern "C" void M2GCCDeclare_DeclareParameters (unsigned int sym)
12024 : : {
12025 : 165212 : DeclareUnboundedProcedureParameters (sym);
12026 : 165212 : }
12027 : :
12028 : :
12029 : : /*
12030 : : DeclareConstant - checks to see whether, sym, is a constant and
12031 : : declares the constant to gcc.
12032 : : */
12033 : :
12034 : 1408897 : extern "C" void M2GCCDeclare_DeclareConstant (unsigned int tokenno, unsigned int sym)
12035 : : {
12036 : 1408897 : unsigned int type;
12037 : 1408897 : m2tree_Tree t;
12038 : :
12039 : 1408897 : if (SymbolTable_IsConst (sym))
12040 : : {
12041 : 680347 : TraverseDependants (sym);
12042 : 680347 : type = SymbolTable_GetSType (sym);
12043 : 1360694 : M2Debug_Assert ((type == SymbolTable_NulSym) || (M2GCCDeclare_CompletelyResolved (type)));
12044 : 1360694 : M2Debug_Assert ((! (SymbolTable_IsConstructor (sym))) || (SymbolTable_IsConstructorConstant (sym)));
12045 : 1360694 : M2Debug_Assert ((type != SymbolTable_NulSym) || (! ((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym)))));
12046 : 680347 : t = DeclareConst (tokenno, sym);
12047 : 680347 : M2Debug_Assert (t != NULL);
12048 : : }
12049 : 1408897 : }
12050 : :
12051 : :
12052 : : /*
12053 : : DeclareConstructor - declares a constructor.
12054 : : */
12055 : :
12056 : 1169712 : extern "C" void M2GCCDeclare_DeclareConstructor (unsigned int tokenno, unsigned int quad, unsigned int sym)
12057 : : {
12058 : 1169712 : if (sym == SymbolTable_NulSym)
12059 : : {
12060 : 0 : M2Error_InternalError ((const char *) "trying to declare the NulSym", 28);
12061 : : }
12062 : 1169712 : if ((SymbolTable_IsConstructor (sym)) && (! (SymbolConversion_GccKnowsAbout (sym))))
12063 : : {
12064 : 0 : WalkConstructor (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
12065 : 0 : DeclareTypesConstantsProceduresInRange (SymbolTable_GetScope (sym), quad, quad);
12066 : 0 : M2Debug_Assert (M2ALU_IsConstructorDependants (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared}));
12067 : 0 : SymbolTable_PushValue (sym);
12068 : 0 : DeclareConstantFromTree (sym, M2ALU_PopConstructorTree (tokenno));
12069 : : }
12070 : 1169712 : }
12071 : :
12072 : :
12073 : : /*
12074 : : TryDeclareConstant - try and declare a constant. If, sym, is a
12075 : : constant try and declare it, if we cannot
12076 : : then enter it into the to do list.
12077 : : */
12078 : :
12079 : 12521062 : extern "C" void M2GCCDeclare_TryDeclareConstant (unsigned int tokenno, unsigned int sym)
12080 : : {
12081 : 12521062 : unsigned int type;
12082 : :
12083 : 12521062 : M2GCCDeclare_TryDeclareConstructor (tokenno, sym);
12084 : 12521056 : if (SymbolTable_IsConst (sym))
12085 : : {
12086 : 2942621 : TraverseDependants (sym);
12087 : 2942621 : type = SymbolTable_GetSType (sym);
12088 : 2942621 : if ((type != SymbolTable_NulSym) && (! (M2GCCDeclare_CompletelyResolved (type))))
12089 : : {
12090 : 6250 : TraverseDependants (sym);
12091 : : /*
12092 : : WatchIncludeList(sym, todolist) ;
12093 : : WatchIncludeList(type, todolist) ;
12094 : : */
12095 : 6250 : return ;
12096 : : }
12097 : 2936371 : if ((SymbolTable_IsConstructor (sym)) && (! (SymbolTable_IsConstructorConstant (sym))))
12098 : : {
12099 : 0 : TraverseDependants (sym);
12100 : : /*
12101 : : WatchIncludeList(sym, todolist) ;
12102 : : */
12103 : 0 : return ;
12104 : : }
12105 : 2936371 : if (((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym))) && (type == SymbolTable_NulSym))
12106 : : {
12107 : : /*
12108 : : WatchIncludeList(sym, todolist) ;
12109 : : */
12110 : 390 : TraverseDependants (sym);
12111 : 390 : return ;
12112 : : }
12113 : 2935981 : if (Sets_IsElementInSet (GlobalGroup->ToBeSolvedByQuads, sym))
12114 : : {
12115 : : /* we allow the above rules to be executed even if it is fully declared
12116 : : so to ensure that types of compiler builtin constants (BitsetSize
12117 : : etc) are fully declared.
12118 : :
12119 : : However at this point if, sym, is fully declared we return
12120 : : */
12121 : 14090 : if (IsFullyDeclared (sym))
12122 : : {
12123 : : return ;
12124 : : }
12125 : 14066 : TraverseDependants (sym);
12126 : : }
12127 : : else
12128 : : {
12129 : : /*
12130 : : WatchIncludeList(sym, todolist)
12131 : : */
12132 : 2921891 : TryDeclareConst (tokenno, sym);
12133 : : }
12134 : : }
12135 : : }
12136 : :
12137 : :
12138 : : /*
12139 : : TryDeclareConstructor - try and declare a constructor. If, sym, is a
12140 : : constructor try and declare it, if we cannot
12141 : : then enter it into the to do list.
12142 : : */
12143 : :
12144 : 14114093 : extern "C" void M2GCCDeclare_TryDeclareConstructor (unsigned int tokenno, unsigned int sym)
12145 : : {
12146 : 14114093 : if (sym != SymbolTable_NulSym)
12147 : : {
12148 : 14114093 : if ((SymbolTable_IsConstructor (sym)) && (! (SymbolConversion_GccKnowsAbout (sym))))
12149 : : {
12150 : 13201 : WalkConstructor (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
12151 : 13201 : if (! (Sets_IsElementInSet (GlobalGroup->ToBeSolvedByQuads, sym)))
12152 : : {
12153 : 10669 : M2ALU_TryEvaluateValue (sym);
12154 : 10663 : if (M2ALU_IsConstructorDependants (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared}))
12155 : : {
12156 : 7423 : SymbolTable_PushValue (sym);
12157 : 7423 : DeclareConstantFromTree (sym, M2ALU_PopConstructorTree (tokenno));
12158 : : }
12159 : : }
12160 : : }
12161 : : }
12162 : 14114087 : }
12163 : :
12164 : :
12165 : : /*
12166 : : DeclareLocalVariables - declares Local variables for procedure.
12167 : : */
12168 : :
12169 : 62471 : extern "C" void M2GCCDeclare_DeclareLocalVariables (unsigned int procedure)
12170 : : {
12171 : 62471 : unsigned int i;
12172 : 62471 : unsigned int var;
12173 : :
12174 : 62471 : i = (SymbolTable_NoOfParam (procedure))+1;
12175 : 62471 : var = SymbolTable_GetNth (procedure, i);
12176 : 645233 : while (var != SymbolTable_NulSym)
12177 : : {
12178 : 520291 : M2Debug_Assert (procedure == (SymbolTable_GetScope (var)));
12179 : 520291 : M2GCCDeclare_DeclareLocalVariable (var);
12180 : 520291 : i += 1;
12181 : 520291 : var = SymbolTable_GetNth (procedure, i);
12182 : : }
12183 : 62471 : }
12184 : :
12185 : :
12186 : : /*
12187 : : DeclareLocalVariable - declare a local variable var.
12188 : : */
12189 : :
12190 : 520291 : extern "C" void M2GCCDeclare_DeclareLocalVariable (unsigned int var)
12191 : : {
12192 : 520291 : M2Debug_Assert (AllDependantsFullyDeclared (var));
12193 : 520291 : DoVariableDeclaration (var, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (var)), false, false, SymbolTable_IsTemporary (var), false, SymbolConversion_Mod2Gcc (SymbolTable_GetScope (var))); /* and are not global */
12194 : 520291 : }
12195 : :
12196 : :
12197 : : /*
12198 : : DeclareProcedure - declares procedure, sym, or all procedures inside
12199 : : module sym.
12200 : : */
12201 : :
12202 : 3464237 : extern "C" void M2GCCDeclare_DeclareProcedure (unsigned int sym)
12203 : : {
12204 : 3464237 : if (SymbolTable_IsProcedure (sym))
12205 : : {
12206 : 3315242 : DeclareProcedureToGcc (sym);
12207 : : }
12208 : 148995 : else if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
12209 : : {
12210 : : /* avoid dangling else. */
12211 : 148995 : SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
12212 : : }
12213 : : else
12214 : : {
12215 : : /* avoid dangling else. */
12216 : 0 : M2Error_InternalError ((const char *) "expecting procedure", 19);
12217 : : }
12218 : 3464237 : }
12219 : :
12220 : :
12221 : : /*
12222 : : DeclareModuleVariables - declares Module variables for a module
12223 : : which was declared inside a procedure.
12224 : : */
12225 : :
12226 : 144 : extern "C" void M2GCCDeclare_DeclareModuleVariables (unsigned int sym)
12227 : : {
12228 : 144 : m2tree_Tree scope;
12229 : 144 : unsigned int i;
12230 : 144 : unsigned int Var;
12231 : :
12232 : 144 : i = 1;
12233 : 144 : scope = SymbolConversion_Mod2Gcc (SymbolTable_GetProcedureScope (sym));
12234 : 144 : Var = SymbolTable_GetNth (sym, i);
12235 : 366 : while (Var != SymbolTable_NulSym)
12236 : : {
12237 : 78 : M2Debug_Assert (AllDependantsFullyDeclared (SymbolTable_GetSType (Var)));
12238 : 78 : DoVariableDeclaration (Var, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (Var)), false, false, SymbolTable_IsTemporary (Var), false, scope); /* and are not global */
12239 : 78 : i += 1;
12240 : 78 : Var = SymbolTable_GetNth (sym, i);
12241 : : }
12242 : 144 : }
12243 : :
12244 : :
12245 : : /*
12246 : : IsProcedureGccNested - returns TRUE if procedure, sym, will be considered
12247 : : as nested by GCC.
12248 : : This will occur if either its outer defining scope
12249 : : is a procedure or is a module which is inside a
12250 : : procedure.
12251 : : */
12252 : :
12253 : 2042093 : extern "C" bool M2GCCDeclare_IsProcedureGccNested (unsigned int sym)
12254 : : {
12255 : 2042093 : return (SymbolTable_IsProcedureNested (sym)) || ((SymbolTable_IsModule (SymbolTable_GetScope (sym))) && (SymbolTable_IsModuleWithinProcedure (SymbolTable_GetScope (sym))));
12256 : : /* static analysis guarentees a RETURN statement will be used before here. */
12257 : : __builtin_unreachable ();
12258 : : }
12259 : :
12260 : :
12261 : : /*
12262 : : PoisonSymbols - poisons all gcc symbols from procedure, sym.
12263 : : A debugging aid.
12264 : : */
12265 : :
12266 : 62471 : extern "C" void M2GCCDeclare_PoisonSymbols (unsigned int sym)
12267 : : {
12268 : 62471 : if (SymbolTable_IsProcedure (sym))
12269 : : {
12270 : 62471 : SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SymbolConversion_Poison});
12271 : : }
12272 : 62471 : }
12273 : :
12274 : :
12275 : : /*
12276 : : PromoteToString - declare, sym, and then promote it to a string.
12277 : : Note that if sym is a single character we do
12278 : : *not* record it as a string
12279 : : but as a char however we always
12280 : : return a string constant.
12281 : : */
12282 : :
12283 : 21482 : extern "C" m2tree_Tree M2GCCDeclare_PromoteToString (unsigned int tokenno, unsigned int sym)
12284 : : {
12285 : 21482 : unsigned int size;
12286 : 21482 : char ch;
12287 : :
12288 : 21482 : M2GCCDeclare_DeclareConstant (tokenno, sym);
12289 : 21482 : if ((SymbolTable_IsConst (sym)) && ((SymbolTable_GetSType (sym)) == M2Base_Char))
12290 : : {
12291 : 1512 : SymbolTable_PushValue (sym);
12292 : 1512 : ch = M2ALU_PopChar (tokenno);
12293 : 1512 : return m2decl_BuildCStringConstant (DynamicStrings_string (DynamicStrings_InitStringChar (ch)), 1);
12294 : : }
12295 : : else
12296 : : {
12297 : 19970 : M2Debug_Assert (SymbolTable_IsConstStringKnown (sym));
12298 : 19970 : size = SymbolTable_GetStringLength (tokenno, sym);
12299 : 19970 : if (size > 1)
12300 : : {
12301 : : /* It will be already be declared as a string, so return it. */
12302 : 19675 : return (m2tree_Tree) (SymbolConversion_Mod2Gcc (sym));
12303 : : }
12304 : : else
12305 : : {
12306 : 295 : return m2decl_BuildStringConstant (NameKey_KeyToCharStar (SymbolTable_GetString (sym)), static_cast<int> (SymbolTable_GetStringLength (tokenno, sym)));
12307 : : }
12308 : : }
12309 : : /* static analysis guarentees a RETURN statement will be used before here. */
12310 : : __builtin_unreachable ();
12311 : : }
12312 : :
12313 : :
12314 : : /*
12315 : : PromoteToCString - declare, sym, and then promote it to a string.
12316 : : Note that if sym is a single character we do
12317 : : *not* record it as a string
12318 : : but as a char however we always
12319 : : return a string constant.
12320 : : */
12321 : :
12322 : 42 : extern "C" m2tree_Tree M2GCCDeclare_PromoteToCString (unsigned int tokenno, unsigned int sym)
12323 : : {
12324 : 42 : unsigned int size;
12325 : 42 : char ch;
12326 : :
12327 : 42 : M2GCCDeclare_DeclareConstant (tokenno, sym);
12328 : 42 : M2Debug_Assert (SymbolTable_IsConstStringKnown (sym));
12329 : 42 : if ((SymbolTable_IsConst (sym)) && ((SymbolTable_GetSType (sym)) == M2Base_Char))
12330 : : {
12331 : 12 : SymbolTable_PushValue (sym);
12332 : 12 : ch = M2ALU_PopChar (tokenno);
12333 : 12 : return m2decl_BuildCStringConstant (DynamicStrings_string (DynamicStrings_InitStringChar (ch)), 1);
12334 : : }
12335 : : else
12336 : : {
12337 : 30 : size = SymbolTable_GetStringLength (tokenno, sym);
12338 : 30 : return m2decl_BuildCStringConstant (NameKey_KeyToCharStar (SymbolTable_GetString (sym)), static_cast<int> (size));
12339 : : }
12340 : : /* static analysis guarentees a RETURN statement will be used before here. */
12341 : : __builtin_unreachable ();
12342 : : }
12343 : :
12344 : :
12345 : : /*
12346 : : CompletelyResolved - returns TRUE if a symbols has been completely resolved
12347 : : and is not partically declared (such as a record).
12348 : : */
12349 : :
12350 : 3664553 : extern "C" bool M2GCCDeclare_CompletelyResolved (unsigned int sym)
12351 : : {
12352 : 3664553 : return Sets_IsElementInSet (GlobalGroup->FullyDeclared, sym);
12353 : : /* static analysis guarentees a RETURN statement will be used before here. */
12354 : : __builtin_unreachable ();
12355 : : }
12356 : :
12357 : :
12358 : : /*
12359 : : ConstantKnownAndUsed -
12360 : : */
12361 : :
12362 : 204 : extern "C" void M2GCCDeclare_ConstantKnownAndUsed (unsigned int sym, m2tree_Tree t)
12363 : : {
12364 : 204 : DeclareConstantFromTree (sym, m2block_RememberConstant (t));
12365 : 204 : }
12366 : :
12367 : :
12368 : : /*
12369 : : PutToBeSolvedByQuads - places, sym, to this list and returns,
12370 : : sym.
12371 : : */
12372 : :
12373 : 277058 : extern "C" void M2GCCDeclare_PutToBeSolvedByQuads (unsigned int sym)
12374 : : {
12375 : 277058 : WatchIncludeList (sym, M2GCCDeclare_tobesolvedbyquads);
12376 : 277058 : }
12377 : :
12378 : :
12379 : : /*
12380 : : MarkExported - tell GCC to mark all exported procedures in module sym.
12381 : : */
12382 : :
12383 : 20536 : extern "C" void M2GCCDeclare_MarkExported (unsigned int sym)
12384 : : {
12385 : 20536 : if (M2Options_Optimizing)
12386 : : {
12387 : 14089 : m2type_MarkFunctionReferenced (SymbolConversion_Mod2Gcc (sym));
12388 : 14089 : if ((SymbolTable_IsDefImp (sym)) || (SymbolTable_IsModule (sym)))
12389 : : {
12390 : 5881 : SymbolTable_ForeachExportedDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_MarkExported});
12391 : : }
12392 : : }
12393 : 20536 : }
12394 : :
12395 : :
12396 : : /*
12397 : : GetTypeMin -
12398 : : */
12399 : :
12400 : 3243569 : extern "C" unsigned int M2GCCDeclare_GetTypeMin (unsigned int type)
12401 : : {
12402 : 3245229 : unsigned int min;
12403 : 3245229 : unsigned int max;
12404 : :
12405 : 3245229 : if (SymbolTable_IsSubrange (type))
12406 : : {
12407 : 3077448 : SymbolTable_GetSubrange (type, &max, &min);
12408 : 3077448 : return min;
12409 : : }
12410 : 167781 : else if (SymbolTable_IsSet (type))
12411 : : {
12412 : : /* avoid dangling else. */
12413 : 1648 : return M2GCCDeclare_GetTypeMin (SymbolTable_GetSType (type));
12414 : : }
12415 : 166133 : else if (SymbolTable_IsEnumeration (type))
12416 : : {
12417 : : /* avoid dangling else. */
12418 : 159529 : MinEnumerationField = SymbolTable_NulSym;
12419 : 159529 : MaxEnumerationField = SymbolTable_NulSym;
12420 : 159529 : SymbolTable_ForeachLocalSymDo (type, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) FindMinMaxEnum});
12421 : 159529 : return MinEnumerationField;
12422 : : }
12423 : 6604 : else if (IsBaseType (type))
12424 : : {
12425 : : /* avoid dangling else. */
12426 : 6592 : M2Base_GetBaseTypeMinMax (type, &min, &max);
12427 : 6592 : return min;
12428 : : }
12429 : 12 : else if (M2System_IsSystemType (type))
12430 : : {
12431 : : /* avoid dangling else. */
12432 : 0 : M2System_GetSystemTypeMinMax (type, &min, &max);
12433 : 0 : return min;
12434 : : }
12435 : 12 : else if ((SymbolTable_GetSType (type)) == SymbolTable_NulSym)
12436 : : {
12437 : : /* avoid dangling else. */
12438 : 0 : M2MetaError_MetaError1 ((const char *) "unable to obtain the MIN value for type {%1as}", 46, type);
12439 : 0 : return SymbolTable_NulSym;
12440 : : }
12441 : : else
12442 : : {
12443 : : /* avoid dangling else. */
12444 : 12 : return M2GCCDeclare_GetTypeMin (SymbolTable_GetSType (type));
12445 : : }
12446 : : /* static analysis guarentees a RETURN statement will be used before here. */
12447 : : __builtin_unreachable ();
12448 : : }
12449 : :
12450 : :
12451 : : /*
12452 : : GetTypeMax -
12453 : : */
12454 : :
12455 : 3206705 : extern "C" unsigned int M2GCCDeclare_GetTypeMax (unsigned int type)
12456 : : {
12457 : 3208365 : unsigned int min;
12458 : 3208365 : unsigned int max;
12459 : :
12460 : 3208365 : if (SymbolTable_IsSubrange (type))
12461 : : {
12462 : 3041602 : SymbolTable_GetSubrange (type, &max, &min);
12463 : 3041602 : return max;
12464 : : }
12465 : 166763 : else if (SymbolTable_IsSet (type))
12466 : : {
12467 : : /* avoid dangling else. */
12468 : 1648 : return M2GCCDeclare_GetTypeMax (SymbolTable_GetSType (type));
12469 : : }
12470 : 165115 : else if (SymbolTable_IsEnumeration (type))
12471 : : {
12472 : : /* avoid dangling else. */
12473 : 158529 : MinEnumerationField = SymbolTable_NulSym;
12474 : 158529 : MaxEnumerationField = SymbolTable_NulSym;
12475 : 158529 : SymbolTable_ForeachLocalSymDo (type, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) FindMinMaxEnum});
12476 : 158529 : return MaxEnumerationField;
12477 : : }
12478 : 6586 : else if (IsBaseType (type))
12479 : : {
12480 : : /* avoid dangling else. */
12481 : 6574 : M2Base_GetBaseTypeMinMax (type, &min, &max);
12482 : 6574 : return max;
12483 : : }
12484 : 12 : else if (M2System_IsSystemType (type))
12485 : : {
12486 : : /* avoid dangling else. */
12487 : 0 : M2System_GetSystemTypeMinMax (type, &min, &max);
12488 : 0 : return max;
12489 : : }
12490 : 12 : else if ((SymbolTable_GetSType (type)) == SymbolTable_NulSym)
12491 : : {
12492 : : /* avoid dangling else. */
12493 : 0 : M2MetaError_MetaError1 ((const char *) "unable to obtain the MAX value for type {%1as}", 46, type);
12494 : 0 : return SymbolTable_NulSym;
12495 : : }
12496 : : else
12497 : : {
12498 : : /* avoid dangling else. */
12499 : 12 : return M2GCCDeclare_GetTypeMax (SymbolTable_GetSType (type));
12500 : : }
12501 : : /* static analysis guarentees a RETURN statement will be used before here. */
12502 : : __builtin_unreachable ();
12503 : : }
12504 : :
12505 : :
12506 : : /*
12507 : : PrintSym - prints limited information about a symbol.
12508 : : This procedure is externally visible.
12509 : : */
12510 : :
12511 : 0 : extern "C" void M2GCCDeclare_PrintSym (unsigned int sym)
12512 : : {
12513 : 0 : M2Printf_printf1 ((const char *) "information about symbol: %d\\n", 30, (const unsigned char *) &sym, (sizeof (sym)-1));
12514 : 0 : M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "==============================\\n", 32);
12515 : 0 : PrintVerbose (sym);
12516 : 0 : }
12517 : :
12518 : :
12519 : : /*
12520 : : IncludeDumpSymbol - include sym into the watch list and all syms dependants.
12521 : : */
12522 : :
12523 : 0 : extern "C" void M2GCCDeclare_IncludeDumpSymbol (unsigned int sym)
12524 : : {
12525 : 0 : if (sym != SymbolTable_NulSym)
12526 : : {
12527 : : /*
12528 : : fprintf0 (GetDumpFile (), "
12529 : : ") ;
12530 : : PrintVerbose (sym) ;
12531 : : fprintf0 (GetDumpFile (), "
12532 : : ")
12533 : : */
12534 : 0 : AddSymToWatch (sym);
12535 : : }
12536 : 0 : }
12537 : :
12538 : :
12539 : : /*
12540 : : DumpFilteredResolver - dumps the gimple or tree representation of all watched symbols.
12541 : : */
12542 : :
12543 : 0 : extern "C" void M2GCCDeclare_DumpFilteredResolver (void)
12544 : : {
12545 : 0 : Sets_ForeachElementInSetDo (WatchList, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DumpResolver});
12546 : 0 : }
12547 : :
12548 : :
12549 : : /*
12550 : : DumpFilteredDefinitive - dumps the gimple or tree representation of all watched symbols.
12551 : : */
12552 : :
12553 : 0 : extern "C" void M2GCCDeclare_DumpFilteredDefinitive (void)
12554 : : {
12555 : 0 : Sets_ForeachElementInSetDo (WatchList, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DumpDefinitive});
12556 : 0 : }
12557 : :
12558 : :
12559 : : /*
12560 : : InitDeclarations - initializes default types and the source filename.
12561 : : */
12562 : :
12563 : 12454 : extern "C" void M2GCCDeclare_InitDeclarations (void)
12564 : : {
12565 : 12454 : DeclareDefaultTypes ();
12566 : 12454 : DeclareDefaultConstants ();
12567 : 12454 : }
12568 : :
12569 : 12963 : extern "C" void _M2_M2GCCDeclare_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
12570 : : {
12571 : 12963 : FreeGroup = NULL;
12572 : 12963 : GlobalGroup = InitGroup ();
12573 : 12963 : ChainedList = Sets_InitSet (1);
12574 : 12963 : WatchList = Sets_InitSet (1);
12575 : 12963 : VisitedList = NULL;
12576 : 12963 : EnumerationIndex = Indexing_InitIndex (1);
12577 : 12963 : HaveInitDefaultTypes = false;
12578 : 12963 : recursionCaught = false;
12579 : 12963 : }
12580 : :
12581 : 0 : extern "C" void _M2_M2GCCDeclare_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
12582 : : {
12583 : 0 : }
|