Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2Error. */
2 : : /* M2Error.mod error reporting interface.
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 NameKey_Name;
47 : :
48 : : # define NameKey_NulName 0
49 : : # define SymbolTable_NulSym 0
50 : : # define SYSTEM_BITSPERBYTE 8
51 : : # define SYSTEM_BYTESPERWORD 4
52 : : typedef struct M2StackAddress__T7_r M2StackAddress__T7;
53 : :
54 : : typedef M2StackAddress__T7 *M2StackAddress_StackOfAddress;
55 : :
56 : : typedef struct M2StackAddress__T8_r M2StackAddress__T8;
57 : :
58 : : typedef M2StackAddress__T8 *M2StackAddress_StackBucket;
59 : :
60 : : typedef struct M2StackAddress__T9_a M2StackAddress__T9;
61 : :
62 : : typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP;
63 : :
64 : : typedef unsigned int FIO_File;
65 : :
66 : : extern FIO_File FIO_StdErr;
67 : : extern FIO_File FIO_StdIn;
68 : : extern FIO_File FIO_StdOut;
69 : : # define M2LexBuf_UnknownTokenNo 0
70 : : # define M2LexBuf_BuiltinTokenNo 1
71 : : extern int M2LexBuf_currentinteger;
72 : : extern unsigned int M2LexBuf_currentcolumn;
73 : : extern void * M2LexBuf_currentstring;
74 : : typedef unsigned int m2linemap_location_t;
75 : :
76 : : extern bool M2Options_Profiling;
77 : : extern bool M2Options_Coding;
78 : : extern bool M2Options_Optimizing;
79 : : extern bool M2Options_GenerateStatementNote;
80 : : extern bool M2Options_DebugFunctionLineNumbers;
81 : : extern bool M2Options_ForcedLocation;
82 : : extern bool M2Options_SharedFlag;
83 : : extern bool M2Options_GenModuleList;
84 : : extern bool M2Options_ScaffoldMain;
85 : : extern bool M2Options_ScaffoldStatic;
86 : : extern bool M2Options_ScaffoldDynamic;
87 : : extern bool M2Options_SaveTemps;
88 : : extern bool M2Options_AutoInit;
89 : : extern bool M2Options_DebugBuiltins;
90 : : extern bool M2Options_LowerCaseKeywords;
91 : : extern bool M2Options_UninitVariableConditionalChecking;
92 : : extern bool M2Options_UninitVariableChecking;
93 : : extern bool M2Options_UnusedParameterChecking;
94 : : extern bool M2Options_UnusedVariableChecking;
95 : : extern bool M2Options_Exceptions;
96 : : extern bool M2Options_GenerateSwig;
97 : : extern bool M2Options_DumpSystemExports;
98 : : extern bool M2Options_ExtendedOpaque;
99 : : extern bool M2Options_CPreProcessor;
100 : : extern bool M2Options_StrictTypeChecking;
101 : : extern bool M2Options_LineDirectives;
102 : : extern bool M2Options_Quiet;
103 : : extern bool M2Options_CaseEnumChecking;
104 : : extern bool M2Options_VariantValueChecking;
105 : : extern bool M2Options_CaseElseChecking;
106 : : extern bool M2Options_ReturnChecking;
107 : : extern bool M2Options_RangeChecking;
108 : : extern bool M2Options_IndexChecking;
109 : : extern bool M2Options_FloatValueChecking;
110 : : extern bool M2Options_WholeValueChecking;
111 : : extern bool M2Options_WholeDivChecking;
112 : : extern bool M2Options_NilChecking;
113 : : extern bool M2Options_WholeProgram;
114 : : extern bool M2Options_OptimizeCommonSubExpressions;
115 : : extern bool M2Options_OptimizeBasicBlock;
116 : : extern bool M2Options_OptimizeUncalledProcedures;
117 : : extern bool M2Options_VerboseUnbounded;
118 : : extern bool M2Options_UnboundedByReference;
119 : : extern bool M2Options_DumpLangQuad;
120 : : extern bool M2Options_DumpLangGimple;
121 : : extern bool M2Options_DumpLangDecl;
122 : : extern bool M2Options_StyleChecking;
123 : : extern bool M2Options_Statistics;
124 : : extern bool M2Options_PedanticCast;
125 : : extern bool M2Options_PedanticParamNames;
126 : : extern bool M2Options_Pedantic;
127 : : extern bool M2Options_Verbose;
128 : : extern bool M2Options_GenerateLineDebug;
129 : : extern bool M2Options_GenerateDebugging;
130 : : extern bool M2Options_DebugTraceAPI;
131 : : extern bool M2Options_DebugTraceQuad;
132 : : extern bool M2Options_CompilerDebugging;
133 : : extern bool M2Options_PositiveModFloorDiv;
134 : : extern bool M2Options_Pim4;
135 : : extern bool M2Options_Pim3;
136 : : extern bool M2Options_Pim2;
137 : : extern bool M2Options_Pim;
138 : : extern bool M2Options_Iso;
139 : : extern bool M2Options_cflag;
140 : : extern bool M2Options_PPonly;
141 : : extern bool M2Options_Xcode;
142 : : typedef struct Indexing_IndexProcedure_p Indexing_IndexProcedure;
143 : :
144 : : typedef struct SymbolTable_FamilyOperation_p SymbolTable_FamilyOperation;
145 : :
146 : : typedef struct Lists_list_r Lists_list;
147 : :
148 : : typedef struct Lists__T11_a Lists__T11;
149 : :
150 : : typedef Lists_list *Lists_List;
151 : :
152 : : typedef void *m2tree_Tree;
153 : :
154 : : typedef struct SymbolKey_PerformOperation_p SymbolKey_PerformOperation;
155 : :
156 : : typedef void (*SymbolKey_PerformOperation_t) (unsigned int);
157 : : struct SymbolKey_PerformOperation_p { SymbolKey_PerformOperation_t proc; };
158 : :
159 : : typedef long int libc_time_t;
160 : :
161 : : typedef struct libc_tm_r libc_tm;
162 : :
163 : : typedef libc_tm *libc_ptrToTM;
164 : :
165 : : typedef struct libc_timeb_r libc_timeb;
166 : :
167 : : typedef struct libc_exitP_p libc_exitP;
168 : :
169 : : # define ASCII_nul (char) 000
170 : : # define ASCII_soh (char) 001
171 : : # define ASCII_stx (char) 002
172 : : # define ASCII_etx (char) 003
173 : : # define ASCII_eot (char) 004
174 : : # define ASCII_enq (char) 005
175 : : # define ASCII_ack (char) 006
176 : : # define ASCII_bel (char) 007
177 : : # define ASCII_bs (char) 010
178 : : # define ASCII_ht (char) 011
179 : : # define ASCII_nl (char) 012
180 : : # define ASCII_vt (char) 013
181 : : # define ASCII_np (char) 014
182 : : # define ASCII_cr (char) 015
183 : : # define ASCII_so (char) 016
184 : : # define ASCII_si (char) 017
185 : : # define ASCII_dle (char) 020
186 : : # define ASCII_dc1 (char) 021
187 : : # define ASCII_dc2 (char) 022
188 : : # define ASCII_dc3 (char) 023
189 : : # define ASCII_dc4 (char) 024
190 : : # define ASCII_nak (char) 025
191 : : # define ASCII_syn (char) 026
192 : : # define ASCII_etb (char) 027
193 : : # define ASCII_can (char) 030
194 : : # define ASCII_em (char) 031
195 : : # define ASCII_sub (char) 032
196 : : # define ASCII_esc (char) 033
197 : : # define ASCII_fs (char) 034
198 : : # define ASCII_gs (char) 035
199 : : # define ASCII_rs (char) 036
200 : : # define ASCII_us (char) 037
201 : : # define ASCII_sp (char) 040
202 : : # define ASCII_lf ASCII_nl
203 : : # define ASCII_ff ASCII_np
204 : : # define ASCII_eof ASCII_eot
205 : : # define ASCII_tab ASCII_ht
206 : : # define ASCII_del (char) 0177
207 : : # define ASCII_EOL ASCII_nl
208 : : extern NameKey_Name M2Reserved_RDirectiveTok;
209 : : extern NameKey_Name M2Reserved_LDirectiveTok;
210 : : extern NameKey_Name M2Reserved_InlineTok;
211 : : extern NameKey_Name M2Reserved_BuiltinTok;
212 : : extern NameKey_Name M2Reserved_AttributeTok;
213 : : extern NameKey_Name M2Reserved_FileTok;
214 : : extern NameKey_Name M2Reserved_LineTok;
215 : : extern NameKey_Name M2Reserved_DateTok;
216 : : extern NameKey_Name M2Reserved_VolatileTok;
217 : : extern NameKey_Name M2Reserved_AsmTok;
218 : : extern NameKey_Name M2Reserved_EofTok;
219 : : extern NameKey_Name M2Reserved_WithTok;
220 : : extern NameKey_Name M2Reserved_WhileTok;
221 : : extern NameKey_Name M2Reserved_VarTok;
222 : : extern NameKey_Name M2Reserved_UntilTok;
223 : : extern NameKey_Name M2Reserved_TypeTok;
224 : : extern NameKey_Name M2Reserved_ToTok;
225 : : extern NameKey_Name M2Reserved_ThenTok;
226 : : extern NameKey_Name M2Reserved_SetTok;
227 : : extern NameKey_Name M2Reserved_ReturnTok;
228 : : extern NameKey_Name M2Reserved_RepeatTok;
229 : : extern NameKey_Name M2Reserved_RemTok;
230 : : extern NameKey_Name M2Reserved_RetryTok;
231 : : extern NameKey_Name M2Reserved_RecordTok;
232 : : extern NameKey_Name M2Reserved_UnQualifiedTok;
233 : : extern NameKey_Name M2Reserved_QualifiedTok;
234 : : extern NameKey_Name M2Reserved_ProcedureTok;
235 : : extern NameKey_Name M2Reserved_PointerTok;
236 : : extern NameKey_Name M2Reserved_PackedSetTok;
237 : : extern NameKey_Name M2Reserved_OrTok;
238 : : extern NameKey_Name M2Reserved_OfTok;
239 : : extern NameKey_Name M2Reserved_NotTok;
240 : : extern NameKey_Name M2Reserved_ModuleTok;
241 : : extern NameKey_Name M2Reserved_ModTok;
242 : : extern NameKey_Name M2Reserved_LoopTok;
243 : : extern NameKey_Name M2Reserved_InTok;
244 : : extern NameKey_Name M2Reserved_ImportTok;
245 : : extern NameKey_Name M2Reserved_ImplementationTok;
246 : : extern NameKey_Name M2Reserved_IfTok;
247 : : extern NameKey_Name M2Reserved_FromTok;
248 : : extern NameKey_Name M2Reserved_ForTok;
249 : : extern NameKey_Name M2Reserved_FinallyTok;
250 : : extern NameKey_Name M2Reserved_ExportTok;
251 : : extern NameKey_Name M2Reserved_ExitTok;
252 : : extern NameKey_Name M2Reserved_ExceptTok;
253 : : extern NameKey_Name M2Reserved_EndTok;
254 : : extern NameKey_Name M2Reserved_ElsifTok;
255 : : extern NameKey_Name M2Reserved_ElseTok;
256 : : extern NameKey_Name M2Reserved_DoTok;
257 : : extern NameKey_Name M2Reserved_DivTok;
258 : : extern NameKey_Name M2Reserved_DefinitionTok;
259 : : extern NameKey_Name M2Reserved_ConstTok;
260 : : extern NameKey_Name M2Reserved_CaseTok;
261 : : extern NameKey_Name M2Reserved_ByTok;
262 : : extern NameKey_Name M2Reserved_BeginTok;
263 : : extern NameKey_Name M2Reserved_ArrayTok;
264 : : extern NameKey_Name M2Reserved_AndTok;
265 : : extern NameKey_Name M2Reserved_DoubleQuotesTok;
266 : : extern NameKey_Name M2Reserved_BarTok;
267 : : extern NameKey_Name M2Reserved_RCBraTok;
268 : : extern NameKey_Name M2Reserved_RSBraTok;
269 : : extern NameKey_Name M2Reserved_RParaTok;
270 : : extern NameKey_Name M2Reserved_ColonTok;
271 : : extern NameKey_Name M2Reserved_PeriodPeriodTok;
272 : : extern NameKey_Name M2Reserved_GreaterEqualTok;
273 : : extern NameKey_Name M2Reserved_LessEqualTok;
274 : : extern NameKey_Name M2Reserved_LessGreaterTok;
275 : : extern NameKey_Name M2Reserved_GreaterTok;
276 : : extern NameKey_Name M2Reserved_LessTok;
277 : : extern NameKey_Name M2Reserved_HashTok;
278 : : extern NameKey_Name M2Reserved_EqualTok;
279 : : extern NameKey_Name M2Reserved_SingleQuoteTok;
280 : : extern NameKey_Name M2Reserved_UpArrowTok;
281 : : extern NameKey_Name M2Reserved_LCBraTok;
282 : : extern NameKey_Name M2Reserved_LSBraTok;
283 : : extern NameKey_Name M2Reserved_LParaTok;
284 : : extern NameKey_Name M2Reserved_SemiColonTok;
285 : : extern NameKey_Name M2Reserved_CommaTok;
286 : : extern NameKey_Name M2Reserved_PeriodTok;
287 : : extern NameKey_Name M2Reserved_AmbersandTok;
288 : : extern NameKey_Name M2Reserved_BecomesTok;
289 : : extern NameKey_Name M2Reserved_DivideTok;
290 : : extern NameKey_Name M2Reserved_TimesTok;
291 : : extern NameKey_Name M2Reserved_MinusTok;
292 : : extern NameKey_Name M2Reserved_PlusTok;
293 : : extern NameKey_Name M2Reserved_NulTok;
294 : : # define SymbolKey_NulKey 0
295 : : typedef struct SymbolKey_IsSymbol_p SymbolKey_IsSymbol;
296 : :
297 : : typedef struct SymbolKey_Node_r SymbolKey_Node;
298 : :
299 : : typedef SymbolKey_Node *SymbolKey_SymbolTree;
300 : :
301 : : # define Debugging true
302 : : # define DebugTrace false
303 : : # define DebugError false
304 : : typedef struct M2Error__T4_r M2Error__T4;
305 : :
306 : : typedef struct M2Error__T6_r M2Error__T6;
307 : :
308 : : # define MaxBuf 127
309 : : typedef enum {M2Error_noscope, M2Error_definition, M2Error_implementation, M2Error_program, M2Error_module, M2Error_procedure} M2Error_KindScope;
310 : :
311 : : # define MaxBucket 10
312 : : 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;
313 : :
314 : : extern M2Reserved_toktype M2LexBuf_currenttoken;
315 : : typedef enum {SymbolTable_NoValue, SymbolTable_ImmediateValue, SymbolTable_RightValue, SymbolTable_LeftValue} SymbolTable_ModeOfAddr;
316 : :
317 : : # define MaxNoOfElements 5
318 : : typedef M2Error__T4 *M2Error_Error;
319 : :
320 : : typedef M2Error__T6 *M2Error_ErrorScope;
321 : :
322 : : typedef struct DynamicStrings_stringRecord_r DynamicStrings_stringRecord;
323 : :
324 : : typedef struct DynamicStrings_Contents_r DynamicStrings_Contents;
325 : :
326 : : typedef struct DynamicStrings__T5_a DynamicStrings__T5;
327 : :
328 : : typedef DynamicStrings_stringRecord *DynamicStrings_String;
329 : :
330 : : typedef struct Indexing__T10_r Indexing__T10;
331 : :
332 : : typedef Indexing__T10 *Indexing_Index;
333 : :
334 : : struct M2StackAddress__T7_r {
335 : : M2StackAddress_StackBucket tail;
336 : : };
337 : :
338 : : struct M2StackAddress__T9_a { void * array[(MaxBucket-1)+1]; };
339 : : typedef void (*M2RTS_ArgCVEnvP_t) (int, void *, void *);
340 : : struct M2RTS_ArgCVEnvP_p { M2RTS_ArgCVEnvP_t proc; };
341 : :
342 : : typedef void (*Indexing_IndexProcedure_t) (void *);
343 : : struct Indexing_IndexProcedure_p { Indexing_IndexProcedure_t proc; };
344 : :
345 : : typedef void (*SymbolTable_FamilyOperation_t) (unsigned int, unsigned int, unsigned int);
346 : : struct SymbolTable_FamilyOperation_p { SymbolTable_FamilyOperation_t proc; };
347 : :
348 : : struct Lists__T11_a { unsigned int array[MaxNoOfElements-1+1]; };
349 : : struct libc_tm_r {
350 : : int tm_sec;
351 : : int tm_min;
352 : : int tm_hour;
353 : : int tm_mday;
354 : : int tm_mon;
355 : : int tm_year;
356 : : int tm_wday;
357 : : int tm_yday;
358 : : int tm_isdst;
359 : : long int tm_gmtoff;
360 : : void *tm_zone;
361 : : };
362 : :
363 : : struct libc_timeb_r {
364 : : libc_time_t time_;
365 : : short unsigned int millitm;
366 : : short unsigned int timezone;
367 : : short unsigned int dstflag;
368 : : };
369 : :
370 : : typedef int (*libc_exitP_t) (void);
371 : : typedef libc_exitP_t libc_exitP_C;
372 : :
373 : : struct libc_exitP_p { libc_exitP_t proc; };
374 : :
375 : : typedef bool (*SymbolKey_IsSymbol_t) (unsigned int);
376 : : struct SymbolKey_IsSymbol_p { SymbolKey_IsSymbol_t proc; };
377 : :
378 : : struct SymbolKey_Node_r {
379 : : NameKey_Name KeyName;
380 : : unsigned int KeySym;
381 : : SymbolKey_SymbolTree Left;
382 : : SymbolKey_SymbolTree Right;
383 : : };
384 : :
385 : : struct M2Error__T4_r {
386 : : M2Error_Error parent;
387 : : M2Error_Error child;
388 : : M2Error_Error next;
389 : : bool note;
390 : : bool fatal;
391 : : DynamicStrings_String s;
392 : : unsigned int token;
393 : : bool color;
394 : : M2Error_ErrorScope scope;
395 : : };
396 : :
397 : : struct M2Error__T6_r {
398 : : M2Error_KindScope scopeKind;
399 : : NameKey_Name scopeName;
400 : : unsigned int symbol;
401 : : };
402 : :
403 : : struct DynamicStrings__T5_a { char array[(MaxBuf-1)+1]; };
404 : : struct Indexing__T10_r {
405 : : void *ArrayStart;
406 : : unsigned int ArraySize;
407 : : unsigned int Used;
408 : : unsigned int Low;
409 : : unsigned int High;
410 : : bool Debug;
411 : : unsigned int Map;
412 : : unsigned int GrowFactor;
413 : : };
414 : :
415 : : struct M2StackAddress__T8_r {
416 : : M2StackAddress__T9 bucket;
417 : : unsigned int items;
418 : : M2StackAddress_StackBucket prev;
419 : : };
420 : :
421 : : struct Lists_list_r {
422 : : unsigned int NoOfElements;
423 : : Lists__T11 Elements;
424 : : Lists_List Next;
425 : : };
426 : :
427 : : struct DynamicStrings_Contents_r {
428 : : DynamicStrings__T5 buf;
429 : : unsigned int len;
430 : : DynamicStrings_String next;
431 : : };
432 : :
433 : : typedef struct DynamicStrings_descriptor_r DynamicStrings_descriptor;
434 : :
435 : : typedef DynamicStrings_descriptor *DynamicStrings_Descriptor;
436 : :
437 : : typedef struct DynamicStrings_DebugInfo_r DynamicStrings_DebugInfo;
438 : :
439 : : typedef enum {DynamicStrings_inuse, DynamicStrings_marked, DynamicStrings_onlist, DynamicStrings_poisoned} DynamicStrings_desState;
440 : :
441 : : struct DynamicStrings_descriptor_r {
442 : : bool charStarUsed;
443 : : void *charStar;
444 : : unsigned int charStarSize;
445 : : bool charStarValid;
446 : : DynamicStrings_desState state;
447 : : DynamicStrings_String garbage;
448 : : };
449 : :
450 : : struct DynamicStrings_DebugInfo_r {
451 : : DynamicStrings_String next;
452 : : void *file;
453 : : unsigned int line;
454 : : void *proc;
455 : : };
456 : :
457 : : static M2Error_Error head;
458 : : static bool InInternal;
459 : : static M2Error_ErrorScope lastScope;
460 : : static unsigned int scopeIndex;
461 : : static Indexing_Index scopeArray;
462 : : static M2Error_ErrorScope currentScope;
463 : : static M2StackAddress_StackOfAddress scopeStack;
464 : : struct DynamicStrings_stringRecord_r {
465 : : DynamicStrings_Contents contents;
466 : : DynamicStrings_Descriptor head;
467 : : DynamicStrings_DebugInfo debug;
468 : : };
469 : :
470 : : extern "C" void SYSTEM_ShiftVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int ShiftCount);
471 : : 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);
472 : : 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);
473 : : extern "C" void SYSTEM_RotateVal (unsigned int *s, unsigned int _s_high, unsigned int *d, unsigned int _d_high, unsigned int SetSizeInBits, int RotateCount);
474 : : 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);
475 : : 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);
476 : : extern "C" void M2RTS_ConstructModules (void * applicationmodule, void * libname, void * overrideliborder, int argc, void * argv, void * envp);
477 : : extern "C" void M2RTS_DeconstructModules (void * applicationmodule, void * libname, int argc, void * argv, void * envp);
478 : : extern "C" void M2RTS_RegisterModule (void * name, void * libname, M2RTS_ArgCVEnvP init, M2RTS_ArgCVEnvP fini, PROC dependencies);
479 : : extern "C" void M2RTS_RequestDependant (void * modulename, void * libname, void * dependantmodule, void * dependantlibname);
480 : : extern "C" bool M2RTS_InstallTerminationProcedure (PROC p);
481 : : extern "C" void M2RTS_ExecuteInitialProcedures (void);
482 : : extern "C" bool M2RTS_InstallInitialProcedure (PROC p);
483 : : extern "C" void M2RTS_ExecuteTerminationProcedures (void);
484 : : extern "C" void M2RTS_Terminate (void) __attribute__ ((noreturn));
485 : : extern "C" void M2RTS_HALT (int exitcode) __attribute__ ((noreturn));
486 : : 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));
487 : : extern "C" void M2RTS_HaltC (void * description, void * filename, void * function, unsigned int line) __attribute__ ((noreturn));
488 : : extern "C" void M2RTS_ExitOnHalt (int e);
489 : : 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));
490 : : extern "C" unsigned int M2RTS_Length (const char *a_, unsigned int _a_high);
491 : : extern "C" void M2RTS_AssignmentException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
492 : : extern "C" void M2RTS_ReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
493 : : extern "C" void M2RTS_IncException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
494 : : extern "C" void M2RTS_DecException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
495 : : extern "C" void M2RTS_InclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
496 : : extern "C" void M2RTS_ExclException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
497 : : extern "C" void M2RTS_ShiftException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
498 : : extern "C" void M2RTS_RotateException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
499 : : extern "C" void M2RTS_StaticArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
500 : : extern "C" void M2RTS_DynamicArraySubscriptException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
501 : : extern "C" void M2RTS_ForLoopBeginException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
502 : : extern "C" void M2RTS_ForLoopToException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
503 : : extern "C" void M2RTS_ForLoopEndException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
504 : : extern "C" void M2RTS_PointerNilException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
505 : : extern "C" void M2RTS_NoReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
506 : : extern "C" void M2RTS_CaseException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
507 : : extern "C" void M2RTS_WholeNonPosDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
508 : : extern "C" void M2RTS_WholeNonPosModException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
509 : : extern "C" void M2RTS_WholeZeroDivException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
510 : : extern "C" void M2RTS_WholeZeroRemException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
511 : : extern "C" void M2RTS_WholeValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
512 : : extern "C" void M2RTS_RealValueException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
513 : : extern "C" void M2RTS_ParameterException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
514 : : extern "C" void M2RTS_NoException (void * filename, unsigned int line, unsigned int column, void * scope, void * message) __attribute__ ((noreturn));
515 : :
516 : : /*
517 : : InternalError - displays an internal error message together with the compiler source
518 : : file and line number.
519 : : This function is not buffered and is used when the compiler is about
520 : : to give up.
521 : : */
522 : :
523 : : extern "C" void M2Error_InternalError (const char *message_, unsigned int _message_high) __attribute__ ((noreturn));
524 : :
525 : : /*
526 : : WriteFormat0 - displays the source module and line together
527 : : with the encapsulated format string.
528 : : Used for simple error messages tied to the current token.
529 : : */
530 : :
531 : : extern "C" void M2Error_WriteFormat0 (const char *a_, unsigned int _a_high);
532 : :
533 : : /*
534 : : WriteFormat1 - displays the source module and line together
535 : : with the encapsulated format string.
536 : : Used for simple error messages tied to the current token.
537 : : */
538 : :
539 : : extern "C" void M2Error_WriteFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
540 : :
541 : : /*
542 : : WriteFormat2 - displays the module and line together with the encapsulated
543 : : format strings.
544 : : Used for simple error messages tied to the current token.
545 : : */
546 : :
547 : : 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);
548 : :
549 : : /*
550 : : WriteFormat3 - displays the module and line together with the encapsulated
551 : : format strings.
552 : : Used for simple error messages tied to the current token.
553 : : */
554 : :
555 : : 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);
556 : :
557 : : /*
558 : : NewError - creates and returns a new error handle.
559 : : */
560 : :
561 : : extern "C" M2Error_Error M2Error_NewError (unsigned int AtTokenNo);
562 : :
563 : : /*
564 : : NewWarning - creates and returns a new error handle suitable for a warning.
565 : : A warning will not stop compilation.
566 : : */
567 : :
568 : : extern "C" M2Error_Error M2Error_NewWarning (unsigned int AtTokenNo);
569 : :
570 : : /*
571 : : NewNote - creates and returns a new error handle suitable for a note.
572 : : A note will not stop compilation.
573 : : */
574 : :
575 : : extern "C" M2Error_Error M2Error_NewNote (unsigned int AtTokenNo);
576 : :
577 : : /*
578 : : ChainError - creates and returns a new error handle, this new error
579 : : is associated with, e, and is chained onto the end of, e.
580 : : If, e, is NIL then the result to NewError is returned.
581 : : */
582 : :
583 : : extern "C" M2Error_Error M2Error_ChainError (unsigned int AtTokenNo, M2Error_Error e);
584 : :
585 : : /*
586 : : MoveError - repositions an error, e, to token, AtTokenNo, and returns, e.
587 : : */
588 : :
589 : : extern "C" M2Error_Error M2Error_MoveError (M2Error_Error e, unsigned int AtTokenNo);
590 : :
591 : : /*
592 : : SetColor - informs the error module that this error will have had colors
593 : : assigned to it. If an error is issued without colors assigned
594 : : then the default colors will be assigned to the legacy error
595 : : messages.
596 : : */
597 : :
598 : : extern "C" M2Error_Error M2Error_SetColor (M2Error_Error e);
599 : : extern "C" void M2Error_ErrorFormat0 (M2Error_Error e, const char *a_, unsigned int _a_high);
600 : : extern "C" void M2Error_ErrorFormat1 (M2Error_Error e, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
601 : : 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);
602 : : 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);
603 : : extern "C" void M2Error_ErrorString (M2Error_Error e, DynamicStrings_String str);
604 : :
605 : : /*
606 : : ErrorStringAt - given an error string, s, it places this
607 : : string at token position, tok.
608 : : The string is consumed.
609 : : */
610 : :
611 : : extern "C" void M2Error_ErrorStringAt (DynamicStrings_String s, unsigned int tok);
612 : :
613 : : /*
614 : : ErrorStringAt2 - given an error string, s, it places this
615 : : string at token positions, tok1 and tok2, respectively.
616 : : The string is consumed.
617 : : */
618 : :
619 : : extern "C" void M2Error_ErrorStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2);
620 : :
621 : : /*
622 : : ErrorStringsAt2 - given error strings, s1, and, s2, it places these
623 : : strings at token positions, tok1 and tok2, respectively.
624 : : Both strings are consumed.
625 : : */
626 : :
627 : : extern "C" void M2Error_ErrorStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2);
628 : :
629 : : /*
630 : : WarnStringAt - given an error string, s, it places this
631 : : string at token position, tok.
632 : : The string is consumed.
633 : : */
634 : :
635 : : extern "C" void M2Error_WarnStringAt (DynamicStrings_String s, unsigned int tok);
636 : :
637 : : /*
638 : : WarnStringAt2 - given an warning string, s, it places this
639 : : string at token positions, tok1 and tok2, respectively.
640 : : The string is consumed.
641 : : */
642 : :
643 : : extern "C" void M2Error_WarnStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2);
644 : :
645 : : /*
646 : : WarnStringsAt2 - given warning strings, s1, and, s2, it places these
647 : : strings at token positions, tok1 and tok2, respectively.
648 : : Both strings are consumed.
649 : : */
650 : :
651 : : extern "C" void M2Error_WarnStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2);
652 : :
653 : : /*
654 : : WarnFormat0 - displays the source module and line together
655 : : with the encapsulated format string.
656 : : Used for simple warning messages tied to the current token.
657 : : */
658 : :
659 : : extern "C" void M2Error_WarnFormat0 (const char *a_, unsigned int _a_high);
660 : :
661 : : /*
662 : : WarnFormat1 - displays the source module and line together
663 : : with the encapsulated format string.
664 : : Used for simple warning messages tied to the current token.
665 : : */
666 : :
667 : : extern "C" void M2Error_WarnFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
668 : :
669 : : /*
670 : : FlushErrors - switches the output channel to the error channel
671 : : and then writes out all errors.
672 : : */
673 : :
674 : : extern "C" void M2Error_FlushErrors (void);
675 : :
676 : : /*
677 : : FlushWarnings - switches the output channel to the error channel
678 : : and then writes out all warnings.
679 : : If an error is present the compilation is terminated,
680 : : if warnings only were emitted then compilation will
681 : : continue.
682 : : */
683 : :
684 : : extern "C" void M2Error_FlushWarnings (void);
685 : :
686 : : /*
687 : : ErrorAbort0 - aborts compiling, it flushes all warnings and errors before aborting.
688 : : */
689 : :
690 : : extern "C" void M2Error_ErrorAbort0 (const char *a_, unsigned int _a_high) __attribute__ ((noreturn));
691 : :
692 : : /*
693 : : AnnounceScope - return the error string s with a scope description prepended
694 : : assuming that scope has changed.
695 : : */
696 : :
697 : : extern "C" DynamicStrings_String M2Error_AnnounceScope (M2Error_Error e, DynamicStrings_String message);
698 : :
699 : : /*
700 : : EnterImplementationScope - signifies to the error routines that the front end
701 : : has started to compile implementation module scopeName.
702 : : */
703 : :
704 : : extern "C" void M2Error_EnterImplementationScope (NameKey_Name scopename);
705 : :
706 : : /*
707 : : EnterProgramScope - signifies to the error routines that the front end
708 : : has started to compile program module scopeName.
709 : : */
710 : :
711 : : extern "C" void M2Error_EnterProgramScope (NameKey_Name scopename);
712 : :
713 : : /*
714 : : EnterModuleScope - signifies to the error routines that the front end
715 : : has started to compile an inner module scopeName.
716 : : */
717 : :
718 : : extern "C" void M2Error_EnterModuleScope (NameKey_Name scopename);
719 : :
720 : : /*
721 : : EnterDefinitionScope - signifies to the error routines that the front end
722 : : has started to compile definition module scopeName.
723 : : */
724 : :
725 : : extern "C" void M2Error_EnterDefinitionScope (NameKey_Name scopename);
726 : :
727 : : /*
728 : : EnterProcedureScope - signifies to the error routines that the front end
729 : : has started to compile definition module scopeName.
730 : : */
731 : :
732 : : extern "C" void M2Error_EnterProcedureScope (NameKey_Name scopename);
733 : :
734 : : /*
735 : : DepthScope - returns the depth of the scope stack.
736 : : */
737 : :
738 : : extern "C" unsigned int M2Error_DepthScope (void);
739 : :
740 : : /*
741 : : GetAnnounceScope - return message with the error scope attached to message.
742 : : filename and message are treated as read only by this
743 : : procedure function.
744 : : */
745 : :
746 : : extern "C" DynamicStrings_String M2Error_GetAnnounceScope (DynamicStrings_String filename, DynamicStrings_String message);
747 : :
748 : : /*
749 : : DefaultProgramModule - sets up an unnamed program scope before the Ident is seen.
750 : : */
751 : :
752 : : extern "C" void M2Error_DefaultProgramModule (void);
753 : :
754 : : /*
755 : : DefaultImplementationModule - sets up an unnamed implementation
756 : : scope before the Ident is seen.
757 : : */
758 : :
759 : : extern "C" void M2Error_DefaultImplementationModule (void);
760 : :
761 : : /*
762 : : DefaultDefinitionModule - sets up an unnamed definition
763 : : scope before the Ident is seen.
764 : : */
765 : :
766 : : extern "C" void M2Error_DefaultDefinitionModule (void);
767 : :
768 : : /*
769 : : DefaultInnerModule - sets up an unnamed inner
770 : : scope before the Ident is seen.
771 : : */
772 : :
773 : : extern "C" void M2Error_DefaultInnerModule (void);
774 : :
775 : : /*
776 : : DefaultProcedure - sets up an unnamed procedure
777 : : scope before the Ident is seen.
778 : : */
779 : :
780 : : extern "C" void M2Error_DefaultProcedure (void);
781 : :
782 : : /*
783 : : EnterErrorScope - pushes the currentScope and sets currentScope to scope.
784 : : */
785 : :
786 : : extern "C" void M2Error_EnterErrorScope (M2Error_ErrorScope scope);
787 : :
788 : : /*
789 : : LeaveErrorScope - leave the current scope and pop into the previous one.
790 : : */
791 : :
792 : : extern "C" void M2Error_LeaveErrorScope (void);
793 : :
794 : : /*
795 : : GetCurrentErrorScope - returns currentScope.
796 : : */
797 : :
798 : : extern "C" M2Error_ErrorScope M2Error_GetCurrentErrorScope (void);
799 : :
800 : : /*
801 : : ResetErrorScope - should be called at the start of each pass to
802 : : reset the error scope index.
803 : : */
804 : :
805 : : extern "C" void M2Error_ResetErrorScope (void);
806 : :
807 : : /*
808 : : InitString - creates and returns a String type object.
809 : : Initial contents are, a.
810 : : */
811 : :
812 : : extern "C" DynamicStrings_String DynamicStrings_InitString (const char *a_, unsigned int _a_high);
813 : :
814 : : /*
815 : : KillString - frees String, s, and its contents.
816 : : NIL is returned.
817 : : */
818 : :
819 : : extern "C" DynamicStrings_String DynamicStrings_KillString (DynamicStrings_String s);
820 : :
821 : : /*
822 : : Fin - finishes with a string, it calls KillString with, s.
823 : : The purpose of the procedure is to provide a short cut
824 : : to calling KillString and then testing the return result.
825 : : */
826 : :
827 : : extern "C" void DynamicStrings_Fin (DynamicStrings_String s);
828 : :
829 : : /*
830 : : InitStringCharStar - initializes and returns a String to contain the C string.
831 : : */
832 : :
833 : : extern "C" DynamicStrings_String DynamicStrings_InitStringCharStar (void * a);
834 : :
835 : : /*
836 : : InitStringChar - initializes and returns a String to contain the single character, ch.
837 : : */
838 : :
839 : : extern "C" DynamicStrings_String DynamicStrings_InitStringChar (char ch);
840 : :
841 : : /*
842 : : Mark - marks String, s, ready for garbage collection.
843 : : */
844 : :
845 : : extern "C" DynamicStrings_String DynamicStrings_Mark (DynamicStrings_String s);
846 : :
847 : : /*
848 : : Length - returns the length of the String, s.
849 : : */
850 : :
851 : : extern "C" unsigned int DynamicStrings_Length (DynamicStrings_String s);
852 : :
853 : : /*
854 : : ConCat - returns String, a, after the contents of, b, have been appended.
855 : : */
856 : :
857 : : extern "C" DynamicStrings_String DynamicStrings_ConCat (DynamicStrings_String a, DynamicStrings_String b);
858 : :
859 : : /*
860 : : ConCatChar - returns String, a, after character, ch, has been appended.
861 : : */
862 : :
863 : : extern "C" DynamicStrings_String DynamicStrings_ConCatChar (DynamicStrings_String a, char ch);
864 : :
865 : : /*
866 : : Assign - assigns the contents of, b, into, a.
867 : : String, a, is returned.
868 : : */
869 : :
870 : : extern "C" DynamicStrings_String DynamicStrings_Assign (DynamicStrings_String a, DynamicStrings_String b);
871 : :
872 : : /*
873 : : ReplaceChar - returns string s after it has changed all occurances of from to to.
874 : : */
875 : :
876 : : extern "C" DynamicStrings_String DynamicStrings_ReplaceChar (DynamicStrings_String s, char from, char to);
877 : :
878 : : /*
879 : : Dup - duplicate a String, s, returning the copy of s.
880 : : */
881 : :
882 : : extern "C" DynamicStrings_String DynamicStrings_Dup (DynamicStrings_String s);
883 : :
884 : : /*
885 : : Add - returns a new String which contains the contents of a and b.
886 : : */
887 : :
888 : : extern "C" DynamicStrings_String DynamicStrings_Add (DynamicStrings_String a, DynamicStrings_String b);
889 : :
890 : : /*
891 : : Equal - returns TRUE if String, a, and, b, are equal.
892 : : */
893 : :
894 : : extern "C" bool DynamicStrings_Equal (DynamicStrings_String a, DynamicStrings_String b);
895 : :
896 : : /*
897 : : EqualCharStar - returns TRUE if contents of String, s, is the same as the
898 : : string, a.
899 : : */
900 : :
901 : : extern "C" bool DynamicStrings_EqualCharStar (DynamicStrings_String s, void * a);
902 : :
903 : : /*
904 : : EqualArray - returns TRUE if contents of String, s, is the same as the
905 : : string, a.
906 : : */
907 : :
908 : : extern "C" bool DynamicStrings_EqualArray (DynamicStrings_String s, const char *a_, unsigned int _a_high);
909 : :
910 : : /*
911 : : Mult - returns a new string which is n concatenations of String, s.
912 : : */
913 : :
914 : : extern "C" DynamicStrings_String DynamicStrings_Mult (DynamicStrings_String s, unsigned int n);
915 : :
916 : : /*
917 : : Slice - returns a new string which contains the elements
918 : : low..high-1
919 : :
920 : : strings start at element 0
921 : : Slice(s, 0, 2) will return elements 0, 1 but not 2
922 : : Slice(s, 1, 3) will return elements 1, 2 but not 3
923 : : Slice(s, 2, 0) will return elements 2..max
924 : : Slice(s, 3, -1) will return elements 3..max-1
925 : : Slice(s, 4, -2) will return elements 4..max-2
926 : : */
927 : :
928 : : extern "C" DynamicStrings_String DynamicStrings_Slice (DynamicStrings_String s, int low, int high);
929 : :
930 : : /*
931 : : Index - returns the indice of the first occurance of, ch, in
932 : : String, s. -1 is returned if, ch, does not exist.
933 : : The search starts at position, o.
934 : : */
935 : :
936 : : extern "C" int DynamicStrings_Index (DynamicStrings_String s, char ch, unsigned int o);
937 : :
938 : : /*
939 : : RIndex - returns the indice of the last occurance of, ch,
940 : : in String, s. The search starts at position, o.
941 : : -1 is returned if, ch, is not found. The search
942 : : is performed left to right.
943 : : */
944 : :
945 : : extern "C" int DynamicStrings_RIndex (DynamicStrings_String s, char ch, unsigned int o);
946 : :
947 : : /*
948 : : ReverseIndex - returns the indice of the last occurance of ch
949 : : in String s. The search starts at position o
950 : : and searches from right to left. The start position
951 : : may be indexed negatively from the right (-1 is the
952 : : last index).
953 : : The return value if ch is found will always be positive.
954 : : -1 is returned if ch is not found.
955 : : */
956 : :
957 : : extern "C" int DynamicStrings_ReverseIndex (DynamicStrings_String s, char ch, int o);
958 : :
959 : : /*
960 : : RemoveComment - assuming that, comment, is a comment delimiter
961 : : which indicates anything to its right is a comment
962 : : then strip off the comment and also any white space
963 : : on the remaining right hand side.
964 : : It leaves any white space on the left hand side alone.
965 : : */
966 : :
967 : : extern "C" DynamicStrings_String DynamicStrings_RemoveComment (DynamicStrings_String s, char comment);
968 : :
969 : : /*
970 : : RemoveWhitePrefix - removes any leading white space from String, s.
971 : : A new string is returned.
972 : : */
973 : :
974 : : extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePrefix (DynamicStrings_String s);
975 : :
976 : : /*
977 : : RemoveWhitePostfix - removes any leading white space from String, s.
978 : : A new string is returned.
979 : : */
980 : :
981 : : extern "C" DynamicStrings_String DynamicStrings_RemoveWhitePostfix (DynamicStrings_String s);
982 : :
983 : : /*
984 : : ToUpper - returns string, s, after it has had its lower case characters
985 : : replaced by upper case characters.
986 : : The string, s, is not duplicated.
987 : : */
988 : :
989 : : extern "C" DynamicStrings_String DynamicStrings_ToUpper (DynamicStrings_String s);
990 : :
991 : : /*
992 : : ToLower - returns string, s, after it has had its upper case characters
993 : : replaced by lower case characters.
994 : : The string, s, is not duplicated.
995 : : */
996 : :
997 : : extern "C" DynamicStrings_String DynamicStrings_ToLower (DynamicStrings_String s);
998 : :
999 : : /*
1000 : : CopyOut - copies string, s, to a.
1001 : : */
1002 : :
1003 : : extern "C" void DynamicStrings_CopyOut (char *a, unsigned int _a_high, DynamicStrings_String s);
1004 : :
1005 : : /*
1006 : : char - returns the character, ch, at position, i, in String, s.
1007 : : */
1008 : :
1009 : : extern "C" char DynamicStrings_char (DynamicStrings_String s, int i);
1010 : :
1011 : : /*
1012 : : string - returns the C style char * of String, s.
1013 : : */
1014 : :
1015 : : extern "C" void * DynamicStrings_string (DynamicStrings_String s);
1016 : :
1017 : : /*
1018 : : InitStringDB - the debug version of InitString.
1019 : : */
1020 : :
1021 : : extern "C" DynamicStrings_String DynamicStrings_InitStringDB (const char *a_, unsigned int _a_high, const char *file_, unsigned int _file_high, unsigned int line);
1022 : :
1023 : : /*
1024 : : InitStringCharStarDB - the debug version of InitStringCharStar.
1025 : : */
1026 : :
1027 : : extern "C" DynamicStrings_String DynamicStrings_InitStringCharStarDB (void * a, const char *file_, unsigned int _file_high, unsigned int line);
1028 : :
1029 : : /*
1030 : : InitStringCharDB - the debug version of InitStringChar.
1031 : : */
1032 : :
1033 : : extern "C" DynamicStrings_String DynamicStrings_InitStringCharDB (char ch, const char *file_, unsigned int _file_high, unsigned int line);
1034 : :
1035 : : /*
1036 : : MultDB - the debug version of MultDB.
1037 : : */
1038 : :
1039 : : extern "C" DynamicStrings_String DynamicStrings_MultDB (DynamicStrings_String s, unsigned int n, const char *file_, unsigned int _file_high, unsigned int line);
1040 : :
1041 : : /*
1042 : : DupDB - the debug version of Dup.
1043 : : */
1044 : :
1045 : : extern "C" DynamicStrings_String DynamicStrings_DupDB (DynamicStrings_String s, const char *file_, unsigned int _file_high, unsigned int line);
1046 : :
1047 : : /*
1048 : : SliceDB - debug version of Slice.
1049 : : */
1050 : :
1051 : : extern "C" DynamicStrings_String DynamicStrings_SliceDB (DynamicStrings_String s, int low, int high, const char *file_, unsigned int _file_high, unsigned int line);
1052 : :
1053 : : /*
1054 : : PushAllocation - pushes the current allocation/deallocation lists.
1055 : : */
1056 : :
1057 : : extern "C" void DynamicStrings_PushAllocation (void);
1058 : :
1059 : : /*
1060 : : PopAllocation - test to see that all strings are deallocated since
1061 : : the last push. Then it pops to the previous
1062 : : allocation/deallocation lists.
1063 : :
1064 : : If halt is true then the application terminates
1065 : : with an exit code of 1.
1066 : : */
1067 : :
1068 : : extern "C" void DynamicStrings_PopAllocation (bool halt);
1069 : :
1070 : : /*
1071 : : PopAllocationExemption - test to see that all strings are deallocated, except
1072 : : string e since the last push.
1073 : : Post-condition: it pops to the previous allocation/deallocation
1074 : : lists.
1075 : :
1076 : : If halt is true then the application terminates
1077 : : with an exit code of 1.
1078 : : */
1079 : :
1080 : : extern "C" DynamicStrings_String DynamicStrings_PopAllocationExemption (bool halt, DynamicStrings_String e);
1081 : : extern "C" NameKey_Name NameKey_MakeKey (const char *a_, unsigned int _a_high);
1082 : : extern "C" NameKey_Name NameKey_makekey (void * a);
1083 : : extern "C" void NameKey_GetKey (NameKey_Name key, char *a, unsigned int _a_high);
1084 : : extern "C" unsigned int NameKey_LengthKey (NameKey_Name Key);
1085 : : extern "C" bool NameKey_IsKey (const char *a_, unsigned int _a_high);
1086 : : extern "C" void NameKey_WriteKey (NameKey_Name key);
1087 : : extern "C" bool NameKey_IsSameExcludingCase (NameKey_Name key1, NameKey_Name key2);
1088 : : extern "C" void * NameKey_KeyToCharStar (NameKey_Name key);
1089 : : extern "C" char NameKey_CharKey (NameKey_Name key, unsigned int i);
1090 : : extern "C" bool FIO_IsNoError (FIO_File f);
1091 : : extern "C" bool FIO_IsActive (FIO_File f);
1092 : : extern "C" bool FIO_Exists (const char *fname_, unsigned int _fname_high);
1093 : : extern "C" FIO_File FIO_OpenToRead (const char *fname_, unsigned int _fname_high);
1094 : : extern "C" FIO_File FIO_OpenToWrite (const char *fname_, unsigned int _fname_high);
1095 : : extern "C" FIO_File FIO_OpenForRandom (const char *fname_, unsigned int _fname_high, bool towrite, bool newfile);
1096 : : extern "C" void FIO_Close (FIO_File f);
1097 : : extern "C" bool FIO_exists (void * fname, unsigned int flength);
1098 : : extern "C" FIO_File FIO_openToRead (void * fname, unsigned int flength);
1099 : : extern "C" FIO_File FIO_openToWrite (void * fname, unsigned int flength);
1100 : : extern "C" FIO_File FIO_openForRandom (void * fname, unsigned int flength, bool towrite, bool newfile);
1101 : : extern "C" void FIO_FlushBuffer (FIO_File f);
1102 : : extern "C" unsigned int FIO_ReadNBytes (FIO_File f, unsigned int nBytes, void * dest);
1103 : : extern "C" void FIO_ReadAny (FIO_File f, unsigned char *a, unsigned int _a_high);
1104 : : extern "C" unsigned int FIO_WriteNBytes (FIO_File f, unsigned int nBytes, void * src);
1105 : : extern "C" void FIO_WriteAny (FIO_File f, unsigned char *a, unsigned int _a_high);
1106 : : extern "C" void FIO_WriteChar (FIO_File f, char ch);
1107 : : extern "C" bool FIO_EOF (FIO_File f);
1108 : : extern "C" bool FIO_EOLN (FIO_File f);
1109 : : extern "C" bool FIO_WasEOLN (FIO_File f);
1110 : : extern "C" char FIO_ReadChar (FIO_File f);
1111 : : extern "C" void FIO_UnReadChar (FIO_File f, char ch);
1112 : : extern "C" void FIO_WriteLine (FIO_File f);
1113 : : extern "C" void FIO_WriteString (FIO_File f, const char *a_, unsigned int _a_high);
1114 : : extern "C" void FIO_ReadString (FIO_File f, char *a, unsigned int _a_high);
1115 : : extern "C" void FIO_WriteCardinal (FIO_File f, unsigned int c);
1116 : : extern "C" unsigned int FIO_ReadCardinal (FIO_File f);
1117 : : extern "C" int FIO_GetUnixFileDescriptor (FIO_File f);
1118 : : extern "C" void FIO_SetPositionFromBeginning (FIO_File f, long int pos);
1119 : : extern "C" void FIO_SetPositionFromEnd (FIO_File f, long int pos);
1120 : : extern "C" long int FIO_FindPosition (FIO_File f);
1121 : : extern "C" void FIO_GetFileName (FIO_File f, char *a, unsigned int _a_high);
1122 : : extern "C" void * FIO_getFileName (FIO_File f);
1123 : : extern "C" unsigned int FIO_getFileNameLength (FIO_File f);
1124 : : extern "C" void FIO_FlushOutErr (void);
1125 : : 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);
1126 : : extern "C" bool StrLib_StrLess (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
1127 : : extern "C" bool StrLib_StrEqual (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
1128 : : extern "C" unsigned int StrLib_StrLen (const char *a_, unsigned int _a_high);
1129 : : extern "C" void StrLib_StrCopy (const char *src_, unsigned int _src_high, char *dest, unsigned int _dest_high);
1130 : : extern "C" bool StrLib_IsSubString (const char *a_, unsigned int _a_high, const char *b_, unsigned int _b_high);
1131 : : extern "C" void StrLib_StrRemoveWhitePrefix (const char *a_, unsigned int _a_high, char *b, unsigned int _b_high);
1132 : : extern "C" DynamicStrings_String FormatStrings_Sprintf0 (DynamicStrings_String fmt);
1133 : : extern "C" DynamicStrings_String FormatStrings_Sprintf1 (DynamicStrings_String fmt, const unsigned char *w_, unsigned int _w_high);
1134 : : 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);
1135 : : 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);
1136 : : 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);
1137 : : extern "C" DynamicStrings_String FormatStrings_HandleEscape (DynamicStrings_String s);
1138 : : extern "C" bool M2LexBuf_OpenSource (DynamicStrings_String s);
1139 : : extern "C" void M2LexBuf_CloseSource (void);
1140 : : extern "C" void M2LexBuf_ReInitialize (void);
1141 : : extern "C" void M2LexBuf_ResetForNewPass (void);
1142 : : extern "C" void M2LexBuf_GetToken (void);
1143 : : extern "C" void M2LexBuf_InsertToken (M2Reserved_toktype token);
1144 : : extern "C" void M2LexBuf_InsertTokenAndRewind (M2Reserved_toktype token);
1145 : : extern "C" unsigned int M2LexBuf_GetPreviousTokenLineNo (void);
1146 : : extern "C" unsigned int M2LexBuf_GetLineNo (void);
1147 : : extern "C" unsigned int M2LexBuf_GetTokenNo (void);
1148 : : extern "C" NameKey_Name M2LexBuf_GetTokenName (unsigned int tokenno);
1149 : : extern "C" unsigned int M2LexBuf_TokenToLineNo (unsigned int tokenno, unsigned int depth);
1150 : : extern "C" unsigned int M2LexBuf_GetColumnNo (void);
1151 : : extern "C" unsigned int M2LexBuf_TokenToColumnNo (unsigned int tokenno, unsigned int depth);
1152 : : extern "C" m2linemap_location_t M2LexBuf_TokenToLocation (unsigned int tokenno);
1153 : : extern "C" DynamicStrings_String M2LexBuf_FindFileNameFromToken (unsigned int tokenno, unsigned int depth);
1154 : : extern "C" DynamicStrings_String M2LexBuf_GetFileName (void);
1155 : : extern "C" unsigned int M2LexBuf_MakeVirtualTok (unsigned int caret, unsigned int left, unsigned int right);
1156 : : extern "C" unsigned int M2LexBuf_MakeVirtual2Tok (unsigned int left, unsigned int right);
1157 : : extern "C" void M2LexBuf_AddTok (M2Reserved_toktype t);
1158 : : extern "C" void M2LexBuf_AddTokCharStar (M2Reserved_toktype t, void * s);
1159 : : extern "C" void M2LexBuf_AddTokInteger (M2Reserved_toktype t, int i);
1160 : : extern "C" void M2LexBuf_SetFile (void * filename);
1161 : : extern "C" void M2LexBuf_PushFile (void * filename);
1162 : : extern "C" void M2LexBuf_PopFile (void * filename);
1163 : : extern "C" void M2LexBuf_PrintTokenNo (unsigned int tokenno);
1164 : : extern "C" void M2LexBuf_DisplayToken (M2Reserved_toktype tok);
1165 : : extern "C" void M2LexBuf_DumpTokens (void);
1166 : : extern "C" void Storage_ALLOCATE (void * *a, unsigned int Size);
1167 : : extern "C" void Storage_DEALLOCATE (void * *a, unsigned int Size);
1168 : : extern "C" void Storage_REALLOCATE (void * *a, unsigned int Size);
1169 : : extern "C" bool Storage_Available (unsigned int Size);
1170 : : extern "C" void M2Printf_printf0 (const char *a_, unsigned int _a_high);
1171 : : extern "C" void M2Printf_printf1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
1172 : : 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);
1173 : : 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);
1174 : : 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);
1175 : : extern "C" void M2Printf_fprintf0 (FIO_File file, const char *a_, unsigned int _a_high);
1176 : : extern "C" void M2Printf_fprintf1 (FIO_File file, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
1177 : : 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);
1178 : : 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);
1179 : : 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);
1180 : : extern "C" void M2Options_SetM (bool value);
1181 : : extern "C" bool M2Options_GetM (void);
1182 : : extern "C" void M2Options_SetMM (bool value);
1183 : : extern "C" bool M2Options_GetMM (void);
1184 : : extern "C" void M2Options_SetMF (void * arg);
1185 : : extern "C" void * M2Options_GetMF (void);
1186 : : extern "C" void M2Options_SetM2Prefix (void * arg);
1187 : : extern "C" void * M2Options_GetM2Prefix (void);
1188 : : extern "C" void M2Options_SetM2PathName (void * arg);
1189 : : extern "C" void * M2Options_GetM2PathName (void);
1190 : : extern "C" void M2Options_SetPPOnly (bool value);
1191 : : extern "C" bool M2Options_GetPPOnly (void);
1192 : : extern "C" void M2Options_Setc (bool value);
1193 : : extern "C" bool M2Options_Getc (void);
1194 : : extern "C" void M2Options_SetB (void * arg);
1195 : : extern "C" void * M2Options_GetB (void);
1196 : : extern "C" void M2Options_SetMD (bool value);
1197 : : extern "C" bool M2Options_GetMD (void);
1198 : : extern "C" void M2Options_SetMMD (bool value);
1199 : : extern "C" bool M2Options_GetMMD (void);
1200 : : extern "C" void M2Options_SetMQ (void * arg);
1201 : : extern "C" void * M2Options_GetMQ (void);
1202 : : extern "C" void M2Options_SetMT (void * arg);
1203 : : extern "C" void * M2Options_GetMT (void);
1204 : : extern "C" void * M2Options_GetDepTarget (void);
1205 : : extern "C" void M2Options_SetMP (bool value);
1206 : : extern "C" bool M2Options_GetMP (void);
1207 : : extern "C" void M2Options_SetObj (void * arg);
1208 : : extern "C" void * M2Options_GetObj (void);
1209 : : extern "C" void M2Options_SetScaffoldDynamic (bool value);
1210 : : extern "C" void M2Options_SetScaffoldStatic (bool value);
1211 : : extern "C" bool M2Options_GetScaffoldDynamic (void);
1212 : : extern "C" bool M2Options_GetScaffoldStatic (void);
1213 : : extern "C" void M2Options_SetScaffoldMain (bool value);
1214 : : extern "C" void M2Options_SetRuntimeModuleOverride (void * override);
1215 : : extern "C" void * M2Options_GetRuntimeModuleOverride (void);
1216 : : extern "C" void M2Options_SetUselist (bool value, void * filename);
1217 : : extern "C" bool M2Options_GetUselist (void);
1218 : : extern "C" DynamicStrings_String M2Options_GetUselistFilename (void);
1219 : : extern "C" void M2Options_SetWholeProgram (bool value);
1220 : : extern "C" bool M2Options_SetAutoInit (bool value);
1221 : : extern "C" bool M2Options_SetReturnCheck (bool value);
1222 : : extern "C" bool M2Options_SetNilCheck (bool value);
1223 : : extern "C" bool M2Options_SetCaseCheck (bool value);
1224 : : extern "C" bool M2Options_SetCheckAll (bool value);
1225 : : extern "C" bool M2Options_SetVerboseUnbounded (bool value);
1226 : : extern "C" bool M2Options_SetQuiet (bool value);
1227 : : extern "C" void M2Options_SetCC1Quiet (bool value);
1228 : : extern "C" bool M2Options_SetCpp (bool value);
1229 : : extern "C" bool M2Options_GetCpp (void);
1230 : : extern "C" bool M2Options_SetM2g (bool value);
1231 : : extern "C" bool M2Options_GetM2g (void);
1232 : : extern "C" bool M2Options_SetLowerCaseKeywords (bool value);
1233 : : extern "C" bool M2Options_SetUnboundedByReference (bool value);
1234 : : extern "C" void M2Options_SetSearchPath (void * arg);
1235 : : extern "C" void M2Options_SetISO (bool value);
1236 : : extern "C" void M2Options_SetPIM (bool value);
1237 : : extern "C" void M2Options_SetPIM2 (bool value);
1238 : : extern "C" void M2Options_SetPIM3 (bool value);
1239 : : extern "C" void M2Options_SetPIM4 (bool value);
1240 : : extern "C" void M2Options_SetPositiveModFloor (bool value);
1241 : : extern "C" void M2Options_SetWholeDiv (bool value);
1242 : : extern "C" void M2Options_SetIndex (bool value);
1243 : : extern "C" void M2Options_SetRange (bool value);
1244 : : extern "C" void M2Options_SetExceptions (bool value);
1245 : : extern "C" void M2Options_SetStyle (bool value);
1246 : : extern "C" void M2Options_SetPedantic (bool value);
1247 : : extern "C" void M2Options_SetPedanticParamNames (bool value);
1248 : : extern "C" void M2Options_SetPedanticCast (bool value);
1249 : : extern "C" void M2Options_SetExtendedOpaque (bool value);
1250 : : extern "C" void M2Options_SetXCode (bool value);
1251 : : extern "C" void M2Options_SetCompilerDebugging (bool value);
1252 : : extern "C" void M2Options_SetQuadDebugging (bool value);
1253 : : extern "C" void M2Options_SetDebugTraceQuad (bool value);
1254 : : extern "C" void M2Options_SetDebugTraceAPI (bool value);
1255 : : extern "C" void M2Options_SetDebugFunctionLineNumbers (bool value);
1256 : : extern "C" void M2Options_SetGenerateStatementNote (bool value);
1257 : : extern "C" void M2Options_SetSources (bool value);
1258 : : extern "C" void M2Options_SetDumpSystemExports (bool value);
1259 : : extern "C" void M2Options_SetSwig (bool value);
1260 : : extern "C" void M2Options_SetOptimizing (unsigned int value);
1261 : : extern "C" m2linemap_location_t M2Options_OverrideLocation (m2linemap_location_t location);
1262 : : extern "C" void M2Options_SetForcedLocation (m2linemap_location_t location);
1263 : : extern "C" void M2Options_SetUnusedVariableChecking (bool value);
1264 : : extern "C" void M2Options_SetUnusedParameterChecking (bool value);
1265 : : extern "C" void M2Options_SetStrictTypeChecking (bool value);
1266 : : extern "C" void M2Options_setdefextension (void * arg);
1267 : : extern "C" void M2Options_setmodextension (void * arg);
1268 : : extern "C" void M2Options_SetStatistics (bool on);
1269 : : extern "C" bool M2Options_SetVerbose (bool value);
1270 : : extern "C" void M2Options_CppArg (void * opt, void * arg, bool joined);
1271 : : extern "C" DynamicStrings_String M2Options_CppCommandLine (void);
1272 : : extern "C" void M2Options_CppRemember (DynamicStrings_String s);
1273 : : extern "C" bool M2Options_GetISO (void);
1274 : : extern "C" bool M2Options_GetPIM (void);
1275 : : extern "C" bool M2Options_GetPIM2 (void);
1276 : : extern "C" bool M2Options_GetPIM3 (void);
1277 : : extern "C" bool M2Options_GetPIM4 (void);
1278 : : extern "C" bool M2Options_GetPositiveModFloor (void);
1279 : : extern "C" bool M2Options_GetFloatValueCheck (void);
1280 : : extern "C" void M2Options_SetFloatValueCheck (bool value);
1281 : : extern "C" bool M2Options_GetWholeValueCheck (void);
1282 : : extern "C" void M2Options_SetWholeValueCheck (bool value);
1283 : : extern "C" void M2Options_SetWall (bool value);
1284 : : extern "C" void M2Options_SetSaveTemps (bool value);
1285 : : extern "C" void M2Options_SetSaveTempsDir (void * arg);
1286 : : extern "C" DynamicStrings_String M2Options_GetSaveTempsDir (void);
1287 : : extern "C" void M2Options_SetDumpDir (void * arg);
1288 : : extern "C" DynamicStrings_String M2Options_GetDumpDir (void);
1289 : : extern "C" void M2Options_SetGenModuleList (bool value, void * filename);
1290 : : extern "C" DynamicStrings_String M2Options_GetGenModuleFilename (void);
1291 : : extern "C" void M2Options_SetShared (bool value);
1292 : : extern "C" int M2Options_SetUninitVariableChecking (bool value, void * arg);
1293 : : extern "C" void M2Options_SetCaseEnumChecking (bool value);
1294 : : extern "C" void M2Options_SetDebugBuiltins (bool value);
1295 : : extern "C" void M2Options_SetIBMLongDouble (bool value);
1296 : : extern "C" bool M2Options_GetIBMLongDouble (void);
1297 : : extern "C" void M2Options_SetIEEELongDouble (bool value);
1298 : : extern "C" bool M2Options_GetIEEELongDouble (void);
1299 : : extern "C" DynamicStrings_String M2Options_GetDumpLangDeclFilename (void);
1300 : : extern "C" void M2Options_SetDumpLangDeclFilename (bool value, void * filename);
1301 : : extern "C" DynamicStrings_String M2Options_GetDumpLangQuadFilename (void);
1302 : : extern "C" void M2Options_SetDumpLangQuadFilename (bool value, void * filename);
1303 : : extern "C" DynamicStrings_String M2Options_GetDumpLangGimpleFilename (void);
1304 : : extern "C" void M2Options_SetDumpLangGimpleFilename (bool value, void * filename);
1305 : : extern "C" void M2Options_SetM2DumpFilter (bool value, void * filter);
1306 : : extern "C" void * M2Options_GetM2DumpFilter (void);
1307 : : extern "C" bool M2Options_GetDumpLangGimple (void);
1308 : : extern "C" void M2Options_FinaliseOptions (void);
1309 : : extern "C" void M2Emit_EmitError (bool error, bool note, unsigned int token, DynamicStrings_String message);
1310 : : extern "C" void M2Emit_InternalError (const char *message_, unsigned int _message_high);
1311 : : extern "C" m2linemap_location_t M2Emit_UnknownLocation (void);
1312 : : extern "C" m2linemap_location_t M2Emit_BuiltinsLocation (void);
1313 : :
1314 : : /*
1315 : : InitStackAddress - creates and returns a new stack.
1316 : : */
1317 : :
1318 : : extern "C" M2StackAddress_StackOfAddress M2StackAddress_InitStackAddress (void);
1319 : :
1320 : : /*
1321 : : KillStackAddress - destroys a stack, returning NIL.
1322 : : */
1323 : :
1324 : : extern "C" M2StackAddress_StackOfAddress M2StackAddress_KillStackAddress (M2StackAddress_StackOfAddress s);
1325 : :
1326 : : /*
1327 : : PushAddress - pushes a word, w, onto, s.
1328 : : */
1329 : :
1330 : : extern "C" void M2StackAddress_PushAddress (M2StackAddress_StackOfAddress s, void * w);
1331 : :
1332 : : /*
1333 : : PopAddress - pops an element from stack, s.
1334 : : */
1335 : :
1336 : : extern "C" void * M2StackAddress_PopAddress (M2StackAddress_StackOfAddress s);
1337 : :
1338 : : /*
1339 : : IsEmptyAddress - returns TRUE if stack, s, is empty.
1340 : : */
1341 : :
1342 : : extern "C" bool M2StackAddress_IsEmptyAddress (M2StackAddress_StackOfAddress s);
1343 : :
1344 : : /*
1345 : : PeepAddress - returns the element at, n, items below in the stack.
1346 : : Top of stack can be seen via Peep(s, 1)
1347 : : */
1348 : :
1349 : : extern "C" void * M2StackAddress_PeepAddress (M2StackAddress_StackOfAddress s, unsigned int n);
1350 : :
1351 : : /*
1352 : : ReduceAddress - reduce the stack by n elements.
1353 : : */
1354 : :
1355 : : extern "C" void M2StackAddress_ReduceAddress (M2StackAddress_StackOfAddress s, unsigned int n);
1356 : :
1357 : : /*
1358 : : NoOfItemsInStackAddress - returns the number of items held in the stack, s.
1359 : : */
1360 : :
1361 : : extern "C" unsigned int M2StackAddress_NoOfItemsInStackAddress (M2StackAddress_StackOfAddress s);
1362 : :
1363 : : /*
1364 : : InitIndexTuned - creates a dynamic array with low indice.
1365 : : The minsize is the initial number of elements the
1366 : : array is allocated and growfactor determines how
1367 : : it will be resized once it becomes full.
1368 : : */
1369 : :
1370 : : extern "C" Indexing_Index Indexing_InitIndexTuned (unsigned int low, unsigned int minsize, unsigned int growfactor);
1371 : :
1372 : : /*
1373 : : InitIndex - creates and returns an Index.
1374 : : */
1375 : :
1376 : : extern "C" Indexing_Index Indexing_InitIndex (unsigned int low);
1377 : :
1378 : : /*
1379 : : KillIndex - returns Index to free storage.
1380 : : */
1381 : :
1382 : : extern "C" Indexing_Index Indexing_KillIndex (Indexing_Index i);
1383 : :
1384 : : /*
1385 : : DebugIndex - turns on debugging within an index.
1386 : : */
1387 : :
1388 : : extern "C" Indexing_Index Indexing_DebugIndex (Indexing_Index i);
1389 : :
1390 : : /*
1391 : : InBounds - returns TRUE if indice, n, is within the bounds
1392 : : of the dynamic array.
1393 : : */
1394 : :
1395 : : extern "C" bool Indexing_InBounds (Indexing_Index i, unsigned int n);
1396 : :
1397 : : /*
1398 : : HighIndice - returns the last legally accessible indice of this array.
1399 : : */
1400 : :
1401 : : extern "C" unsigned int Indexing_HighIndice (Indexing_Index i);
1402 : :
1403 : : /*
1404 : : LowIndice - returns the first legally accessible indice of this array.
1405 : : */
1406 : :
1407 : : extern "C" unsigned int Indexing_LowIndice (Indexing_Index i);
1408 : :
1409 : : /*
1410 : : PutIndice - places, a, into the dynamic array at position i[n]
1411 : : */
1412 : :
1413 : : extern "C" void Indexing_PutIndice (Indexing_Index i, unsigned int n, void * a);
1414 : :
1415 : : /*
1416 : : GetIndice - retrieves, element i[n] from the dynamic array.
1417 : : */
1418 : :
1419 : : extern "C" void * Indexing_GetIndice (Indexing_Index i, unsigned int n);
1420 : :
1421 : : /*
1422 : : IsIndiceInIndex - returns TRUE if, a, is in the index, i.
1423 : : */
1424 : :
1425 : : extern "C" bool Indexing_IsIndiceInIndex (Indexing_Index i, void * a);
1426 : :
1427 : : /*
1428 : : RemoveIndiceFromIndex - removes, a, from Index, i.
1429 : : */
1430 : :
1431 : : extern "C" void Indexing_RemoveIndiceFromIndex (Indexing_Index i, void * a);
1432 : :
1433 : : /*
1434 : : DeleteIndice - delete i[j] from the array.
1435 : : */
1436 : :
1437 : : extern "C" void Indexing_DeleteIndice (Indexing_Index i, unsigned int j);
1438 : :
1439 : : /*
1440 : : IncludeIndiceIntoIndex - if the indice is not in the index, then
1441 : : add it at the end.
1442 : : */
1443 : :
1444 : : extern "C" void Indexing_IncludeIndiceIntoIndex (Indexing_Index i, void * a);
1445 : :
1446 : : /*
1447 : : ForeachIndiceInIndexDo - for each j indice of i, call procedure p(i[j])
1448 : : */
1449 : :
1450 : : extern "C" void Indexing_ForeachIndiceInIndexDo (Indexing_Index i, Indexing_IndexProcedure p);
1451 : :
1452 : : /*
1453 : : IsEmpty - return TRUE if the array has no entries it.
1454 : : */
1455 : :
1456 : : extern "C" bool Indexing_IsEmpty (Indexing_Index i);
1457 : : extern "C" void M2Debug_Assert (bool q);
1458 : : extern "C" void M2Debug_WriteDebug (const char *a_, unsigned int _a_high);
1459 : : extern "C" void M2Pass_SetPassToNoPass (void);
1460 : : extern "C" void M2Pass_SetPassToPass0 (void);
1461 : : extern "C" void M2Pass_SetPassToPass1 (void);
1462 : : extern "C" void M2Pass_SetPassToPass2 (void);
1463 : : extern "C" void M2Pass_SetPassToPassC (void);
1464 : : extern "C" void M2Pass_SetPassToPass3 (void);
1465 : : extern "C" void M2Pass_SetPassToPassHidden (void);
1466 : : extern "C" void M2Pass_SetPassToCodeGeneration (void);
1467 : : extern "C" void M2Pass_SetPassToErrorPass (void);
1468 : : extern "C" bool M2Pass_IsNoPass (void);
1469 : : extern "C" bool M2Pass_IsPass0 (void);
1470 : : extern "C" bool M2Pass_IsPass1 (void);
1471 : : extern "C" bool M2Pass_IsPass2 (void);
1472 : : extern "C" bool M2Pass_IsPassC (void);
1473 : : extern "C" bool M2Pass_IsPass3 (void);
1474 : : extern "C" bool M2Pass_IsPassHidden (void);
1475 : : extern "C" bool M2Pass_IsPassCodeGeneration (void);
1476 : : extern "C" bool M2Pass_IsErrorPass (void);
1477 : : extern "C" unsigned int SymbolTable_FinalSymbol (void);
1478 : : extern "C" unsigned int SymbolTable_MakeComponentRecord (unsigned int tok, SymbolTable_ModeOfAddr Mode, unsigned int record);
1479 : : extern "C" unsigned int SymbolTable_MakeComponentRef (unsigned int sym, unsigned int field);
1480 : : extern "C" bool SymbolTable_IsComponent (unsigned int sym);
1481 : : extern "C" unsigned int SymbolTable_MakeTemporary (unsigned int tok, SymbolTable_ModeOfAddr Mode);
1482 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpression (unsigned int tok, unsigned int e, SymbolTable_ModeOfAddr mode);
1483 : : extern "C" unsigned int SymbolTable_MakeTemporaryFromExpressions (unsigned int tok, unsigned int e1, unsigned int e2, SymbolTable_ModeOfAddr mode);
1484 : : extern "C" void SymbolTable_PutMode (unsigned int Sym, SymbolTable_ModeOfAddr SymMode);
1485 : : extern "C" SymbolTable_ModeOfAddr SymbolTable_GetMode (unsigned int Sym);
1486 : : extern "C" void SymbolTable_StartScope (unsigned int Sym);
1487 : : extern "C" void SymbolTable_EndScope (void);
1488 : : extern "C" void SymbolTable_PseudoScope (unsigned int Sym);
1489 : : extern "C" unsigned int SymbolTable_GetCurrentScope (void);
1490 : : extern "C" bool SymbolTable_IsDeclaredIn (unsigned int scope, unsigned int sym);
1491 : : extern "C" void SymbolTable_SetCurrentModule (unsigned int Sym);
1492 : : extern "C" void SymbolTable_SetFileModule (unsigned int Sym);
1493 : : extern "C" void SymbolTable_SetMainModule (unsigned int Sym);
1494 : : extern "C" NameKey_Name SymbolTable_CheckAnonymous (NameKey_Name name);
1495 : : extern "C" bool SymbolTable_IsNameAnonymous (unsigned int sym);
1496 : : extern "C" unsigned int SymbolTable_NoOfVariables (unsigned int scope);
1497 : : extern "C" unsigned int SymbolTable_MakeModule (unsigned int tok, NameKey_Name ModuleName);
1498 : : extern "C" unsigned int SymbolTable_MakeDefImp (unsigned int tok, NameKey_Name DefImpName);
1499 : : extern "C" unsigned int SymbolTable_MakeInnerModule (unsigned int tok, NameKey_Name ModuleName);
1500 : : extern "C" unsigned int SymbolTable_MakeProcedure (unsigned int tok, NameKey_Name ProcedureName);
1501 : : extern "C" unsigned int SymbolTable_MakeProcedureCtorExtern (unsigned int tokenno, NameKey_Name libname, NameKey_Name modulename);
1502 : : extern "C" void SymbolTable_PutLibName (unsigned int sym, NameKey_Name libname);
1503 : : extern "C" NameKey_Name SymbolTable_GetLibName (unsigned int sym);
1504 : : extern "C" void SymbolTable_PutMonoName (unsigned int sym, bool value);
1505 : : extern "C" bool SymbolTable_IsMonoName (unsigned int sym);
1506 : : extern "C" void SymbolTable_PutExtern (unsigned int sym, bool value);
1507 : : extern "C" bool SymbolTable_IsExtern (unsigned int sym);
1508 : : extern "C" void SymbolTable_PutPublic (unsigned int sym, bool value);
1509 : : extern "C" bool SymbolTable_IsPublic (unsigned int sym);
1510 : : extern "C" void SymbolTable_PutCtor (unsigned int sym, bool value);
1511 : : extern "C" bool SymbolTable_IsCtor (unsigned int sym);
1512 : : extern "C" void SymbolTable_GetModuleCtors (unsigned int mod, unsigned int *ctor, unsigned int *init, unsigned int *fini, unsigned int *dep);
1513 : : extern "C" void SymbolTable_MakeModuleCtor (unsigned int moduleTok, unsigned int beginTok, unsigned int finallyTok, unsigned int moduleSym);
1514 : : extern "C" void SymbolTable_PutModuleCtorExtern (unsigned int tok, unsigned int sym, bool external);
1515 : : extern "C" void SymbolTable_PutVarHeap (unsigned int sym, bool value);
1516 : : extern "C" bool SymbolTable_IsVarHeap (unsigned int sym);
1517 : : extern "C" unsigned int SymbolTable_MakeVar (unsigned int tok, NameKey_Name VarName);
1518 : : extern "C" unsigned int SymbolTable_MakeRecord (unsigned int tok, NameKey_Name RecordName);
1519 : : extern "C" unsigned int SymbolTable_MakeVarient (unsigned int tok, unsigned int RecOrVarFieldSym);
1520 : : extern "C" unsigned int SymbolTable_MakeFieldVarient (NameKey_Name n, unsigned int Sym);
1521 : : extern "C" unsigned int SymbolTable_MakeEnumeration (unsigned int tok, NameKey_Name EnumerationName);
1522 : : extern "C" unsigned int SymbolTable_MakeType (unsigned int tok, NameKey_Name TypeName);
1523 : : extern "C" unsigned int SymbolTable_MakeHiddenType (unsigned int tok, NameKey_Name TypeName);
1524 : : extern "C" unsigned int SymbolTable_MakeConstant (unsigned int tok, unsigned int value);
1525 : : extern "C" unsigned int SymbolTable_MakeConstLit (unsigned int tok, NameKey_Name constName, unsigned int constType);
1526 : : extern "C" unsigned int SymbolTable_MakeConstVar (unsigned int tok, NameKey_Name ConstVarName);
1527 : : extern "C" unsigned int SymbolTable_MakeConstString (unsigned int tok, NameKey_Name ConstName);
1528 : : extern "C" unsigned int SymbolTable_MakeConstStringCnul (unsigned int tok, NameKey_Name name, bool known);
1529 : : extern "C" unsigned int SymbolTable_MakeConstStringM2nul (unsigned int tok, NameKey_Name name, bool known);
1530 : : extern "C" void SymbolTable_PutConstStringKnown (unsigned int tok, unsigned int sym, NameKey_Name contents, bool escape, bool known);
1531 : : extern "C" void SymbolTable_CopyConstString (unsigned int tok, unsigned int des, unsigned int expr);
1532 : : extern "C" bool SymbolTable_IsConstStringKnown (unsigned int sym);
1533 : : extern "C" bool SymbolTable_IsConstStringM2 (unsigned int sym);
1534 : : extern "C" bool SymbolTable_IsConstStringC (unsigned int sym);
1535 : : extern "C" bool SymbolTable_IsConstStringM2nul (unsigned int sym);
1536 : : extern "C" bool SymbolTable_IsConstStringCnul (unsigned int sym);
1537 : : extern "C" unsigned int SymbolTable_MakeSubrange (unsigned int tok, NameKey_Name SubrangeName);
1538 : : extern "C" unsigned int SymbolTable_MakeSet (unsigned int tok, NameKey_Name SetName);
1539 : : extern "C" unsigned int SymbolTable_MakeArray (unsigned int tok, NameKey_Name ArrayName);
1540 : : extern "C" void SymbolTable_PutArrayLarge (unsigned int array);
1541 : : extern "C" bool SymbolTable_IsArrayLarge (unsigned int array);
1542 : : extern "C" void SymbolTable_PutPriority (unsigned int module, unsigned int priority);
1543 : : extern "C" unsigned int SymbolTable_GetPriority (unsigned int module);
1544 : : extern "C" void SymbolTable_PutNeedSavePriority (unsigned int sym);
1545 : : extern "C" bool SymbolTable_GetNeedSavePriority (unsigned int sym);
1546 : : extern "C" void SymbolTable_PutVariableAtAddress (unsigned int sym, unsigned int address);
1547 : : extern "C" unsigned int SymbolTable_GetVariableAtAddress (unsigned int sym);
1548 : : extern "C" bool SymbolTable_IsVariableAtAddress (unsigned int sym);
1549 : : extern "C" void SymbolTable_PutVariableSSA (unsigned int sym, bool value);
1550 : : extern "C" bool SymbolTable_IsVariableSSA (unsigned int sym);
1551 : : extern "C" void SymbolTable_PutVarConst (unsigned int sym, bool value);
1552 : : extern "C" unsigned int SymbolTable_MakeGnuAsm (void);
1553 : : extern "C" void SymbolTable_PutGnuAsm (unsigned int sym, unsigned int string);
1554 : : extern "C" void SymbolTable_PutGnuAsmOutput (unsigned int sym, unsigned int out);
1555 : : extern "C" void SymbolTable_PutGnuAsmInput (unsigned int sym, unsigned int in);
1556 : : extern "C" void SymbolTable_PutGnuAsmTrash (unsigned int sym, unsigned int trash);
1557 : : extern "C" unsigned int SymbolTable_GetGnuAsm (unsigned int sym);
1558 : : extern "C" unsigned int SymbolTable_GetGnuAsmInput (unsigned int sym);
1559 : : extern "C" unsigned int SymbolTable_GetGnuAsmOutput (unsigned int sym);
1560 : : extern "C" unsigned int SymbolTable_GetGnuAsmTrash (unsigned int sym);
1561 : : extern "C" void SymbolTable_PutGnuAsmVolatile (unsigned int Sym);
1562 : : extern "C" void SymbolTable_PutGnuAsmSimple (unsigned int Sym);
1563 : : extern "C" unsigned int SymbolTable_MakeRegInterface (void);
1564 : : 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_);
1565 : : extern "C" void SymbolTable_GetRegInterface (unsigned int sym, unsigned int i, unsigned int *tok, NameKey_Name *n, unsigned int *string, unsigned int *object);
1566 : : extern "C" unsigned int SymbolTable_GetModule (NameKey_Name name);
1567 : : extern "C" unsigned int SymbolTable_GetCurrentModule (void);
1568 : : extern "C" unsigned int SymbolTable_GetFileModule (void);
1569 : : extern "C" unsigned int SymbolTable_GetBaseModule (void);
1570 : : extern "C" unsigned int SymbolTable_GetMainModule (void);
1571 : : extern "C" unsigned int SymbolTable_GetCurrentModuleScope (void);
1572 : : extern "C" unsigned int SymbolTable_GetLastModuleScope (void);
1573 : : extern "C" void SymbolTable_AddSymToModuleScope (unsigned int ModSym, unsigned int Sym);
1574 : : extern "C" unsigned int SymbolTable_GetType (unsigned int Sym);
1575 : : extern "C" unsigned int SymbolTable_SkipType (unsigned int Sym);
1576 : : extern "C" unsigned int SymbolTable_SkipTypeAndSubrange (unsigned int Sym);
1577 : : extern "C" unsigned int SymbolTable_GetLowestType (unsigned int Sym);
1578 : : extern "C" unsigned int SymbolTable_GetLType (unsigned int sym);
1579 : : extern "C" unsigned int SymbolTable_GetSType (unsigned int sym);
1580 : : extern "C" unsigned int SymbolTable_GetDType (unsigned int sym);
1581 : : extern "C" unsigned int SymbolTable_GetTypeMode (unsigned int sym);
1582 : : extern "C" unsigned int SymbolTable_GetSym (NameKey_Name name);
1583 : : extern "C" unsigned int SymbolTable_GetDeclareSym (unsigned int tok, NameKey_Name SymName);
1584 : : extern "C" unsigned int SymbolTable_GetLocalSym (unsigned int Sym, NameKey_Name name);
1585 : : extern "C" unsigned int SymbolTable_GetRecord (unsigned int Sym);
1586 : : extern "C" unsigned int SymbolTable_FromModuleGetSym (unsigned int tok, NameKey_Name n, unsigned int mod);
1587 : : extern "C" unsigned int SymbolTable_GetNth (unsigned int Sym, unsigned int n);
1588 : : extern "C" unsigned int SymbolTable_GetNthParam (unsigned int Sym, unsigned int ParamNo);
1589 : : extern "C" unsigned int SymbolTable_GetVarScope (unsigned int Sym);
1590 : : extern "C" void SymbolTable_GetSubrange (unsigned int Sym, unsigned int *HighSym, unsigned int *LowSym);
1591 : : extern "C" unsigned int SymbolTable_GetParam (unsigned int Sym, unsigned int ParamNo);
1592 : : extern "C" NameKey_Name SymbolTable_GetString (unsigned int Sym);
1593 : : extern "C" unsigned int SymbolTable_GetStringLength (unsigned int tok, unsigned int sym);
1594 : : extern "C" NameKey_Name SymbolTable_GetProcedureBuiltin (unsigned int Sym);
1595 : : extern "C" void SymbolTable_PutProcedureBuiltin (unsigned int Sym, NameKey_Name name);
1596 : : extern "C" bool SymbolTable_IsProcedureBuiltin (unsigned int Sym);
1597 : : extern "C" void SymbolTable_PutProcedureInline (unsigned int Sym);
1598 : : extern "C" bool SymbolTable_IsProcedureInline (unsigned int Sym);
1599 : : extern "C" void SymbolTable_PutExceptionBlock (unsigned int sym);
1600 : : extern "C" bool SymbolTable_HasExceptionBlock (unsigned int sym);
1601 : : extern "C" void SymbolTable_PutExceptionFinally (unsigned int sym);
1602 : : extern "C" bool SymbolTable_HasExceptionFinally (unsigned int sym);
1603 : : extern "C" void SymbolTable_PutVar (unsigned int Sym, unsigned int VarType);
1604 : : extern "C" void SymbolTable_PutLeftValueFrontBackType (unsigned int Sym, unsigned int FrontType, unsigned int BackType);
1605 : : extern "C" unsigned int SymbolTable_GetVarBackEndType (unsigned int Sym);
1606 : : extern "C" void SymbolTable_PutVarPointerCheck (unsigned int sym, bool value);
1607 : : extern "C" bool SymbolTable_GetVarPointerCheck (unsigned int sym);
1608 : : extern "C" void SymbolTable_PutVarWritten (unsigned int sym, bool value);
1609 : : extern "C" bool SymbolTable_GetVarWritten (unsigned int sym);
1610 : : extern "C" void SymbolTable_PutConst (unsigned int Sym, unsigned int ConstType);
1611 : : extern "C" void SymbolTable_PutConstSet (unsigned int Sym);
1612 : : extern "C" bool SymbolTable_IsConstSet (unsigned int Sym);
1613 : : extern "C" void SymbolTable_PutConstructor (unsigned int Sym);
1614 : : extern "C" void SymbolTable_PutConstructorFrom (unsigned int Sym, unsigned int from);
1615 : : extern "C" unsigned int SymbolTable_PutFieldRecord (unsigned int Sym, NameKey_Name FieldName, unsigned int FieldType, unsigned int VarSym);
1616 : : extern "C" void SymbolTable_PutFieldVarient (unsigned int Field, unsigned int Sym);
1617 : : extern "C" unsigned int SymbolTable_GetVarient (unsigned int Field);
1618 : : extern "C" bool SymbolTable_IsRecordFieldAVarientTag (unsigned int sym);
1619 : : extern "C" bool SymbolTable_IsEmptyFieldVarient (unsigned int sym);
1620 : : extern "C" unsigned int SymbolTable_GetVarientTag (unsigned int Sym);
1621 : : extern "C" void SymbolTable_PutVarientTag (unsigned int Sym, unsigned int Tag);
1622 : : extern "C" void SymbolTable_PutFieldEnumeration (unsigned int tok, unsigned int Sym, NameKey_Name FieldName);
1623 : : extern "C" void SymbolTable_PutSubrange (unsigned int Sym, unsigned int LowSym, unsigned int HighSym, unsigned int TypeSymbol);
1624 : : extern "C" void SymbolTable_PutSet (unsigned int Sym, unsigned int SimpleType, bool packed);
1625 : : extern "C" bool SymbolTable_IsSetPacked (unsigned int Sym);
1626 : : extern "C" unsigned int SymbolTable_GetArraySubscript (unsigned int Sym);
1627 : : extern "C" void SymbolTable_PutArraySubscript (unsigned int Sym, unsigned int SubscriptSymbol);
1628 : : extern "C" void SymbolTable_PutType (unsigned int Sym, unsigned int TypeSymbol);
1629 : : extern "C" void SymbolTable_PutFunction (unsigned int Sym, unsigned int TypeSym);
1630 : : extern "C" void SymbolTable_PutOptFunction (unsigned int Sym, unsigned int TypeSym);
1631 : : extern "C" bool SymbolTable_IsReturnOptional (unsigned int sym);
1632 : : extern "C" bool SymbolTable_PutParam (unsigned int tok, unsigned int Sym, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded);
1633 : : extern "C" bool SymbolTable_PutVarParam (unsigned int tok, unsigned int Sym, unsigned int ParamNo, NameKey_Name ParamName, unsigned int ParamType, bool isUnbounded);
1634 : : extern "C" void SymbolTable_PutParamName (unsigned int tok, unsigned int ProcSym, unsigned int no, NameKey_Name name);
1635 : : extern "C" void SymbolTable_PutProcedureReachable (unsigned int Sym);
1636 : : extern "C" bool SymbolTable_IsProcedureReachable (unsigned int Sym);
1637 : : extern "C" void SymbolTable_PutProcedureNoReturn (unsigned int Sym, bool value);
1638 : : extern "C" bool SymbolTable_IsProcedureNoReturn (unsigned int Sym);
1639 : : extern "C" void SymbolTable_PutModuleStartQuad (unsigned int Sym, unsigned int QuadNumber);
1640 : : extern "C" void SymbolTable_PutModuleEndQuad (unsigned int Sym, unsigned int QuadNumber);
1641 : : extern "C" void SymbolTable_PutModuleFinallyStartQuad (unsigned int Sym, unsigned int QuadNumber);
1642 : : extern "C" void SymbolTable_PutModuleFinallyEndQuad (unsigned int Sym, unsigned int QuadNumber);
1643 : : extern "C" void SymbolTable_GetModuleQuads (unsigned int Sym, unsigned int *StartInit, unsigned int *EndInit, unsigned int *StartFinish, unsigned int *EndFinish);
1644 : : extern "C" void SymbolTable_PutModuleFinallyFunction (unsigned int Sym, m2tree_Tree finally);
1645 : : extern "C" m2tree_Tree SymbolTable_GetModuleFinallyFunction (unsigned int Sym);
1646 : : extern "C" void SymbolTable_PutProcedureScopeQuad (unsigned int Sym, unsigned int QuadNumber);
1647 : : extern "C" void SymbolTable_PutProcedureStartQuad (unsigned int Sym, unsigned int QuadNumber);
1648 : : extern "C" void SymbolTable_PutProcedureEndQuad (unsigned int Sym, unsigned int QuadNumber);
1649 : : extern "C" void SymbolTable_GetProcedureQuads (unsigned int Sym, unsigned int *scope, unsigned int *start, unsigned int *end);
1650 : : extern "C" void SymbolTable_GetQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
1651 : : extern "C" void SymbolTable_GetReadQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
1652 : : extern "C" void SymbolTable_GetWriteQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int *Start, unsigned int *End);
1653 : : extern "C" void SymbolTable_PutReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
1654 : : extern "C" void SymbolTable_RemoveReadQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
1655 : : extern "C" void SymbolTable_PutWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
1656 : : extern "C" void SymbolTable_RemoveWriteQuad (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int Quad);
1657 : : extern "C" void SymbolTable_GetReadLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
1658 : : extern "C" void SymbolTable_GetWriteLimitQuads (unsigned int Sym, SymbolTable_ModeOfAddr m, unsigned int StartLimit, unsigned int EndLimit, unsigned int *Start, unsigned int *End);
1659 : : extern "C" unsigned int SymbolTable_GetNthProcedure (unsigned int Sym, unsigned int n);
1660 : : extern "C" unsigned int SymbolTable_GetDeclaredDef (unsigned int Sym);
1661 : : extern "C" unsigned int SymbolTable_GetDeclaredMod (unsigned int Sym);
1662 : : extern "C" unsigned int SymbolTable_GetDeclaredDefinition (unsigned int Sym);
1663 : : extern "C" unsigned int SymbolTable_GetDeclaredModule (unsigned int Sym);
1664 : : extern "C" void SymbolTable_PutDeclared (unsigned int tok, unsigned int Sym);
1665 : : extern "C" unsigned int SymbolTable_GetFirstUsed (unsigned int Sym);
1666 : : extern "C" void SymbolTable_PutProcedureBegin (unsigned int Sym, unsigned int begin);
1667 : : extern "C" void SymbolTable_PutProcedureEnd (unsigned int Sym, unsigned int end);
1668 : : extern "C" void SymbolTable_GetProcedureBeginEnd (unsigned int Sym, unsigned int *begin, unsigned int *end);
1669 : : extern "C" void SymbolTable_ForeachProcedureDo (unsigned int Sym, SymbolKey_PerformOperation P);
1670 : : extern "C" void SymbolTable_ForeachModuleDo (SymbolKey_PerformOperation P);
1671 : : extern "C" void SymbolTable_ForeachInnerModuleDo (unsigned int Sym, SymbolKey_PerformOperation P);
1672 : : extern "C" bool SymbolTable_IsVarParam (unsigned int Sym, unsigned int ParamNo);
1673 : : extern "C" bool SymbolTable_IsUnboundedParam (unsigned int Sym, unsigned int ParamNo);
1674 : : extern "C" bool SymbolTable_IsParameterUnbounded (unsigned int Sym);
1675 : : extern "C" bool SymbolTable_IsParameterVar (unsigned int Sym);
1676 : : extern "C" unsigned int SymbolTable_GetParameterShadowVar (unsigned int sym);
1677 : : extern "C" unsigned int SymbolTable_NoOfParam (unsigned int Sym);
1678 : : extern "C" bool SymbolTable_HasVarParameters (unsigned int p);
1679 : : extern "C" unsigned int SymbolTable_NoOfLocalVar (unsigned int Sym);
1680 : : extern "C" bool SymbolTable_IsDefImp (unsigned int Sym);
1681 : : extern "C" bool SymbolTable_IsModule (unsigned int Sym);
1682 : : extern "C" bool SymbolTable_IsInnerModule (unsigned int Sym);
1683 : : extern "C" NameKey_Name SymbolTable_GetSymName (unsigned int Sym);
1684 : : extern "C" void SymbolTable_RenameSym (unsigned int Sym, NameKey_Name SymName);
1685 : : extern "C" bool SymbolTable_IsUnknown (unsigned int Sym);
1686 : : extern "C" bool SymbolTable_IsPartialUnbounded (unsigned int sym);
1687 : : extern "C" unsigned int SymbolTable_RequestSym (unsigned int tok, NameKey_Name SymName);
1688 : : extern "C" void SymbolTable_PutImported (unsigned int Sym);
1689 : : extern "C" void SymbolTable_PutIncluded (unsigned int Sym);
1690 : : extern "C" void SymbolTable_PutExported (unsigned int Sym);
1691 : : extern "C" void SymbolTable_PutExportQualified (unsigned int tokenno, NameKey_Name SymName);
1692 : : extern "C" void SymbolTable_PutExportUnQualified (unsigned int tokenno, NameKey_Name SymName);
1693 : : extern "C" void SymbolTable_PutExportUnImplemented (unsigned int tokenno, unsigned int Sym);
1694 : : extern "C" unsigned int SymbolTable_GetExported (unsigned int tokenno, unsigned int ModSym, NameKey_Name SymName);
1695 : : extern "C" unsigned int SymbolTable_GetFromOuterModule (unsigned int tokenno, NameKey_Name SymName);
1696 : : extern "C" unsigned int SymbolTable_TryMoveUndeclaredSymToInnerModule (unsigned int OuterScope, unsigned int InnerScope, NameKey_Name name);
1697 : : extern "C" bool SymbolTable_IsExportQualified (unsigned int Sym);
1698 : : extern "C" bool SymbolTable_IsExportUnQualified (unsigned int Sym);
1699 : : extern "C" bool SymbolTable_IsExported (unsigned int ModSym, unsigned int Sym);
1700 : : extern "C" bool SymbolTable_IsImplicityExported (unsigned int ModSym, unsigned int Sym);
1701 : : extern "C" bool SymbolTable_IsImported (unsigned int ModSym, unsigned int Sym);
1702 : : extern "C" void SymbolTable_PutIncludedByDefinition (unsigned int Sym);
1703 : : extern "C" bool SymbolTable_IsIncludedByDefinition (unsigned int ModSym, unsigned int Sym);
1704 : : extern "C" void SymbolTable_ForeachImportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
1705 : : extern "C" void SymbolTable_ForeachExportedDo (unsigned int ModSym, SymbolKey_PerformOperation P);
1706 : : extern "C" void SymbolTable_CheckForExportedImplementation (unsigned int Sym);
1707 : : extern "C" void SymbolTable_CheckForUnImplementedExports (void);
1708 : : extern "C" void SymbolTable_CheckForUndeclaredExports (unsigned int ModSym);
1709 : : extern "C" void SymbolTable_CheckForUnknownInModule (void);
1710 : : extern "C" void SymbolTable_UnknownReported (unsigned int sym);
1711 : : extern "C" bool SymbolTable_IsReallyPointer (unsigned int Sym);
1712 : : extern "C" void SymbolTable_CheckHiddenTypeAreAddress (void);
1713 : : extern "C" void SymbolTable_PutDefinitionForC (unsigned int Sym);
1714 : : extern "C" bool SymbolTable_IsDefinitionForC (unsigned int Sym);
1715 : : extern "C" void SymbolTable_PutDoesNeedExportList (unsigned int Sym);
1716 : : extern "C" void SymbolTable_PutDoesNotNeedExportList (unsigned int Sym);
1717 : : extern "C" bool SymbolTable_DoesNotNeedExportList (unsigned int Sym);
1718 : : extern "C" void SymbolTable_CheckForEnumerationInCurrentModule (unsigned int Sym);
1719 : : extern "C" void SymbolTable_SanityCheckConstants (void);
1720 : : extern "C" void SymbolTable_ForeachLocalSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
1721 : : extern "C" void SymbolTable_ForeachParamSymDo (unsigned int Sym, SymbolKey_PerformOperation P);
1722 : : extern "C" void SymbolTable_ForeachFieldEnumerationDo (unsigned int Sym, SymbolKey_PerformOperation P);
1723 : : extern "C" bool SymbolTable_IsType (unsigned int Sym);
1724 : : extern "C" bool SymbolTable_IsProcedure (unsigned int Sym);
1725 : : extern "C" bool SymbolTable_IsParameter (unsigned int Sym);
1726 : : extern "C" void SymbolTable_ProcedureParametersDefined (unsigned int Sym);
1727 : : extern "C" bool SymbolTable_AreProcedureParametersDefined (unsigned int Sym);
1728 : : extern "C" void SymbolTable_ParametersDefinedInDefinition (unsigned int Sym);
1729 : : extern "C" bool SymbolTable_AreParametersDefinedInDefinition (unsigned int Sym);
1730 : : extern "C" void SymbolTable_ParametersDefinedInImplementation (unsigned int Sym);
1731 : : extern "C" bool SymbolTable_AreParametersDefinedInImplementation (unsigned int Sym);
1732 : : extern "C" void SymbolTable_PutUseVarArgs (unsigned int Sym);
1733 : : extern "C" bool SymbolTable_UsesVarArgs (unsigned int Sym);
1734 : : extern "C" void SymbolTable_PutUseOptArg (unsigned int Sym);
1735 : : extern "C" bool SymbolTable_UsesOptArg (unsigned int Sym);
1736 : : extern "C" void SymbolTable_PutOptArgInit (unsigned int ProcSym, unsigned int Sym);
1737 : : extern "C" unsigned int SymbolTable_GetOptArgInit (unsigned int ProcSym);
1738 : : extern "C" unsigned int SymbolTable_MakePointer (unsigned int tok, NameKey_Name PointerName);
1739 : : extern "C" void SymbolTable_PutPointer (unsigned int Sym, unsigned int PointerType);
1740 : : extern "C" bool SymbolTable_IsPointer (unsigned int Sym);
1741 : : extern "C" bool SymbolTable_IsRecord (unsigned int Sym);
1742 : : extern "C" bool SymbolTable_IsVarient (unsigned int Sym);
1743 : : extern "C" bool SymbolTable_IsFieldVarient (unsigned int Sym);
1744 : : extern "C" bool SymbolTable_IsFieldEnumeration (unsigned int Sym);
1745 : : extern "C" bool SymbolTable_IsArray (unsigned int Sym);
1746 : : extern "C" bool SymbolTable_IsEnumeration (unsigned int Sym);
1747 : : extern "C" bool SymbolTable_IsSet (unsigned int Sym);
1748 : : extern "C" bool SymbolTable_IsHiddenType (unsigned int Sym);
1749 : : extern "C" bool SymbolTable_IsOAFamily (unsigned int Sym);
1750 : : extern "C" unsigned int SymbolTable_GetDimension (unsigned int sym);
1751 : : extern "C" unsigned int SymbolTable_MakeOAFamily (unsigned int SimpleType);
1752 : : extern "C" unsigned int SymbolTable_GetOAFamily (unsigned int SimpleType);
1753 : : extern "C" void SymbolTable_ForeachOAFamily (unsigned int sym, SymbolTable_FamilyOperation p);
1754 : : extern "C" bool SymbolTable_IsUnbounded (unsigned int Sym);
1755 : : extern "C" unsigned int SymbolTable_GetUnbounded (unsigned int oaf, unsigned int ndim);
1756 : : extern "C" unsigned int SymbolTable_GetUnboundedRecordType (unsigned int Sym);
1757 : : extern "C" unsigned int SymbolTable_GetUnboundedAddressOffset (unsigned int sym);
1758 : : extern "C" unsigned int SymbolTable_GetUnboundedHighOffset (unsigned int sym, unsigned int ndim);
1759 : : extern "C" unsigned int SymbolTable_MakeSubscript (void);
1760 : : extern "C" void SymbolTable_PutSubscript (unsigned int Sym, unsigned int SimpleType);
1761 : : extern "C" unsigned int SymbolTable_MakeUnbounded (unsigned int tok, unsigned int SimpleType, unsigned int ndim);
1762 : : extern "C" unsigned int SymbolTable_NoOfElements (unsigned int Sym);
1763 : : extern "C" void SymbolTable_PutArray (unsigned int Sym, unsigned int TypeSymbol);
1764 : : extern "C" void SymbolTable_ResolveImports (void);
1765 : : extern "C" void SymbolTable_ResolveConstructorTypes (void);
1766 : : extern "C" void SymbolTable_AddNameToScope (NameKey_Name n);
1767 : : extern "C" void SymbolTable_AddNameToImportList (NameKey_Name n);
1768 : : extern "C" unsigned int SymbolTable_GetScope (unsigned int Sym);
1769 : : extern "C" unsigned int SymbolTable_GetModuleScope (unsigned int sym);
1770 : : extern "C" unsigned int SymbolTable_GetProcedureScope (unsigned int sym);
1771 : : extern "C" bool SymbolTable_IsModuleWithinProcedure (unsigned int sym);
1772 : : extern "C" unsigned int SymbolTable_GetParent (unsigned int Sym);
1773 : : extern "C" bool SymbolTable_IsRecordField (unsigned int Sym);
1774 : : extern "C" unsigned int SymbolTable_MakeProcType (unsigned int tok, NameKey_Name ProcTypeName);
1775 : : extern "C" void SymbolTable_PutProcTypeParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded);
1776 : : extern "C" void SymbolTable_PutProcTypeVarParam (unsigned int Sym, unsigned int ParamType, bool isUnbounded);
1777 : : extern "C" bool SymbolTable_IsProcType (unsigned int Sym);
1778 : : extern "C" bool SymbolTable_IsVar (unsigned int Sym);
1779 : : extern "C" bool SymbolTable_IsVarConst (unsigned int sym);
1780 : : extern "C" bool SymbolTable_IsConst (unsigned int Sym);
1781 : : extern "C" bool SymbolTable_IsConstString (unsigned int sym);
1782 : : extern "C" bool SymbolTable_IsConstStringNulTerminated (unsigned int sym);
1783 : : extern "C" bool SymbolTable_IsConstLit (unsigned int Sym);
1784 : : extern "C" bool SymbolTable_IsConstructor (unsigned int Sym);
1785 : : extern "C" bool SymbolTable_IsDummy (unsigned int Sym);
1786 : : extern "C" bool SymbolTable_IsTemporary (unsigned int Sym);
1787 : : extern "C" bool SymbolTable_IsVarAParam (unsigned int Sym);
1788 : : extern "C" bool SymbolTable_IsSubscript (unsigned int Sym);
1789 : : extern "C" bool SymbolTable_IsSubrange (unsigned int Sym);
1790 : : extern "C" bool SymbolTable_IsProcedureVariable (unsigned int Sym);
1791 : : extern "C" bool SymbolTable_IsProcedureNested (unsigned int Sym);
1792 : : extern "C" bool SymbolTable_IsAModula2Type (unsigned int Sym);
1793 : : extern "C" bool SymbolTable_IsGnuAsmVolatile (unsigned int Sym);
1794 : : extern "C" bool SymbolTable_IsGnuAsmSimple (unsigned int Sym);
1795 : : extern "C" bool SymbolTable_IsGnuAsm (unsigned int Sym);
1796 : : extern "C" bool SymbolTable_IsRegInterface (unsigned int Sym);
1797 : : extern "C" bool SymbolTable_IsSizeSolved (unsigned int Sym);
1798 : : extern "C" bool SymbolTable_IsOffsetSolved (unsigned int Sym);
1799 : : extern "C" bool SymbolTable_IsValueSolved (unsigned int Sym);
1800 : : extern "C" bool SymbolTable_IsConstructorConstant (unsigned int Sym);
1801 : : extern "C" bool SymbolTable_IsComposite (unsigned int sym);
1802 : : extern "C" bool SymbolTable_IsSumOfParamSizeSolved (unsigned int Sym);
1803 : : extern "C" void SymbolTable_PutAlignment (unsigned int type, unsigned int align);
1804 : : extern "C" unsigned int SymbolTable_GetAlignment (unsigned int type);
1805 : : extern "C" unsigned int SymbolTable_GetDefaultRecordFieldAlignment (unsigned int sym);
1806 : : extern "C" void SymbolTable_PutDefaultRecordFieldAlignment (unsigned int sym, unsigned int align);
1807 : : extern "C" void SymbolTable_PutUnused (unsigned int sym);
1808 : : extern "C" bool SymbolTable_IsUnused (unsigned int sym);
1809 : : extern "C" void SymbolTable_PutDeclaredPacked (unsigned int sym, bool b);
1810 : : extern "C" bool SymbolTable_IsDeclaredPacked (unsigned int sym);
1811 : : extern "C" bool SymbolTable_IsDeclaredPackedResolved (unsigned int sym);
1812 : : extern "C" unsigned int SymbolTable_GetPackedEquivalent (unsigned int sym);
1813 : : extern "C" unsigned int SymbolTable_GetNonPackedEquivalent (unsigned int sym);
1814 : : extern "C" bool SymbolTable_IsEquivalent (unsigned int sym);
1815 : : extern "C" void SymbolTable_PushSize (unsigned int Sym);
1816 : : extern "C" void SymbolTable_PushOffset (unsigned int Sym);
1817 : : extern "C" void SymbolTable_PushValue (unsigned int Sym);
1818 : : extern "C" void SymbolTable_PushParamSize (unsigned int Sym, unsigned int ParamNo);
1819 : : extern "C" void SymbolTable_PushSumOfLocalVarSize (unsigned int Sym);
1820 : : extern "C" void SymbolTable_PushSumOfParamSize (unsigned int Sym);
1821 : : extern "C" void SymbolTable_PushVarSize (unsigned int Sym);
1822 : : extern "C" void SymbolTable_PopValue (unsigned int Sym);
1823 : : extern "C" void SymbolTable_PopSize (unsigned int Sym);
1824 : : extern "C" void SymbolTable_PopOffset (unsigned int Sym);
1825 : : extern "C" void SymbolTable_PopSumOfParamSize (unsigned int Sym);
1826 : : extern "C" bool SymbolTable_IsObject (unsigned int Sym);
1827 : : extern "C" bool SymbolTable_IsTuple (unsigned int Sym);
1828 : : extern "C" unsigned int SymbolTable_Make2Tuple (unsigned int a, unsigned int b);
1829 : : extern "C" unsigned int SymbolTable_MakeError (unsigned int tok, NameKey_Name name);
1830 : : extern "C" unsigned int SymbolTable_MakeErrorS (unsigned int tok, DynamicStrings_String name);
1831 : : extern "C" bool SymbolTable_IsError (unsigned int Sym);
1832 : : extern "C" bool SymbolTable_IsLegal (unsigned int sym);
1833 : : extern "C" void SymbolTable_PutModuleContainsBuiltin (void);
1834 : : extern "C" bool SymbolTable_IsBuiltinInModule (unsigned int Sym);
1835 : : extern "C" void SymbolTable_PutHiddenTypeDeclared (void);
1836 : : extern "C" bool SymbolTable_IsHiddenTypeDeclared (unsigned int Sym);
1837 : : extern "C" void SymbolTable_DisplayTrees (unsigned int ModSym);
1838 : : extern "C" void SymbolTable_DebugLineNumbers (unsigned int sym);
1839 : : extern "C" M2Error_ErrorScope SymbolTable_GetErrorScope (unsigned int sym);
1840 : : extern "C" unsigned int SymbolTable_MakeImport (unsigned int tok, unsigned int moduleSym, unsigned int listno, bool isqualified);
1841 : : extern "C" unsigned int SymbolTable_MakeImportStatement (unsigned int tok, unsigned int listno);
1842 : : extern "C" bool SymbolTable_IsImport (unsigned int sym);
1843 : : extern "C" bool SymbolTable_IsImportStatement (unsigned int sym);
1844 : : extern "C" unsigned int SymbolTable_GetImportModule (unsigned int sym);
1845 : : extern "C" unsigned int SymbolTable_GetImportDeclared (unsigned int sym);
1846 : : extern "C" Lists_List SymbolTable_GetImportStatementList (unsigned int sym);
1847 : : extern "C" Lists_List SymbolTable_GetModuleDefImportStatementList (unsigned int sym);
1848 : : extern "C" Lists_List SymbolTable_GetModuleModImportStatementList (unsigned int sym);
1849 : : extern "C" void SymbolTable_AppendModuleImportStatement (unsigned int module, unsigned int statement);
1850 : : extern "C" void SymbolTable_AppendModuleOnImportStatement (unsigned int module, unsigned int import);
1851 : : extern "C" void SymbolTable_PutModLink (unsigned int sym, bool link);
1852 : : extern "C" bool SymbolTable_IsModLink (unsigned int sym);
1853 : : extern "C" void SymbolTable_PutDefLink (unsigned int sym, bool link);
1854 : : extern "C" bool SymbolTable_IsDefLink (unsigned int sym);
1855 : : extern "C" bool SymbolTable_IsModuleBuiltin (unsigned int sym);
1856 : : extern "C" void SymbolTable_PutModuleBuiltin (unsigned int sym, bool value);
1857 : : extern "C" void SymbolTable_PutVarArrayRef (unsigned int sym, bool value);
1858 : : extern "C" bool SymbolTable_IsVarArrayRef (unsigned int sym);
1859 : : extern "C" bool SymbolTable_VarCheckReadInit (unsigned int sym, SymbolTable_ModeOfAddr mode);
1860 : : extern "C" void SymbolTable_VarInitState (unsigned int sym);
1861 : : extern "C" void SymbolTable_PutVarInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode);
1862 : : extern "C" bool SymbolTable_PutVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
1863 : : extern "C" bool SymbolTable_GetVarFieldInitialized (unsigned int sym, SymbolTable_ModeOfAddr mode, Lists_List fieldlist);
1864 : : extern "C" void SymbolTable_PrintInitialized (unsigned int sym);
1865 : : extern "C" unsigned int SymbolTable_GetParameterHeapVar (unsigned int ParSym);
1866 : : extern "C" void SymbolTable_PutProcedureParameterHeapVars (unsigned int sym);
1867 : : extern "C" bool SymbolTable_IsProcedureBuiltinAvailable (unsigned int procedure);
1868 : : extern "C" void SymbolTable_PutConstLitInternal (unsigned int sym, bool value);
1869 : : extern "C" bool SymbolTable_IsConstLitInternal (unsigned int sym);
1870 : : extern "C" bool M2ColorString_SetEnableColor (bool b);
1871 : : extern "C" DynamicStrings_String M2ColorString_quoteOpen (DynamicStrings_String s);
1872 : : extern "C" DynamicStrings_String M2ColorString_quoteClose (DynamicStrings_String s);
1873 : : extern "C" DynamicStrings_String M2ColorString_endColor (DynamicStrings_String s);
1874 : : extern "C" DynamicStrings_String M2ColorString_quoteColor (DynamicStrings_String s);
1875 : : extern "C" DynamicStrings_String M2ColorString_errorColor (DynamicStrings_String s);
1876 : : extern "C" DynamicStrings_String M2ColorString_warningColor (DynamicStrings_String s);
1877 : : extern "C" DynamicStrings_String M2ColorString_noteColor (DynamicStrings_String s);
1878 : : extern "C" DynamicStrings_String M2ColorString_locusColor (DynamicStrings_String s);
1879 : : extern "C" DynamicStrings_String M2ColorString_insertColor (DynamicStrings_String s);
1880 : : extern "C" DynamicStrings_String M2ColorString_deleteColor (DynamicStrings_String s);
1881 : : extern "C" DynamicStrings_String M2ColorString_filenameColor (DynamicStrings_String s);
1882 : : extern "C" DynamicStrings_String M2ColorString_typeColor (DynamicStrings_String s);
1883 : : extern "C" DynamicStrings_String M2ColorString_range1Color (DynamicStrings_String s);
1884 : : extern "C" DynamicStrings_String M2ColorString_range2Color (DynamicStrings_String s);
1885 : : extern "C" ssize_t libc_write (int d, void * buf, size_t nbytes);
1886 : : extern "C" ssize_t libc_read (int d, void * buf, size_t nbytes);
1887 : : extern "C" int libc_system (void * a);
1888 : : extern "C" void libc_abort (void) __attribute__ ((noreturn));
1889 : : extern "C" void * libc_malloc (size_t size);
1890 : : extern "C" void libc_free (void * ptr);
1891 : : extern "C" void * libc_realloc (void * ptr, size_t size);
1892 : : extern "C" int libc_isatty (int fd);
1893 : : extern "C" void libc_exit (int r) __attribute__ ((noreturn));
1894 : : extern "C" void * libc_getenv (void * s);
1895 : : extern "C" int libc_putenv (void * s);
1896 : : extern "C" int libc_getpid (void);
1897 : : extern "C" int libc_dup (int d);
1898 : : extern "C" int libc_close (int d);
1899 : : extern "C" int libc_open (void * filename, int oflag, ...);
1900 : : extern "C" int libc_creat (void * filename, unsigned int mode);
1901 : : extern "C" ssize_t libc_lseek (int fd, ssize_t offset, int whence);
1902 : : extern "C" void libc_perror (const char *string_, unsigned int _string_high);
1903 : : extern "C" int libc_readv (int fd, void * v, int n);
1904 : : extern "C" int libc_writev (int fd, void * v, int n);
1905 : : extern "C" void * libc_getcwd (void * buf, size_t size);
1906 : : extern "C" int libc_chown (void * filename, int uid, int gid);
1907 : : extern "C" size_t libc_strlen (void * a);
1908 : : extern "C" void * libc_strcpy (void * dest, void * src);
1909 : : extern "C" void * libc_strncpy (void * dest, void * src, unsigned int n);
1910 : : extern "C" int libc_unlink (void * file);
1911 : : extern "C" void * libc_memcpy (void * dest, void * src, size_t size);
1912 : : extern "C" void * libc_memset (void * s, int c, size_t size);
1913 : : extern "C" void * libc_memmove (void * dest, void * src, size_t size);
1914 : : extern "C" int libc_printf (const char *format_, unsigned int _format_high, ...);
1915 : : extern "C" int libc_snprintf (void * dest, size_t size, const char *format_, unsigned int _format_high, ...);
1916 : : extern "C" int libc_setenv (void * name, void * value, int overwrite);
1917 : : extern "C" void libc_srand (int seed);
1918 : : extern "C" int libc_rand (void);
1919 : : extern "C" libc_time_t libc_time (void * a);
1920 : : extern "C" void * libc_localtime (libc_time_t *t);
1921 : : extern "C" int libc_ftime (libc_timeb *t);
1922 : : extern "C" int libc_shutdown (int s, int how);
1923 : : extern "C" int libc_rename (void * oldpath, void * newpath);
1924 : : extern "C" int libc_setjmp (void * env);
1925 : : extern "C" void libc_longjmp (void * env, int val);
1926 : : extern "C" int libc_atexit (libc_exitP_C proc);
1927 : : extern "C" void * libc_ttyname (int filedes);
1928 : : extern "C" unsigned int libc_sleep (unsigned int seconds);
1929 : : extern "C" int libc_execv (void * pathname, void * argv);
1930 : : extern "C" void Assertion_Assert (bool Condition);
1931 : : extern "C" bool M2Reserved_IsReserved (NameKey_Name n, M2Reserved_toktype *tok);
1932 : : extern "C" NameKey_Name M2Reserved_tokToTok (M2Reserved_toktype t);
1933 : : extern "C" void m2linemap_StartFile (void * filename, unsigned int linebegin);
1934 : : extern "C" void m2linemap_EndFile (void);
1935 : : extern "C" void m2linemap_StartLine (unsigned int linenumber, unsigned int linesize);
1936 : : extern "C" m2linemap_location_t m2linemap_GetLocationColumn (unsigned int column);
1937 : : extern "C" m2linemap_location_t m2linemap_GetLocationRange (unsigned int start, unsigned int end);
1938 : : extern "C" m2linemap_location_t m2linemap_GetLocationBinary (m2linemap_location_t caret, m2linemap_location_t left, m2linemap_location_t right);
1939 : : extern "C" m2linemap_location_t m2linemap_UnknownLocation (void);
1940 : : extern "C" m2linemap_location_t m2linemap_BuiltinsLocation (void);
1941 : : extern "C" int m2linemap_GetLineNoFromLocation (m2linemap_location_t location);
1942 : : extern "C" int m2linemap_GetColumnNoFromLocation (m2linemap_location_t location);
1943 : : extern "C" void * m2linemap_GetFilenameFromLocation (m2linemap_location_t location);
1944 : : extern "C" void m2linemap_ErrorAt (m2linemap_location_t location, void * message);
1945 : : extern "C" void m2linemap_ErrorAtf (m2linemap_location_t location, void * message);
1946 : : extern "C" void m2linemap_WarningAtf (m2linemap_location_t location, void * message);
1947 : : extern "C" void m2linemap_NoteAtf (m2linemap_location_t location, void * message);
1948 : : extern "C" void m2linemap_internal_error (void * message);
1949 : : extern "C" void SymbolKey_InitTree (SymbolKey_SymbolTree *t);
1950 : : extern "C" void SymbolKey_KillTree (SymbolKey_SymbolTree *t);
1951 : :
1952 : : /*
1953 : : ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey.
1954 : : */
1955 : :
1956 : : extern "C" unsigned int SymbolKey_GetSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey);
1957 : :
1958 : : /*
1959 : : ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey.
1960 : : */
1961 : :
1962 : : extern "C" void SymbolKey_PutSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey, unsigned int SymKey);
1963 : :
1964 : : /*
1965 : : DelSymKey - deletes an entry in the binary tree.
1966 : :
1967 : : NB in order for this to work we must ensure that the InitTree sets
1968 : : both Left and Right to NIL.
1969 : : */
1970 : :
1971 : : extern "C" void SymbolKey_DelSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey);
1972 : :
1973 : : /*
1974 : : IsEmptyTree - returns true if SymbolTree, t, is empty.
1975 : : */
1976 : :
1977 : : extern "C" bool SymbolKey_IsEmptyTree (SymbolKey_SymbolTree t);
1978 : :
1979 : : /*
1980 : : DoesTreeContainAny - returns true if SymbolTree, t, contains any
1981 : : symbols which in turn return true when procedure,
1982 : : P, is called with a symbol as its parameter.
1983 : : The SymbolTree root is empty apart from the field,
1984 : : Left, hence we need two procedures.
1985 : : */
1986 : :
1987 : : extern "C" bool SymbolKey_DoesTreeContainAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P);
1988 : :
1989 : : /*
1990 : : ForeachNodeDo - for each node in SymbolTree, t, a procedure, P,
1991 : : is called with the node symbol as its parameter.
1992 : : The tree root node only contains a legal Left pointer,
1993 : : therefore we need two procedures to examine this tree.
1994 : : */
1995 : :
1996 : : extern "C" void SymbolKey_ForeachNodeDo (SymbolKey_SymbolTree t, SymbolKey_PerformOperation P);
1997 : :
1998 : : /*
1999 : : ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey.
2000 : : */
2001 : :
2002 : : extern "C" bool SymbolKey_ContainsSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey);
2003 : :
2004 : : /*
2005 : : NoOfNodes - returns the number of nodes in the tree t.
2006 : : */
2007 : :
2008 : : extern "C" unsigned int SymbolKey_NoOfNodes (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition);
2009 : :
2010 : : /*
2011 : : ForeachNodeConditionDo - traverse the tree t and for any node which satisfied
2012 : : condition call P.
2013 : : */
2014 : :
2015 : : extern "C" void SymbolKey_ForeachNodeConditionDo (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition, SymbolKey_PerformOperation P);
2016 : : extern "C" bool m2tree_IsAConstant (m2tree_Tree t);
2017 : : extern "C" bool m2tree_IsOrdinal (m2tree_Tree type);
2018 : : extern "C" bool m2tree_IsTreeOverflow (m2tree_Tree value);
2019 : : extern "C" m2tree_Tree m2tree_skip_const_decl (m2tree_Tree exp);
2020 : : extern "C" m2tree_Tree m2tree_skip_type_decl (m2tree_Tree type);
2021 : : extern "C" bool m2tree_is_type (m2tree_Tree type);
2022 : : extern "C" bool m2tree_is_array (m2tree_Tree array);
2023 : : extern "C" bool m2tree_is_var (m2tree_Tree var);
2024 : : extern "C" void m2tree_debug_tree (m2tree_Tree t);
2025 : :
2026 : : /*
2027 : : InitList - creates a new list, l.
2028 : : */
2029 : :
2030 : : extern "C" void Lists_InitList (Lists_List *l);
2031 : :
2032 : : /*
2033 : : KillList - deletes the complete list, l.
2034 : : */
2035 : :
2036 : : extern "C" void Lists_KillList (Lists_List *l);
2037 : :
2038 : : /*
2039 : : PutItemIntoList - places a WORD, c, into list, l.
2040 : : */
2041 : :
2042 : : extern "C" void Lists_PutItemIntoList (Lists_List l, unsigned int c);
2043 : : extern "C" unsigned int Lists_GetItemFromList (Lists_List l, unsigned int n);
2044 : :
2045 : : /*
2046 : : GetIndexOfList - returns the index for WORD, c, in list, l.
2047 : : If more than one WORD, c, exists the index
2048 : : for the first is returned.
2049 : : */
2050 : :
2051 : : extern "C" unsigned int Lists_GetIndexOfList (Lists_List l, unsigned int c);
2052 : :
2053 : : /*
2054 : : NoOfItemsInList - returns the number of items in list, l.
2055 : : (iterative algorithm of the above).
2056 : : */
2057 : :
2058 : : extern "C" unsigned int Lists_NoOfItemsInList (Lists_List l);
2059 : :
2060 : : /*
2061 : : IncludeItemIntoList - adds a WORD, c, into a list providing
2062 : : the value does not already exist.
2063 : : */
2064 : :
2065 : : extern "C" void Lists_IncludeItemIntoList (Lists_List l, unsigned int c);
2066 : :
2067 : : /*
2068 : : RemoveItemFromList - removes a WORD, c, from a list.
2069 : : It assumes that this value only appears once.
2070 : : */
2071 : :
2072 : : extern "C" void Lists_RemoveItemFromList (Lists_List l, unsigned int c);
2073 : :
2074 : : /*
2075 : : IsItemInList - returns true if a WORD, c, was found in list, l.
2076 : : */
2077 : :
2078 : : extern "C" bool Lists_IsItemInList (Lists_List l, unsigned int c);
2079 : :
2080 : : /*
2081 : : ForeachItemInListDo - calls procedure, P, foreach item in list, l.
2082 : : */
2083 : :
2084 : : extern "C" void Lists_ForeachItemInListDo (Lists_List l, SymbolKey_PerformOperation P);
2085 : :
2086 : : /*
2087 : : DuplicateList - returns a duplicate list derived from, l.
2088 : : */
2089 : :
2090 : : extern "C" Lists_List Lists_DuplicateList (Lists_List l);
2091 : : extern "C" void StrIO_WriteLn (void);
2092 : : extern "C" void StrIO_ReadString (char *a, unsigned int _a_high);
2093 : : extern "C" void StrIO_WriteString (const char *a_, unsigned int _a_high);
2094 : : extern "C" void NumberIO_ReadCard (unsigned int *x);
2095 : : extern "C" void NumberIO_WriteCard (unsigned int x, unsigned int n);
2096 : : extern "C" void NumberIO_ReadHex (unsigned int *x);
2097 : : extern "C" void NumberIO_WriteHex (unsigned int x, unsigned int n);
2098 : : extern "C" void NumberIO_ReadInt (int *x);
2099 : : extern "C" void NumberIO_WriteInt (int x, unsigned int n);
2100 : : extern "C" void NumberIO_CardToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
2101 : : extern "C" void NumberIO_StrToCard (const char *a_, unsigned int _a_high, unsigned int *x);
2102 : : extern "C" void NumberIO_HexToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
2103 : : extern "C" void NumberIO_StrToHex (const char *a_, unsigned int _a_high, unsigned int *x);
2104 : : extern "C" void NumberIO_IntToStr (int x, unsigned int n, char *a, unsigned int _a_high);
2105 : : extern "C" void NumberIO_StrToInt (const char *a_, unsigned int _a_high, int *x);
2106 : : extern "C" void NumberIO_ReadOct (unsigned int *x);
2107 : : extern "C" void NumberIO_WriteOct (unsigned int x, unsigned int n);
2108 : : extern "C" void NumberIO_OctToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
2109 : : extern "C" void NumberIO_StrToOct (const char *a_, unsigned int _a_high, unsigned int *x);
2110 : : extern "C" void NumberIO_ReadBin (unsigned int *x);
2111 : : extern "C" void NumberIO_WriteBin (unsigned int x, unsigned int n);
2112 : : extern "C" void NumberIO_BinToStr (unsigned int x, unsigned int n, char *a, unsigned int _a_high);
2113 : : extern "C" void NumberIO_StrToBin (const char *a_, unsigned int _a_high, unsigned int *x);
2114 : : extern "C" void NumberIO_StrToBinInt (const char *a_, unsigned int _a_high, int *x);
2115 : : extern "C" void NumberIO_StrToHexInt (const char *a_, unsigned int _a_high, int *x);
2116 : : extern "C" void NumberIO_StrToOctInt (const char *a_, unsigned int _a_high, int *x);
2117 : : 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);
2118 : : extern "C" void Debug_DebugString (const char *a_, unsigned int _a_high);
2119 : :
2120 : : /*
2121 : : Cast - casts a := b
2122 : : */
2123 : :
2124 : : static void Cast (unsigned char *a, unsigned int _a_high, const unsigned char *b_, unsigned int _b_high);
2125 : : static bool TranslateNameToCharStar (char *a, unsigned int _a_high, unsigned int n);
2126 : :
2127 : : /*
2128 : : DoFormat1 -
2129 : : */
2130 : :
2131 : : static DynamicStrings_String DoFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high);
2132 : :
2133 : : /*
2134 : : DoFormat2 -
2135 : : */
2136 : :
2137 : : static DynamicStrings_String DoFormat2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high);
2138 : :
2139 : : /*
2140 : : WriteFormat2 - displays the module and line together with the encapsulated
2141 : : format strings.
2142 : : Used for simple error messages tied to the current token.
2143 : : */
2144 : :
2145 : : static DynamicStrings_String DoFormat3 (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);
2146 : :
2147 : : /*
2148 : : Init - initializes the error list.
2149 : : */
2150 : :
2151 : : static void Init (void);
2152 : :
2153 : : /*
2154 : : CheckIncludes - generates a sequence of error messages which determine the relevant
2155 : : included file and line number.
2156 : : For example:
2157 : :
2158 : : gcc a.c
2159 : : In file included from b.h:1,
2160 : : from a.c:1:
2161 : : c.h:1: parse error before `and'
2162 : :
2163 : : where a.c is: #include "b.h"
2164 : : b.h is: #include "c.h"
2165 : : c.h is: and this and that
2166 : :
2167 : : we attempt to follow the error messages that gcc issues.
2168 : : */
2169 : :
2170 : : static void CheckIncludes (unsigned int token, unsigned int depth);
2171 : :
2172 : : /*
2173 : : FlushAll - flushes all errors in list, e.
2174 : : */
2175 : :
2176 : : static bool FlushAll (M2Error_Error e, bool FatalStatus);
2177 : :
2178 : : /*
2179 : : IsErrorScopeNul - returns TRUE if es is NIL or it has a NulName.
2180 : : */
2181 : :
2182 : : static bool IsErrorScopeNul (M2Error_ErrorScope es);
2183 : :
2184 : : /*
2185 : : IsSameScope - return TRUE if a and b refer to the same scope.
2186 : : */
2187 : :
2188 : : static bool IsSameScope (M2Error_ErrorScope a, M2Error_ErrorScope b);
2189 : :
2190 : : /*
2191 : : newErrorScope - create an ErrorScope of kindScope and return the object.
2192 : : It is also added the a dynamic array.
2193 : : */
2194 : :
2195 : : static M2Error_ErrorScope newErrorScope (M2Error_KindScope kind);
2196 : :
2197 : :
2198 : : /*
2199 : : Cast - casts a := b
2200 : : */
2201 : :
2202 : 6 : static void Cast (unsigned char *a, unsigned int _a_high, const unsigned char *b_, unsigned int _b_high)
2203 : : {
2204 : 6 : unsigned int i;
2205 : 6 : unsigned char b[_b_high+1];
2206 : :
2207 : : /* make a local copy of each unbounded array. */
2208 : 6 : memcpy (b, b_, _b_high+1);
2209 : :
2210 : 6 : if (_a_high == _b_high)
2211 : : {
2212 : 30 : for (i=0; i<=_a_high; i++)
2213 : : {
2214 : 24 : a[i] = b[i];
2215 : : }
2216 : : }
2217 : 6 : }
2218 : :
2219 : 6 : static bool TranslateNameToCharStar (char *a, unsigned int _a_high, unsigned int n)
2220 : : {
2221 : 6 : unsigned int argno;
2222 : 6 : unsigned int i;
2223 : 6 : unsigned int h;
2224 : :
2225 : : /*
2226 : : TranslateNameToString - takes a format specification string, a, and
2227 : : if they consist of of %a then this is translated
2228 : : into a String and %a is replaced by %s.
2229 : : */
2230 : 6 : argno = 1;
2231 : 6 : i = 0;
2232 : 6 : h = StrLib_StrLen ((const char *) a, _a_high);
2233 : 90 : while (i < h)
2234 : : {
2235 : 84 : if ((a[i] == '%') && ((i+1) < h))
2236 : : {
2237 : 6 : if ((a[i+1] == 'a') && (argno == n))
2238 : : {
2239 : 6 : a[i+1] = 's';
2240 : 6 : return true;
2241 : : }
2242 : 0 : argno += 1;
2243 : 0 : if (argno > n)
2244 : : {
2245 : : /* all done */
2246 : : return false;
2247 : : }
2248 : : }
2249 : 78 : i += 1;
2250 : : }
2251 : : return false;
2252 : : /* static analysis guarentees a RETURN statement will be used before here. */
2253 : : __builtin_unreachable ();
2254 : : }
2255 : :
2256 : :
2257 : : /*
2258 : : DoFormat1 -
2259 : : */
2260 : :
2261 : 6 : static DynamicStrings_String DoFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high)
2262 : : {
2263 : 6 : DynamicStrings_String s;
2264 : 6 : NameKey_Name n;
2265 : 6 : char a[_a_high+1];
2266 : 6 : unsigned char w[_w_high+1];
2267 : :
2268 : : /* make a local copy of each unbounded array. */
2269 : 6 : memcpy (a, a_, _a_high+1);
2270 : 6 : memcpy (w, w_, _w_high+1);
2271 : :
2272 : 6 : n = NameKey_NulName;
2273 : 6 : if (TranslateNameToCharStar ((char *) a, _a_high, 1))
2274 : : {
2275 : 6 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w, _w_high);
2276 : 6 : s = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
2277 : 6 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s, (sizeof (s)-1));
2278 : : }
2279 : : else
2280 : : {
2281 : 0 : s = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w, _w_high);
2282 : : }
2283 : 6 : return s;
2284 : : /* static analysis guarentees a RETURN statement will be used before here. */
2285 : : __builtin_unreachable ();
2286 : 6 : }
2287 : :
2288 : :
2289 : : /*
2290 : : DoFormat2 -
2291 : : */
2292 : :
2293 : 0 : static DynamicStrings_String DoFormat2 (const char *a_, unsigned int _a_high, const unsigned char *w1_, unsigned int _w1_high, const unsigned char *w2_, unsigned int _w2_high)
2294 : : {
2295 : 0 : NameKey_Name n;
2296 : 0 : DynamicStrings_String s;
2297 : 0 : DynamicStrings_String s1;
2298 : 0 : DynamicStrings_String s2;
2299 : 0 : unsigned int b;
2300 : 0 : char a[_a_high+1];
2301 : 0 : unsigned char w1[_w1_high+1];
2302 : 0 : unsigned char w2[_w2_high+1];
2303 : :
2304 : : /* make a local copy of each unbounded array. */
2305 : 0 : memcpy (a, a_, _a_high+1);
2306 : 0 : memcpy (w1, w1_, _w1_high+1);
2307 : 0 : memcpy (w2, w2_, _w2_high+1);
2308 : :
2309 : 0 : b = (unsigned int) 0;
2310 : 0 : n = NameKey_NulName;
2311 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 1))
2312 : : {
2313 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w1, _w1_high);
2314 : 0 : s1 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
2315 : 0 : b |= (1 << (1 ));
2316 : : }
2317 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 2))
2318 : : {
2319 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w2, _w2_high);
2320 : 0 : s2 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
2321 : 0 : b |= (1 << (2 ));
2322 : : }
2323 : 0 : switch (b)
2324 : : {
2325 : 0 : case (unsigned int) 0:
2326 : 0 : s = FormatStrings_Sprintf2 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high);
2327 : 0 : break;
2328 : :
2329 : 0 : case (unsigned int) ((1 << (1))):
2330 : 0 : s = FormatStrings_Sprintf2 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high);
2331 : 0 : break;
2332 : :
2333 : 0 : case (unsigned int) ((1 << (2))):
2334 : 0 : s = FormatStrings_Sprintf2 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1));
2335 : 0 : break;
2336 : :
2337 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2))):
2338 : 0 : s = FormatStrings_Sprintf2 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1));
2339 : 0 : break;
2340 : :
2341 : :
2342 : 0 : default:
2343 : 0 : M2RTS_HALT (-1);
2344 : : __builtin_unreachable ();
2345 : 0 : break;
2346 : : }
2347 : 0 : return s;
2348 : : /* static analysis guarentees a RETURN statement will be used before here. */
2349 : : __builtin_unreachable ();
2350 : 0 : }
2351 : :
2352 : :
2353 : : /*
2354 : : WriteFormat2 - displays the module and line together with the encapsulated
2355 : : format strings.
2356 : : Used for simple error messages tied to the current token.
2357 : : */
2358 : :
2359 : 0 : static DynamicStrings_String DoFormat3 (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)
2360 : : {
2361 : 0 : NameKey_Name n;
2362 : 0 : DynamicStrings_String s;
2363 : 0 : DynamicStrings_String s1;
2364 : 0 : DynamicStrings_String s2;
2365 : 0 : DynamicStrings_String s3;
2366 : 0 : unsigned int b;
2367 : 0 : char a[_a_high+1];
2368 : 0 : unsigned char w1[_w1_high+1];
2369 : 0 : unsigned char w2[_w2_high+1];
2370 : 0 : unsigned char w3[_w3_high+1];
2371 : :
2372 : : /* make a local copy of each unbounded array. */
2373 : 0 : memcpy (a, a_, _a_high+1);
2374 : 0 : memcpy (w1, w1_, _w1_high+1);
2375 : 0 : memcpy (w2, w2_, _w2_high+1);
2376 : 0 : memcpy (w3, w3_, _w3_high+1);
2377 : :
2378 : 0 : b = (unsigned int) 0;
2379 : 0 : n = NameKey_NulName;
2380 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 1))
2381 : : {
2382 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w1, _w1_high);
2383 : 0 : s1 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
2384 : 0 : b |= (1 << (1 ));
2385 : : }
2386 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 2))
2387 : : {
2388 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w2, _w2_high);
2389 : 0 : s2 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
2390 : 0 : b |= (1 << (2 ));
2391 : : }
2392 : 0 : if (TranslateNameToCharStar ((char *) a, _a_high, 3))
2393 : : {
2394 : 0 : Cast ((unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) w3, _w3_high);
2395 : 0 : s3 = DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (n)));
2396 : 0 : b |= (1 << (3 ));
2397 : : }
2398 : 0 : switch (b)
2399 : : {
2400 : 0 : case (unsigned int) 0:
2401 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high);
2402 : 0 : break;
2403 : :
2404 : 0 : case (unsigned int) ((1 << (1))):
2405 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high);
2406 : 0 : break;
2407 : :
2408 : 0 : case (unsigned int) ((1 << (2))):
2409 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) w3, _w3_high);
2410 : 0 : break;
2411 : :
2412 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2))):
2413 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) w3, _w3_high);
2414 : 0 : break;
2415 : :
2416 : 0 : case (unsigned int) ((1 << (3))):
2417 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) &s3, (sizeof (s3)-1));
2418 : 0 : break;
2419 : :
2420 : 0 : case (unsigned int) ((1 << (1)) | (1 << (3))):
2421 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) w2, _w2_high, (const unsigned char *) &s3, (sizeof (s3)-1));
2422 : 0 : break;
2423 : :
2424 : 0 : case (unsigned int) ((1 << (2)) | (1 << (3))):
2425 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) w1, _w1_high, (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) &s3, (sizeof (s3)-1));
2426 : 0 : break;
2427 : :
2428 : 0 : case (unsigned int) ((1 << (1)) | (1 << (2)) | (1 << (3))):
2429 : 0 : s = FormatStrings_Sprintf3 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)), (const unsigned char *) &s1, (sizeof (s1)-1), (const unsigned char *) &s2, (sizeof (s2)-1), (const unsigned char *) &s3, (sizeof (s3)-1));
2430 : 0 : break;
2431 : :
2432 : :
2433 : 0 : default:
2434 : 0 : M2RTS_HALT (-1);
2435 : : __builtin_unreachable ();
2436 : 0 : break;
2437 : : }
2438 : 0 : return s;
2439 : : /* static analysis guarentees a RETURN statement will be used before here. */
2440 : : __builtin_unreachable ();
2441 : 0 : }
2442 : :
2443 : :
2444 : : /*
2445 : : Init - initializes the error list.
2446 : : */
2447 : :
2448 : 16867 : static void Init (void)
2449 : : {
2450 : 16867 : head = NULL;
2451 : 16867 : InInternal = false;
2452 : 16867 : scopeStack = M2StackAddress_InitStackAddress ();
2453 : 16867 : scopeArray = Indexing_InitIndex (1);
2454 : 16867 : currentScope = NULL;
2455 : 16867 : scopeIndex = 0;
2456 : 16867 : }
2457 : :
2458 : :
2459 : : /*
2460 : : CheckIncludes - generates a sequence of error messages which determine the relevant
2461 : : included file and line number.
2462 : : For example:
2463 : :
2464 : : gcc a.c
2465 : : In file included from b.h:1,
2466 : : from a.c:1:
2467 : : c.h:1: parse error before `and'
2468 : :
2469 : : where a.c is: #include "b.h"
2470 : : b.h is: #include "c.h"
2471 : : c.h is: and this and that
2472 : :
2473 : : we attempt to follow the error messages that gcc issues.
2474 : : */
2475 : :
2476 : 1755 : static void CheckIncludes (unsigned int token, unsigned int depth)
2477 : : {
2478 : 1755 : DynamicStrings_String included;
2479 : 1755 : unsigned int lineno;
2480 : :
2481 : 1755 : included = M2LexBuf_FindFileNameFromToken (token, depth+1);
2482 : 1755 : if (included != NULL)
2483 : : {
2484 : 0 : lineno = M2LexBuf_TokenToLineNo (token, depth+1);
2485 : 0 : if (depth == 0)
2486 : : {
2487 : 0 : M2Printf_printf2 ((const char *) "In file included from %s:%d", 27, (const unsigned char *) &included, (sizeof (included)-1), (const unsigned char *) &lineno, (sizeof (lineno)-1));
2488 : : }
2489 : : else
2490 : : {
2491 : 0 : M2Printf_printf2 ((const char *) " from %s:%d", 27, (const unsigned char *) &included, (sizeof (included)-1), (const unsigned char *) &lineno, (sizeof (lineno)-1));
2492 : : }
2493 : 0 : if ((M2LexBuf_FindFileNameFromToken (token, depth+2)) == NULL)
2494 : : {
2495 : 0 : M2Printf_printf0 ((const char *) ":\\n", 3);
2496 : : }
2497 : : else
2498 : : {
2499 : 0 : M2Printf_printf0 ((const char *) ",\\n", 3);
2500 : : }
2501 : 0 : CheckIncludes (token, depth+1);
2502 : : }
2503 : 1755 : }
2504 : :
2505 : :
2506 : : /*
2507 : : FlushAll - flushes all errors in list, e.
2508 : : */
2509 : :
2510 : 233640 : static bool FlushAll (M2Error_Error e, bool FatalStatus)
2511 : : {
2512 : 233640 : M2Error_Error f;
2513 : 233640 : bool written;
2514 : :
2515 : 233640 : written = false;
2516 : 233640 : if (e != NULL)
2517 : : {
2518 : 3438 : do {
2519 : 3438 : if ((FatalStatus == e->fatal) && (e->s != NULL))
2520 : : {
2521 : 1755 : currentScope = e->scope;
2522 : 1755 : CheckIncludes (e->token, 0);
2523 : 1755 : M2Emit_EmitError (e->fatal, e->note, e->token, M2Error_AnnounceScope (e, e->s));
2524 : 1755 : if ((e->child != NULL) && (FlushAll (e->child, FatalStatus)))
2525 : : {} /* empty. */
2526 : 1755 : e->s = NULL;
2527 : 1755 : written = true;
2528 : : }
2529 : 3438 : f = e;
2530 : 3438 : e = e->next;
2531 : 3438 : if (! Debugging)
2532 : : {
2533 : : f->s = DynamicStrings_KillString (f->s);
2534 : : Storage_DEALLOCATE ((void **) &f, sizeof (M2Error__T4));
2535 : : }
2536 : 3438 : } while (! (e == NULL));
2537 : : }
2538 : 233640 : return written;
2539 : : /* static analysis guarentees a RETURN statement will be used before here. */
2540 : : __builtin_unreachable ();
2541 : : }
2542 : :
2543 : :
2544 : : /*
2545 : : IsErrorScopeNul - returns TRUE if es is NIL or it has a NulName.
2546 : : */
2547 : :
2548 : 1929 : static bool IsErrorScopeNul (M2Error_ErrorScope es)
2549 : : {
2550 : 1887 : return (es == NULL) || (es->scopeName == NameKey_NulName);
2551 : : /* static analysis guarentees a RETURN statement will be used before here. */
2552 : : __builtin_unreachable ();
2553 : : }
2554 : :
2555 : :
2556 : : /*
2557 : : IsSameScope - return TRUE if a and b refer to the same scope.
2558 : : */
2559 : :
2560 : 1755 : static bool IsSameScope (M2Error_ErrorScope a, M2Error_ErrorScope b)
2561 : : {
2562 : 1755 : if (a == b)
2563 : : {
2564 : : return true;
2565 : : }
2566 : 675 : else if ((a == NULL) || (b == NULL))
2567 : : {
2568 : : /* avoid dangling else. */
2569 : : return false;
2570 : : }
2571 : : else
2572 : : {
2573 : : /* avoid dangling else. */
2574 : : /* this does not compare the symbol field. */
2575 : 24 : return (a->scopeKind == b->scopeKind) && (a->scopeName == b->scopeName);
2576 : : }
2577 : : /* static analysis guarentees a RETURN statement will be used before here. */
2578 : : __builtin_unreachable ();
2579 : : }
2580 : :
2581 : :
2582 : : /*
2583 : : newErrorScope - create an ErrorScope of kindScope and return the object.
2584 : : It is also added the a dynamic array.
2585 : : */
2586 : :
2587 : 15338118 : static M2Error_ErrorScope newErrorScope (M2Error_KindScope kind)
2588 : : {
2589 : 15338118 : M2Error_ErrorScope es;
2590 : 15338118 : unsigned int c;
2591 : :
2592 : 15338118 : if (M2Pass_IsPass0 ())
2593 : : {
2594 : : /* avoid dangling else. */
2595 : 3074562 : Storage_ALLOCATE ((void **) &es, sizeof (M2Error__T6));
2596 : 3074562 : es->scopeKind = kind;
2597 : 3074562 : es->scopeName = NameKey_NulName;
2598 : 3074562 : es->symbol = SymbolTable_NulSym;
2599 : 3074562 : Indexing_PutIndice (scopeArray, (Indexing_HighIndice (scopeArray))+1, reinterpret_cast<void *> (es));
2600 : 3074562 : if (DebugError)
2601 : : {
2602 : : c = Indexing_HighIndice (scopeArray);
2603 : : M2Printf_printf2 ((const char *) "pass 0: %d %d\\n", 17, (const unsigned char *) &c, (sizeof (c)-1), (const unsigned char *) &kind, (sizeof (kind)-1));
2604 : : }
2605 : : }
2606 : : else
2607 : : {
2608 : 12263556 : scopeIndex += 1;
2609 : 12263556 : es = static_cast<M2Error_ErrorScope> (Indexing_GetIndice (scopeArray, scopeIndex));
2610 : 12263556 : if (DebugError)
2611 : : {
2612 : : /* avoid gcc warning by using compound statement even if not strictly necessary. */
2613 : : if (M2Pass_IsPass1 ())
2614 : : {
2615 : : M2Printf_printf3 ((const char *) "pass 1: %d %d %d\\n", 21, (const unsigned char *) &scopeIndex, (sizeof (scopeIndex)-1), (const unsigned char *) &es->scopeKind, (sizeof (es->scopeKind)-1), (const unsigned char *) &kind, (sizeof (kind)-1));
2616 : : }
2617 : : else
2618 : : {
2619 : : M2Printf_printf3 ((const char *) "pass 2: %d %d %d\\n", 21, (const unsigned char *) &scopeIndex, (sizeof (scopeIndex)-1), (const unsigned char *) &es->scopeKind, (sizeof (es->scopeKind)-1), (const unsigned char *) &kind, (sizeof (kind)-1));
2620 : : }
2621 : : }
2622 : 12263556 : M2Debug_Assert (es->scopeKind == kind);
2623 : : }
2624 : 15338118 : return es;
2625 : : /* static analysis guarentees a RETURN statement will be used before here. */
2626 : : __builtin_unreachable ();
2627 : : }
2628 : :
2629 : :
2630 : : /*
2631 : : InternalError - displays an internal error message together with the compiler source
2632 : : file and line number.
2633 : : This function is not buffered and is used when the compiler is about
2634 : : to give up.
2635 : : */
2636 : :
2637 : 48 : extern "C" void M2Error_InternalError (const char *message_, unsigned int _message_high)
2638 : : {
2639 : 48 : char message[_message_high+1];
2640 : :
2641 : : /* make a local copy of each unbounded array. */
2642 : 48 : memcpy (message, message_, _message_high+1);
2643 : :
2644 : 48 : if (! InInternal)
2645 : : {
2646 : 48 : InInternal = true;
2647 : 48 : M2Error_FlushErrors ();
2648 : : }
2649 : 24 : M2Emit_InternalError ((const char *) message, _message_high);
2650 : 0 : M2RTS_HALT (-1);
2651 : : __builtin_unreachable ();
2652 : 48 : }
2653 : :
2654 : :
2655 : : /*
2656 : : WriteFormat0 - displays the source module and line together
2657 : : with the encapsulated format string.
2658 : : Used for simple error messages tied to the current token.
2659 : : */
2660 : :
2661 : 30 : extern "C" void M2Error_WriteFormat0 (const char *a_, unsigned int _a_high)
2662 : : {
2663 : 30 : M2Error_Error e;
2664 : 30 : char a[_a_high+1];
2665 : :
2666 : : /* make a local copy of each unbounded array. */
2667 : 30 : memcpy (a, a_, _a_high+1);
2668 : :
2669 : 30 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
2670 : 30 : e->s = FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
2671 : 30 : }
2672 : :
2673 : :
2674 : : /*
2675 : : WriteFormat1 - displays the source module and line together
2676 : : with the encapsulated format string.
2677 : : Used for simple error messages tied to the current token.
2678 : : */
2679 : :
2680 : 0 : extern "C" void M2Error_WriteFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high)
2681 : : {
2682 : 0 : M2Error_Error e;
2683 : 0 : char a[_a_high+1];
2684 : 0 : unsigned char w[_w_high+1];
2685 : :
2686 : : /* make a local copy of each unbounded array. */
2687 : 0 : memcpy (a, a_, _a_high+1);
2688 : 0 : memcpy (w, w_, _w_high+1);
2689 : :
2690 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
2691 : 0 : e->s = DoFormat1 ((const char *) a, _a_high, (const unsigned char *) w, _w_high);
2692 : 0 : }
2693 : :
2694 : :
2695 : : /*
2696 : : WriteFormat2 - displays the module and line together with the encapsulated
2697 : : format strings.
2698 : : Used for simple error messages tied to the current token.
2699 : : */
2700 : :
2701 : 0 : 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)
2702 : : {
2703 : 0 : M2Error_Error e;
2704 : 0 : char a[_a_high+1];
2705 : 0 : unsigned char w1[_w1_high+1];
2706 : 0 : unsigned char w2[_w2_high+1];
2707 : :
2708 : : /* make a local copy of each unbounded array. */
2709 : 0 : memcpy (a, a_, _a_high+1);
2710 : 0 : memcpy (w1, w1_, _w1_high+1);
2711 : 0 : memcpy (w2, w2_, _w2_high+1);
2712 : :
2713 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
2714 : 0 : e->s = DoFormat2 ((const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high);
2715 : 0 : }
2716 : :
2717 : :
2718 : : /*
2719 : : WriteFormat3 - displays the module and line together with the encapsulated
2720 : : format strings.
2721 : : Used for simple error messages tied to the current token.
2722 : : */
2723 : :
2724 : 0 : 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)
2725 : : {
2726 : 0 : M2Error_Error e;
2727 : 0 : char a[_a_high+1];
2728 : 0 : unsigned char w1[_w1_high+1];
2729 : 0 : unsigned char w2[_w2_high+1];
2730 : 0 : unsigned char w3[_w3_high+1];
2731 : :
2732 : : /* make a local copy of each unbounded array. */
2733 : 0 : memcpy (a, a_, _a_high+1);
2734 : 0 : memcpy (w1, w1_, _w1_high+1);
2735 : 0 : memcpy (w2, w2_, _w2_high+1);
2736 : 0 : memcpy (w3, w3_, _w3_high+1);
2737 : :
2738 : 0 : e = M2Error_NewError (M2LexBuf_GetTokenNo ());
2739 : 0 : e->s = DoFormat3 ((const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high);
2740 : 0 : }
2741 : :
2742 : :
2743 : : /*
2744 : : NewError - creates and returns a new error handle.
2745 : : */
2746 : :
2747 : 1623 : extern "C" M2Error_Error M2Error_NewError (unsigned int AtTokenNo)
2748 : : {
2749 : 1623 : M2Error_Error e;
2750 : 1623 : M2Error_Error f;
2751 : :
2752 : 1623 : if (AtTokenNo == M2LexBuf_UnknownTokenNo)
2753 : : {} /* empty. */
2754 : : /* This could be used as a useful debugging hook as the front end
2755 : : has forgotten the token no. */
2756 : 1623 : Storage_ALLOCATE ((void **) &e, sizeof (M2Error__T4));
2757 : 1623 : e->s = NULL;
2758 : 1623 : e->token = AtTokenNo;
2759 : 1623 : e->next = NULL;
2760 : 1623 : e->parent = NULL;
2761 : 1623 : e->child = NULL;
2762 : 1623 : e->note = false;
2763 : 1623 : e->fatal = true;
2764 : 1623 : e->color = false;
2765 : : /* Assert (scopeKind # noscope) ; */
2766 : 1623 : e->scope = currentScope;
2767 : 1623 : if ((head == NULL) || (head->token > AtTokenNo))
2768 : : {
2769 : 1094 : e->next = head;
2770 : 1094 : head = e;
2771 : : }
2772 : : else
2773 : : {
2774 : : f = head;
2775 : 715 : while ((f->next != NULL) && (f->next->token < AtTokenNo))
2776 : : {
2777 : : f = f->next;
2778 : : }
2779 : 529 : e->next = f->next;
2780 : 529 : f->next = e;
2781 : : }
2782 : 1623 : return e;
2783 : : /* static analysis guarentees a RETURN statement will be used before here. */
2784 : : __builtin_unreachable ();
2785 : : }
2786 : :
2787 : :
2788 : : /*
2789 : : NewWarning - creates and returns a new error handle suitable for a warning.
2790 : : A warning will not stop compilation.
2791 : : */
2792 : :
2793 : 468 : extern "C" M2Error_Error M2Error_NewWarning (unsigned int AtTokenNo)
2794 : : {
2795 : 468 : M2Error_Error e;
2796 : :
2797 : 468 : e = M2Error_NewError (AtTokenNo);
2798 : 468 : e->fatal = false;
2799 : 468 : e->note = false;
2800 : 468 : return e;
2801 : : /* static analysis guarentees a RETURN statement will be used before here. */
2802 : : __builtin_unreachable ();
2803 : : }
2804 : :
2805 : :
2806 : : /*
2807 : : NewNote - creates and returns a new error handle suitable for a note.
2808 : : A note will not stop compilation.
2809 : : */
2810 : :
2811 : 3 : extern "C" M2Error_Error M2Error_NewNote (unsigned int AtTokenNo)
2812 : : {
2813 : 3 : M2Error_Error e;
2814 : :
2815 : 3 : e = M2Error_NewError (AtTokenNo);
2816 : 3 : e->fatal = false;
2817 : 3 : e->note = true;
2818 : 3 : return e;
2819 : : /* static analysis guarentees a RETURN statement will be used before here. */
2820 : : __builtin_unreachable ();
2821 : : }
2822 : :
2823 : :
2824 : : /*
2825 : : ChainError - creates and returns a new error handle, this new error
2826 : : is associated with, e, and is chained onto the end of, e.
2827 : : If, e, is NIL then the result to NewError is returned.
2828 : : */
2829 : :
2830 : 216 : extern "C" M2Error_Error M2Error_ChainError (unsigned int AtTokenNo, M2Error_Error e)
2831 : : {
2832 : 216 : M2Error_Error f;
2833 : :
2834 : 216 : if (e == NULL)
2835 : : {
2836 : 0 : return M2Error_NewError (AtTokenNo);
2837 : : }
2838 : : else
2839 : : {
2840 : 216 : Storage_ALLOCATE ((void **) &f, sizeof (M2Error__T4));
2841 : 216 : f->s = NULL;
2842 : 216 : f->token = AtTokenNo;
2843 : 216 : f->next = e->child;
2844 : 216 : f->parent = e;
2845 : 216 : f->child = NULL;
2846 : 216 : f->fatal = e->fatal;
2847 : 216 : f->scope = e->scope;
2848 : 216 : e->child = f;
2849 : : }
2850 : 216 : return f;
2851 : : /* static analysis guarentees a RETURN statement will be used before here. */
2852 : : __builtin_unreachable ();
2853 : : }
2854 : :
2855 : :
2856 : : /*
2857 : : MoveError - repositions an error, e, to token, AtTokenNo, and returns, e.
2858 : : */
2859 : :
2860 : 30 : extern "C" M2Error_Error M2Error_MoveError (M2Error_Error e, unsigned int AtTokenNo)
2861 : : {
2862 : 30 : if (e != NULL)
2863 : : {
2864 : 30 : e->token = AtTokenNo;
2865 : : }
2866 : 30 : return e;
2867 : : /* static analysis guarentees a RETURN statement will be used before here. */
2868 : : __builtin_unreachable ();
2869 : : }
2870 : :
2871 : :
2872 : : /*
2873 : : SetColor - informs the error module that this error will have had colors
2874 : : assigned to it. If an error is issued without colors assigned
2875 : : then the default colors will be assigned to the legacy error
2876 : : messages.
2877 : : */
2878 : :
2879 : 1395 : extern "C" M2Error_Error M2Error_SetColor (M2Error_Error e)
2880 : : {
2881 : 1395 : e->color = true;
2882 : 1395 : return e;
2883 : : /* static analysis guarentees a RETURN statement will be used before here. */
2884 : : __builtin_unreachable ();
2885 : : }
2886 : :
2887 : 24 : extern "C" void M2Error_ErrorFormat0 (M2Error_Error e, const char *a_, unsigned int _a_high)
2888 : : {
2889 : 24 : char a[_a_high+1];
2890 : :
2891 : : /* make a local copy of each unbounded array. */
2892 : 24 : memcpy (a, a_, _a_high+1);
2893 : :
2894 : : /*
2895 : : ErrorFormat routines provide a printf capability for the error handle.
2896 : : */
2897 : 24 : if (e->s == NULL)
2898 : : {
2899 : 24 : e->s = FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
2900 : : }
2901 : : else
2902 : : {
2903 : 0 : e->s = DynamicStrings_ConCat (e->s, DynamicStrings_Mark (FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)))));
2904 : : }
2905 : 24 : }
2906 : :
2907 : 6 : extern "C" void M2Error_ErrorFormat1 (M2Error_Error e, const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high)
2908 : : {
2909 : 6 : DynamicStrings_String s1;
2910 : 6 : char a[_a_high+1];
2911 : 6 : unsigned char w[_w_high+1];
2912 : :
2913 : : /* make a local copy of each unbounded array. */
2914 : 6 : memcpy (a, a_, _a_high+1);
2915 : 6 : memcpy (w, w_, _w_high+1);
2916 : :
2917 : 12 : s1 = DoFormat1 ((const char *) a, _a_high, (const unsigned char *) w, _w_high);
2918 : 6 : if (e->s == NULL)
2919 : : {
2920 : 6 : e->s = s1;
2921 : : }
2922 : : else
2923 : : {
2924 : 0 : e->s = DynamicStrings_ConCat (e->s, DynamicStrings_Mark (s1));
2925 : : }
2926 : 6 : }
2927 : :
2928 : 0 : 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)
2929 : : {
2930 : 0 : DynamicStrings_String s1;
2931 : 0 : char a[_a_high+1];
2932 : 0 : unsigned char w1[_w1_high+1];
2933 : 0 : unsigned char w2[_w2_high+1];
2934 : :
2935 : : /* make a local copy of each unbounded array. */
2936 : 0 : memcpy (a, a_, _a_high+1);
2937 : 0 : memcpy (w1, w1_, _w1_high+1);
2938 : 0 : memcpy (w2, w2_, _w2_high+1);
2939 : :
2940 : 0 : s1 = DoFormat2 ((const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high);
2941 : 0 : if (e->s == NULL)
2942 : : {
2943 : 0 : e->s = s1;
2944 : : }
2945 : : else
2946 : : {
2947 : 0 : e->s = DynamicStrings_ConCat (e->s, DynamicStrings_Mark (s1));
2948 : : }
2949 : 0 : }
2950 : :
2951 : 0 : 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)
2952 : : {
2953 : 0 : DynamicStrings_String s1;
2954 : 0 : char a[_a_high+1];
2955 : 0 : unsigned char w1[_w1_high+1];
2956 : 0 : unsigned char w2[_w2_high+1];
2957 : 0 : unsigned char w3[_w3_high+1];
2958 : :
2959 : : /* make a local copy of each unbounded array. */
2960 : 0 : memcpy (a, a_, _a_high+1);
2961 : 0 : memcpy (w1, w1_, _w1_high+1);
2962 : 0 : memcpy (w2, w2_, _w2_high+1);
2963 : 0 : memcpy (w3, w3_, _w3_high+1);
2964 : :
2965 : 0 : s1 = DoFormat3 ((const char *) a, _a_high, (const unsigned char *) w1, _w1_high, (const unsigned char *) w2, _w2_high, (const unsigned char *) w3, _w3_high);
2966 : 0 : if (e->s == NULL)
2967 : : {
2968 : 0 : e->s = s1;
2969 : : }
2970 : : else
2971 : : {
2972 : 0 : e->s = DynamicStrings_ConCat (e->s, DynamicStrings_Mark (s1));
2973 : : }
2974 : 0 : }
2975 : :
2976 : 1701 : extern "C" void M2Error_ErrorString (M2Error_Error e, DynamicStrings_String str)
2977 : : {
2978 : 1701 : e->s = str;
2979 : 1701 : }
2980 : :
2981 : :
2982 : : /*
2983 : : ErrorStringAt - given an error string, s, it places this
2984 : : string at token position, tok.
2985 : : The string is consumed.
2986 : : */
2987 : :
2988 : 18 : extern "C" void M2Error_ErrorStringAt (DynamicStrings_String s, unsigned int tok)
2989 : : {
2990 : 18 : M2Error_Error e;
2991 : :
2992 : 18 : e = M2Error_NewError (tok);
2993 : 18 : M2Error_ErrorString (e, s);
2994 : 18 : }
2995 : :
2996 : :
2997 : : /*
2998 : : ErrorStringAt2 - given an error string, s, it places this
2999 : : string at token positions, tok1 and tok2, respectively.
3000 : : The string is consumed.
3001 : : */
3002 : :
3003 : 24 : extern "C" void M2Error_ErrorStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2)
3004 : : {
3005 : 24 : M2Error_ErrorStringsAt2 (s, s, tok1, tok2);
3006 : 24 : }
3007 : :
3008 : :
3009 : : /*
3010 : : ErrorStringsAt2 - given error strings, s1, and, s2, it places these
3011 : : strings at token positions, tok1 and tok2, respectively.
3012 : : Both strings are consumed.
3013 : : */
3014 : :
3015 : 24 : extern "C" void M2Error_ErrorStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2)
3016 : : {
3017 : 24 : M2Error_Error e;
3018 : :
3019 : 24 : if (s1 == s2)
3020 : : {
3021 : 24 : s2 = DynamicStrings_Dup (s1);
3022 : : }
3023 : 24 : e = M2Error_NewError (tok1);
3024 : 24 : M2Error_ErrorString (e, s1);
3025 : 24 : M2Error_ErrorString (M2Error_ChainError (tok2, e), s2);
3026 : 24 : }
3027 : :
3028 : :
3029 : : /*
3030 : : WarnStringAt - given an error string, s, it places this
3031 : : string at token position, tok.
3032 : : The string is consumed.
3033 : : */
3034 : :
3035 : 0 : extern "C" void M2Error_WarnStringAt (DynamicStrings_String s, unsigned int tok)
3036 : : {
3037 : 0 : M2Error_Error e;
3038 : :
3039 : 0 : e = M2Error_NewWarning (tok);
3040 : 0 : M2Error_ErrorString (e, s);
3041 : 0 : }
3042 : :
3043 : :
3044 : : /*
3045 : : WarnStringAt2 - given an warning string, s, it places this
3046 : : string at token positions, tok1 and tok2, respectively.
3047 : : The string is consumed.
3048 : : */
3049 : :
3050 : 0 : extern "C" void M2Error_WarnStringAt2 (DynamicStrings_String s, unsigned int tok1, unsigned int tok2)
3051 : : {
3052 : 0 : M2Error_WarnStringsAt2 (s, s, tok1, tok2);
3053 : 0 : }
3054 : :
3055 : :
3056 : : /*
3057 : : WarnStringsAt2 - given warning strings, s1, and, s2, it places these
3058 : : strings at token positions, tok1 and tok2, respectively.
3059 : : Both strings are consumed.
3060 : : */
3061 : :
3062 : 0 : extern "C" void M2Error_WarnStringsAt2 (DynamicStrings_String s1, DynamicStrings_String s2, unsigned int tok1, unsigned int tok2)
3063 : : {
3064 : 0 : M2Error_Error e;
3065 : :
3066 : 0 : if (s1 == s2)
3067 : : {
3068 : 0 : s2 = DynamicStrings_Dup (s1);
3069 : : }
3070 : 0 : e = M2Error_NewWarning (tok1);
3071 : 0 : M2Error_ErrorString (e, s1);
3072 : 0 : M2Error_ErrorString (M2Error_ChainError (tok2, e), s2);
3073 : 0 : }
3074 : :
3075 : :
3076 : : /*
3077 : : WarnFormat0 - displays the source module and line together
3078 : : with the encapsulated format string.
3079 : : Used for simple warning messages tied to the current token.
3080 : : */
3081 : :
3082 : 0 : extern "C" void M2Error_WarnFormat0 (const char *a_, unsigned int _a_high)
3083 : : {
3084 : 0 : M2Error_Error e;
3085 : 0 : char a[_a_high+1];
3086 : :
3087 : : /* make a local copy of each unbounded array. */
3088 : 0 : memcpy (a, a_, _a_high+1);
3089 : :
3090 : 0 : e = M2Error_NewWarning (M2LexBuf_GetTokenNo ());
3091 : 0 : e->s = FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) a, _a_high)));
3092 : 0 : }
3093 : :
3094 : :
3095 : : /*
3096 : : WarnFormat1 - displays the source module and line together
3097 : : with the encapsulated format string.
3098 : : Used for simple warning messages tied to the current token.
3099 : : */
3100 : :
3101 : 0 : extern "C" void M2Error_WarnFormat1 (const char *a_, unsigned int _a_high, const unsigned char *w_, unsigned int _w_high)
3102 : : {
3103 : 0 : M2Error_Error e;
3104 : 0 : char a[_a_high+1];
3105 : 0 : unsigned char w[_w_high+1];
3106 : :
3107 : : /* make a local copy of each unbounded array. */
3108 : 0 : memcpy (a, a_, _a_high+1);
3109 : 0 : memcpy (w, w_, _w_high+1);
3110 : :
3111 : 0 : e = M2Error_NewWarning (M2LexBuf_GetTokenNo ());
3112 : 0 : e->s = DoFormat1 ((const char *) a, _a_high, (const unsigned char *) w, _w_high);
3113 : 0 : }
3114 : :
3115 : :
3116 : : /*
3117 : : FlushErrors - switches the output channel to the error channel
3118 : : and then writes out all errors.
3119 : : */
3120 : :
3121 : 116802 : extern "C" void M2Error_FlushErrors (void)
3122 : : {
3123 : 116802 : if (DebugTrace)
3124 : : {
3125 : : M2Printf_printf0 ((const char *) "\\nFlushing all errors\\n", 23);
3126 : : M2Printf_printf0 ((const char *) "===================\\n", 21);
3127 : : }
3128 : 116802 : if (FlushAll (head, true))
3129 : : {
3130 : 690 : M2RTS_ExitOnHalt (1);
3131 : 690 : M2RTS_HALT (-1);
3132 : : __builtin_unreachable ();
3133 : : }
3134 : 116112 : }
3135 : :
3136 : :
3137 : : /*
3138 : : FlushWarnings - switches the output channel to the error channel
3139 : : and then writes out all warnings.
3140 : : If an error is present the compilation is terminated,
3141 : : if warnings only were emitted then compilation will
3142 : : continue.
3143 : : */
3144 : :
3145 : 116622 : extern "C" void M2Error_FlushWarnings (void)
3146 : : {
3147 : 116622 : if (FlushAll (head, false))
3148 : : {} /* empty. */
3149 : 116622 : }
3150 : :
3151 : :
3152 : : /*
3153 : : ErrorAbort0 - aborts compiling, it flushes all warnings and errors before aborting.
3154 : : */
3155 : :
3156 : 6 : extern "C" void M2Error_ErrorAbort0 (const char *a_, unsigned int _a_high)
3157 : : {
3158 : 6 : char a[_a_high+1];
3159 : :
3160 : : /* make a local copy of each unbounded array. */
3161 : 6 : memcpy (a, a_, _a_high+1);
3162 : :
3163 : 6 : M2Error_FlushWarnings ();
3164 : 6 : if (! (StrLib_StrEqual ((const char *) a, _a_high, (const char *) "", 0)))
3165 : : {
3166 : 0 : M2Error_WriteFormat0 ((const char *) a, _a_high);
3167 : : }
3168 : 6 : if (! (FlushAll (head, true)))
3169 : : {
3170 : 0 : M2Error_WriteFormat0 ((const char *) "unidentified error", 18);
3171 : 0 : if (FlushAll (head, true))
3172 : : {} /* empty. */
3173 : : }
3174 : 6 : M2RTS_ExitOnHalt (1);
3175 : 6 : M2RTS_HALT (-1);
3176 : : __builtin_unreachable ();
3177 : 6 : }
3178 : :
3179 : :
3180 : : /*
3181 : : AnnounceScope - return the error string s with a scope description prepended
3182 : : assuming that scope has changed.
3183 : : */
3184 : :
3185 : 1755 : extern "C" DynamicStrings_String M2Error_AnnounceScope (M2Error_Error e, DynamicStrings_String message)
3186 : : {
3187 : 1755 : if (! (IsSameScope (lastScope, e->scope)))
3188 : : {
3189 : 675 : lastScope = e->scope;
3190 : 675 : if (IsErrorScopeNul (lastScope))
3191 : : {
3192 : 48 : return DynamicStrings_ConCat (DynamicStrings_InitString ((const char *) "no scope active: ", 17), message);
3193 : : }
3194 : : else
3195 : : {
3196 : 627 : M2Debug_Assert ((e->scope != NULL) && (e->scope->scopeKind != M2Error_noscope));
3197 : : /* filename := FindFileNameFromToken (e^.token, 0) ; */
3198 : 627 : message = M2Error_GetAnnounceScope (NULL, message);
3199 : : }
3200 : : }
3201 : : return message;
3202 : : /* static analysis guarentees a RETURN statement will be used before here. */
3203 : : __builtin_unreachable ();
3204 : : }
3205 : :
3206 : :
3207 : : /*
3208 : : EnterImplementationScope - signifies to the error routines that the front end
3209 : : has started to compile implementation module scopeName.
3210 : : */
3211 : :
3212 : 210506 : extern "C" void M2Error_EnterImplementationScope (NameKey_Name scopename)
3213 : : {
3214 : 210506 : M2Debug_Assert (currentScope != NULL);
3215 : 210506 : M2Debug_Assert (currentScope->scopeKind == M2Error_implementation);
3216 : 210506 : if (currentScope->scopeName == NameKey_NulName)
3217 : : {
3218 : 52718 : if (DebugError)
3219 : : {
3220 : : M2Printf_printf1 ((const char *) "seen implementation: %a\\n", 25, (const unsigned char *) &scopename, (sizeof (scopename)-1));
3221 : : }
3222 : 52718 : currentScope->scopeName = scopename;
3223 : : }
3224 : 210506 : }
3225 : :
3226 : :
3227 : : /*
3228 : : EnterProgramScope - signifies to the error routines that the front end
3229 : : has started to compile program module scopeName.
3230 : : */
3231 : :
3232 : 40738 : extern "C" void M2Error_EnterProgramScope (NameKey_Name scopename)
3233 : : {
3234 : 40738 : M2Debug_Assert (currentScope != NULL);
3235 : 40738 : M2Debug_Assert (currentScope->scopeKind == M2Error_program);
3236 : 40738 : if (currentScope->scopeName == NameKey_NulName)
3237 : : {
3238 : 10240 : if (DebugError)
3239 : : {
3240 : : M2Printf_printf1 ((const char *) "seen program: %a\\n", 18, (const unsigned char *) &scopename, (sizeof (scopename)-1));
3241 : : }
3242 : 10240 : currentScope->scopeName = scopename;
3243 : : }
3244 : 40738 : }
3245 : :
3246 : :
3247 : : /*
3248 : : EnterModuleScope - signifies to the error routines that the front end
3249 : : has started to compile an inner module scopeName.
3250 : : */
3251 : :
3252 : 1626 : extern "C" void M2Error_EnterModuleScope (NameKey_Name scopename)
3253 : : {
3254 : 1626 : M2Debug_Assert (currentScope != NULL);
3255 : 1626 : M2Debug_Assert (currentScope->scopeKind == M2Error_module);
3256 : 1626 : if (currentScope->scopeName == NameKey_NulName)
3257 : : {
3258 : 408 : if (DebugError)
3259 : : {
3260 : : M2Printf_printf1 ((const char *) "seen module: %a\\n", 17, (const unsigned char *) &scopename, (sizeof (scopename)-1));
3261 : : }
3262 : 408 : currentScope->scopeName = scopename;
3263 : : }
3264 : 1626 : }
3265 : :
3266 : :
3267 : : /*
3268 : : EnterDefinitionScope - signifies to the error routines that the front end
3269 : : has started to compile definition module scopeName.
3270 : : */
3271 : :
3272 : 501516 : extern "C" void M2Error_EnterDefinitionScope (NameKey_Name scopename)
3273 : : {
3274 : 501516 : M2Debug_Assert (currentScope != NULL);
3275 : 501516 : M2Debug_Assert (currentScope->scopeKind == M2Error_definition);
3276 : 501516 : if (currentScope->scopeName == NameKey_NulName)
3277 : : {
3278 : 125724 : if (DebugError)
3279 : : {
3280 : : M2Printf_printf1 ((const char *) "seen definition: %a\\n", 21, (const unsigned char *) &scopename, (sizeof (scopename)-1));
3281 : : }
3282 : 125724 : currentScope->scopeName = scopename;
3283 : : }
3284 : 501516 : }
3285 : :
3286 : :
3287 : : /*
3288 : : EnterProcedureScope - signifies to the error routines that the front end
3289 : : has started to compile definition module scopeName.
3290 : : */
3291 : :
3292 : 9507440 : extern "C" void M2Error_EnterProcedureScope (NameKey_Name scopename)
3293 : : {
3294 : 9507440 : M2Debug_Assert (currentScope != NULL);
3295 : 9507440 : M2Debug_Assert (currentScope->scopeKind == M2Error_procedure);
3296 : 9507440 : if (currentScope->scopeName == NameKey_NulName)
3297 : : {
3298 : 2881290 : if (DebugError)
3299 : : {
3300 : : M2Printf_printf1 ((const char *) "seen procedure: %a\\n", 20, (const unsigned char *) &scopename, (sizeof (scopename)-1));
3301 : : }
3302 : 2881290 : currentScope->scopeName = scopename;
3303 : : }
3304 : 9507440 : }
3305 : :
3306 : :
3307 : : /*
3308 : : DepthScope - returns the depth of the scope stack.
3309 : : */
3310 : :
3311 : 0 : extern "C" unsigned int M2Error_DepthScope (void)
3312 : : {
3313 : 0 : return M2StackAddress_NoOfItemsInStackAddress (scopeStack);
3314 : : /* static analysis guarentees a RETURN statement will be used before here. */
3315 : : __builtin_unreachable ();
3316 : : }
3317 : :
3318 : :
3319 : : /*
3320 : : GetAnnounceScope - return message with the error scope attached to message.
3321 : : filename and message are treated as read only by this
3322 : : procedure function.
3323 : : */
3324 : :
3325 : 627 : extern "C" DynamicStrings_String M2Error_GetAnnounceScope (DynamicStrings_String filename, DynamicStrings_String message)
3326 : : {
3327 : 627 : DynamicStrings_String pre;
3328 : 627 : DynamicStrings_String fmt;
3329 : 627 : DynamicStrings_String desc;
3330 : 627 : DynamicStrings_String quoted;
3331 : :
3332 : 627 : if (filename == NULL)
3333 : : {
3334 : 627 : pre = DynamicStrings_InitString ((const char *) "", 0);
3335 : : }
3336 : : else
3337 : : {
3338 : 0 : pre = FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) "%s: ", 4)), (const unsigned char *) &filename, (sizeof (filename)-1));
3339 : : }
3340 : 627 : if (! (IsErrorScopeNul (currentScope)))
3341 : : {
3342 : 627 : quoted = DynamicStrings_InitString ((const char *) "", 0);
3343 : 627 : quoted = M2ColorString_quoteOpen (quoted);
3344 : 627 : quoted = DynamicStrings_ConCat (quoted, DynamicStrings_Mark (DynamicStrings_InitStringCharStar (NameKey_KeyToCharStar (currentScope->scopeName))));
3345 : 627 : quoted = M2ColorString_quoteClose (quoted);
3346 : : }
3347 : 627 : if (currentScope == NULL)
3348 : : {
3349 : 0 : desc = DynamicStrings_InitString ((const char *) "no scope active", 15);
3350 : : }
3351 : : else
3352 : : {
3353 : 627 : switch (currentScope->scopeKind)
3354 : : {
3355 : 18 : case M2Error_definition:
3356 : 18 : desc = DynamicStrings_InitString ((const char *) "In definition module", 20);
3357 : 18 : break;
3358 : :
3359 : 24 : case M2Error_implementation:
3360 : 24 : desc = DynamicStrings_InitString ((const char *) "In implementation module", 24);
3361 : 24 : break;
3362 : :
3363 : 270 : case M2Error_program:
3364 : 270 : desc = DynamicStrings_InitString ((const char *) "In program module", 17);
3365 : 270 : break;
3366 : :
3367 : 6 : case M2Error_module:
3368 : 6 : desc = DynamicStrings_InitString ((const char *) "In inner module", 15);
3369 : 6 : break;
3370 : :
3371 : 309 : case M2Error_procedure:
3372 : 309 : desc = DynamicStrings_InitString ((const char *) "In procedure", 12);
3373 : 309 : break;
3374 : :
3375 : 0 : case M2Error_noscope:
3376 : 0 : desc = DynamicStrings_InitString ((const char *) "Unknown scope", 13);
3377 : 0 : break;
3378 : :
3379 : :
3380 : 0 : default:
3381 : 0 : CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Error.def", 20, 1);
3382 : 0 : __builtin_unreachable ();
3383 : : }
3384 : : }
3385 : 627 : fmt = DynamicStrings_ConCat (pre, DynamicStrings_Mark (desc));
3386 : 627 : if (IsErrorScopeNul (currentScope))
3387 : : {
3388 : 0 : fmt = DynamicStrings_ConCat (fmt, FormatStrings_Sprintf0 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) ": ", 2))));
3389 : : }
3390 : : else
3391 : : {
3392 : 627 : fmt = DynamicStrings_ConCat (fmt, FormatStrings_Sprintf1 (DynamicStrings_Mark (DynamicStrings_InitString ((const char *) " %s: ", 5)), (const unsigned char *) "ed, (sizeof (quoted)-1)));
3393 : : }
3394 : 627 : return DynamicStrings_ConCat (fmt, message);
3395 : : /* static analysis guarentees a RETURN statement will be used before here. */
3396 : : __builtin_unreachable ();
3397 : : }
3398 : :
3399 : :
3400 : : /*
3401 : : DefaultProgramModule - sets up an unnamed program scope before the Ident is seen.
3402 : : */
3403 : :
3404 : 50954 : extern "C" void M2Error_DefaultProgramModule (void)
3405 : : {
3406 : 50954 : M2StackAddress_PushAddress (scopeStack, reinterpret_cast<void *> (currentScope));
3407 : 50954 : currentScope = newErrorScope (M2Error_program);
3408 : 50954 : }
3409 : :
3410 : :
3411 : : /*
3412 : : DefaultImplementationModule - sets up an unnamed implementation
3413 : : scope before the Ident is seen.
3414 : : */
3415 : :
3416 : 263170 : extern "C" void M2Error_DefaultImplementationModule (void)
3417 : : {
3418 : 263170 : M2StackAddress_PushAddress (scopeStack, reinterpret_cast<void *> (currentScope));
3419 : 263170 : currentScope = newErrorScope (M2Error_implementation);
3420 : 263170 : }
3421 : :
3422 : :
3423 : : /*
3424 : : DefaultDefinitionModule - sets up an unnamed definition
3425 : : scope before the Ident is seen.
3426 : : */
3427 : :
3428 : 627066 : extern "C" void M2Error_DefaultDefinitionModule (void)
3429 : : {
3430 : 627066 : M2StackAddress_PushAddress (scopeStack, reinterpret_cast<void *> (currentScope));
3431 : 627066 : currentScope = newErrorScope (M2Error_definition);
3432 : 627066 : }
3433 : :
3434 : :
3435 : : /*
3436 : : DefaultInnerModule - sets up an unnamed inner
3437 : : scope before the Ident is seen.
3438 : : */
3439 : :
3440 : 2034 : extern "C" void M2Error_DefaultInnerModule (void)
3441 : : {
3442 : 2034 : M2StackAddress_PushAddress (scopeStack, reinterpret_cast<void *> (currentScope));
3443 : 2034 : currentScope = newErrorScope (M2Error_module);
3444 : 2034 : }
3445 : :
3446 : :
3447 : : /*
3448 : : DefaultProcedure - sets up an unnamed procedure
3449 : : scope before the Ident is seen.
3450 : : */
3451 : :
3452 : 14394894 : extern "C" void M2Error_DefaultProcedure (void)
3453 : : {
3454 : 14394894 : M2StackAddress_PushAddress (scopeStack, reinterpret_cast<void *> (currentScope));
3455 : 14394894 : currentScope = newErrorScope (M2Error_procedure);
3456 : 14394894 : }
3457 : :
3458 : :
3459 : : /*
3460 : : EnterErrorScope - pushes the currentScope and sets currentScope to scope.
3461 : : */
3462 : :
3463 : 3499199 : extern "C" void M2Error_EnterErrorScope (M2Error_ErrorScope scope)
3464 : : {
3465 : 3499199 : M2StackAddress_PushAddress (scopeStack, reinterpret_cast<void *> (currentScope));
3466 : 3499199 : currentScope = scope;
3467 : 3499199 : }
3468 : :
3469 : :
3470 : : /*
3471 : : LeaveErrorScope - leave the current scope and pop into the previous one.
3472 : : */
3473 : :
3474 : 17768925 : extern "C" void M2Error_LeaveErrorScope (void)
3475 : : {
3476 : 17768925 : currentScope = static_cast<M2Error_ErrorScope> (M2StackAddress_PopAddress (scopeStack));
3477 : 17768925 : }
3478 : :
3479 : :
3480 : : /*
3481 : : GetCurrentErrorScope - returns currentScope.
3482 : : */
3483 : :
3484 : 10188489 : extern "C" M2Error_ErrorScope M2Error_GetCurrentErrorScope (void)
3485 : : {
3486 : 10188489 : return currentScope;
3487 : : /* static analysis guarentees a RETURN statement will be used before here. */
3488 : : __builtin_unreachable ();
3489 : : }
3490 : :
3491 : :
3492 : : /*
3493 : : ResetErrorScope - should be called at the start of each pass to
3494 : : reset the error scope index.
3495 : : */
3496 : :
3497 : 67130 : extern "C" void M2Error_ResetErrorScope (void)
3498 : : {
3499 : 67130 : scopeIndex = 0;
3500 : 67130 : }
3501 : :
3502 : 16867 : extern "C" void _M2_M2Error_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
3503 : : {
3504 : 16867 : Init ();
3505 : 16867 : }
3506 : :
3507 : 0 : extern "C" void _M2_M2Error_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
3508 : : {
3509 : 0 : }
|