Line data Source code
1 : /* do not edit automatically generated by mc from M2Base. */
2 : /* M2Base.mod provides a mechanism to check fundamental types.
3 :
4 : Copyright (C) 2001-2026 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 "gcc-consolidation.h"
26 :
27 : #include <stdbool.h>
28 : # if !defined (PROC_D)
29 : # define PROC_D
30 : typedef void (*PROC_t) (void);
31 : typedef struct { PROC_t proc; } PROC;
32 : # endif
33 :
34 : # if !defined (TRUE)
35 : # define TRUE (1==1)
36 : # endif
37 :
38 : # if !defined (FALSE)
39 : # define FALSE (1==0)
40 : # endif
41 :
42 : # include "Gmcrts.h"
43 : #define _M2Base_C
44 :
45 : #include "GM2Base.h"
46 : # include "GDynamicStrings.h"
47 : # include "GM2LexBuf.h"
48 : # include "GNameKey.h"
49 : # include "GM2Debug.h"
50 : # include "GSYSTEM.h"
51 : # include "GM2Error.h"
52 : # include "GM2Pass.h"
53 : # include "GFormatStrings.h"
54 : # include "GStrLib.h"
55 : # include "GM2MetaError.h"
56 : # include "GSymbolTable.h"
57 : # include "GM2ALU.h"
58 : # include "GM2Batch.h"
59 : # include "GM2Bitset.h"
60 : # include "GM2Size.h"
61 : # include "GM2System.h"
62 : # include "GM2Options.h"
63 : # include "Gm2type.h"
64 : # include "Gm2expr.h"
65 : # include "Ggcctypes.h"
66 : # include "Gm2linemap.h"
67 : # include "Gm2decl.h"
68 :
69 : typedef struct M2Base_CompatibilityArray_a M2Base_CompatibilityArray;
70 :
71 : typedef struct M2Base__T1_a M2Base__T1;
72 :
73 : typedef enum {M2Base_const, M2Base_word, M2Base_byte, M2Base_address, M2Base_chr, M2Base_normint, M2Base_shortint, M2Base_longint, M2Base_normcard, M2Base_shortcard, M2Base_longcard, M2Base_pointer, M2Base_enum, M2Base_real, M2Base_shortreal, M2Base_longreal, M2Base_set, M2Base_opaque, M2Base_loc, M2Base_rtype, M2Base_ztype, M2Base_int8, M2Base_int16, M2Base_int32, M2Base_int64, M2Base_card8, M2Base_card16, M2Base_card32, M2Base_card64, M2Base_word16, M2Base_word32, M2Base_word64, M2Base_real32, M2Base_real64, M2Base_real96, M2Base_real128, M2Base_set8, M2Base_set16, M2Base_set32, M2Base_complex, M2Base_shortcomplex, M2Base_longcomplex, M2Base_complex32, M2Base_complex64, M2Base_complex96, M2Base_complex128, M2Base_ctype, M2Base_rec, M2Base_array, M2Base_procedure, M2Base_unknown} M2Base_MetaType;
74 :
75 : typedef enum {M2Base_uninitialized, M2Base_no, M2Base_warnfirst, M2Base_warnsecond, M2Base_first, M2Base_second} M2Base_Compatible;
76 :
77 : typedef enum {M2Base_expression, M2Base_assignment, M2Base_parameter, M2Base_comparison} M2Base_Compatability;
78 :
79 : struct M2Base__T1_a { M2Base_Compatible array[M2Base_unknown-M2Base_const+1]; };
80 : struct M2Base_CompatibilityArray_a { M2Base__T1 array[M2Base_unknown-M2Base_const+1]; };
81 : static M2Base_CompatibilityArray Comp;
82 : static M2Base_CompatibilityArray Expr;
83 : static M2Base_CompatibilityArray Ass;
84 : static unsigned int m2wideset;
85 : static unsigned int Ord;
86 : static unsigned int OrdS;
87 : static unsigned int OrdL;
88 : static unsigned int Float;
89 : static unsigned int FloatS;
90 : static unsigned int SFloat;
91 : static unsigned int FloatL;
92 : static unsigned int LFloat;
93 : static unsigned int Trunc;
94 : static unsigned int TruncS;
95 : static unsigned int TruncL;
96 : static unsigned int Int;
97 : static unsigned int IntS;
98 : static unsigned int IntL;
99 : static unsigned int m2rts;
100 : static unsigned int MinReal;
101 : static unsigned int MaxReal;
102 : static unsigned int MinShortReal;
103 : static unsigned int MaxShortReal;
104 : static unsigned int MinLongReal;
105 : static unsigned int MaxLongReal;
106 : static unsigned int MinLongInt;
107 : static unsigned int MaxLongInt;
108 : static unsigned int MinLongCard;
109 : static unsigned int MaxLongCard;
110 : static unsigned int MinShortInt;
111 : static unsigned int MaxShortInt;
112 : static unsigned int MinShortCard;
113 : static unsigned int MaxShortCard;
114 : static unsigned int MinChar;
115 : static unsigned int MaxChar;
116 : static unsigned int MinCardinal;
117 : static unsigned int MaxCardinal;
118 : static unsigned int MinInteger;
119 : static unsigned int MaxInteger;
120 : static unsigned int MaxEnum;
121 : static unsigned int MinEnum;
122 :
123 : /*
124 : InitBase - initializes the base types and procedures
125 : used in the Modula-2 compiler.
126 : */
127 :
128 : extern "C" void M2Base_InitBase (location_t location, unsigned int *sym);
129 :
130 : /*
131 : GetBaseTypeMinMax - returns the minimum and maximum values for a
132 : given base type. This procedure should only
133 : be called if the type is NOT a subrange.
134 : */
135 :
136 : extern "C" void M2Base_GetBaseTypeMinMax (unsigned int type, unsigned int *min, unsigned int *max);
137 :
138 : /*
139 : IsPseudoBaseFunction - returns true if Sym is a Base pseudo function.
140 : */
141 :
142 : extern "C" bool M2Base_IsPseudoBaseFunction (unsigned int Sym);
143 :
144 : /*
145 : IsPseudoBaseProcedure - returns true if Sym is a Base pseudo procedure.
146 : */
147 :
148 : extern "C" bool M2Base_IsPseudoBaseProcedure (unsigned int Sym);
149 :
150 : /*
151 : IsNeededAtRunTime - returns TRUE if procedure, sym, is a
152 : runtime procedure. A runtime procedure is
153 : not a pseudo procedure (like NEW/DISPOSE)
154 : and it is implemented in M2RTS or SYSTEM
155 : and also exported.
156 : */
157 :
158 : extern "C" bool M2Base_IsNeededAtRunTime (unsigned int tok, unsigned int sym);
159 :
160 : /*
161 : IsBaseType - returns TRUE if Sym is a Base type.
162 : */
163 :
164 : extern "C" bool M2Base_IsBaseType (unsigned int Sym);
165 :
166 : /*
167 : IsOrdinalType - returns TRUE if, sym, is an ordinal type.
168 : An ordinal type is defined as:
169 : a base type which contains whole numbers or
170 : a subrange type or an enumeration type.
171 : */
172 :
173 : extern "C" bool M2Base_IsOrdinalType (unsigned int Sym);
174 :
175 : /*
176 : IsOrd - returns TRUE if, sym, is ORD or its typed counterparts
177 : ORDL, ORDS.
178 : */
179 :
180 : extern "C" bool M2Base_IsOrd (unsigned int sym);
181 :
182 : /*
183 : IsTrunc - returns TRUE if, sym, is TRUNC or its typed counterparts
184 : TRUNCL, TRUNCS.
185 : */
186 :
187 : extern "C" bool M2Base_IsTrunc (unsigned int sym);
188 :
189 : /*
190 : IsFloat - returns TRUE if, sym, is FLOAT or its typed counterparts
191 : FLOATL, FLOATS.
192 : */
193 :
194 : extern "C" bool M2Base_IsFloat (unsigned int sym);
195 :
196 : /*
197 : IsInt - returns TRUE if, sym, is INT or its typed counterparts
198 : INTL, INTS.
199 : */
200 :
201 : extern "C" bool M2Base_IsInt (unsigned int sym);
202 :
203 : /*
204 : AssignmentRequiresWarning - returns TRUE if t1 and t2 can be used during
205 : an assignment, but should generate a warning.
206 : For example in PIM we can assign ADDRESS
207 : and WORD providing they are both the
208 : same size.
209 : No warning is necessary if the types are the same.
210 : */
211 :
212 : extern "C" bool M2Base_AssignmentRequiresWarning (unsigned int t1, unsigned int t2);
213 :
214 : /*
215 : IsAssignmentCompatible - returns TRUE if t1 and t2 are assignment
216 : compatible.
217 : */
218 :
219 : extern "C" bool M2Base_IsAssignmentCompatible (unsigned int t1, unsigned int t2);
220 :
221 : /*
222 : IsExpressionCompatible - returns TRUE if t1 and t2 are expression
223 : compatible.
224 : */
225 :
226 : extern "C" bool M2Base_IsExpressionCompatible (unsigned int t1, unsigned int t2);
227 :
228 : /*
229 : IsParameterCompatible - returns TRUE if t1 and t2 are expression
230 : compatible.
231 : */
232 :
233 : extern "C" bool M2Base_IsParameterCompatible (unsigned int t1, unsigned int t2);
234 :
235 : /*
236 : IsComparisonCompatible - returns TRUE if t1 and t2 are comparison compatible.
237 : */
238 :
239 : extern "C" bool M2Base_IsComparisonCompatible (unsigned int t1, unsigned int t2);
240 :
241 : /*
242 : IsValidParameter - returns TRUE if an, actual, parameter can be passed
243 : to the, formal, parameter. This differs from
244 : IsParameterCompatible as this procedure includes checks
245 : for unbounded formal parameters, var parameters and
246 : constant actual parameters.
247 : */
248 :
249 : extern "C" bool M2Base_IsValidParameter (unsigned int formal, unsigned int actual);
250 :
251 : /*
252 : CheckExpressionCompatible - returns if t1 and t2 are compatible types for
253 : +, -, *, DIV, >, <, =, etc.
254 : If t1 and t2 are not compatible then an error
255 : message is displayed.
256 : */
257 :
258 : extern "C" void M2Base_CheckExpressionCompatible (unsigned int tok, unsigned int left, unsigned int right);
259 :
260 : /*
261 : CheckAssignmentCompatible - returns if t1 and t2 are compatible types for
262 : :=, =, #.
263 : If t1 and t2 are not compatible then an error
264 : message is displayed.
265 : */
266 :
267 : extern "C" void M2Base_CheckAssignmentCompatible (unsigned int tok, unsigned int left, unsigned int right);
268 :
269 : /*
270 : CheckParameterCompatible - checks to see if types, t1, and, t2, are
271 : compatible for parameter passing.
272 : */
273 :
274 : extern "C" void M2Base_CheckParameterCompatible (unsigned int tok, unsigned int t1, unsigned int t2);
275 :
276 : /*
277 : CannotCheckTypeInPass3 - returns TRUE if we are unable to check the
278 : type of, e, in pass 3.
279 : */
280 :
281 : extern "C" bool M2Base_CannotCheckTypeInPass3 (unsigned int e);
282 :
283 : /*
284 : MixTypes - given types leftType and rightType return a type symbol that
285 : provides expression type compatibility.
286 : NearTok is used to identify the source position if a type
287 : incompatability occurs.
288 : */
289 :
290 : extern "C" unsigned int M2Base_MixTypes (unsigned int leftType, unsigned int rightType, unsigned int NearTok);
291 :
292 : /*
293 : MixTypesDecl - returns a type symbol which provides expression compatibility
294 : between leftType and rightType. An error is emitted if this
295 : is not possible. left and right are the source (variable,
296 : constant) of leftType and rightType respectively.
297 : */
298 :
299 : extern "C" unsigned int M2Base_MixTypesDecl (unsigned int left, unsigned int right, unsigned int leftType, unsigned int rightType, unsigned int NearTok);
300 :
301 : /*
302 : NegateType - if the type is unsigned then returns the
303 : signed equivalent.
304 : */
305 :
306 : extern "C" unsigned int M2Base_NegateType (unsigned int type);
307 :
308 : /*
309 : IsMathType - returns TRUE if the type is a mathematical type.
310 : A mathematical type has a range larger than INTEGER.
311 : (Typically SHORTREAL/REAL/LONGREAL/LONGINT/LONGCARD)
312 : */
313 :
314 : extern "C" bool M2Base_IsMathType (unsigned int type);
315 :
316 : /*
317 : IsRealType - returns TRUE if, t, is a real type.
318 : */
319 :
320 : extern "C" bool M2Base_IsRealType (unsigned int t);
321 :
322 : /*
323 : IsRealGCC - return TRUE if type is LONGREAL, REAL, SHORTREAL or any of
324 : the sized REAL types supported by GCC exported by SYSTEM.
325 : */
326 :
327 : extern "C" bool M2Base_IsRealGCC (unsigned int type);
328 :
329 : /*
330 : IsComplexType - returns TRUE if, sym, is COMPLEX,
331 : LONGCOMPLEX or SHORTCOMPLEX.
332 : */
333 :
334 : extern "C" bool M2Base_IsComplexType (unsigned int sym);
335 :
336 : /*
337 : ComplexToScalar - returns the scalar (or base type) of the complex type, sym.
338 : */
339 :
340 : extern "C" unsigned int M2Base_ComplexToScalar (unsigned int sym);
341 :
342 : /*
343 : ScalarToComplex - given a real type, t, return the equivalent complex type.
344 : */
345 :
346 : extern "C" unsigned int M2Base_ScalarToComplex (unsigned int sym);
347 :
348 : /*
349 : GetCmplxReturnType - this code implements the table given in the
350 : ISO standard Page 293 with an addition for
351 : SHORTCOMPLEX.
352 : */
353 :
354 : extern "C" unsigned int M2Base_GetCmplxReturnType (unsigned int t1, unsigned int t2);
355 :
356 : /*
357 : InitBuiltins -
358 : */
359 :
360 : static void InitBuiltins (void);
361 :
362 : /*
363 : InitBaseConstants - initialises the base constant NIL.
364 : */
365 :
366 : static void InitBaseConstants (void);
367 :
368 : /*
369 : InitBaseSimpleTypes - initialises the base simple types,
370 : CARDINAL, INTEGER, CHAR, BOOLEAN.
371 : */
372 :
373 : static void InitBaseSimpleTypes (location_t location);
374 :
375 : /*
376 : FindMinMaxEnum - finds the minimum and maximum enumeration fields.
377 : */
378 :
379 : static void FindMinMaxEnum (unsigned int field);
380 :
381 : /*
382 : ImportFrom - imports symbol, name, from module and returns the
383 : symbol.
384 : */
385 :
386 : static unsigned int ImportFrom (unsigned int tok, unsigned int module, const char *name_, unsigned int _name_high);
387 :
388 : /*
389 : InitBaseProcedures - initialises the base procedures,
390 : INC, DEC, INCL, EXCL, NEW and DISPOSE.
391 : */
392 :
393 : static void InitBaseProcedures (void);
394 :
395 : /*
396 : BuildOrdFunctions - creates ORD, ORDS, ORDL.
397 : */
398 :
399 : static void BuildOrdFunctions (void);
400 :
401 : /*
402 : BuildTruncFunctions - creates TRUNC, TRUNCS, TRUNCL.
403 : */
404 :
405 : static void BuildTruncFunctions (void);
406 :
407 : /*
408 : BuildFloatFunctions - creates TRUNC, TRUNCS, TRUNCL.
409 : */
410 :
411 : static void BuildFloatFunctions (void);
412 :
413 : /*
414 : BuildIntFunctions - creates INT, INTS, INTL.
415 : */
416 :
417 : static void BuildIntFunctions (void);
418 :
419 : /*
420 : InitBaseFunctions - initialises the base function, HIGH.
421 : */
422 :
423 : static void InitBaseFunctions (void);
424 :
425 : /*
426 : IsISOPseudoBaseFunction -
427 : */
428 :
429 : static bool IsISOPseudoBaseFunction (unsigned int Sym);
430 :
431 : /*
432 : IsPIMPseudoBaseFunction -
433 : */
434 :
435 : static bool IsPIMPseudoBaseFunction (unsigned int Sym);
436 :
437 : /*
438 : EmitTypeIncompatibleWarning - emit a type incompatibility warning.
439 : */
440 :
441 : static void EmitTypeIncompatibleWarning (unsigned int tok, M2Base_Compatability kind, unsigned int t1, unsigned int t2);
442 :
443 : /*
444 : EmitTypeIncompatibleError - emit a type incompatibility error.
445 : */
446 :
447 : static void EmitTypeIncompatibleError (unsigned int tok, M2Base_Compatability kind, unsigned int t1, unsigned int t2);
448 :
449 : /*
450 : CheckCompatible - returns if t1 and t2 are kind compatible
451 : */
452 :
453 : static void CheckCompatible (unsigned int tok, unsigned int left, unsigned int right, M2Base_Compatability kind);
454 :
455 : /*
456 : FindMetaType - returns the MetaType associated with, sym.
457 : */
458 :
459 : static M2Base_MetaType FindMetaType (unsigned int sym);
460 :
461 : /*
462 : IsBaseCompatible - returns an enumeration field determining whether a simple base type
463 : comparison is legal.
464 : */
465 :
466 : static M2Base_Compatible IsBaseCompatible (unsigned int t1, unsigned int t2, M2Base_Compatability kind);
467 :
468 : /*
469 : IsCompatible - returns true if the types, t1, and, t2, are compatible.
470 : */
471 :
472 : static M2Base_Compatible IsCompatible (unsigned int t1, unsigned int t2, M2Base_Compatability kind);
473 :
474 : /*
475 : IsPointerSame - returns TRUE if pointers, a, and, b, are the same.
476 : */
477 :
478 : static bool IsPointerSame (unsigned int a, unsigned int b, bool error);
479 :
480 : /*
481 : IsSubrangeSame - checks to see whether the subranges are the same.
482 : */
483 :
484 : static bool IsSubrangeSame (unsigned int a, unsigned int b);
485 :
486 : /*
487 : IsVarientSame - returns TRUE if varient types, a, and, b, are identical.
488 : */
489 :
490 : static bool IsVarientSame (unsigned int a, unsigned int b, bool error);
491 :
492 : /*
493 : IsRecordSame -
494 : */
495 :
496 : static bool IsRecordSame (unsigned int a, unsigned int b, bool error);
497 :
498 : /*
499 : IsArraySame -
500 : */
501 :
502 : static bool IsArraySame (unsigned int t1, unsigned int t2, bool error);
503 :
504 : /*
505 : IsEnumerationSame -
506 : */
507 :
508 : static bool IsEnumerationSame (unsigned int t1, unsigned int t2);
509 :
510 : /*
511 : IsSetSame -
512 : */
513 :
514 : static bool IsSetSame (unsigned int t1, unsigned int t2, bool error);
515 :
516 : /*
517 : IsSameType - returns TRUE if
518 : */
519 :
520 : static bool IsSameType (unsigned int t1, unsigned int t2, bool error);
521 :
522 : /*
523 : IsProcTypeSame -
524 : */
525 :
526 : static bool IsProcTypeSame (unsigned int p1, unsigned int p2, bool error);
527 :
528 : /*
529 : doProcTypeCheck -
530 : */
531 :
532 : static bool doProcTypeCheck (unsigned int p1, unsigned int p2, bool error);
533 :
534 : /*
535 : AfterResolved - a thorough test for type compatibility.
536 : */
537 :
538 : static M2Base_Compatible AfterResolved (unsigned int t1, unsigned int t2, M2Base_Compatability kind);
539 :
540 : /*
541 : BeforeResolved - attempts to test for type compatibility before all types are
542 : completely resolved. In particular set types and constructor
543 : types are not fully known before the end of pass 3.
544 : However we can test base types.
545 : */
546 :
547 : static M2Base_Compatible BeforeResolved (unsigned int t1, unsigned int t2, M2Base_Compatability kind);
548 :
549 : /*
550 : MixMetaTypes -
551 : */
552 :
553 : static unsigned int MixMetaTypes (unsigned int left, unsigned int right, unsigned int leftType, unsigned int rightType, unsigned int NearTok);
554 :
555 : /*
556 : IsUserType - return TRUE if type was created by the user as a synonym.
557 : */
558 :
559 : static bool IsUserType (unsigned int type);
560 :
561 : /*
562 : IsVarParamCompatible - returns TRUE if types, actual, and, formal
563 : are compatible even if formal is a VAR
564 : parameter.
565 : */
566 :
567 : static bool IsVarParamCompatible (unsigned int actual, unsigned int formal);
568 :
569 : /*
570 : IsArrayUnboundedCompatible - returns TRUE if unbounded or array types, t1, and, t2,
571 : are compatible.
572 : */
573 :
574 : static bool IsArrayUnboundedCompatible (unsigned int t1, unsigned int t2);
575 :
576 : /*
577 : IsValidUnboundedParameter -
578 : */
579 :
580 : static bool IsValidUnboundedParameter (unsigned int formal, unsigned int actual);
581 :
582 : /*
583 : PushSizeOf - pushes the size of a meta type.
584 : */
585 :
586 : static void PushSizeOf (M2Base_MetaType t);
587 :
588 : /*
589 : IsSizeSame -
590 : */
591 :
592 : static bool IsSizeSame (M2Base_MetaType t1, M2Base_MetaType t2);
593 :
594 : /*
595 : InitArray -
596 : */
597 :
598 : static void InitArray (M2Base_CompatibilityArray *c, M2Base_MetaType y, const char *a_, unsigned int _a_high);
599 :
600 : /*
601 : A - initialize the assignment array
602 : */
603 :
604 : static void A (M2Base_MetaType y, const char *a_, unsigned int _a_high);
605 :
606 : /*
607 : E - initialize the expression array
608 : */
609 :
610 : static void E (M2Base_MetaType y, const char *a_, unsigned int _a_high);
611 :
612 : /*
613 : C - initialize the comparision array
614 : */
615 :
616 : static void C (M2Base_MetaType y, const char *a_, unsigned int _a_high);
617 :
618 : /*
619 : InitCompatibilityMatrices - initializes the tables above.
620 : */
621 :
622 : static void InitCompatibilityMatrices (void);
623 :
624 :
625 : /*
626 : InitBuiltins -
627 : */
628 :
629 16979 : static void InitBuiltins (void)
630 : {
631 16979 : unsigned int builtins;
632 :
633 16979 : if (M2Options_DebugBuiltins)
634 : {
635 : /* We will need to parse this module as functions alloca/memcpy will be used. */
636 0 : builtins = M2Batch_MakeDefinitionSource (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "Builtins", 8));
637 0 : if (builtins == SymbolTable_NulSym)
638 : {
639 0 : M2MetaError_MetaError0 ((const char *) "unable to find core module Builtins", 35);
640 : }
641 : }
642 16979 : }
643 :
644 :
645 : /*
646 : InitBaseConstants - initialises the base constant NIL.
647 : */
648 :
649 16979 : static void InitBaseConstants (void)
650 : {
651 16979 : M2Base_Nil = SymbolTable_MakeConstVar (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "NIL", 3));
652 16979 : SymbolTable_PutConst (M2Base_Nil, M2System_Address);
653 16979 : }
654 :
655 :
656 : /*
657 : InitBaseSimpleTypes - initialises the base simple types,
658 : CARDINAL, INTEGER, CHAR, BOOLEAN.
659 : */
660 :
661 16979 : static void InitBaseSimpleTypes (location_t location)
662 : {
663 16979 : m2type_InitBaseTypes (location);
664 16979 : M2Base_ZType = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "Modula-2 base Z", 15));
665 16979 : SymbolTable_PutType (M2Base_ZType, SymbolTable_NulSym); /* Base Type */
666 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2ZType ())); /* Base Type */
667 16979 : SymbolTable_PopSize (M2Base_ZType);
668 16979 : M2Base_RType = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "Modula-2 base R", 15));
669 16979 : SymbolTable_PutType (M2Base_RType, SymbolTable_NulSym); /* Base Type */
670 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2RType ())); /* Base Type */
671 16979 : SymbolTable_PopSize (M2Base_RType);
672 16979 : M2Base_CType = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "Modula-2 base C", 15));
673 16979 : SymbolTable_PutType (M2Base_CType, SymbolTable_NulSym); /* Base Type */
674 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2CType ())); /* Base Type */
675 16979 : SymbolTable_PopSize (M2Base_CType);
676 16979 : M2Base_Integer = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "INTEGER", 7));
677 16979 : SymbolTable_PutType (M2Base_Integer, SymbolTable_NulSym); /* Base Type */
678 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2IntegerType ())); /* Base Type */
679 16979 : SymbolTable_PopSize (M2Base_Integer);
680 16979 : M2Base_Cardinal = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "CARDINAL", 8));
681 16979 : SymbolTable_PutType (M2Base_Cardinal, SymbolTable_NulSym);
682 : /* Base Type */
683 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2CardinalType ()));
684 16979 : SymbolTable_PopSize (M2Base_Cardinal);
685 16979 : M2Base_LongInt = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "LONGINT", 7));
686 16979 : SymbolTable_PutType (M2Base_LongInt, SymbolTable_NulSym); /* Base Type */
687 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2LongIntType ())); /* Base Type */
688 16979 : SymbolTable_PopSize (M2Base_LongInt);
689 16979 : M2Base_LongCard = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "LONGCARD", 8));
690 16979 : SymbolTable_PutType (M2Base_LongCard, SymbolTable_NulSym); /* Base Type */
691 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2LongCardType ())); /* Base Type */
692 16979 : SymbolTable_PopSize (M2Base_LongCard);
693 16979 : M2Base_ShortInt = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SHORTINT", 8));
694 16979 : SymbolTable_PutType (M2Base_ShortInt, SymbolTable_NulSym); /* Base Type */
695 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2ShortIntType ())); /* Base Type */
696 16979 : SymbolTable_PopSize (M2Base_ShortInt);
697 16979 : M2Base_ShortCard = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SHORTCARD", 9));
698 16979 : SymbolTable_PutType (M2Base_ShortCard, SymbolTable_NulSym); /* Base Type */
699 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2ShortCardType ())); /* Base Type */
700 16979 : SymbolTable_PopSize (M2Base_ShortCard);
701 16979 : M2Base_Real = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "REAL", 4));
702 16979 : SymbolTable_PutType (M2Base_Real, SymbolTable_NulSym); /* Base Type */
703 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2RealType ())); /* Base Type */
704 16979 : SymbolTable_PopSize (M2Base_Real);
705 16979 : M2Base_ShortReal = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SHORTREAL", 9));
706 16979 : SymbolTable_PutType (M2Base_ShortReal, SymbolTable_NulSym); /* Base Type */
707 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2ShortRealType ())); /* Base Type */
708 16979 : SymbolTable_PopSize (M2Base_ShortReal);
709 16979 : M2Base_LongReal = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "LONGREAL", 8));
710 16979 : SymbolTable_PutType (M2Base_LongReal, SymbolTable_NulSym); /* Base Type */
711 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2LongRealType ())); /* Base Type */
712 16979 : SymbolTable_PopSize (M2Base_LongReal);
713 16979 : M2Base_Complex = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "COMPLEX", 7));
714 16979 : SymbolTable_PutType (M2Base_Complex, SymbolTable_NulSym); /* Base Type */
715 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2ComplexType ())); /* Base Type */
716 16979 : SymbolTable_PopSize (M2Base_Complex);
717 16979 : M2Base_LongComplex = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "LONGCOMPLEX", 11));
718 16979 : SymbolTable_PutType (M2Base_LongComplex, SymbolTable_NulSym); /* Base Type */
719 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2LongComplexType ())); /* Base Type */
720 16979 : SymbolTable_PopSize (M2Base_LongComplex);
721 16979 : M2Base_ShortComplex = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SHORTCOMPLEX", 12));
722 16979 : SymbolTable_PutType (M2Base_ShortComplex, SymbolTable_NulSym); /* Base Type */
723 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2ShortComplexType ())); /* Base Type */
724 16979 : SymbolTable_PopSize (M2Base_ShortComplex);
725 16979 : M2Base_Char = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "CHAR", 4));
726 16979 : SymbolTable_PutType (M2Base_Char, SymbolTable_NulSym); /* Base Type */
727 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetM2CharType ())); /* Base Type */
728 16979 : SymbolTable_PopSize (M2Base_Char);
729 : /*
730 : Boolean = (FALSE, TRUE) ;
731 : */
732 16979 : M2Base_Boolean = SymbolTable_MakeEnumeration (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "BOOLEAN", 7));
733 16979 : SymbolTable_PutFieldEnumeration (M2LexBuf_BuiltinTokenNo, M2Base_Boolean, NameKey_MakeKey ((const char *) "FALSE", 5));
734 16979 : SymbolTable_PutFieldEnumeration (M2LexBuf_BuiltinTokenNo, M2Base_Boolean, NameKey_MakeKey ((const char *) "TRUE", 4));
735 16979 : M2Base_True = SymbolTable_RequestSym (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "TRUE", 4));
736 16979 : M2Base_False = SymbolTable_RequestSym (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "FALSE", 5));
737 16979 : M2Base_Proc = SymbolTable_MakeProcType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "PROC", 4));
738 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (location, m2type_GetProcType ()));
739 16979 : SymbolTable_PopSize (M2Base_Proc);
740 : /* MinChar */
741 16979 : MinChar = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
742 16979 : M2ALU_PushIntegerTree (m2type_GetMinFrom (location, m2type_GetM2CharType ()));
743 16979 : SymbolTable_PopValue (MinChar);
744 16979 : SymbolTable_PutVar (MinChar, M2Base_Char);
745 : /* MaxChar */
746 16979 : MaxChar = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
747 16979 : M2ALU_PushIntegerTree (m2type_GetMaxFrom (location, m2type_GetM2CharType ()));
748 16979 : SymbolTable_PopValue (MaxChar);
749 16979 : SymbolTable_PutVar (MaxChar, M2Base_Char);
750 : /* MinInteger */
751 16979 : MinInteger = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
752 16979 : M2ALU_PushIntegerTree (m2type_GetMinFrom (location, m2type_GetM2IntegerType ()));
753 16979 : SymbolTable_PopValue (MinInteger);
754 16979 : SymbolTable_PutVar (MinInteger, M2Base_Integer);
755 : /* MaxInteger */
756 16979 : MaxInteger = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
757 16979 : M2ALU_PushIntegerTree (m2type_GetMaxFrom (location, m2type_GetM2IntegerType ()));
758 16979 : SymbolTable_PopValue (MaxInteger);
759 16979 : SymbolTable_PutVar (MaxInteger, M2Base_Integer);
760 : /* MinCardinal */
761 16979 : MinCardinal = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
762 16979 : M2ALU_PushIntegerTree (m2type_GetMinFrom (m2linemap_BuiltinsLocation (), m2type_GetM2CardinalType ()));
763 16979 : SymbolTable_PopValue (MinCardinal);
764 16979 : SymbolTable_PutVar (MinCardinal, M2Base_Cardinal);
765 : /* MaxCardinal */
766 16979 : MaxCardinal = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
767 16979 : M2ALU_PushIntegerTree (m2type_GetMaxFrom (location, m2type_GetM2CardinalType ()));
768 16979 : SymbolTable_PopValue (MaxCardinal);
769 16979 : SymbolTable_PutVar (MaxCardinal, M2Base_Cardinal);
770 : /* MinLongInt */
771 16979 : MinLongInt = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
772 16979 : M2ALU_PushIntegerTree (m2type_GetMinFrom (location, m2type_GetM2LongIntType ()));
773 16979 : SymbolTable_PopValue (MinLongInt);
774 16979 : SymbolTable_PutVar (MinLongInt, M2Base_LongInt);
775 : /* MaxLongInt */
776 16979 : MaxLongInt = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
777 16979 : M2ALU_PushIntegerTree (m2type_GetMaxFrom (location, m2type_GetM2LongIntType ()));
778 16979 : SymbolTable_PopValue (MaxLongInt);
779 16979 : SymbolTable_PutVar (MaxLongInt, M2Base_LongInt);
780 : /* MinLongCard */
781 16979 : MinLongCard = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
782 16979 : M2ALU_PushIntegerTree (m2type_GetMinFrom (location, m2type_GetM2LongCardType ()));
783 16979 : SymbolTable_PopValue (MinLongCard);
784 16979 : SymbolTable_PutVar (MinLongCard, M2Base_LongCard);
785 : /* MinLongCard */
786 16979 : MaxLongCard = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
787 16979 : M2ALU_PushIntegerTree (m2type_GetMaxFrom (m2linemap_BuiltinsLocation (), m2type_GetM2LongCardType ()));
788 16979 : SymbolTable_PopValue (MaxLongCard);
789 16979 : SymbolTable_PutVar (MaxLongCard, M2Base_LongCard);
790 : /* MinReal */
791 16979 : MinReal = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
792 16979 : M2ALU_PushRealTree (m2type_GetMinFrom (location, m2type_GetM2RealType ()));
793 16979 : SymbolTable_PopValue (MinReal);
794 16979 : SymbolTable_PutVar (MinReal, M2Base_Real);
795 : /* MaxReal */
796 16979 : MaxReal = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
797 16979 : M2ALU_PushRealTree (m2type_GetMaxFrom (location, m2type_GetM2RealType ()));
798 16979 : SymbolTable_PopValue (MaxReal);
799 16979 : SymbolTable_PutVar (MaxReal, M2Base_Real);
800 : /* MinShortReal */
801 16979 : MinShortReal = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
802 16979 : M2ALU_PushRealTree (m2type_GetMinFrom (location, m2type_GetM2ShortRealType ()));
803 16979 : SymbolTable_PopValue (MinShortReal);
804 16979 : SymbolTable_PutVar (MinShortReal, M2Base_ShortReal);
805 : /* MaxShortReal */
806 16979 : MaxShortReal = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
807 16979 : M2ALU_PushRealTree (m2type_GetMaxFrom (location, m2type_GetM2ShortRealType ()));
808 16979 : SymbolTable_PopValue (MaxShortReal);
809 16979 : SymbolTable_PutVar (MaxShortReal, M2Base_ShortReal);
810 : /* MinLongReal */
811 16979 : MinLongReal = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
812 16979 : M2ALU_PushRealTree (m2type_GetMinFrom (location, m2type_GetM2LongRealType ()));
813 16979 : SymbolTable_PopValue (MinLongReal);
814 16979 : SymbolTable_PutVar (MinLongReal, M2Base_LongReal);
815 : /* MaxLongReal */
816 16979 : MaxLongReal = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
817 16979 : M2ALU_PushRealTree (m2type_GetMaxFrom (location, m2type_GetM2LongRealType ()));
818 16979 : SymbolTable_PopValue (MaxLongReal);
819 16979 : SymbolTable_PutVar (MaxLongReal, M2Base_LongReal);
820 : /* MaxShortInt */
821 16979 : MaxShortInt = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
822 16979 : M2ALU_PushIntegerTree (m2type_GetMaxFrom (location, m2type_GetM2ShortIntType ()));
823 16979 : SymbolTable_PopValue (MaxShortInt);
824 16979 : SymbolTable_PutVar (MaxShortInt, M2Base_ShortInt);
825 : /* MinShortInt */
826 16979 : MinShortInt = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
827 16979 : M2ALU_PushIntegerTree (m2type_GetMinFrom (location, m2type_GetM2ShortIntType ()));
828 16979 : SymbolTable_PopValue (MinShortInt);
829 16979 : SymbolTable_PutVar (MinShortInt, M2Base_ShortInt);
830 : /* MaxShortCard */
831 16979 : MaxShortCard = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
832 16979 : M2ALU_PushIntegerTree (m2type_GetMaxFrom (location, m2type_GetM2ShortCardType ()));
833 16979 : SymbolTable_PopValue (MaxShortCard);
834 16979 : SymbolTable_PutVar (MaxShortCard, M2Base_ShortCard);
835 : /* MinShortCard */
836 16979 : MinShortCard = SymbolTable_MakeTemporary (M2LexBuf_BuiltinTokenNo, SymbolTable_ImmediateValue);
837 16979 : M2ALU_PushIntegerTree (m2type_GetMinFrom (location, m2type_GetM2ShortCardType ()));
838 16979 : SymbolTable_PopValue (MinShortCard);
839 16979 : SymbolTable_PutVar (MinShortCard, M2Base_ShortCard);
840 16979 : }
841 :
842 :
843 : /*
844 : FindMinMaxEnum - finds the minimum and maximum enumeration fields.
845 : */
846 :
847 354624 : static void FindMinMaxEnum (unsigned int field)
848 : {
849 354624 : if (MaxEnum == SymbolTable_NulSym)
850 : {
851 97449 : MaxEnum = static_cast<unsigned int> (field);
852 : }
853 : else
854 : {
855 257175 : SymbolTable_PushValue (field);
856 257175 : SymbolTable_PushValue (MaxEnum);
857 257175 : if (M2ALU_Gre (M2LexBuf_GetTokenNo ()))
858 : {
859 6960 : MaxEnum = static_cast<unsigned int> (field);
860 : }
861 : }
862 354624 : if (MinEnum == SymbolTable_NulSym)
863 : {
864 97449 : MinEnum = static_cast<unsigned int> (field);
865 : }
866 : else
867 : {
868 257175 : SymbolTable_PushValue (field);
869 257175 : SymbolTable_PushValue (MinEnum);
870 257175 : if (M2ALU_Less (M2LexBuf_GetTokenNo ()))
871 : {
872 234321 : MinEnum = static_cast<unsigned int> (field);
873 : }
874 : }
875 354624 : }
876 :
877 :
878 : /*
879 : ImportFrom - imports symbol, name, from module and returns the
880 : symbol.
881 : */
882 :
883 65106 : static unsigned int ImportFrom (unsigned int tok, unsigned int module, const char *name_, unsigned int _name_high)
884 : {
885 65106 : char name[_name_high+1];
886 :
887 : /* make a local copy of each unbounded array. */
888 65106 : memcpy (name, name_, _name_high+1);
889 :
890 65106 : SymbolTable_PutImported (SymbolTable_GetExported (tok, module, NameKey_MakeKey ((const char *) name, _name_high)));
891 65106 : return SymbolTable_GetSym (NameKey_MakeKey ((const char *) name, _name_high));
892 : /* static analysis guarentees a RETURN statement will be used before here. */
893 : __builtin_unreachable ();
894 65106 : }
895 :
896 :
897 : /*
898 : InitBaseProcedures - initialises the base procedures,
899 : INC, DEC, INCL, EXCL, NEW and DISPOSE.
900 : */
901 :
902 16979 : static void InitBaseProcedures (void)
903 : {
904 16979 : unsigned int rtexceptions;
905 :
906 : /*
907 : The pseudo procedures NEW and DISPOSE are in fact "macro"
908 : substituted for ALLOCATE and DEALLOCATE.
909 : However they both have symbols in the base module so that
910 : the procedure mechanism treats all procedure calls the same.
911 : "Macro" substitution occurs in M2Quads.
912 : */
913 16979 : M2Base_New = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "NEW", 3));
914 16979 : M2Base_Dispose = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "DISPOSE", 7));
915 16979 : M2Base_Inc = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "INC", 3));
916 16979 : M2Base_Dec = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "DEC", 3));
917 16979 : M2Base_Incl = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "INCL", 4));
918 16979 : M2Base_Excl = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "EXCL", 4));
919 16979 : if (! M2Options_Pim2)
920 : {
921 : /* PIM-2 Modula-2 */
922 16893 : M2Size_MakeSize ();
923 : }
924 16979 : if (M2Options_GetWideset ())
925 : {
926 : /* Ensure that M2WIDESET is available if needed by M2GenGCC.mod.
927 : By default -fwideset is TRUE however the user may override using
928 : -fno-wideset. */
929 16973 : m2wideset = M2Batch_MakeDefinitionSource (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "M2WIDESET", 9));
930 : }
931 : /*
932 : The procedure HALT is a real procedure which
933 : is defined in M2RTS. However to remain compatible
934 : with other Modula-2 implementations HALT can be used
935 : without the need to import it from M2RTS. ie it is
936 : within the BaseType module scope.
937 : */
938 16979 : m2rts = M2Batch_MakeDefinitionSource (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "M2RTS", 5));
939 16979 : SymbolTable_PutImported (SymbolTable_GetExported (M2LexBuf_BuiltinTokenNo, m2rts, NameKey_MakeKey ((const char *) "HALT", 4)));
940 16979 : M2Base_ExceptionAssign = SymbolTable_NulSym;
941 16979 : M2Base_ExceptionReturn = SymbolTable_NulSym;
942 16979 : M2Base_ExceptionInc = SymbolTable_NulSym;
943 16979 : M2Base_ExceptionDec = SymbolTable_NulSym;
944 16979 : M2Base_ExceptionIncl = SymbolTable_NulSym;
945 16979 : M2Base_ExceptionExcl = SymbolTable_NulSym;
946 16979 : M2Base_ExceptionShift = SymbolTable_NulSym;
947 16979 : M2Base_ExceptionRotate = SymbolTable_NulSym;
948 16979 : M2Base_ExceptionStaticArray = SymbolTable_NulSym;
949 16979 : M2Base_ExceptionDynamicArray = SymbolTable_NulSym;
950 16979 : M2Base_ExceptionForLoopBegin = SymbolTable_NulSym;
951 16979 : M2Base_ExceptionForLoopTo = SymbolTable_NulSym;
952 16979 : M2Base_ExceptionForLoopEnd = SymbolTable_NulSym;
953 16979 : M2Base_ExceptionPointerNil = SymbolTable_NulSym;
954 16979 : M2Base_ExceptionNoReturn = SymbolTable_NulSym;
955 16979 : M2Base_ExceptionCase = SymbolTable_NulSym;
956 16979 : M2Base_ExceptionNonPosDiv = SymbolTable_NulSym;
957 16979 : M2Base_ExceptionNonPosMod = SymbolTable_NulSym;
958 16979 : M2Base_ExceptionZeroDiv = SymbolTable_NulSym;
959 16979 : M2Base_ExceptionZeroRem = SymbolTable_NulSym;
960 16979 : M2Base_ExceptionWholeValue = SymbolTable_NulSym;
961 16979 : M2Base_ExceptionRealValue = SymbolTable_NulSym;
962 16979 : M2Base_ExceptionParameterBounds = SymbolTable_NulSym;
963 16979 : M2Base_ExceptionNo = SymbolTable_NulSym;
964 16979 : if (M2Options_NilChecking)
965 : {
966 2063 : M2Base_ExceptionPointerNil = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "PointerNilException", 19);
967 : }
968 16979 : if (M2Options_RangeChecking)
969 : {
970 2069 : M2Base_ExceptionAssign = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "AssignmentException", 19);
971 2069 : M2Base_ExceptionReturn = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "ReturnException", 15);
972 2069 : M2Base_ExceptionInc = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "IncException", 12);
973 2069 : M2Base_ExceptionDec = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "DecException", 12);
974 2069 : M2Base_ExceptionIncl = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "InclException", 13);
975 2069 : M2Base_ExceptionExcl = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "ExclException", 13);
976 2069 : M2Base_ExceptionShift = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "ShiftException", 14);
977 2069 : M2Base_ExceptionRotate = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "RotateException", 15);
978 2069 : M2Base_ExceptionForLoopBegin = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "ForLoopBeginException", 21);
979 2069 : M2Base_ExceptionForLoopTo = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "ForLoopToException", 18);
980 2069 : M2Base_ExceptionForLoopEnd = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "ForLoopEndException", 19);
981 2069 : M2Base_ExceptionParameterBounds = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "ParameterException", 18);
982 : }
983 16979 : if (M2Options_IndexChecking)
984 : {
985 2063 : M2Base_ExceptionStaticArray = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "StaticArraySubscriptException", 29);
986 2063 : M2Base_ExceptionDynamicArray = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "DynamicArraySubscriptException", 30);
987 : }
988 16979 : if (M2Options_WholeDivChecking)
989 : {
990 2063 : M2Base_ExceptionNonPosDiv = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "WholeNonPosDivException", 23);
991 2063 : M2Base_ExceptionNonPosMod = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "WholeNonPosModException", 23);
992 2063 : M2Base_ExceptionZeroDiv = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "WholeZeroDivException", 21);
993 2063 : M2Base_ExceptionZeroRem = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "WholeZeroRemException", 21);
994 : }
995 16979 : if (M2Options_ReturnChecking)
996 : {
997 2063 : M2Base_ExceptionNoReturn = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "NoReturnException", 17);
998 : }
999 16979 : if (M2Options_CaseElseChecking)
1000 : {
1001 2687 : M2Base_ExceptionCase = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "CaseException", 13);
1002 : }
1003 16979 : if (M2Options_WholeValueChecking)
1004 : {
1005 2063 : M2Base_ExceptionWholeValue = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "WholeValueException", 19);
1006 2063 : M2Base_ExceptionRealValue = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "RealValueException", 18);
1007 : }
1008 16979 : if (M2Options_Exceptions)
1009 : {
1010 16961 : M2Base_ExceptionNo = ImportFrom (M2LexBuf_BuiltinTokenNo, m2rts, (const char *) "NoException", 11);
1011 : /* ensure that this module is included */
1012 16961 : rtexceptions = M2Batch_MakeDefinitionSource (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "RTExceptions", 12));
1013 16961 : if (rtexceptions == SymbolTable_NulSym)
1014 : {
1015 0 : M2MetaError_MetaError0 ((const char *) "unable to find required runtime module RTExceptions", 51);
1016 : }
1017 : }
1018 16979 : }
1019 :
1020 :
1021 : /*
1022 : BuildOrdFunctions - creates ORD, ORDS, ORDL.
1023 : */
1024 :
1025 16979 : static void BuildOrdFunctions (void)
1026 : {
1027 16979 : Ord = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ORD", 3));
1028 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, Ord, SymbolTable_DefProcedure, M2Base_Cardinal);
1029 16979 : OrdS = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ORDS", 4));
1030 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, OrdS, SymbolTable_DefProcedure, M2Base_ShortCard);
1031 16979 : OrdL = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ORDL", 4));
1032 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, OrdL, SymbolTable_DefProcedure, M2Base_LongCard);
1033 16979 : }
1034 :
1035 :
1036 : /*
1037 : BuildTruncFunctions - creates TRUNC, TRUNCS, TRUNCL.
1038 : */
1039 :
1040 16979 : static void BuildTruncFunctions (void)
1041 : {
1042 16979 : if ((M2Options_Pim2 || M2Options_Pim3) || M2Options_Iso)
1043 : {
1044 4559 : Trunc = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "TRUNC", 5));
1045 4559 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, Trunc, SymbolTable_DefProcedure, M2Base_Cardinal);
1046 4559 : TruncS = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "STRUNC", 6));
1047 4559 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, TruncS, SymbolTable_DefProcedure, M2Base_ShortCard);
1048 4559 : TruncL = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "LTRUNC", 6));
1049 4559 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, TruncL, SymbolTable_DefProcedure, M2Base_LongCard);
1050 : }
1051 : else
1052 : {
1053 12420 : Trunc = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "TRUNC", 5));
1054 12420 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, Trunc, SymbolTable_DefProcedure, M2Base_Integer);
1055 12420 : TruncS = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "STRUNC", 6));
1056 12420 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, TruncS, SymbolTable_DefProcedure, M2Base_ShortInt);
1057 12420 : TruncL = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "LTRUNC", 6));
1058 12420 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, TruncL, SymbolTable_DefProcedure, M2Base_LongInt);
1059 : }
1060 16979 : }
1061 :
1062 :
1063 : /*
1064 : BuildFloatFunctions - creates TRUNC, TRUNCS, TRUNCL.
1065 : */
1066 :
1067 16979 : static void BuildFloatFunctions (void)
1068 : {
1069 16979 : Float = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "FLOAT", 5));
1070 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, Float, SymbolTable_DefProcedure, M2Base_Real);
1071 16979 : SFloat = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SFLOAT", 6));
1072 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, SFloat, SymbolTable_DefProcedure, M2Base_ShortReal);
1073 16979 : LFloat = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "LFLOAT", 6));
1074 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, LFloat, SymbolTable_DefProcedure, M2Base_LongReal);
1075 16979 : FloatS = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "FLOATS", 6));
1076 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, FloatS, SymbolTable_DefProcedure, M2Base_ShortReal);
1077 16979 : FloatL = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "FLOATL", 6));
1078 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, FloatL, SymbolTable_DefProcedure, M2Base_LongReal);
1079 16979 : }
1080 :
1081 :
1082 : /*
1083 : BuildIntFunctions - creates INT, INTS, INTL.
1084 : */
1085 :
1086 16979 : static void BuildIntFunctions (void)
1087 : {
1088 16979 : Int = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "INT", 3));
1089 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, Int, SymbolTable_DefProcedure, M2Base_Integer);
1090 16979 : IntS = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "INTS", 4));
1091 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, IntS, SymbolTable_DefProcedure, M2Base_ShortInt);
1092 16979 : IntL = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "INTL", 4));
1093 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, IntL, SymbolTable_DefProcedure, M2Base_LongInt);
1094 16979 : }
1095 :
1096 :
1097 : /*
1098 : InitBaseFunctions - initialises the base function, HIGH.
1099 : */
1100 :
1101 16979 : static void InitBaseFunctions (void)
1102 : {
1103 : /* Now declare the dynamic array components, HIGH */
1104 16979 : M2Base_High = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "HIGH", 4)); /* Pseudo Base function HIGH */
1105 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_High, SymbolTable_DefProcedure, M2Base_Cardinal);
1106 : /*
1107 : _TemplateProcedure is a procedure which has a local variable _ActivationPointer
1108 : whose offset is used for all nested procedures. (The activation pointer
1109 : being in the same relative position for all procedures).
1110 : */
1111 16979 : M2Base_TemplateProcedure = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "_TemplateProcedure", 18));
1112 16979 : SymbolTable_StartScope (M2Base_TemplateProcedure);
1113 16979 : M2Base_ActivationPointer = SymbolTable_MakeVar (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "_ActivationPointer", 18));
1114 16979 : SymbolTable_PutVar (M2Base_ActivationPointer, M2System_Address);
1115 16979 : SymbolTable_EndScope ();
1116 : /* and the base functions */
1117 16979 : M2Base_Convert = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "CONVERT", 7)); /* Internal function CONVERT */
1118 16979 : if (M2Options_Iso) /* Internal function CONVERT */
1119 : {
1120 4461 : M2Base_LengthS = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "LENGTH", 6)); /* Pseudo Base function LENGTH */
1121 4461 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_LengthS, SymbolTable_DefProcedure, M2Base_ZType); /* Pseudo Base function LENGTH */
1122 : }
1123 : else
1124 : {
1125 12518 : M2Base_LengthS = SymbolTable_NulSym;
1126 : }
1127 16979 : M2Base_Abs = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ABS", 3)); /* Pseudo Base function ABS */
1128 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_Abs, SymbolTable_DefProcedure, M2Base_ZType); /* Pseudo Base function ABS */
1129 16979 : M2Base_Cap = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "CAP", 3)); /* Pseudo Base function CAP */
1130 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_Cap, SymbolTable_DefProcedure, M2Base_Char); /* Pseudo Base function CAP */
1131 16979 : M2Base_Odd = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ODD", 3)); /* Pseudo Base function ODD */
1132 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_Odd, SymbolTable_DefProcedure, M2Base_Boolean); /* Pseudo Base function ODD */
1133 16979 : M2Base_Chr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "CHR", 3)); /* Pseudo Base function CHR */
1134 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_Chr, SymbolTable_DefProcedure, M2Base_Char);
1135 : /* the parameters. */
1136 16979 : M2Base_Val = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "VAL", 3)); /* Pseudo Base function VAL */
1137 16979 : M2Base_Min = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "MIN", 3)); /* Pseudo Base function MIN */
1138 16979 : M2Base_Max = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "MAX", 3)); /* Pseudo Base function MIN */
1139 16979 : M2Base_Re = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "RE", 2)); /* Pseudo Base function RE */
1140 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_Re, SymbolTable_DefProcedure, M2Base_RType); /* Pseudo Base function RE */
1141 16979 : M2Base_Im = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "IM", 2)); /* Pseudo Base function IM */
1142 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_Im, SymbolTable_DefProcedure, M2Base_RType); /* Pseudo Base function IM */
1143 16979 : M2Base_Cmplx = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "CMPLX", 5)); /* Pseudo Base function CMPLX */
1144 16979 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2Base_Cmplx, SymbolTable_DefProcedure, M2Base_CType); /* Pseudo Base function CMPLX */
1145 16979 : BuildFloatFunctions ();
1146 16979 : BuildTruncFunctions ();
1147 16979 : BuildOrdFunctions ();
1148 16979 : BuildIntFunctions ();
1149 16979 : }
1150 :
1151 :
1152 : /*
1153 : IsISOPseudoBaseFunction -
1154 : */
1155 :
1156 5653609 : static bool IsISOPseudoBaseFunction (unsigned int Sym)
1157 : {
1158 5653609 : return (M2Options_Iso && (Sym != SymbolTable_NulSym)) && ((((((Sym == M2Base_LengthS) || (Sym == M2Size_Size)) || (Sym == M2Base_Cmplx)) || (Sym == M2Base_Re)) || (Sym == M2Base_Im)) || (M2Base_IsInt (Sym)));
1159 : /* static analysis guarentees a RETURN statement will be used before here. */
1160 : __builtin_unreachable ();
1161 : }
1162 :
1163 :
1164 : /*
1165 : IsPIMPseudoBaseFunction -
1166 : */
1167 :
1168 5620274 : static bool IsPIMPseudoBaseFunction (unsigned int Sym)
1169 : {
1170 5620274 : return ((! M2Options_Iso && ! M2Options_Pim2) && (Sym != SymbolTable_NulSym)) && (Sym == M2Size_Size);
1171 : /* static analysis guarentees a RETURN statement will be used before here. */
1172 : __builtin_unreachable ();
1173 : }
1174 :
1175 :
1176 : /*
1177 : EmitTypeIncompatibleWarning - emit a type incompatibility warning.
1178 : */
1179 :
1180 0 : static void EmitTypeIncompatibleWarning (unsigned int tok, M2Base_Compatability kind, unsigned int t1, unsigned int t2)
1181 : {
1182 0 : switch (kind)
1183 : {
1184 0 : case M2Base_expression:
1185 0 : M2MetaError_MetaErrorT2 (tok, (const char *) "{%1W:} type incompatibility found {%1as:{%2as:between types {%1as} {%2as}}} in an expression, hint one of the expressions should be converted", 141, t1, t2);
1186 0 : break;
1187 :
1188 0 : case M2Base_assignment:
1189 0 : M2MetaError_MetaErrorT2 (tok, (const char *) "{%1W:} type incompatibility found {%1as:{%2as:between types {%1as} {%2as}}} during an assignment, hint maybe the expression should be converted", 143, t1, t2);
1190 0 : break;
1191 :
1192 0 : case M2Base_parameter:
1193 0 : M2MetaError_MetaErrorT2 (tok, (const char *) "{%1W:} type incompatibility found when passing a parameter {%1as:{%2as:between formal parameter and actual parameter types {%1as} {%2as}}}, hint the actual parameter {%2a} should be converted", 191, t1, t2);
1194 0 : break;
1195 :
1196 0 : case M2Base_comparison:
1197 0 : M2MetaError_MetaErrorT2 (tok, (const char *) "{%1W:} type incompatibility found {%1as:{%2as:between types {%1as} {%2as}}} in a relational expression, hint one of the expressions should be converted", 151, t1, t2);
1198 0 : break;
1199 :
1200 :
1201 : default:
1202 : break;
1203 : }
1204 0 : }
1205 :
1206 :
1207 : /*
1208 : EmitTypeIncompatibleError - emit a type incompatibility error.
1209 : */
1210 :
1211 30 : static void EmitTypeIncompatibleError (unsigned int tok, M2Base_Compatability kind, unsigned int t1, unsigned int t2)
1212 : {
1213 30 : switch (kind)
1214 : {
1215 0 : case M2Base_expression:
1216 0 : M2MetaError_MetaErrorT2 (tok, (const char *) "type incompatibility found {%1as:{%2as:between types {%1as} and {%2as}}} in an expression, hint one of the expressions should be converted", 138, t1, t2);
1217 0 : break;
1218 :
1219 30 : case M2Base_assignment:
1220 30 : M2MetaError_MetaErrorT2 (tok, (const char *) "type incompatibility found {%1as:{%2as:between types {%1as} and {%2as}}} during an assignment, hint maybe the expression should be converted", 140, t1, t2);
1221 30 : break;
1222 :
1223 0 : case M2Base_parameter:
1224 0 : M2MetaError_MetaErrorT2 (tok, (const char *) "type incompatibility found when passing a parameter {%1as:{%2as:between formal parameter and actual parameter types {%1as} and {%2as}}}, hint the actual parameter should be converted", 182, t1, t2);
1225 0 : break;
1226 :
1227 0 : case M2Base_comparison:
1228 0 : M2MetaError_MetaErrorT2 (tok, (const char *) "type incompatibility found {%1as:{%2as:between types {%1as} and {%2as}}} in a relational expression, hint one of the expressions should be converted", 148, t1, t2);
1229 0 : break;
1230 :
1231 :
1232 : default:
1233 : break;
1234 : }
1235 30 : }
1236 :
1237 :
1238 : /*
1239 : CheckCompatible - returns if t1 and t2 are kind compatible
1240 : */
1241 :
1242 24026 : static void CheckCompatible (unsigned int tok, unsigned int left, unsigned int right, M2Base_Compatability kind)
1243 : {
1244 24026 : DynamicStrings_String s;
1245 24026 : M2Base_Compatible r;
1246 :
1247 24026 : r = IsCompatible (left, right, kind);
1248 24026 : if ((r != M2Base_first) && (r != M2Base_second))
1249 : {
1250 30 : if ((r == M2Base_warnfirst) || (r == M2Base_warnsecond))
1251 : {
1252 0 : s = DynamicStrings_InitString ((const char *) "{%1W}", 5);
1253 : }
1254 : else
1255 : {
1256 30 : s = DynamicStrings_InitString ((const char *) "", 0);
1257 : }
1258 30 : if ((SymbolTable_IsUnknown (left)) && (SymbolTable_IsUnknown (right)))
1259 : {
1260 : /* Spellcheck. */
1261 0 : s = DynamicStrings_ConCat (s, DynamicStrings_InitString ((const char *) "two different unknown types {%1a:{%2a:{%1a} and {%2a}}} must either be declared or imported {%1&Ts} {%2&Ts}", 107));
1262 0 : M2MetaError_MetaErrorStringT2 (tok, s, left, right);
1263 : }
1264 30 : else if (SymbolTable_IsUnknown (left))
1265 : {
1266 : /* avoid dangling else. */
1267 : /* Spellcheck. */
1268 0 : s = DynamicStrings_ConCat (s, DynamicStrings_InitString ((const char *) "this type {%1a} is currently unknown, it must be declared or imported {%1&Ts}", 77));
1269 0 : M2MetaError_MetaErrorStringT1 (tok, s, left);
1270 : }
1271 30 : else if (SymbolTable_IsUnknown (right))
1272 : {
1273 : /* avoid dangling else. */
1274 : /* Spellcheck. */
1275 0 : s = DynamicStrings_ConCat (s, DynamicStrings_InitString ((const char *) "this type {%1a} is currently unknown, it must be declared or imported {%1&Ts}", 77));
1276 0 : M2MetaError_MetaErrorStringT1 (tok, s, right);
1277 : }
1278 : else
1279 : {
1280 : /* avoid dangling else. */
1281 30 : if ((r == M2Base_warnfirst) || (r == M2Base_warnsecond))
1282 : {
1283 0 : EmitTypeIncompatibleWarning (tok, kind, left, right);
1284 : }
1285 : else
1286 : {
1287 30 : EmitTypeIncompatibleError (tok, kind, left, right);
1288 : }
1289 : }
1290 : }
1291 24026 : }
1292 :
1293 :
1294 : /*
1295 : FindMetaType - returns the MetaType associated with, sym.
1296 : */
1297 :
1298 2555646 : static M2Base_MetaType FindMetaType (unsigned int sym)
1299 : {
1300 2591678 : if (sym == SymbolTable_NulSym)
1301 : {
1302 : return M2Base_const;
1303 : }
1304 2555646 : else if (sym == M2System_Word)
1305 : {
1306 : /* avoid dangling else. */
1307 : return M2Base_word;
1308 : }
1309 2548478 : else if (sym == M2System_Byte)
1310 : {
1311 : /* avoid dangling else. */
1312 : return M2Base_byte;
1313 : }
1314 2547902 : else if (sym == M2System_Loc)
1315 : {
1316 : /* avoid dangling else. */
1317 : return M2Base_loc;
1318 : }
1319 2547886 : else if (sym == M2System_Address)
1320 : {
1321 : /* avoid dangling else. */
1322 : return M2Base_address;
1323 : }
1324 2530788 : else if (sym == M2Base_Char)
1325 : {
1326 : /* avoid dangling else. */
1327 : return M2Base_chr;
1328 : }
1329 2530058 : else if (sym == M2Base_Integer)
1330 : {
1331 : /* avoid dangling else. */
1332 : return M2Base_normint;
1333 : }
1334 2094380 : else if (sym == M2Base_ShortInt)
1335 : {
1336 : /* avoid dangling else. */
1337 : return M2Base_shortint;
1338 : }
1339 2094082 : else if (sym == M2Base_LongInt)
1340 : {
1341 : /* avoid dangling else. */
1342 : return M2Base_longint;
1343 : }
1344 2084432 : else if (sym == M2Base_Cardinal)
1345 : {
1346 : /* avoid dangling else. */
1347 : return M2Base_normcard;
1348 : }
1349 1554511 : else if (sym == M2Base_ShortCard)
1350 : {
1351 : /* avoid dangling else. */
1352 : return M2Base_shortcard;
1353 : }
1354 1553757 : else if (sym == M2Base_LongCard)
1355 : {
1356 : /* avoid dangling else. */
1357 : return M2Base_longcard;
1358 : }
1359 1542286 : else if (sym == M2Base_ZType)
1360 : {
1361 : /* avoid dangling else. */
1362 : return M2Base_ztype;
1363 : }
1364 704118 : else if (sym == M2Base_RType)
1365 : {
1366 : /* avoid dangling else. */
1367 : return M2Base_rtype;
1368 : }
1369 601478 : else if (sym == M2Base_Real)
1370 : {
1371 : /* avoid dangling else. */
1372 : return M2Base_real;
1373 : }
1374 549462 : else if (sym == M2Base_ShortReal)
1375 : {
1376 : /* avoid dangling else. */
1377 : return M2Base_shortreal;
1378 : }
1379 539178 : else if (sym == M2Base_LongReal)
1380 : {
1381 : /* avoid dangling else. */
1382 : return M2Base_longreal;
1383 : }
1384 484586 : else if (sym == (M2System_IntegerN (8)))
1385 : {
1386 : /* avoid dangling else. */
1387 : return M2Base_int8;
1388 : }
1389 444140 : else if (sym == (M2System_IntegerN (16)))
1390 : {
1391 : /* avoid dangling else. */
1392 : return M2Base_int16;
1393 : }
1394 406628 : else if (sym == (M2System_IntegerN (32)))
1395 : {
1396 : /* avoid dangling else. */
1397 : return M2Base_int32;
1398 : }
1399 371486 : else if (sym == (M2System_IntegerN (64)))
1400 : {
1401 : /* avoid dangling else. */
1402 : return M2Base_int64;
1403 : }
1404 339302 : else if (sym == (M2System_CardinalN (8)))
1405 : {
1406 : /* avoid dangling else. */
1407 : return M2Base_card8;
1408 : }
1409 299492 : else if (sym == (M2System_CardinalN (16)))
1410 : {
1411 : /* avoid dangling else. */
1412 : return M2Base_card16;
1413 : }
1414 264836 : else if (sym == (M2System_CardinalN (32)))
1415 : {
1416 : /* avoid dangling else. */
1417 : return M2Base_card32;
1418 : }
1419 227894 : else if (sym == (M2System_CardinalN (64)))
1420 : {
1421 : /* avoid dangling else. */
1422 : return M2Base_card64;
1423 : }
1424 188648 : else if (sym == (M2System_WordN (16)))
1425 : {
1426 : /* avoid dangling else. */
1427 : return M2Base_word16;
1428 : }
1429 188648 : else if (sym == (M2System_WordN (32)))
1430 : {
1431 : /* avoid dangling else. */
1432 : return M2Base_word32;
1433 : }
1434 181508 : else if (sym == (M2System_WordN (64)))
1435 : {
1436 : /* avoid dangling else. */
1437 : return M2Base_word64;
1438 : }
1439 181508 : else if (sym == (M2System_SetN (8)))
1440 : {
1441 : /* avoid dangling else. */
1442 : return M2Base_set8;
1443 : }
1444 181508 : else if (sym == (M2System_SetN (16)))
1445 : {
1446 : /* avoid dangling else. */
1447 : return M2Base_set16;
1448 : }
1449 181508 : else if (sym == (M2System_SetN (32)))
1450 : {
1451 : /* avoid dangling else. */
1452 : return M2Base_set32;
1453 : }
1454 181508 : else if (sym == (M2System_RealN (32)))
1455 : {
1456 : /* avoid dangling else. */
1457 : return M2Base_real32;
1458 : }
1459 167492 : else if (sym == (M2System_RealN (64)))
1460 : {
1461 : /* avoid dangling else. */
1462 : return M2Base_real64;
1463 : }
1464 167492 : else if (sym == (M2System_RealN (96)))
1465 : {
1466 : /* avoid dangling else. */
1467 : return M2Base_real96;
1468 : }
1469 167492 : else if (sym == (M2System_RealN (128)))
1470 : {
1471 : /* avoid dangling else. */
1472 : return M2Base_real128;
1473 : }
1474 167492 : else if (sym == M2Base_Complex)
1475 : {
1476 : /* avoid dangling else. */
1477 : return M2Base_complex;
1478 : }
1479 140564 : else if (sym == M2Base_ShortComplex)
1480 : {
1481 : /* avoid dangling else. */
1482 : return M2Base_shortcomplex;
1483 : }
1484 140564 : else if (sym == M2Base_LongComplex)
1485 : {
1486 : /* avoid dangling else. */
1487 : return M2Base_longcomplex;
1488 : }
1489 110996 : else if (sym == (M2System_ComplexN (32)))
1490 : {
1491 : /* avoid dangling else. */
1492 : return M2Base_complex32;
1493 : }
1494 110996 : else if (sym == (M2System_ComplexN (64)))
1495 : {
1496 : /* avoid dangling else. */
1497 : return M2Base_complex64;
1498 : }
1499 110996 : else if (sym == (M2System_ComplexN (96)))
1500 : {
1501 : /* avoid dangling else. */
1502 : return M2Base_complex96;
1503 : }
1504 110996 : else if (sym == (M2System_ComplexN (128)))
1505 : {
1506 : /* avoid dangling else. */
1507 : return M2Base_complex128;
1508 : }
1509 110996 : else if (sym == M2Base_CType)
1510 : {
1511 : /* avoid dangling else. */
1512 : return M2Base_ctype;
1513 : }
1514 54500 : else if (SymbolTable_IsSet (sym))
1515 : {
1516 : /* avoid dangling else. */
1517 : return M2Base_set;
1518 : }
1519 54464 : else if (SymbolTable_IsHiddenType (sym))
1520 : {
1521 : /* avoid dangling else. */
1522 : return M2Base_opaque;
1523 : }
1524 54322 : else if (SymbolTable_IsPointer (sym))
1525 : {
1526 : /* avoid dangling else. */
1527 : return M2Base_pointer;
1528 : }
1529 36926 : else if (SymbolTable_IsEnumeration (sym))
1530 : {
1531 : /* avoid dangling else. */
1532 : return M2Base_enum;
1533 : }
1534 36080 : else if (SymbolTable_IsRecord (sym))
1535 : {
1536 : /* avoid dangling else. */
1537 : return M2Base_rec;
1538 : }
1539 36080 : else if (SymbolTable_IsArray (sym))
1540 : {
1541 : /* avoid dangling else. */
1542 : return M2Base_array;
1543 : }
1544 36056 : else if (SymbolTable_IsType (sym))
1545 : {
1546 : /* avoid dangling else. */
1547 36032 : return FindMetaType (SymbolTable_GetType (sym));
1548 : }
1549 24 : else if ((SymbolTable_IsProcedure (sym)) || (SymbolTable_IsProcType (sym)))
1550 : {
1551 : /* avoid dangling else. */
1552 24 : return M2Base_procedure;
1553 : }
1554 : else
1555 : {
1556 : /* avoid dangling else. */
1557 : return M2Base_unknown;
1558 : }
1559 : /* static analysis guarentees a RETURN statement will be used before here. */
1560 : __builtin_unreachable ();
1561 : }
1562 :
1563 :
1564 : /*
1565 : IsBaseCompatible - returns an enumeration field determining whether a simple base type
1566 : comparison is legal.
1567 : */
1568 :
1569 668119 : static M2Base_Compatible IsBaseCompatible (unsigned int t1, unsigned int t2, M2Base_Compatability kind)
1570 : {
1571 668119 : M2Base_MetaType mt1;
1572 668119 : M2Base_MetaType mt2;
1573 :
1574 668119 : if ((t1 == t2) && ((kind == M2Base_assignment) || (kind == M2Base_parameter)))
1575 : {
1576 : return M2Base_first;
1577 : }
1578 : else
1579 : {
1580 668119 : mt1 = FindMetaType (t1);
1581 668119 : mt2 = FindMetaType (t2);
1582 668119 : if ((mt1 == M2Base_unknown) || (mt2 == M2Base_unknown))
1583 : {
1584 : return M2Base_no;
1585 : }
1586 668119 : switch (kind)
1587 : {
1588 48942 : case M2Base_expression:
1589 48942 : return Expr.array[mt1-M2Base_const].array[mt2-M2Base_const];
1590 565817 : break;
1591 :
1592 565817 : case M2Base_assignment:
1593 565817 : return Ass.array[mt1-M2Base_const].array[mt2-M2Base_const];
1594 3600 : break;
1595 :
1596 3600 : case M2Base_parameter:
1597 3600 : return Ass.array[mt1-M2Base_const].array[mt2-M2Base_const];
1598 49760 : break;
1599 :
1600 49760 : case M2Base_comparison:
1601 49760 : return Comp.array[mt1-M2Base_const].array[mt2-M2Base_const];
1602 0 : break;
1603 :
1604 :
1605 0 : default:
1606 0 : M2Error_InternalError ((const char *) "unexpected compatibility", 24);
1607 : break;
1608 : }
1609 : }
1610 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2Base.def", 20, 1);
1611 : __builtin_unreachable ();
1612 : }
1613 :
1614 :
1615 : /*
1616 : IsCompatible - returns true if the types, t1, and, t2, are compatible.
1617 : */
1618 :
1619 771201 : static M2Base_Compatible IsCompatible (unsigned int t1, unsigned int t2, M2Base_Compatability kind)
1620 : {
1621 771201 : t1 = SymbolTable_SkipType (t1);
1622 771201 : t2 = SymbolTable_SkipType (t2);
1623 771201 : if (t1 == t2)
1624 : {
1625 : /* same types are always compatible. */
1626 : return M2Base_first;
1627 : }
1628 714217 : else if (M2Pass_IsPassCodeGeneration ())
1629 : {
1630 : /* avoid dangling else. */
1631 645214 : return AfterResolved (t1, t2, kind);
1632 : }
1633 : else
1634 : {
1635 : /* avoid dangling else. */
1636 69003 : return BeforeResolved (t1, t2, kind);
1637 : }
1638 : /* static analysis guarentees a RETURN statement will be used before here. */
1639 : __builtin_unreachable ();
1640 : }
1641 :
1642 :
1643 : /*
1644 : IsPointerSame - returns TRUE if pointers, a, and, b, are the same.
1645 : */
1646 :
1647 0 : static bool IsPointerSame (unsigned int a, unsigned int b, bool error)
1648 : {
1649 0 : return IsSameType (SymbolTable_SkipType (SymbolTable_GetType (a)), SymbolTable_SkipType (SymbolTable_GetType (b)), error);
1650 : /* static analysis guarentees a RETURN statement will be used before here. */
1651 : __builtin_unreachable ();
1652 : }
1653 :
1654 :
1655 : /*
1656 : IsSubrangeSame - checks to see whether the subranges are the same.
1657 : */
1658 :
1659 6 : static bool IsSubrangeSame (unsigned int a, unsigned int b)
1660 : {
1661 6 : unsigned int al;
1662 6 : unsigned int ah;
1663 6 : unsigned int bl;
1664 6 : unsigned int bh;
1665 :
1666 6 : a = SymbolTable_SkipType (a);
1667 6 : b = SymbolTable_SkipType (b);
1668 6 : if (a != b)
1669 : {
1670 6 : SymbolTable_GetSubrange (a, &ah, &al);
1671 6 : SymbolTable_GetSubrange (b, &bh, &bl);
1672 6 : SymbolTable_PushValue (al);
1673 6 : SymbolTable_PushValue (bl);
1674 6 : if (! (M2ALU_Equ (SymbolTable_GetDeclaredMod (a))))
1675 : {
1676 : return false;
1677 : }
1678 6 : SymbolTable_PushValue (ah);
1679 6 : SymbolTable_PushValue (bh);
1680 6 : if (! (M2ALU_Equ (SymbolTable_GetDeclaredMod (a))))
1681 : {
1682 : return false;
1683 : }
1684 : }
1685 : return true;
1686 : /* static analysis guarentees a RETURN statement will be used before here. */
1687 : __builtin_unreachable ();
1688 : }
1689 :
1690 :
1691 : /*
1692 : IsVarientSame - returns TRUE if varient types, a, and, b, are identical.
1693 : */
1694 :
1695 0 : static bool IsVarientSame (unsigned int a, unsigned int b, bool error)
1696 : {
1697 0 : unsigned int i;
1698 0 : unsigned int j;
1699 0 : unsigned int fa;
1700 0 : unsigned int fb;
1701 0 : unsigned int ga;
1702 0 : unsigned int gb;
1703 :
1704 0 : i = 1;
1705 0 : ga = SymbolTable_NulSym;
1706 0 : gb = SymbolTable_NulSym;
1707 0 : do {
1708 0 : fa = SymbolTable_GetNth (a, i);
1709 0 : fb = SymbolTable_GetNth (b, i);
1710 0 : if ((fa != SymbolTable_NulSym) && (fb != SymbolTable_NulSym))
1711 : {
1712 0 : M2Debug_Assert (SymbolTable_IsFieldVarient (fa));
1713 0 : M2Debug_Assert (SymbolTable_IsFieldVarient (fb));
1714 0 : j = 1;
1715 0 : do {
1716 0 : ga = SymbolTable_GetNth (fa, j);
1717 0 : gb = SymbolTable_GetNth (fb, j);
1718 0 : if ((ga != SymbolTable_NulSym) && (gb != SymbolTable_NulSym))
1719 : {
1720 0 : if (! (IsSameType (SymbolTable_GetType (ga), SymbolTable_GetType (gb), error)))
1721 : {
1722 : return false;
1723 : }
1724 0 : j += 1;
1725 : }
1726 0 : } while (! ((ga == SymbolTable_NulSym) || (gb == SymbolTable_NulSym)));
1727 0 : if (ga != gb)
1728 : {
1729 : return false;
1730 : }
1731 : }
1732 0 : i += 1;
1733 0 : } while (! ((fa == SymbolTable_NulSym) || (fb == SymbolTable_NulSym)));
1734 0 : return ga == gb;
1735 : /* static analysis guarentees a RETURN statement will be used before here. */
1736 : __builtin_unreachable ();
1737 : }
1738 :
1739 :
1740 : /*
1741 : IsRecordSame -
1742 : */
1743 :
1744 0 : static bool IsRecordSame (unsigned int a, unsigned int b, bool error)
1745 : {
1746 0 : unsigned int ta;
1747 0 : unsigned int tb;
1748 0 : unsigned int fa;
1749 0 : unsigned int fb;
1750 0 : unsigned int i;
1751 :
1752 0 : i = 1;
1753 0 : do {
1754 0 : fa = SymbolTable_GetNth (a, i);
1755 0 : fb = SymbolTable_GetNth (b, i);
1756 0 : if ((fa != SymbolTable_NulSym) && (fb != SymbolTable_NulSym))
1757 : {
1758 0 : ta = SymbolTable_GetType (fa);
1759 0 : tb = SymbolTable_GetType (fb);
1760 0 : if ((SymbolTable_IsRecordField (fa)) && (SymbolTable_IsRecordField (fb)))
1761 : {
1762 : /* avoid dangling else. */
1763 0 : if (! (IsSameType (ta, tb, error)))
1764 : {
1765 : return false;
1766 : }
1767 : }
1768 0 : else if ((SymbolTable_IsVarient (fa)) && (SymbolTable_IsVarient (fb)))
1769 : {
1770 : /* avoid dangling else. */
1771 0 : if (! (IsVarientSame (ta, tb, error)))
1772 : {
1773 : return false;
1774 : }
1775 : }
1776 0 : else if ((SymbolTable_IsFieldVarient (fa)) || (SymbolTable_IsFieldVarient (fb)))
1777 : {
1778 : /* avoid dangling else. */
1779 0 : M2Error_InternalError ((const char *) "should not see a field varient", 30);
1780 : }
1781 : else
1782 : {
1783 : /* avoid dangling else. */
1784 : return false;
1785 : }
1786 : }
1787 0 : i += 1;
1788 0 : } while (! ((fa == SymbolTable_NulSym) || (fb == SymbolTable_NulSym)));
1789 0 : return fa == fb;
1790 : /* static analysis guarentees a RETURN statement will be used before here. */
1791 : __builtin_unreachable ();
1792 : }
1793 :
1794 :
1795 : /*
1796 : IsArraySame -
1797 : */
1798 :
1799 0 : static bool IsArraySame (unsigned int t1, unsigned int t2, bool error)
1800 : {
1801 0 : unsigned int s1;
1802 0 : unsigned int s2;
1803 :
1804 0 : s1 = SymbolTable_GetArraySubscript (t1);
1805 0 : s2 = SymbolTable_GetArraySubscript (t2);
1806 0 : return (IsSameType (SymbolTable_GetType (s1), SymbolTable_GetType (s2), error)) && (IsSameType (SymbolTable_GetType (t1), SymbolTable_GetType (t2), error));
1807 : /* static analysis guarentees a RETURN statement will be used before here. */
1808 : __builtin_unreachable ();
1809 : }
1810 :
1811 :
1812 : /*
1813 : IsEnumerationSame -
1814 : */
1815 :
1816 0 : static bool IsEnumerationSame (unsigned int t1, unsigned int t2)
1817 : {
1818 0 : return t1 == t2;
1819 : /* static analysis guarentees a RETURN statement will be used before here. */
1820 : __builtin_unreachable ();
1821 : }
1822 :
1823 :
1824 : /*
1825 : IsSetSame -
1826 : */
1827 :
1828 6 : static bool IsSetSame (unsigned int t1, unsigned int t2, bool error)
1829 : {
1830 6 : return IsSameType (SymbolTable_GetType (t1), SymbolTable_GetType (t2), error);
1831 : /* static analysis guarentees a RETURN statement will be used before here. */
1832 : __builtin_unreachable ();
1833 : }
1834 :
1835 :
1836 : /*
1837 : IsSameType - returns TRUE if
1838 : */
1839 :
1840 6 : static bool IsSameType (unsigned int t1, unsigned int t2, bool error)
1841 : {
1842 6 : t1 = SymbolTable_SkipType (t1);
1843 6 : t2 = SymbolTable_SkipType (t2);
1844 6 : if (t1 == t2)
1845 : {
1846 : return true;
1847 : }
1848 6 : else if ((SymbolTable_IsArray (t1)) && (SymbolTable_IsArray (t2)))
1849 : {
1850 : /* avoid dangling else. */
1851 0 : return IsArraySame (t1, t2, error);
1852 : }
1853 6 : else if ((SymbolTable_IsSubrange (t1)) && (SymbolTable_IsSubrange (t2)))
1854 : {
1855 : /* avoid dangling else. */
1856 6 : return IsSubrangeSame (t1, t2);
1857 : }
1858 0 : else if ((SymbolTable_IsProcType (t1)) && (SymbolTable_IsProcType (t2)))
1859 : {
1860 : /* avoid dangling else. */
1861 0 : return IsProcTypeSame (t1, t2, error);
1862 : }
1863 0 : else if ((SymbolTable_IsEnumeration (t1)) && (SymbolTable_IsEnumeration (t2)))
1864 : {
1865 : /* avoid dangling else. */
1866 : return IsEnumerationSame (t1, t2); /* , error */
1867 : }
1868 0 : else if ((SymbolTable_IsRecord (t1)) && (SymbolTable_IsRecord (t2)))
1869 : {
1870 : /* avoid dangling else. */
1871 0 : return IsRecordSame (t1, t2, error);
1872 : }
1873 0 : else if ((SymbolTable_IsSet (t1)) && (SymbolTable_IsSet (t2)))
1874 : {
1875 : /* avoid dangling else. */
1876 0 : return IsSetSame (t1, t2, error);
1877 : }
1878 0 : else if ((SymbolTable_IsPointer (t1)) && (SymbolTable_IsPointer (t2)))
1879 : {
1880 : /* avoid dangling else. */
1881 0 : return IsPointerSame (t1, t2, error);
1882 : }
1883 : else
1884 : {
1885 : /* avoid dangling else. */
1886 : return false;
1887 : }
1888 : /* static analysis guarentees a RETURN statement will be used before here. */
1889 : __builtin_unreachable ();
1890 : }
1891 :
1892 :
1893 : /*
1894 : IsProcTypeSame -
1895 : */
1896 :
1897 0 : static bool IsProcTypeSame (unsigned int p1, unsigned int p2, bool error)
1898 : {
1899 0 : unsigned int pa;
1900 0 : unsigned int pb;
1901 0 : unsigned int n;
1902 0 : unsigned int i;
1903 :
1904 0 : n = SymbolTable_NoOfParamAny (p1);
1905 0 : if (n != (SymbolTable_NoOfParamAny (p2)))
1906 : {
1907 0 : if (error)
1908 : {
1909 0 : M2MetaError_MetaError2 ((const char *) "parameter is incompatible as {%1Dd} was declared with {%2n} parameters", 70, p1, SymbolTable_NoOfParamAny (p1));
1910 0 : M2MetaError_MetaError2 ((const char *) "whereas {%1Dd} was declared with {%2n} parameters", 49, p2, SymbolTable_NoOfParamAny (p2));
1911 : }
1912 : return false;
1913 : }
1914 : i = 1;
1915 0 : while (i <= n)
1916 : {
1917 0 : pa = SymbolTable_GetNthParamAny (p1, i);
1918 0 : pb = SymbolTable_GetNthParamAny (p2, i);
1919 0 : if ((SymbolTable_IsParameterVar (pa)) != (SymbolTable_IsParameterVar (pb)))
1920 : {
1921 0 : if (error)
1922 : {
1923 0 : M2MetaError_MetaErrors3 ((const char *) "the {%1n} parameter is incompatible between {%2Dad} and {%3ad} as only one was declared as VAR", 94, (const char *) "the {%1n} parameter is incompatible between {%2ad} and {%3Dad} as only one was declared as VAR", 94, i, pa, pb);
1924 : }
1925 : return false;
1926 : }
1927 0 : if (! (IsSameType (SymbolTable_GetType (pa), SymbolTable_GetType (pb), error)))
1928 : {
1929 : return false;
1930 : }
1931 0 : i += 1;
1932 : }
1933 0 : return IsSameType (SymbolTable_GetType (p1), SymbolTable_GetType (p2), error);
1934 : /* static analysis guarentees a RETURN statement will be used before here. */
1935 : __builtin_unreachable ();
1936 : }
1937 :
1938 :
1939 : /*
1940 : doProcTypeCheck -
1941 : */
1942 :
1943 0 : static bool doProcTypeCheck (unsigned int p1, unsigned int p2, bool error)
1944 : {
1945 0 : if (((SymbolTable_IsProcType (p1)) || (SymbolTable_IsProcedure (p1))) && ((SymbolTable_IsProcType (p2)) || (SymbolTable_IsProcedure (p2))))
1946 : {
1947 0 : if (p1 == p2)
1948 : {
1949 : return true;
1950 : }
1951 : else
1952 : {
1953 0 : return IsProcTypeSame (p1, p2, error);
1954 : }
1955 : }
1956 : else
1957 : {
1958 : return false;
1959 : }
1960 : /* static analysis guarentees a RETURN statement will be used before here. */
1961 : __builtin_unreachable ();
1962 : }
1963 :
1964 :
1965 : /*
1966 : AfterResolved - a thorough test for type compatibility.
1967 : */
1968 :
1969 645214 : static M2Base_Compatible AfterResolved (unsigned int t1, unsigned int t2, M2Base_Compatability kind)
1970 : {
1971 645214 : M2Base_MetaType mt1;
1972 645214 : M2Base_MetaType mt2;
1973 :
1974 645214 : if ((t1 == SymbolTable_NulSym) || (t2 == SymbolTable_NulSym))
1975 : {
1976 : return M2Base_first;
1977 : }
1978 644866 : else if (((kind == M2Base_parameter) || (kind == M2Base_assignment)) && (t1 == t2))
1979 : {
1980 : /* avoid dangling else. */
1981 : return M2Base_first;
1982 : }
1983 644866 : else if (SymbolTable_IsSubrange (t1))
1984 : {
1985 : /* avoid dangling else. */
1986 41930 : return IsCompatible (SymbolTable_GetType (t1), t2, kind);
1987 : }
1988 602936 : else if (SymbolTable_IsSubrange (t2))
1989 : {
1990 : /* avoid dangling else. */
1991 0 : return IsCompatible (t1, SymbolTable_GetType (t2), kind);
1992 : }
1993 : else
1994 : {
1995 : /* avoid dangling else. */
1996 602936 : mt1 = FindMetaType (t1);
1997 602936 : mt2 = FindMetaType (t2);
1998 602936 : if (mt1 == mt2)
1999 : {
2000 12 : switch (mt1)
2001 : {
2002 6 : case M2Base_set:
2003 6 : case M2Base_set8:
2004 6 : case M2Base_set16:
2005 6 : case M2Base_set32:
2006 6 : if (IsSetSame (t1, t2, false))
2007 : {
2008 : return M2Base_first;
2009 : }
2010 : else
2011 : {
2012 0 : return M2Base_no;
2013 : }
2014 0 : break;
2015 :
2016 0 : case M2Base_enum:
2017 0 : if (IsEnumerationSame (t1, t2)) /* , FALSE */
2018 : {
2019 : return M2Base_first;
2020 : }
2021 : else
2022 : {
2023 0 : return M2Base_no;
2024 : }
2025 0 : break;
2026 :
2027 0 : case M2Base_pointer:
2028 0 : if (IsPointerSame (t1, t2, false))
2029 : {
2030 : return M2Base_first;
2031 : }
2032 : else
2033 : {
2034 0 : return M2Base_no;
2035 : }
2036 : break;
2037 :
2038 : case M2Base_opaque:
2039 : return M2Base_no;
2040 0 : break;
2041 :
2042 0 : case M2Base_procedure:
2043 0 : if (doProcTypeCheck (t1, t2, false))
2044 : {
2045 : return M2Base_first;
2046 : }
2047 : else
2048 : {
2049 0 : return M2Base_no;
2050 : }
2051 : break;
2052 :
2053 :
2054 : default:
2055 : break;
2056 : }
2057 : }
2058 : /* fall through */
2059 602930 : return IsBaseCompatible (t1, t2, kind);
2060 : }
2061 : /* static analysis guarentees a RETURN statement will be used before here. */
2062 : __builtin_unreachable ();
2063 : }
2064 :
2065 :
2066 : /*
2067 : BeforeResolved - attempts to test for type compatibility before all types are
2068 : completely resolved. In particular set types and constructor
2069 : types are not fully known before the end of pass 3.
2070 : However we can test base types.
2071 : */
2072 :
2073 69003 : static M2Base_Compatible BeforeResolved (unsigned int t1, unsigned int t2, M2Base_Compatability kind)
2074 : {
2075 69003 : if ((t1 == SymbolTable_NulSym) || (t2 == SymbolTable_NulSym))
2076 : {
2077 : return M2Base_first;
2078 : }
2079 66237 : else if (SymbolTable_IsSubrange (t1))
2080 : {
2081 : /* avoid dangling else. */
2082 286 : return IsCompatible (SymbolTable_GetType (t1), t2, kind);
2083 : }
2084 65951 : else if (SymbolTable_IsSubrange (t2))
2085 : {
2086 : /* avoid dangling else. */
2087 404 : return IsCompatible (t1, SymbolTable_GetType (t2), kind);
2088 : }
2089 65547 : else if ((SymbolTable_IsSet (t1)) || (SymbolTable_IsSet (t2)))
2090 : {
2091 : /* avoid dangling else. */
2092 : /* cannot test set compatibility at this point so we do this again after pass 3 */
2093 : return M2Base_first;
2094 : }
2095 65297 : else if (((SymbolTable_IsProcType (t1)) && (SymbolTable_IsProcedure (t2))) || ((SymbolTable_IsProcedure (t1)) && (SymbolTable_IsProcType (t2))))
2096 : {
2097 : /* avoid dangling else. */
2098 : /* we will perform checking during code generation */
2099 : return M2Base_first;
2100 : }
2101 65213 : else if ((SymbolTable_IsHiddenType (t1)) && (SymbolTable_IsHiddenType (t2)))
2102 : {
2103 : /* avoid dangling else. */
2104 24 : if (t1 == t2)
2105 : {
2106 0 : M2MetaError_MetaError0 ((const char *) "assert about to fail as t1 = t2", 31);
2107 : }
2108 24 : M2Debug_Assert (t1 != t2);
2109 : /* different opaque types are not assignment or expression compatible. */
2110 24 : return M2Base_no;
2111 : }
2112 : else
2113 : {
2114 : /* avoid dangling else. */
2115 : /*
2116 : see M2Quads for the fixme comment at assignment.
2117 :
2118 : PIM2 says that CARDINAL and INTEGER are compatible with subranges of CARDINAL and INTEGER,
2119 : however we do not know the type to our subranges yet as (GetType(SubrangeType)=NulSym).
2120 : So we add type checking in the range checking module which is done post pass 3,
2121 : when all is resolved.
2122 : */
2123 65189 : return IsBaseCompatible (t1, t2, kind);
2124 : }
2125 : /* static analysis guarentees a RETURN statement will be used before here. */
2126 : __builtin_unreachable ();
2127 : }
2128 :
2129 :
2130 : /*
2131 : MixMetaTypes -
2132 : */
2133 :
2134 5550 : static unsigned int MixMetaTypes (unsigned int left, unsigned int right, unsigned int leftType, unsigned int rightType, unsigned int NearTok)
2135 : {
2136 5550 : M2Base_MetaType mt1;
2137 5550 : M2Base_MetaType mt2;
2138 :
2139 5550 : mt1 = FindMetaType (leftType);
2140 5550 : mt2 = FindMetaType (rightType);
2141 5550 : switch (Expr.array[mt1-M2Base_const].array[mt2-M2Base_const])
2142 : {
2143 108 : case M2Base_no:
2144 108 : M2MetaError_MetaErrorT2 (NearTok, (const char *) "type incompatibility between {%1asd} and {%2asd}", 48, leftType, rightType);
2145 108 : M2MetaError_MetaErrorDecl (left, true);
2146 108 : M2MetaError_MetaErrorDecl (right, true);
2147 108 : M2Error_FlushErrors (); /* unrecoverable at present */
2148 0 : break;
2149 :
2150 : case M2Base_warnfirst:
2151 : case M2Base_first:
2152 : return leftType;
2153 100 : break;
2154 :
2155 100 : case M2Base_warnsecond:
2156 100 : case M2Base_second:
2157 100 : return rightType;
2158 0 : break;
2159 :
2160 :
2161 0 : default:
2162 0 : M2Error_InternalError ((const char *) "not expecting this metatype value", 33);
2163 0 : break;
2164 : }
2165 0 : return SymbolTable_MakeError (NearTok, NameKey_NulName);
2166 : /* static analysis guarentees a RETURN statement will be used before here. */
2167 : __builtin_unreachable ();
2168 : }
2169 :
2170 :
2171 : /*
2172 : IsUserType - return TRUE if type was created by the user as a synonym.
2173 : */
2174 :
2175 118174 : static bool IsUserType (unsigned int type)
2176 : {
2177 118174 : return (((SymbolTable_IsType (type)) && (! (M2Base_IsBaseType (type)))) && (! (M2System_IsSystemType (type)))) && (type != M2Base_ZType);
2178 : /* static analysis guarentees a RETURN statement will be used before here. */
2179 : __builtin_unreachable ();
2180 : }
2181 :
2182 :
2183 : /*
2184 : IsVarParamCompatible - returns TRUE if types, actual, and, formal
2185 : are compatible even if formal is a VAR
2186 : parameter.
2187 : */
2188 :
2189 0 : static bool IsVarParamCompatible (unsigned int actual, unsigned int formal)
2190 : {
2191 0 : actual = SymbolTable_SkipType (actual);
2192 0 : formal = SymbolTable_SkipType (formal);
2193 0 : if ((SymbolTable_IsParameter (formal)) && (SymbolTable_IsParameterUnbounded (formal)))
2194 : {
2195 0 : formal = SymbolTable_SkipType (SymbolTable_GetType (SymbolTable_GetType (formal))); /* move over unbounded */
2196 0 : if (M2System_IsGenericSystemType (formal)) /* move over unbounded */
2197 : {
2198 : return true;
2199 : }
2200 0 : return (formal == actual) || ((SymbolTable_IsArray (actual)) && (formal == (SymbolTable_SkipType (SymbolTable_GetType (actual)))));
2201 : }
2202 : else
2203 : {
2204 0 : return (((((actual == formal) || ((SymbolTable_IsPointer (actual)) && (formal == M2System_Address))) || ((SymbolTable_IsPointer (formal)) && (actual == M2System_Address))) || ((M2System_IsGenericSystemType (actual)) && (IsSizeSame (FindMetaType (actual), FindMetaType (formal))))) || ((M2System_IsGenericSystemType (formal)) && (IsSizeSame (FindMetaType (actual), FindMetaType (formal))))) || (M2System_IsSameSizePervasiveType (formal, actual));
2205 : }
2206 : /* static analysis guarentees a RETURN statement will be used before here. */
2207 : __builtin_unreachable ();
2208 : }
2209 :
2210 :
2211 : /*
2212 : IsArrayUnboundedCompatible - returns TRUE if unbounded or array types, t1, and, t2,
2213 : are compatible.
2214 : */
2215 :
2216 0 : static bool IsArrayUnboundedCompatible (unsigned int t1, unsigned int t2)
2217 : {
2218 0 : if ((t1 == SymbolTable_NulSym) || (t2 == SymbolTable_NulSym))
2219 : {
2220 : return false;
2221 : }
2222 0 : else if (((SymbolTable_IsUnbounded (t1)) || (SymbolTable_IsArray (t1))) && ((SymbolTable_IsUnbounded (t2)) || (SymbolTable_IsArray (t2))))
2223 : {
2224 : /* avoid dangling else. */
2225 0 : return (SymbolTable_SkipType (SymbolTable_GetType (t1))) == (SymbolTable_SkipType (SymbolTable_GetType (t2)));
2226 : }
2227 : else
2228 : {
2229 : /* avoid dangling else. */
2230 : return false;
2231 : }
2232 : /* static analysis guarentees a RETURN statement will be used before here. */
2233 : __builtin_unreachable ();
2234 : }
2235 :
2236 :
2237 : /*
2238 : IsValidUnboundedParameter -
2239 : */
2240 :
2241 0 : static bool IsValidUnboundedParameter (unsigned int formal, unsigned int actual)
2242 : {
2243 0 : unsigned int ft;
2244 0 : unsigned int at;
2245 0 : unsigned int n;
2246 0 : unsigned int m;
2247 0 : unsigned int o;
2248 :
2249 0 : M2Debug_Assert (SymbolTable_IsParameterUnbounded (formal));
2250 0 : ft = SymbolTable_SkipType (SymbolTable_GetType (SymbolTable_GetType (formal))); /* ARRAY OF ft */
2251 0 : if ((M2System_IsGenericSystemType (ft)) || (IsArrayUnboundedCompatible (SymbolTable_GetType (formal), SymbolTable_GetType (actual)))) /* ARRAY OF ft */
2252 : {
2253 : return true;
2254 : }
2255 : else
2256 : {
2257 0 : if ((SymbolTable_IsParameter (actual)) && (SymbolTable_IsParameterUnbounded (actual)))
2258 : {
2259 0 : n = SymbolTable_GetDimension (actual);
2260 0 : m = SymbolTable_GetDimension (formal);
2261 0 : if (n != m)
2262 : {
2263 0 : return (M2System_IsGenericSystemType (ft)) && (n < m);
2264 : }
2265 : else
2266 : {
2267 0 : return ((SymbolTable_GetDimension (actual)) == (SymbolTable_GetDimension (formal))) && (M2Base_IsParameterCompatible (SymbolTable_GetType (SymbolTable_GetType (actual)), ft));
2268 : }
2269 : }
2270 : else
2271 : {
2272 0 : if (SymbolTable_IsConstString (actual))
2273 : {
2274 0 : return M2Base_IsParameterCompatible (M2Base_Char, ft);
2275 : }
2276 : else
2277 : {
2278 0 : at = SymbolTable_SkipType (SymbolTable_GetType (actual));
2279 0 : if (SymbolTable_IsArray (at))
2280 : {
2281 0 : m = SymbolTable_GetDimension (formal);
2282 0 : n = SymbolTable_GetDimension (at);
2283 0 : o = 0;
2284 0 : while (SymbolTable_IsArray (at))
2285 : {
2286 0 : o += 1;
2287 0 : at = SymbolTable_SkipType (SymbolTable_GetType (at));
2288 0 : if ((m == o) && (at == ft))
2289 : {
2290 : return true;
2291 : }
2292 : }
2293 0 : if (n != m)
2294 : {
2295 0 : return (M2System_IsGenericSystemType (ft)) && (n < m);
2296 : }
2297 0 : else if (SymbolTable_IsParameterVar (formal))
2298 : {
2299 : /* avoid dangling else. */
2300 0 : return IsVarParamCompatible (at, formal);
2301 : }
2302 : else
2303 : {
2304 : /* avoid dangling else. */
2305 0 : return M2Base_IsParameterCompatible (at, ft);
2306 : }
2307 : }
2308 : else
2309 : {
2310 0 : if (SymbolTable_IsParameterVar (formal))
2311 : {
2312 0 : return IsVarParamCompatible (at, formal);
2313 : }
2314 : else
2315 : {
2316 0 : return M2Base_IsParameterCompatible (at, ft);
2317 : }
2318 : }
2319 : }
2320 : }
2321 : }
2322 : /* static analysis guarentees a RETURN statement will be used before here. */
2323 : __builtin_unreachable ();
2324 : }
2325 :
2326 :
2327 : /*
2328 : PushSizeOf - pushes the size of a meta type.
2329 : */
2330 :
2331 2673760 : static void PushSizeOf (M2Base_MetaType t)
2332 : {
2333 2673760 : switch (t)
2334 : {
2335 0 : case M2Base_const:
2336 0 : M2Error_InternalError ((const char *) "do not know the size of a constant", 34);
2337 657720 : break;
2338 :
2339 657720 : case M2Base_word:
2340 657720 : if (M2Options_Iso)
2341 : {
2342 169518 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetISOWordType ()));
2343 : }
2344 : else
2345 : {
2346 488202 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetWordType ()));
2347 : }
2348 : break;
2349 :
2350 679160 : case M2Base_byte:
2351 679160 : if (M2Options_Iso)
2352 : {
2353 178440 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetISOByteType ()));
2354 : }
2355 : else
2356 : {
2357 500720 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetByteType ()));
2358 : }
2359 : break;
2360 :
2361 33958 : case M2Base_address:
2362 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetPointerType ()));
2363 33958 : break;
2364 :
2365 16979 : case M2Base_chr:
2366 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2CharType ()));
2367 16979 : break;
2368 :
2369 16979 : case M2Base_normint:
2370 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2IntegerType ()));
2371 16979 : break;
2372 :
2373 33958 : case M2Base_shortint:
2374 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2ShortIntType ()));
2375 33958 : break;
2376 :
2377 33958 : case M2Base_longint:
2378 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2LongIntType ()));
2379 33958 : break;
2380 :
2381 16979 : case M2Base_normcard:
2382 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2CardinalType ()));
2383 16979 : break;
2384 :
2385 33958 : case M2Base_shortcard:
2386 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2ShortCardType ()));
2387 33958 : break;
2388 :
2389 33958 : case M2Base_longcard:
2390 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2LongCardType ()));
2391 33958 : break;
2392 :
2393 33958 : case M2Base_pointer:
2394 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetPointerType ()));
2395 33958 : break;
2396 :
2397 16979 : case M2Base_enum:
2398 16979 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetIntegerType ()));
2399 16979 : break;
2400 :
2401 33958 : case M2Base_real:
2402 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2RealType ()));
2403 33958 : break;
2404 :
2405 33958 : case M2Base_shortreal:
2406 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2ShortRealType ()));
2407 33958 : break;
2408 :
2409 33958 : case M2Base_longreal:
2410 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2LongRealType ()));
2411 33958 : break;
2412 :
2413 0 : case M2Base_set:
2414 0 : M2Error_InternalError ((const char *) "do not know the size of a set", 29);
2415 0 : break;
2416 :
2417 0 : case M2Base_opaque:
2418 0 : M2Error_InternalError ((const char *) "do not know the size of an opaque", 33);
2419 50937 : break;
2420 :
2421 50937 : case M2Base_loc:
2422 50937 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetISOLocType ()));
2423 50937 : break;
2424 :
2425 46476 : case M2Base_rtype:
2426 46476 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2RType ()));
2427 46476 : break;
2428 :
2429 0 : case M2Base_ztype:
2430 0 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2ZType ()));
2431 0 : break;
2432 :
2433 118853 : case M2Base_int8:
2434 118853 : case M2Base_card8:
2435 118853 : case M2Base_set8:
2436 118853 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (1));
2437 118853 : break;
2438 :
2439 135832 : case M2Base_word16:
2440 135832 : case M2Base_set16:
2441 135832 : case M2Base_card16:
2442 135832 : case M2Base_int16:
2443 135832 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (2));
2444 135832 : break;
2445 :
2446 169790 : case M2Base_real32:
2447 169790 : case M2Base_word32:
2448 169790 : case M2Base_set32:
2449 169790 : case M2Base_card32:
2450 169790 : case M2Base_int32:
2451 169790 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (4));
2452 169790 : break;
2453 :
2454 135832 : case M2Base_real64:
2455 135832 : case M2Base_word64:
2456 135832 : case M2Base_card64:
2457 135832 : case M2Base_int64:
2458 135832 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (8));
2459 135832 : break;
2460 :
2461 33958 : case M2Base_real96:
2462 33958 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (12));
2463 33958 : break;
2464 :
2465 33958 : case M2Base_real128:
2466 33958 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (16));
2467 33958 : break;
2468 :
2469 33958 : case M2Base_complex:
2470 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2ComplexType ()));
2471 33958 : break;
2472 :
2473 33958 : case M2Base_shortcomplex:
2474 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2ShortComplexType ()));
2475 33958 : break;
2476 :
2477 33958 : case M2Base_longcomplex:
2478 33958 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2LongComplexType ()));
2479 33958 : break;
2480 :
2481 33958 : case M2Base_complex32:
2482 33958 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (4*2));
2483 33958 : break;
2484 :
2485 33958 : case M2Base_complex64:
2486 33958 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (8*2));
2487 33958 : break;
2488 :
2489 33958 : case M2Base_complex96:
2490 33958 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (12*2));
2491 33958 : break;
2492 :
2493 33958 : case M2Base_complex128:
2494 33958 : M2ALU_PushIntegerTree (m2decl_BuildIntegerConstant (16*2));
2495 33958 : break;
2496 :
2497 0 : case M2Base_ctype:
2498 0 : M2ALU_PushIntegerTree (m2expr_GetSizeOf (m2linemap_BuiltinsLocation (), m2type_GetM2CType ()));
2499 0 : break;
2500 :
2501 0 : case M2Base_unknown:
2502 0 : M2Error_InternalError ((const char *) "should not get here", 19);
2503 0 : break;
2504 :
2505 :
2506 0 : default:
2507 0 : M2Error_InternalError ((const char *) "should not get here", 19);
2508 2673760 : break;
2509 : }
2510 2673760 : }
2511 :
2512 :
2513 : /*
2514 : IsSizeSame -
2515 : */
2516 :
2517 1336880 : static bool IsSizeSame (M2Base_MetaType t1, M2Base_MetaType t2)
2518 : {
2519 1336880 : PushSizeOf (t1);
2520 1336880 : PushSizeOf (t2);
2521 1336880 : return M2ALU_Equ (0);
2522 : /* static analysis guarentees a RETURN statement will be used before here. */
2523 : __builtin_unreachable ();
2524 : }
2525 :
2526 :
2527 : /*
2528 : InitArray -
2529 : */
2530 :
2531 2546850 : static void InitArray (M2Base_CompatibilityArray *c, M2Base_MetaType y, const char *a_, unsigned int _a_high)
2532 : {
2533 2546850 : M2Base_MetaType x;
2534 2546850 : unsigned int h;
2535 2546850 : unsigned int i;
2536 2546850 : char a[_a_high+1];
2537 :
2538 : /* make a local copy of each unbounded array. */
2539 2546850 : memcpy (a, a_, _a_high+1);
2540 :
2541 2546850 : h = StrLib_StrLen ((const char *) a, _a_high);
2542 2546850 : i = 0;
2543 2546850 : x = M2Base_const;
2544 254685000 : while (i < h)
2545 : {
2546 252138150 : if ((((*c).array[x-M2Base_const].array[y-M2Base_const] != M2Base_uninitialized) && (x != M2Base_unknown)) && (y != M2Base_unknown))
2547 : {
2548 0 : M2Error_InternalError ((const char *) "expecting array element to be uninitialized", 43);
2549 : }
2550 252138150 : switch (a[i])
2551 : {
2552 : case ' ':
2553 : break;
2554 :
2555 62397825 : case '.':
2556 62397825 : switch ((*c).array[y-M2Base_const].array[x-M2Base_const])
2557 : {
2558 0 : case M2Base_uninitialized:
2559 0 : M2Error_InternalError ((const char *) "cannot reflect value as it is unknown", 37);
2560 5229532 : break;
2561 :
2562 5229532 : case M2Base_first:
2563 5229532 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_second;
2564 5229532 : break;
2565 :
2566 729864 : case M2Base_second:
2567 729864 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_first;
2568 729864 : break;
2569 :
2570 0 : case M2Base_warnfirst:
2571 0 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_warnsecond;
2572 0 : break;
2573 :
2574 0 : case M2Base_warnsecond:
2575 0 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_warnfirst;
2576 0 : break;
2577 :
2578 :
2579 56438429 : default:
2580 56438429 : (*c).array[x-M2Base_const].array[y-M2Base_const] = (*c).array[y-M2Base_const].array[x-M2Base_const];
2581 56438429 : break;
2582 : }
2583 62397825 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2584 62397825 : break;
2585 :
2586 55470393 : case 'F':
2587 55470393 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2588 55470393 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2589 55470393 : break;
2590 :
2591 7572634 : case 'T':
2592 7572634 : case '1':
2593 7572634 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_first;
2594 7572634 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2595 7572634 : break;
2596 :
2597 492391 : case '2':
2598 492391 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_second;
2599 492391 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2600 492391 : break;
2601 :
2602 16979 : case 'W':
2603 16979 : if (M2Options_Pim)
2604 : {
2605 12518 : if (IsSizeSame (x, y))
2606 : {
2607 0 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_warnsecond;
2608 : }
2609 : else
2610 : {
2611 12518 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2612 : }
2613 : }
2614 : else
2615 : {
2616 4461 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2617 : }
2618 16979 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2619 16979 : break;
2620 :
2621 0 : case 'w':
2622 0 : if (M2Options_Pim)
2623 : {
2624 0 : if (IsSizeSame (x, y))
2625 : {
2626 0 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_warnfirst;
2627 : }
2628 : else
2629 : {
2630 0 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2631 : }
2632 : }
2633 : else
2634 : {
2635 0 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2636 : }
2637 0 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2638 0 : break;
2639 :
2640 67916 : case 'P':
2641 67916 : if (M2Options_Pim)
2642 : {
2643 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_second;
2644 : }
2645 : else
2646 : {
2647 17844 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2648 : }
2649 67916 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2650 67916 : break;
2651 :
2652 0 : case 'p':
2653 0 : if (M2Options_Pim)
2654 : {
2655 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_first;
2656 : }
2657 : else
2658 : {
2659 0 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2660 : }
2661 0 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2662 0 : break;
2663 :
2664 0 : case 's':
2665 0 : if (IsSizeSame (x, y))
2666 : {
2667 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_first;
2668 : }
2669 : else
2670 : {
2671 0 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2672 : }
2673 0 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2674 0 : break;
2675 :
2676 1324362 : case 'S':
2677 1324362 : if (IsSizeSame (x, y))
2678 : {
2679 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_second;
2680 : }
2681 : else
2682 : {
2683 1136961 : (*c).array[x-M2Base_const].array[y-M2Base_const] = M2Base_no;
2684 : }
2685 1324362 : x = static_cast<M2Base_MetaType>(static_cast<int>(x)+1);
2686 1324362 : break;
2687 :
2688 :
2689 0 : default:
2690 0 : M2Error_InternalError ((const char *) "unexpected specifier", 20);
2691 252138150 : break;
2692 : }
2693 252138150 : i += 1;
2694 : }
2695 2546850 : }
2696 :
2697 :
2698 : /*
2699 : A - initialize the assignment array
2700 : */
2701 :
2702 848950 : static void A (M2Base_MetaType y, const char *a_, unsigned int _a_high)
2703 : {
2704 848950 : char a[_a_high+1];
2705 :
2706 : /* make a local copy of each unbounded array. */
2707 848950 : memcpy (a, a_, _a_high+1);
2708 :
2709 848950 : InitArray (&Ass, y, (const char *) a, _a_high);
2710 848950 : }
2711 :
2712 :
2713 : /*
2714 : E - initialize the expression array
2715 : */
2716 :
2717 848950 : static void E (M2Base_MetaType y, const char *a_, unsigned int _a_high)
2718 : {
2719 848950 : char a[_a_high+1];
2720 :
2721 : /* make a local copy of each unbounded array. */
2722 848950 : memcpy (a, a_, _a_high+1);
2723 :
2724 848950 : InitArray (&Expr, y, (const char *) a, _a_high);
2725 848950 : }
2726 :
2727 :
2728 : /*
2729 : C - initialize the comparision array
2730 : */
2731 :
2732 848950 : static void C (M2Base_MetaType y, const char *a_, unsigned int _a_high)
2733 : {
2734 848950 : char a[_a_high+1];
2735 :
2736 : /* make a local copy of each unbounded array. */
2737 848950 : memcpy (a, a_, _a_high+1);
2738 :
2739 848950 : InitArray (&Comp, y, (const char *) a, _a_high);
2740 848950 : }
2741 :
2742 :
2743 : /*
2744 : InitCompatibilityMatrices - initializes the tables above.
2745 : */
2746 :
2747 16979 : static void InitCompatibilityMatrices (void)
2748 : {
2749 16979 : M2Base_MetaType i;
2750 16979 : M2Base_MetaType j;
2751 :
2752 882908 : for (i=M2Base_const; i<=M2Base_unknown; i= static_cast<M2Base_MetaType>(static_cast<int>(i+1)))
2753 : {
2754 45028308 : for (j=M2Base_const; j<=M2Base_unknown; j= static_cast<M2Base_MetaType>(static_cast<int>(j+1)))
2755 : {
2756 : /* initialize to a known state */
2757 44162379 : Ass.array[i-M2Base_const].array[j-M2Base_const] = M2Base_uninitialized;
2758 44162379 : Expr.array[i-M2Base_const].array[j-M2Base_const] = M2Base_uninitialized;
2759 : }
2760 : }
2761 882908 : for (i=M2Base_const; i<=M2Base_unknown; i= static_cast<M2Base_MetaType>(static_cast<int>(i+1)))
2762 : {
2763 : /* all unknowns are false */
2764 865929 : Ass.array[i-M2Base_const].array[M2Base_unknown-M2Base_const] = M2Base_no;
2765 865929 : Expr.array[M2Base_unknown-M2Base_const].array[i-M2Base_const] = M2Base_no;
2766 : }
2767 : /*
2768 : 1 p w
2769 :
2770 : C W B A C I S L C S L P E R S L S O L R Z I I I I C C C C W W W R R R R S S S C S L C C C C C R A P
2771 : o o y d h n h o a h o t n e h o e p o t t n n n n a a a a o o o e e e e e e e o h o o o o o t e r r
2772 : n r t d a t o n r o n r u a o n t a c y y t t t t r r r r r r r a a a a t t t m o n m m m m y c r o
2773 : s d e r r e r g d r g m l r g q p p 8 1 3 6 d d d d d d d l l l l 8 1 3 p r g p p p p p a c
2774 : t e g t i i t c t r u e e 6 2 4 8 1 3 6 1 3 6 3 6 9 1 6 2 l t C l l l l e y
2775 : s e i n n c a r e e 6 2 4 6 2 4 2 4 6 2 e C o e e e e
2776 : s r n t a a r e a 8 x o m x x x x
2777 : t l r d a l m p 3 6 9 1
2778 : d l p l 2 4 6 2
2779 : l e 8
2780 : e x
2781 : x
2782 : --------------------------------------------------------------------------------------------------------------
2783 : 2
2784 : P
2785 : W
2786 : */
2787 16979 : A (M2Base_const, (const char *) "T T T T T T T T T T T T T T T T T T T F T T T T T T T T T T T T F F F F F F F F F F F F F F F F F F", 99);
2788 16979 : A (M2Base_word, (const char *) ". T S S S 2 S S 2 S S S 2 S S S T T S S T S S S S S S S S S S S S S S S S S S S S S S S S S T T T F", 99);
2789 16979 : A (M2Base_byte, (const char *) ". . T S 2 S S S S S S S S S S S T T S S T S S S S S S S S S S S S S S S S S S S S S S S S S T T T F", 99);
2790 16979 : A (M2Base_address, (const char *) ". . . T F F F F P F F 2 F F F F F 2 2 F T F F F F F F F F F F F F F F F F F F F F F F F F F F F F T", 99);
2791 16979 : A (M2Base_chr, (const char *) ". . . . T F F F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2792 16979 : A (M2Base_normint, (const char *) ". . . . . T T T T T T F F F F F F F F F T T T T T T T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2793 16979 : A (M2Base_shortint, (const char *) ". . . . . . T T T T T F F F F F F F F F T T T T T T T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2794 16979 : A (M2Base_longint, (const char *) ". . . . . . . T T T T F F F F F F F F F T T T T T T T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2795 16979 : A (M2Base_normcard, (const char *) ". . . . . . . . T T T F F F F F F F F F T T T T T T T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2796 16979 : A (M2Base_shortcard, (const char *) ". . . . . . . . . T T F F F F F F F F F T T T T T T T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2797 16979 : A (M2Base_longcard, (const char *) ". . . . . . . . . . T F F F F F F F F F T T T T T T T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2798 16979 : A (M2Base_pointer, (const char *) ". . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2799 16979 : A (M2Base_enum, (const char *) ". . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F T T F F F F F F F F F F F F F F F F", 99);
2800 16979 : A (M2Base_real, (const char *) ". . . . . . . . . . . . . T T T F F F 2 F F F F F F F F F F F F T T T T F F F F F F F F F F F F F F", 99);
2801 16979 : A (M2Base_shortreal, (const char *) ". . . . . . . . . . . . . . T T F F F 2 F F F F F F F F F F F F T T T T F F F F F F F F F F F F F F", 99);
2802 16979 : A (M2Base_longreal, (const char *) ". . . . . . . . . . . . . . . T F F F 2 F F F F F F F F F F F F T T T T F F F F F F F F F F F F F F", 99);
2803 16979 : A (M2Base_set, (const char *) ". . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2804 16979 : A (M2Base_opaque, (const char *) ". . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2805 16979 : A (M2Base_loc, (const char *) ". . . . . . . . . . . . . . . . . . T F F T F F F T F F F F F F F F F F S F F F F F F F F F F T T F", 99);
2806 16979 : A (M2Base_rtype, (const char *) ". . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F 1 1 1 1 F F F F F F F F F F F F F F", 99);
2807 16979 : A (M2Base_ztype, (const char *) ". . . . . . . . . . . . . . . . . . . . T T T T T T T T T T T T F F F F F F F F F F F F F F F F F F", 99);
2808 16979 : A (M2Base_int8, (const char *) ". . . . . . . . . . . . . . . . . . . . . T T T T T T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2809 16979 : A (M2Base_int16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . T T T T T T T T F F F F F F F F F F F F F F F F F F F F", 99);
2810 16979 : A (M2Base_int32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . T T T T T T F T T F F F F F F F F F F F F F F F F F F", 99);
2811 16979 : A (M2Base_int64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . T T T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2812 16979 : A (M2Base_card8, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . T T T T T F F F F F F F F F F F F F F F F F F F F", 99);
2813 16979 : A (M2Base_card16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . T T T F F F F F F F F F F F F F F F F F F F F F", 99);
2814 16979 : A (M2Base_card32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . T T F T F F F F F F F F F F F F F F F F F F F", 99);
2815 16979 : A (M2Base_card64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F T F F F F F F F F F F F F F F F F F F", 99);
2816 16979 : A (M2Base_word16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F", 99);
2817 16979 : A (M2Base_word32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F F F F F F F F F F F F F F F", 99);
2818 16979 : A (M2Base_word64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F F F F F F F F F F F F F F", 99);
2819 16979 : A (M2Base_real32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F", 99);
2820 16979 : A (M2Base_real64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F", 99);
2821 16979 : A (M2Base_real96, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F", 99);
2822 16979 : A (M2Base_real128, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F", 99);
2823 16979 : A (M2Base_set8, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F", 99);
2824 16979 : A (M2Base_set16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F", 99);
2825 16979 : A (M2Base_set32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F", 99);
2826 16979 : A (M2Base_complex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F T F F F", 99);
2827 16979 : A (M2Base_shortcomplex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F T F F F", 99);
2828 16979 : A (M2Base_longcomplex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F T F F F", 99);
2829 16979 : A (M2Base_complex32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F T F F F", 99);
2830 16979 : A (M2Base_complex64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F T F F F", 99);
2831 16979 : A (M2Base_complex96, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F", 99);
2832 16979 : A (M2Base_complex128, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T F F F", 99);
2833 16979 : A (M2Base_ctype, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F", 99);
2834 16979 : A (M2Base_rec, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F", 99);
2835 16979 : A (M2Base_array, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F", 99);
2836 16979 : A (M2Base_procedure, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T", 99);
2837 : /*
2838 : 1 p w
2839 :
2840 : C W B A C I S L C S L P E R S L S O L R Z I I I I C C C C W W W R R R R S S S C S L C C C C C R A P
2841 : o o y d h n h o a h o t n e h o e p o t t n n n n a a a a o o o e e e e e e e o h o o o o o t e r r
2842 : n r t d a t o n r o n r u a o n t a c y y t t t t r r r r r r r a a a a t t t m o n m m m m y c r o
2843 : s d e r r e r g d r g m l r g q p p 8 1 3 6 d d d d d d d l l l l 8 1 3 p r g p p p p p a c
2844 : t e g t i i t c t r u e e 6 2 4 8 1 3 6 1 3 6 3 6 9 1 6 2 l t C l l l l e y
2845 : s e i n n c a r e e 6 2 4 6 2 4 2 4 6 2 e C o e e e e
2846 : s r n t a a r e a 8 x o m x x x x
2847 : t l r d a l m p 3 6 9 1
2848 : d l p l 2 4 6 2
2849 : l e 8
2850 : e x
2851 : x
2852 : ------------------------------------------------------------------------------------------------------------
2853 : 2
2854 : P
2855 : W
2856 : */
2857 16979 : E (M2Base_const, (const char *) "T T T T T T T T T T T T T T T T T T F F T T T T T T T T T T T T T T T T F F F F F F F F F F F F F F", 99);
2858 16979 : E (M2Base_word, (const char *) ". T F F F F F F F F F F F F F F F F F W F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2859 16979 : E (M2Base_byte, (const char *) ". . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2860 16979 : E (M2Base_address, (const char *) ". . . T F P F F P F F T F F F F F F F F P F F F F F F F F F F F F F F F F F F F F F F F F F F F F T", 99);
2861 16979 : E (M2Base_chr, (const char *) ". . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2862 16979 : E (M2Base_normint, (const char *) ". . . . . T F F F F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2863 16979 : E (M2Base_shortint, (const char *) ". . . . . . T F F F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2864 16979 : E (M2Base_longint, (const char *) ". . . . . . . T F F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2865 16979 : E (M2Base_normcard, (const char *) ". . . . . . . . T F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2866 16979 : E (M2Base_shortcard, (const char *) ". . . . . . . . . T F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2867 16979 : E (M2Base_longcard, (const char *) ". . . . . . . . . . T F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2868 16979 : E (M2Base_pointer, (const char *) ". . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2869 16979 : E (M2Base_enum, (const char *) ". . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2870 16979 : E (M2Base_real, (const char *) ". . . . . . . . . . . . . T F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2871 16979 : E (M2Base_shortreal, (const char *) ". . . . . . . . . . . . . . T F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2872 16979 : E (M2Base_longreal, (const char *) ". . . . . . . . . . . . . . . T F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2873 16979 : E (M2Base_set, (const char *) ". . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2874 16979 : E (M2Base_opaque, (const char *) ". . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2875 16979 : E (M2Base_loc, (const char *) ". . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2876 16979 : E (M2Base_rtype, (const char *) ". . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F 1 1 1 1 F F F F F F F F F F F F F F", 99);
2877 16979 : E (M2Base_ztype, (const char *) ". . . . . . . . . . . . . . . . . . . . T 1 1 1 1 1 1 1 1 1 1 1 F F F F F F F F F F F F F F F F F F", 99);
2878 16979 : E (M2Base_int8, (const char *) ". . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2879 16979 : E (M2Base_int16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2880 16979 : E (M2Base_int32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2881 16979 : E (M2Base_int64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2882 16979 : E (M2Base_card8, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2883 16979 : E (M2Base_card16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F", 99);
2884 16979 : E (M2Base_card32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F", 99);
2885 16979 : E (M2Base_card64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F", 99);
2886 16979 : E (M2Base_word16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F F", 99);
2887 16979 : E (M2Base_word32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F", 99);
2888 16979 : E (M2Base_word64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F", 99);
2889 16979 : E (M2Base_real32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F", 99);
2890 16979 : E (M2Base_real64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F", 99);
2891 16979 : E (M2Base_real96, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F", 99);
2892 16979 : E (M2Base_real128, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F", 99);
2893 16979 : E (M2Base_set8, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F", 99);
2894 16979 : E (M2Base_set16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F", 99);
2895 16979 : E (M2Base_set32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F", 99);
2896 16979 : E (M2Base_complex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F T F F F", 99);
2897 16979 : E (M2Base_shortcomplex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F T F F F", 99);
2898 16979 : E (M2Base_longcomplex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F T F F F", 99);
2899 16979 : E (M2Base_complex32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F T F F F", 99);
2900 16979 : E (M2Base_complex64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F T F F F", 99);
2901 16979 : E (M2Base_complex96, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F", 99);
2902 16979 : E (M2Base_complex128, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T F F F", 99);
2903 16979 : E (M2Base_ctype, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F", 99);
2904 16979 : E (M2Base_rec, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F", 99);
2905 16979 : E (M2Base_array, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F", 99);
2906 16979 : E (M2Base_procedure, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T", 99);
2907 : /*
2908 : 1 p w
2909 :
2910 : C W B A C I S L C S L P E R S L S O L R Z I I I I C C C C W W W R R R R S S S C S L C C C C C R A P
2911 : o o y d h n h o a h o t n e h o e p o t t n n n n a a a a o o o e e e e e e e o h o o o o o t e r r
2912 : n r t d a t o n r o n r u a o n t a c y y t t t t r r r r r r r a a a a t t t m o n m m m m y c r o
2913 : s d e r r e r g d r g m l r g q p p 8 1 3 6 d d d d d d d l l l l 8 1 3 p r g p p p p p a c
2914 : t e g t i i t c t r u e e 6 2 4 8 1 3 6 1 3 6 3 6 9 1 6 2 l t C l l l l e y
2915 : s e i n n c a r e e 6 2 4 6 2 4 2 4 6 2 e C o e e e e
2916 : s r n t a a r e a 8 x o m x x x x
2917 : t l r d a l m p 3 6 9 1
2918 : d l p l 2 4 6 2
2919 : l e 8
2920 : e x
2921 : x
2922 : ------------------------------------------------------------------------------------------------------------
2923 : 2
2924 : P
2925 : W
2926 : */
2927 16979 : C (M2Base_const, (const char *) "T T T T T T T T T T T T T T T T T T F F T T T T T T T T T T T T T T T T F F F F F F F F F F F F F F", 99);
2928 16979 : C (M2Base_word, (const char *) ". T F F F F F F F F F F F F F F F F F F T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2929 16979 : C (M2Base_byte, (const char *) ". . T F F F F F F F F F F F F F F F F F T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2930 16979 : C (M2Base_address, (const char *) ". . . T F F F F F F F T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F T", 99);
2931 16979 : C (M2Base_chr, (const char *) ". . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2932 16979 : C (M2Base_normint, (const char *) ". . . . . T F F F F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2933 16979 : C (M2Base_shortint, (const char *) ". . . . . . T F F F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2934 16979 : C (M2Base_longint, (const char *) ". . . . . . . T F F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2935 16979 : C (M2Base_normcard, (const char *) ". . . . . . . . T F F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2936 16979 : C (M2Base_shortcard, (const char *) ". . . . . . . . . T F F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2937 16979 : C (M2Base_longcard, (const char *) ". . . . . . . . . . T F F F F F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2938 16979 : C (M2Base_pointer, (const char *) ". . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2939 16979 : C (M2Base_enum, (const char *) ". . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2940 16979 : C (M2Base_real, (const char *) ". . . . . . . . . . . . . T F F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2941 16979 : C (M2Base_shortreal, (const char *) ". . . . . . . . . . . . . . T F F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2942 16979 : C (M2Base_longreal, (const char *) ". . . . . . . . . . . . . . . T F F F 2 F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2943 16979 : C (M2Base_set, (const char *) ". . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2944 16979 : C (M2Base_opaque, (const char *) ". . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2945 16979 : C (M2Base_loc, (const char *) ". . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2946 16979 : C (M2Base_rtype, (const char *) ". . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F 1 1 1 1 F F F F F F F F F F F F F F", 99);
2947 16979 : C (M2Base_ztype, (const char *) ". . . . . . . . . . . . . . . . . . . . T 1 1 1 1 1 1 1 1 1 1 1 F F F F F F F F F F F F F F F F F F", 99);
2948 16979 : C (M2Base_int8, (const char *) ". . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2949 16979 : C (M2Base_int16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2950 16979 : C (M2Base_int32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2951 16979 : C (M2Base_int64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2952 16979 : C (M2Base_card8, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F F", 99);
2953 16979 : C (M2Base_card16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F", 99);
2954 16979 : C (M2Base_card32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F", 99);
2955 16979 : C (M2Base_card64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F", 99);
2956 16979 : C (M2Base_word16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F F", 99);
2957 16979 : C (M2Base_word32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F", 99);
2958 16979 : C (M2Base_word64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F", 99);
2959 16979 : C (M2Base_real32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F", 99);
2960 16979 : C (M2Base_real64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F", 99);
2961 16979 : C (M2Base_real96, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F", 99);
2962 16979 : C (M2Base_real128, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F", 99);
2963 16979 : C (M2Base_set8, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F", 99);
2964 16979 : C (M2Base_set16, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F", 99);
2965 16979 : C (M2Base_set32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F", 99);
2966 16979 : C (M2Base_complex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F T F F F", 99);
2967 16979 : C (M2Base_shortcomplex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F T F F F", 99);
2968 16979 : C (M2Base_longcomplex, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F T F F F", 99);
2969 16979 : C (M2Base_complex32, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F T F F F", 99);
2970 16979 : C (M2Base_complex64, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F T F F F", 99);
2971 16979 : C (M2Base_complex96, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F", 99);
2972 16979 : C (M2Base_complex128, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T F F F", 99);
2973 16979 : C (M2Base_ctype, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F", 99);
2974 16979 : C (M2Base_rec, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F", 99);
2975 16979 : C (M2Base_array, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F", 99);
2976 16979 : C (M2Base_procedure, (const char *) ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T", 99);
2977 16979 : }
2978 :
2979 :
2980 : /*
2981 : InitBase - initializes the base types and procedures
2982 : used in the Modula-2 compiler.
2983 : */
2984 :
2985 16979 : extern "C" void M2Base_InitBase (location_t location, unsigned int *sym)
2986 : {
2987 16979 : (*sym) = SymbolTable_MakeModule (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "_BaseTypes", 10));
2988 16979 : SymbolTable_PutModuleBuiltin ((*sym), true);
2989 16979 : SymbolTable_SetCurrentModule ((*sym));
2990 16979 : SymbolTable_StartScope ((*sym));
2991 16979 : InitBaseSimpleTypes (location);
2992 : /* Initialize the SYSTEM module before we ADDRESS. */
2993 16979 : M2System_InitSystem ();
2994 16979 : M2Bitset_MakeBitset (); /* We do this after SYSTEM has been created as BITSET
2995 : is dependant upon WORD and BOOLEAN. */
2996 16979 : InitBaseConstants (); /* We do this after SYSTEM has been created as BITSET
2997 : is dependant upon WORD and BOOLEAN. */
2998 16979 : InitBaseFunctions ();
2999 16979 : InitBaseProcedures ();
3000 : /*
3001 : Note: that we do end the Scope since we keep the symbol to the head
3002 : of the base scope. This head of base scope is searched
3003 : when all other scopes fail to deliver a symbol.
3004 : */
3005 16979 : SymbolTable_EndScope ();
3006 16979 : InitBuiltins ();
3007 16979 : InitCompatibilityMatrices ();
3008 16979 : }
3009 :
3010 :
3011 : /*
3012 : GetBaseTypeMinMax - returns the minimum and maximum values for a
3013 : given base type. This procedure should only
3014 : be called if the type is NOT a subrange.
3015 : */
3016 :
3017 133413 : extern "C" void M2Base_GetBaseTypeMinMax (unsigned int type, unsigned int *min, unsigned int *max)
3018 : {
3019 133413 : if (type == M2Base_Integer)
3020 : {
3021 538 : (*min) = MinInteger;
3022 538 : (*max) = MaxInteger;
3023 : }
3024 132875 : else if (type == M2Base_Cardinal)
3025 : {
3026 : /* avoid dangling else. */
3027 11160 : (*min) = MinCardinal;
3028 11160 : (*max) = MaxCardinal;
3029 : }
3030 121715 : else if (type == M2Base_Char)
3031 : {
3032 : /* avoid dangling else. */
3033 23730 : (*min) = MinChar;
3034 23730 : (*max) = MaxChar;
3035 : }
3036 97985 : else if (type == M2Bitset_Bitset)
3037 : {
3038 : /* avoid dangling else. */
3039 0 : M2Bitset_GetBitsetMinMax (min, max);
3040 : }
3041 97985 : else if (type == M2Base_LongInt)
3042 : {
3043 : /* avoid dangling else. */
3044 384 : (*min) = MinLongInt;
3045 384 : (*max) = MaxLongInt;
3046 : }
3047 97601 : else if (type == M2Base_LongCard)
3048 : {
3049 : /* avoid dangling else. */
3050 38 : (*min) = MinLongCard;
3051 38 : (*max) = MaxLongCard;
3052 : }
3053 97563 : else if (type == M2Base_ShortInt)
3054 : {
3055 : /* avoid dangling else. */
3056 12 : (*min) = MinShortInt;
3057 12 : (*max) = MaxShortInt;
3058 : }
3059 97551 : else if (type == M2Base_ShortCard)
3060 : {
3061 : /* avoid dangling else. */
3062 0 : (*min) = MinShortCard;
3063 0 : (*max) = MaxShortCard;
3064 : }
3065 97551 : else if (type == M2Base_Real)
3066 : {
3067 : /* avoid dangling else. */
3068 78 : (*min) = MinReal;
3069 78 : (*max) = MaxReal;
3070 : }
3071 97473 : else if (type == M2Base_ShortReal)
3072 : {
3073 : /* avoid dangling else. */
3074 12 : (*min) = MinShortReal;
3075 12 : (*max) = MaxShortReal;
3076 : }
3077 97461 : else if (type == M2Base_LongReal)
3078 : {
3079 : /* avoid dangling else. */
3080 12 : (*min) = MinLongReal;
3081 12 : (*max) = MaxLongReal;
3082 : }
3083 97449 : else if (SymbolTable_IsEnumeration (type))
3084 : {
3085 : /* avoid dangling else. */
3086 97449 : MinEnum = SymbolTable_NulSym;
3087 97449 : MaxEnum = SymbolTable_NulSym;
3088 97449 : SymbolTable_ForeachFieldEnumerationDo (type, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) FindMinMaxEnum});
3089 97449 : (*min) = MinEnum;
3090 97449 : (*max) = MaxEnum;
3091 : }
3092 : else
3093 : {
3094 : /* avoid dangling else. */
3095 0 : M2MetaError_MetaError1 ((const char *) "unable to find MIN or MAX for the base type {%1as}", 50, type);
3096 : }
3097 133413 : }
3098 :
3099 :
3100 : /*
3101 : IsPseudoBaseFunction - returns true if Sym is a Base pseudo function.
3102 : */
3103 :
3104 6001512 : extern "C" bool M2Base_IsPseudoBaseFunction (unsigned int Sym)
3105 : {
3106 6001512 : return (((((((((((((Sym == M2Base_High) || (Sym == M2Base_Val)) || (Sym == M2Base_Convert)) || (M2Base_IsOrd (Sym))) || (Sym == M2Base_Chr)) || (M2Base_IsFloat (Sym))) || (M2Base_IsTrunc (Sym))) || (Sym == M2Base_Min)) || (Sym == M2Base_Max)) || (Sym == M2Base_Abs)) || (Sym == M2Base_Odd)) || (Sym == M2Base_Cap)) || (IsISOPseudoBaseFunction (Sym))) || (IsPIMPseudoBaseFunction (Sym));
3107 : /* static analysis guarentees a RETURN statement will be used before here. */
3108 : __builtin_unreachable ();
3109 : }
3110 :
3111 :
3112 : /*
3113 : IsPseudoBaseProcedure - returns true if Sym is a Base pseudo procedure.
3114 : */
3115 :
3116 5995488 : extern "C" bool M2Base_IsPseudoBaseProcedure (unsigned int Sym)
3117 : {
3118 5995488 : return (((((Sym == M2Base_New) || (Sym == M2Base_Dispose)) || (Sym == M2Base_Inc)) || (Sym == M2Base_Dec)) || (Sym == M2Base_Incl)) || (Sym == M2Base_Excl);
3119 : /* static analysis guarentees a RETURN statement will be used before here. */
3120 : __builtin_unreachable ();
3121 : }
3122 :
3123 :
3124 : /*
3125 : IsNeededAtRunTime - returns TRUE if procedure, sym, is a
3126 : runtime procedure. A runtime procedure is
3127 : not a pseudo procedure (like NEW/DISPOSE)
3128 : and it is implemented in M2RTS or SYSTEM
3129 : and also exported.
3130 : */
3131 :
3132 4401815 : extern "C" bool M2Base_IsNeededAtRunTime (unsigned int tok, unsigned int sym)
3133 : {
3134 4401815 : return (((SymbolTable_FromModuleGetSym (tok, SymbolTable_GetSymName (sym), M2System_System)) == sym) || ((SymbolTable_FromModuleGetSym (tok, SymbolTable_GetSymName (sym), m2rts)) == sym)) && ((SymbolTable_IsExportQualified (sym)) || (SymbolTable_IsExportUnQualified (sym)));
3135 : /* static analysis guarentees a RETURN statement will be used before here. */
3136 : __builtin_unreachable ();
3137 : }
3138 :
3139 :
3140 : /*
3141 : IsBaseType - returns TRUE if Sym is a Base type.
3142 : */
3143 :
3144 2640109 : extern "C" bool M2Base_IsBaseType (unsigned int Sym)
3145 : {
3146 2640109 : return (((((((((((((((Sym == M2Base_Cardinal) || (Sym == M2Base_Integer)) || (Sym == M2Base_Boolean)) || (Sym == M2Base_Char)) || (Sym == M2Base_Proc)) || (Sym == M2Base_LongInt)) || (Sym == M2Base_LongCard)) || (Sym == M2Base_ShortInt)) || (Sym == M2Base_ShortCard)) || (Sym == M2Base_Real)) || (Sym == M2Base_LongReal)) || (Sym == M2Base_ShortReal)) || (Sym == M2Base_Complex)) || (Sym == M2Base_LongComplex)) || (Sym == M2Base_ShortComplex)) || (Sym == M2Bitset_Bitset);
3147 : /* static analysis guarentees a RETURN statement will be used before here. */
3148 : __builtin_unreachable ();
3149 : }
3150 :
3151 :
3152 : /*
3153 : IsOrdinalType - returns TRUE if, sym, is an ordinal type.
3154 : An ordinal type is defined as:
3155 : a base type which contains whole numbers or
3156 : a subrange type or an enumeration type.
3157 : */
3158 :
3159 1204218 : extern "C" bool M2Base_IsOrdinalType (unsigned int Sym)
3160 : {
3161 1204218 : return ((((((((((((Sym == M2Base_Cardinal) || (Sym == M2Base_Integer)) || (Sym == M2Base_Char)) || (Sym == M2Base_Boolean)) || (Sym == M2Base_LongInt)) || (Sym == M2Base_LongCard)) || (Sym == M2Base_ShortInt)) || (Sym == M2Base_ShortCard)) || (Sym == M2Base_ZType)) || (SymbolTable_IsSubrange (Sym))) || (SymbolTable_IsEnumeration (Sym))) || (M2System_IsIntegerN (Sym))) || (M2System_IsCardinalN (Sym));
3162 : /* static analysis guarentees a RETURN statement will be used before here. */
3163 : __builtin_unreachable ();
3164 : }
3165 :
3166 :
3167 : /*
3168 : IsOrd - returns TRUE if, sym, is ORD or its typed counterparts
3169 : ORDL, ORDS.
3170 : */
3171 :
3172 5954542 : extern "C" bool M2Base_IsOrd (unsigned int sym)
3173 : {
3174 5954542 : return ((sym == Ord) || (sym == OrdS)) || (sym == OrdL);
3175 : /* static analysis guarentees a RETURN statement will be used before here. */
3176 : __builtin_unreachable ();
3177 : }
3178 :
3179 :
3180 : /*
3181 : IsTrunc - returns TRUE if, sym, is TRUNC or its typed counterparts
3182 : TRUNCL, TRUNCS.
3183 : */
3184 :
3185 5795605 : extern "C" bool M2Base_IsTrunc (unsigned int sym)
3186 : {
3187 5795605 : return ((sym == Trunc) || (sym == TruncS)) || (sym == TruncL);
3188 : /* static analysis guarentees a RETURN statement will be used before here. */
3189 : __builtin_unreachable ();
3190 : }
3191 :
3192 :
3193 : /*
3194 : IsFloat - returns TRUE if, sym, is FLOAT or its typed counterparts
3195 : FLOATL, FLOATS.
3196 : */
3197 :
3198 5877780 : extern "C" bool M2Base_IsFloat (unsigned int sym)
3199 : {
3200 5877780 : return ((((sym == Float) || (sym == FloatS)) || (sym == FloatL)) || (sym == SFloat)) || (sym == LFloat);
3201 : /* static analysis guarentees a RETURN statement will be used before here. */
3202 : __builtin_unreachable ();
3203 : }
3204 :
3205 :
3206 : /*
3207 : IsInt - returns TRUE if, sym, is INT or its typed counterparts
3208 : INTL, INTS.
3209 : */
3210 :
3211 2024109 : extern "C" bool M2Base_IsInt (unsigned int sym)
3212 : {
3213 2024109 : return ((sym == Int) || (sym == IntS)) || (sym == IntL);
3214 : /* static analysis guarentees a RETURN statement will be used before here. */
3215 : __builtin_unreachable ();
3216 : }
3217 :
3218 :
3219 : /*
3220 : AssignmentRequiresWarning - returns TRUE if t1 and t2 can be used during
3221 : an assignment, but should generate a warning.
3222 : For example in PIM we can assign ADDRESS
3223 : and WORD providing they are both the
3224 : same size.
3225 : No warning is necessary if the types are the same.
3226 : */
3227 :
3228 39135 : extern "C" bool M2Base_AssignmentRequiresWarning (unsigned int t1, unsigned int t2)
3229 : {
3230 39135 : return (t1 != t2) && (((IsCompatible (t1, t2, M2Base_assignment)) == M2Base_warnfirst) || ((IsCompatible (t1, t2, M2Base_assignment)) == M2Base_warnsecond));
3231 : /* static analysis guarentees a RETURN statement will be used before here. */
3232 : __builtin_unreachable ();
3233 : }
3234 :
3235 :
3236 : /*
3237 : IsAssignmentCompatible - returns TRUE if t1 and t2 are assignment
3238 : compatible.
3239 : */
3240 :
3241 426587 : extern "C" bool M2Base_IsAssignmentCompatible (unsigned int t1, unsigned int t2)
3242 : {
3243 426587 : return ((t1 == t2) || ((IsCompatible (t1, t2, M2Base_assignment)) == M2Base_first)) || ((IsCompatible (t1, t2, M2Base_assignment)) == M2Base_second);
3244 : /* static analysis guarentees a RETURN statement will be used before here. */
3245 : __builtin_unreachable ();
3246 : }
3247 :
3248 :
3249 : /*
3250 : IsExpressionCompatible - returns TRUE if t1 and t2 are expression
3251 : compatible.
3252 : */
3253 :
3254 78384 : extern "C" bool M2Base_IsExpressionCompatible (unsigned int t1, unsigned int t2)
3255 : {
3256 78384 : return ((IsCompatible (t1, t2, M2Base_expression)) == M2Base_first) || ((IsCompatible (t1, t2, M2Base_expression)) == M2Base_second);
3257 : /* static analysis guarentees a RETURN statement will be used before here. */
3258 : __builtin_unreachable ();
3259 : }
3260 :
3261 :
3262 : /*
3263 : IsParameterCompatible - returns TRUE if t1 and t2 are expression
3264 : compatible.
3265 : */
3266 :
3267 19166 : extern "C" bool M2Base_IsParameterCompatible (unsigned int t1, unsigned int t2)
3268 : {
3269 19166 : return ((IsCompatible (t1, t2, M2Base_parameter)) == M2Base_first) || ((IsCompatible (t1, t2, M2Base_parameter)) == M2Base_second); /* ; tokenNo: CARDINAL */
3270 : /* static analysis guarentees a RETURN statement will be used before here. */
3271 : __builtin_unreachable ();
3272 : }
3273 :
3274 :
3275 : /*
3276 : IsComparisonCompatible - returns TRUE if t1 and t2 are comparison compatible.
3277 : */
3278 :
3279 48830 : extern "C" bool M2Base_IsComparisonCompatible (unsigned int t1, unsigned int t2)
3280 : {
3281 48830 : return ((IsCompatible (t1, t2, M2Base_comparison)) == M2Base_first) || ((IsCompatible (t1, t2, M2Base_comparison)) == M2Base_second); /* ; tokenNo: CARDINAL */
3282 : /* static analysis guarentees a RETURN statement will be used before here. */
3283 : __builtin_unreachable ();
3284 : }
3285 :
3286 :
3287 : /*
3288 : IsValidParameter - returns TRUE if an, actual, parameter can be passed
3289 : to the, formal, parameter. This differs from
3290 : IsParameterCompatible as this procedure includes checks
3291 : for unbounded formal parameters, var parameters and
3292 : constant actual parameters.
3293 : */
3294 :
3295 0 : extern "C" bool M2Base_IsValidParameter (unsigned int formal, unsigned int actual)
3296 : {
3297 0 : unsigned int at;
3298 0 : unsigned int ft;
3299 :
3300 0 : M2Debug_Assert (SymbolTable_IsParameter (formal)); /* ; tokenNo: CARDINAL */
3301 0 : M2Debug_Assert (M2Pass_IsPassCodeGeneration ());
3302 0 : if ((SymbolTable_IsConst (actual)) && (SymbolTable_IsParameterVar (formal)))
3303 : {
3304 : return false;
3305 : }
3306 : else
3307 : {
3308 0 : if (SymbolTable_IsParameterUnbounded (formal))
3309 : {
3310 0 : return IsValidUnboundedParameter (formal, actual);
3311 : }
3312 : else
3313 : {
3314 0 : ft = SymbolTable_SkipType (SymbolTable_GetType (formal));
3315 : }
3316 0 : if ((((SymbolTable_IsConst (actual)) && ((SymbolTable_SkipType (SymbolTable_GetType (actual))) == M2Base_Char)) && (SymbolTable_IsArray (ft))) && ((SymbolTable_SkipType (SymbolTable_GetType (ft))) == M2Base_Char))
3317 : {
3318 : /* a constant char can be either a char or a string */
3319 : return true;
3320 : }
3321 0 : if (SymbolTable_IsProcType (ft))
3322 : {
3323 0 : if (SymbolTable_IsProcedure (actual))
3324 : {
3325 : /* we check this by calling IsValidProcedure for each and every
3326 : parameter of actual and formal */
3327 : return true;
3328 : }
3329 : else
3330 : {
3331 0 : at = SymbolTable_SkipType (SymbolTable_GetType (actual));
3332 0 : return doProcTypeCheck (at, ft, true);
3333 : }
3334 : }
3335 0 : else if (SymbolTable_IsParameterVar (formal))
3336 : {
3337 : /* avoid dangling else. */
3338 0 : return IsVarParamCompatible (SymbolTable_GetType (actual), ft);
3339 : }
3340 : else
3341 : {
3342 : /* avoid dangling else. */
3343 0 : return M2Base_IsParameterCompatible (SymbolTable_GetType (actual), ft);
3344 : }
3345 : }
3346 : /* static analysis guarentees a RETURN statement will be used before here. */
3347 : __builtin_unreachable ();
3348 : }
3349 :
3350 :
3351 : /*
3352 : CheckExpressionCompatible - returns if t1 and t2 are compatible types for
3353 : +, -, *, DIV, >, <, =, etc.
3354 : If t1 and t2 are not compatible then an error
3355 : message is displayed.
3356 : */
3357 :
3358 606 : extern "C" void M2Base_CheckExpressionCompatible (unsigned int tok, unsigned int left, unsigned int right)
3359 : {
3360 606 : CheckCompatible (tok, left, right, M2Base_expression);
3361 606 : }
3362 :
3363 :
3364 : /*
3365 : CheckAssignmentCompatible - returns if t1 and t2 are compatible types for
3366 : :=, =, #.
3367 : If t1 and t2 are not compatible then an error
3368 : message is displayed.
3369 : */
3370 :
3371 59232 : extern "C" void M2Base_CheckAssignmentCompatible (unsigned int tok, unsigned int left, unsigned int right)
3372 : {
3373 59232 : if (left != right)
3374 : {
3375 23420 : CheckCompatible (tok, left, right, M2Base_assignment);
3376 : }
3377 59232 : }
3378 :
3379 :
3380 : /*
3381 : CheckParameterCompatible - checks to see if types, t1, and, t2, are
3382 : compatible for parameter passing.
3383 : */
3384 :
3385 0 : extern "C" void M2Base_CheckParameterCompatible (unsigned int tok, unsigned int t1, unsigned int t2)
3386 : {
3387 0 : CheckCompatible (tok, t1, t2, M2Base_parameter);
3388 0 : }
3389 :
3390 :
3391 : /*
3392 : CannotCheckTypeInPass3 - returns TRUE if we are unable to check the
3393 : type of, e, in pass 3.
3394 : */
3395 :
3396 0 : extern "C" bool M2Base_CannotCheckTypeInPass3 (unsigned int e)
3397 : {
3398 0 : unsigned int t;
3399 0 : M2Base_MetaType mt;
3400 :
3401 0 : t = SymbolTable_SkipType (SymbolTable_GetType (e));
3402 0 : mt = FindMetaType (t);
3403 0 : switch (mt)
3404 : {
3405 : case M2Base_pointer:
3406 : case M2Base_enum:
3407 : case M2Base_set:
3408 : case M2Base_set8:
3409 : case M2Base_set16:
3410 : case M2Base_set32:
3411 : case M2Base_opaque:
3412 : return true;
3413 0 : break;
3414 :
3415 :
3416 0 : default:
3417 0 : return false;
3418 : break;
3419 : }
3420 : /* static analysis guarentees a RETURN statement will be used before here. */
3421 : __builtin_unreachable ();
3422 : }
3423 :
3424 :
3425 : /*
3426 : MixTypes - given types leftType and rightType return a type symbol that
3427 : provides expression type compatibility.
3428 : NearTok is used to identify the source position if a type
3429 : incompatability occurs.
3430 : */
3431 :
3432 240381 : extern "C" unsigned int M2Base_MixTypes (unsigned int leftType, unsigned int rightType, unsigned int NearTok)
3433 : {
3434 240381 : return M2Base_MixTypesDecl (SymbolTable_NulSym, SymbolTable_NulSym, leftType, rightType, NearTok);
3435 : /* static analysis guarentees a RETURN statement will be used before here. */
3436 : __builtin_unreachable ();
3437 : }
3438 :
3439 :
3440 : /*
3441 : MixTypesDecl - returns a type symbol which provides expression compatibility
3442 : between leftType and rightType. An error is emitted if this
3443 : is not possible. left and right are the source (variable,
3444 : constant) of leftType and rightType respectively.
3445 : */
3446 :
3447 425083 : extern "C" unsigned int M2Base_MixTypesDecl (unsigned int left, unsigned int right, unsigned int leftType, unsigned int rightType, unsigned int NearTok)
3448 : {
3449 426351 : if (leftType == rightType)
3450 : {
3451 : return leftType;
3452 : }
3453 81491 : else if ((leftType == M2System_Address) && (rightType == M2Base_Cardinal))
3454 : {
3455 : /* avoid dangling else. */
3456 : return M2System_Address;
3457 : }
3458 81235 : else if ((leftType == M2Base_Cardinal) && (rightType == M2System_Address))
3459 : {
3460 : /* avoid dangling else. */
3461 : return M2System_Address;
3462 : }
3463 80979 : else if ((leftType == M2System_Address) && (rightType == M2Base_Integer))
3464 : {
3465 : /* avoid dangling else. */
3466 : return M2System_Address;
3467 : }
3468 80899 : else if ((leftType == M2Base_Integer) && (rightType == M2System_Address))
3469 : {
3470 : /* avoid dangling else. */
3471 : return M2System_Address;
3472 : }
3473 80819 : else if (leftType == SymbolTable_NulSym)
3474 : {
3475 : /* avoid dangling else. */
3476 : return rightType;
3477 : }
3478 79859 : else if (rightType == SymbolTable_NulSym)
3479 : {
3480 : /* avoid dangling else. */
3481 : return leftType;
3482 : }
3483 61608 : else if ((leftType == M2Bitset_Bitset) && (SymbolTable_IsSet (rightType)))
3484 : {
3485 : /* avoid dangling else. */
3486 : return leftType;
3487 : }
3488 61608 : else if ((SymbolTable_IsSet (leftType)) && (rightType == M2Bitset_Bitset))
3489 : {
3490 : /* avoid dangling else. */
3491 : return rightType;
3492 : }
3493 61608 : else if (SymbolTable_IsEnumeration (leftType))
3494 : {
3495 : /* avoid dangling else. */
3496 80 : return M2Base_MixTypesDecl (left, right, M2Base_Integer, rightType, NearTok);
3497 : }
3498 61528 : else if (SymbolTable_IsEnumeration (rightType))
3499 : {
3500 : /* avoid dangling else. */
3501 90 : return M2Base_MixTypesDecl (left, right, leftType, M2Base_Integer, NearTok);
3502 : }
3503 61438 : else if (SymbolTable_IsSubrange (leftType))
3504 : {
3505 : /* avoid dangling else. */
3506 444 : return M2Base_MixTypesDecl (left, right, SymbolTable_GetType (leftType), rightType, NearTok);
3507 : }
3508 60994 : else if (SymbolTable_IsSubrange (rightType))
3509 : {
3510 : /* avoid dangling else. */
3511 470 : return M2Base_MixTypesDecl (left, right, leftType, SymbolTable_GetType (rightType), NearTok);
3512 : }
3513 60524 : else if ((M2Base_IsRealType (leftType)) && (M2Base_IsRealType (rightType)))
3514 : {
3515 : /* avoid dangling else. */
3516 1246 : if (leftType == M2Base_RType)
3517 : {
3518 : return rightType;
3519 : }
3520 828 : else if (rightType == M2Base_RType)
3521 : {
3522 : /* avoid dangling else. */
3523 : return leftType;
3524 : }
3525 : else
3526 : {
3527 : /* avoid dangling else. */
3528 0 : return M2Base_RType;
3529 : }
3530 : }
3531 59278 : else if ((M2Base_IsComplexType (leftType)) && (M2Base_IsComplexType (rightType)))
3532 : {
3533 : /* avoid dangling else. */
3534 102 : if (leftType == M2Base_CType)
3535 : {
3536 : return rightType;
3537 : }
3538 90 : else if (rightType == M2Base_CType)
3539 : {
3540 : /* avoid dangling else. */
3541 : return leftType;
3542 : }
3543 : else
3544 : {
3545 : /* avoid dangling else. */
3546 0 : return M2Base_CType;
3547 : }
3548 : }
3549 59176 : else if (IsUserType (leftType))
3550 : {
3551 : /* avoid dangling else. */
3552 178 : return M2Base_MixTypesDecl (left, right, SymbolTable_GetType (leftType), rightType, NearTok);
3553 : }
3554 58998 : else if (IsUserType (rightType))
3555 : {
3556 : /* avoid dangling else. */
3557 124 : return M2Base_MixTypes (leftType, SymbolTable_GetType (rightType), NearTok);
3558 : }
3559 58874 : else if (leftType == M2Base_ZType)
3560 : {
3561 : /* avoid dangling else. */
3562 : return rightType;
3563 : }
3564 41224 : else if (rightType == M2Base_ZType)
3565 : {
3566 : /* avoid dangling else. */
3567 : return leftType;
3568 : }
3569 5556 : else if ((leftType == (SymbolTable_GetLowestType (leftType))) && (rightType == (SymbolTable_GetLowestType (rightType))))
3570 : {
3571 : /* avoid dangling else. */
3572 5550 : return MixMetaTypes (left, right, leftType, rightType, NearTok);
3573 : }
3574 : else
3575 : {
3576 : /* avoid dangling else. */
3577 6 : leftType = SymbolTable_GetLowestType (leftType);
3578 6 : rightType = SymbolTable_GetLowestType (rightType);
3579 6 : return M2Base_MixTypesDecl (left, right, leftType, rightType, NearTok);
3580 : }
3581 : /* static analysis guarentees a RETURN statement will be used before here. */
3582 : __builtin_unreachable ();
3583 : }
3584 :
3585 :
3586 : /*
3587 : NegateType - if the type is unsigned then returns the
3588 : signed equivalent.
3589 : */
3590 :
3591 22608 : extern "C" unsigned int M2Base_NegateType (unsigned int type)
3592 : {
3593 22608 : unsigned int lowType;
3594 :
3595 22608 : if (type != SymbolTable_NulSym) /* ; sympos: CARDINAL */
3596 : {
3597 22608 : lowType = SymbolTable_GetLowestType (type);
3598 22608 : if (lowType == M2Base_LongCard)
3599 : {
3600 0 : return M2Base_LongInt;
3601 : }
3602 22608 : else if (lowType == M2Base_Cardinal)
3603 : {
3604 : /* avoid dangling else. */
3605 : /* ELSE
3606 : MetaErrorT1 (sympos, 'the type {%1ad} does not have a negated equivalent and an unary minus cannot be used on an operand of this type', type)
3607 : */
3608 36 : return M2Base_Integer;
3609 : }
3610 : }
3611 : return type;
3612 : /* static analysis guarentees a RETURN statement will be used before here. */
3613 : __builtin_unreachable ();
3614 : }
3615 :
3616 :
3617 : /*
3618 : IsMathType - returns TRUE if the type is a mathematical type.
3619 : A mathematical type has a range larger than INTEGER.
3620 : (Typically SHORTREAL/REAL/LONGREAL/LONGINT/LONGCARD)
3621 : */
3622 :
3623 1505147 : extern "C" bool M2Base_IsMathType (unsigned int type)
3624 : {
3625 1505147 : return ((((((type == M2Base_LongCard) || (type == M2Base_LongInt)) || (type == M2Base_Real)) || (type == M2Base_LongReal)) || (type == M2Base_ShortReal)) || (type == M2Base_RType)) || (type == M2Base_ZType);
3626 : /* static analysis guarentees a RETURN statement will be used before here. */
3627 : __builtin_unreachable ();
3628 : }
3629 :
3630 :
3631 : /*
3632 : IsRealType - returns TRUE if, t, is a real type.
3633 : */
3634 :
3635 3493047 : extern "C" bool M2Base_IsRealType (unsigned int t)
3636 : {
3637 3493047 : return (((t == M2Base_Real) || (t == M2Base_LongReal)) || (t == M2Base_ShortReal)) || (t == M2Base_RType);
3638 : /* static analysis guarentees a RETURN statement will be used before here. */
3639 : __builtin_unreachable ();
3640 : }
3641 :
3642 :
3643 : /*
3644 : IsRealGCC - return TRUE if type is LONGREAL, REAL, SHORTREAL or any of
3645 : the sized REAL types supported by GCC exported by SYSTEM.
3646 : */
3647 :
3648 3431253 : extern "C" bool M2Base_IsRealGCC (unsigned int type)
3649 : {
3650 3431253 : return (M2Base_IsRealType (type)) || (M2System_IsRealN (type));
3651 : /* static analysis guarentees a RETURN statement will be used before here. */
3652 : __builtin_unreachable ();
3653 : }
3654 :
3655 :
3656 : /*
3657 : IsComplexType - returns TRUE if, sym, is COMPLEX,
3658 : LONGCOMPLEX or SHORTCOMPLEX.
3659 : */
3660 :
3661 3819126 : extern "C" bool M2Base_IsComplexType (unsigned int sym)
3662 : {
3663 3819126 : return ((((sym == M2Base_Complex) || (sym == M2Base_LongComplex)) || (sym == M2Base_ShortComplex)) || (sym == M2Base_CType)) || (M2System_IsComplexN (sym));
3664 : /* static analysis guarentees a RETURN statement will be used before here. */
3665 : __builtin_unreachable ();
3666 : }
3667 :
3668 :
3669 : /*
3670 : ComplexToScalar - returns the scalar (or base type) of the complex type, sym.
3671 : */
3672 :
3673 246 : extern "C" unsigned int M2Base_ComplexToScalar (unsigned int sym)
3674 : {
3675 246 : if (sym == SymbolTable_NulSym)
3676 : {
3677 : /* a const complex may have a NulSym type */
3678 0 : return M2Base_RType;
3679 : }
3680 246 : else if (sym == M2Base_Complex)
3681 : {
3682 : /* avoid dangling else. */
3683 66 : return M2Base_Real;
3684 : }
3685 180 : else if (sym == M2Base_LongComplex)
3686 : {
3687 : /* avoid dangling else. */
3688 36 : return M2Base_LongReal;
3689 : }
3690 144 : else if (sym == M2Base_ShortComplex)
3691 : {
3692 : /* avoid dangling else. */
3693 36 : return M2Base_ShortReal;
3694 : }
3695 108 : else if (sym == M2Base_CType)
3696 : {
3697 : /* avoid dangling else. */
3698 108 : return M2Base_RType;
3699 : }
3700 0 : else if (sym == (M2System_ComplexN (32)))
3701 : {
3702 : /* avoid dangling else. */
3703 0 : return M2System_RealN (32);
3704 : }
3705 0 : else if (sym == (M2System_ComplexN (64)))
3706 : {
3707 : /* avoid dangling else. */
3708 0 : return M2System_RealN (64);
3709 : }
3710 0 : else if (sym == (M2System_ComplexN (96)))
3711 : {
3712 : /* avoid dangling else. */
3713 0 : return M2System_RealN (96);
3714 : }
3715 0 : else if (sym == (M2System_ComplexN (128)))
3716 : {
3717 : /* avoid dangling else. */
3718 0 : return M2System_RealN (128);
3719 : }
3720 : else
3721 : {
3722 : /* avoid dangling else. */
3723 0 : M2MetaError_MetaError1 ((const char *) "{%1ad} must be a COMPLEX type", 29, sym);
3724 0 : return M2Base_RType;
3725 : }
3726 : /* static analysis guarentees a RETURN statement will be used before here. */
3727 : __builtin_unreachable ();
3728 : }
3729 :
3730 :
3731 : /*
3732 : ScalarToComplex - given a real type, t, return the equivalent complex type.
3733 : */
3734 :
3735 1218 : extern "C" unsigned int M2Base_ScalarToComplex (unsigned int sym)
3736 : {
3737 1218 : if (sym == M2Base_Real)
3738 : {
3739 90 : return M2Base_Complex;
3740 : }
3741 1128 : else if (sym == M2Base_LongReal)
3742 : {
3743 : /* avoid dangling else. */
3744 72 : return M2Base_LongComplex;
3745 : }
3746 1056 : else if (sym == M2Base_ShortReal)
3747 : {
3748 : /* avoid dangling else. */
3749 72 : return M2Base_ShortComplex;
3750 : }
3751 984 : else if (sym == M2Base_RType)
3752 : {
3753 : /* avoid dangling else. */
3754 960 : return M2Base_CType;
3755 : }
3756 24 : else if (sym == (M2System_RealN (32)))
3757 : {
3758 : /* avoid dangling else. */
3759 24 : return M2System_ComplexN (32);
3760 : }
3761 0 : else if (sym == (M2System_RealN (64)))
3762 : {
3763 : /* avoid dangling else. */
3764 0 : return M2System_ComplexN (64);
3765 : }
3766 0 : else if (sym == (M2System_RealN (96)))
3767 : {
3768 : /* avoid dangling else. */
3769 0 : return M2System_ComplexN (96);
3770 : }
3771 0 : else if (sym == (M2System_RealN (128)))
3772 : {
3773 : /* avoid dangling else. */
3774 0 : return M2System_ComplexN (128);
3775 : }
3776 : else
3777 : {
3778 : /* avoid dangling else. */
3779 0 : M2MetaError_MetaError1 ((const char *) "{%1ad} must be a REAL type", 26, sym);
3780 0 : return M2Base_Complex;
3781 : }
3782 : /* static analysis guarentees a RETURN statement will be used before here. */
3783 : __builtin_unreachable ();
3784 : }
3785 :
3786 :
3787 : /*
3788 : GetCmplxReturnType - this code implements the table given in the
3789 : ISO standard Page 293 with an addition for
3790 : SHORTCOMPLEX.
3791 : */
3792 :
3793 1218 : extern "C" unsigned int M2Base_GetCmplxReturnType (unsigned int t1, unsigned int t2)
3794 : {
3795 1218 : M2Base_MetaType mt1;
3796 1218 : M2Base_MetaType mt2;
3797 :
3798 1218 : t1 = SymbolTable_SkipType (t1);
3799 1218 : t2 = SymbolTable_SkipType (t2);
3800 1218 : if ((M2Base_IsRealGCC (t1)) && (M2Base_IsRealGCC (t2)))
3801 : {
3802 1218 : mt1 = FindMetaType (t1);
3803 1218 : mt2 = FindMetaType (t2);
3804 1218 : if (mt1 == mt2)
3805 : {
3806 1158 : return M2Base_ScalarToComplex (t1);
3807 : }
3808 : else
3809 : {
3810 60 : if (mt1 == M2Base_rtype)
3811 : {
3812 12 : return M2Base_ScalarToComplex (t2);
3813 : }
3814 48 : else if (mt2 == M2Base_rtype)
3815 : {
3816 : /* avoid dangling else. */
3817 48 : return M2Base_ScalarToComplex (t1);
3818 : }
3819 : else
3820 : {
3821 : /* avoid dangling else. */
3822 : return SymbolTable_NulSym;
3823 : }
3824 : }
3825 : }
3826 : else
3827 : {
3828 : return SymbolTable_NulSym;
3829 : }
3830 : /* static analysis guarentees a RETURN statement will be used before here. */
3831 : __builtin_unreachable ();
3832 : }
3833 :
3834 16979 : extern "C" void _M2_M2Base_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
3835 : {
3836 16979 : }
3837 :
3838 0 : extern "C" void _M2_M2Base_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
3839 : {
3840 0 : }
|