| 1 |
(* M2Base.mod provides a mechanism to check fundamental types. |
| 2 |
|
| 3 |
Copyright (C) 2001-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with GNU Modula-2; see the file COPYING3. If not see |
| 20 |
<http://www.gnu.org/licenses/>. *) |
| 21 |
|
| 22 |
IMPLEMENTATION MODULE M2Base ; |
| 23 |
|
| 24 |
(* |
| 25 |
Title : M2Base |
| 26 |
Author : Gaius Mulley |
| 27 |
System : UNIX (gm2) |
| 28 |
Date : Mon Jul 10 20:16:54 2000 |
| 29 |
Description: gcc version of M2Base. This module initializes the front end |
| 30 |
symbol table with the base types. We collect the size of the |
| 31 |
base types and range of values from the gcc backend. |
| 32 |
*) |
| 33 |
|
| 34 |
FROM DynamicStrings IMPORT InitString, String, Mark, InitStringCharStar, ConCat ; |
| 35 |
FROM M2LexBuf IMPORT BuiltinTokenNo, GetTokenNo ; |
| 36 |
FROM NameKey IMPORT NulName, MakeKey, WriteKey, KeyToCharStar ; |
| 37 |
FROM M2Debug IMPORT Assert ; |
| 38 |
FROM SYSTEM IMPORT WORD ; |
| 39 |
|
| 40 |
FROM M2Error IMPORT InternalError, FlushErrors ; |
| 41 |
FROM M2Pass IMPORT IsPassCodeGeneration ; |
| 42 |
FROM FormatStrings IMPORT Sprintf2 ; |
| 43 |
FROM StrLib IMPORT StrLen ; |
| 44 |
|
| 45 |
FROM M2MetaError IMPORT MetaError0, MetaError1, MetaError2, MetaErrors3, |
| 46 |
MetaErrorT1, MetaErrorT2, MetaErrorT4, |
| 47 |
MetaErrorStringT2, MetaErrorStringT1, |
| 48 |
MetaErrorDecl ; |
| 49 |
|
| 50 |
FROM SymbolTable IMPORT ModeOfAddr, ProcedureKind, |
| 51 |
MakeModule, MakeType, PutType, |
| 52 |
MakeEnumeration, PutFieldEnumeration, |
| 53 |
MakeProcType, |
| 54 |
MakeProcedure, PutFunction, |
| 55 |
MakeRecord, PutFieldRecord, |
| 56 |
MakeConstVar, PutConst, |
| 57 |
MakeTemporary, |
| 58 |
MakeVar, PutVar, |
| 59 |
MakeSubrange, PutSubrange, IsSubrange, |
| 60 |
PutModuleBuiltin, |
| 61 |
IsEnumeration, IsSet, IsPointer, IsType, IsUnknown, |
| 62 |
IsHiddenType, IsProcType, |
| 63 |
GetType, GetLowestType, GetDeclaredMod, SkipType, |
| 64 |
SetCurrentModule, |
| 65 |
StartScope, EndScope, PseudoScope, |
| 66 |
ForeachFieldEnumerationDo, |
| 67 |
RequestSym, GetSymName, NulSym, |
| 68 |
PutImported, GetExported, |
| 69 |
PopSize, PopValue, PushValue, |
| 70 |
FromModuleGetSym, GetSym, |
| 71 |
IsExportQualified, IsExportUnQualified, |
| 72 |
IsParameter, IsParameterVar, IsUnbounded, |
| 73 |
IsConst, IsUnboundedParam, |
| 74 |
IsParameterUnbounded, GetSubrange, |
| 75 |
IsArray, IsProcedure, IsConstString, |
| 76 |
IsVarient, IsRecordField, IsFieldVarient, |
| 77 |
IsVarAParam, IsVar, |
| 78 |
GetArraySubscript, IsRecord, NoOfParamAny, |
| 79 |
GetNthParamAny, IsVarParam, GetNth, GetDimension, |
| 80 |
GetVarDeclFullTok, |
| 81 |
MakeError ; |
| 82 |
|
| 83 |
FROM M2ALU IMPORT PushIntegerTree, PushRealTree, PushCard, Equ, Gre, Less ; |
| 84 |
FROM M2Batch IMPORT MakeDefinitionSource ; |
| 85 |
FROM M2Bitset IMPORT Bitset, GetBitsetMinMax, MakeBitset ; |
| 86 |
FROM M2Size IMPORT Size, MakeSize ; |
| 87 |
|
| 88 |
FROM M2System IMPORT Address, Byte, Word, System, Loc, InitSystem, |
| 89 |
IntegerN, CardinalN, WordN, SetN, RealN, ComplexN, |
| 90 |
IsCardinalN, IsIntegerN, IsRealN, IsComplexN, |
| 91 |
IsGenericSystemType, IsSameSizePervasiveType, |
| 92 |
IsSystemType ; |
| 93 |
|
| 94 |
FROM M2Options IMPORT NilChecking, |
| 95 |
WholeDivChecking, WholeValueChecking, |
| 96 |
IndexChecking, RangeChecking, |
| 97 |
ReturnChecking, CaseElseChecking, Exceptions, |
| 98 |
WholeValueChecking, |
| 99 |
DebugBuiltins, |
| 100 |
Iso, Pim, Pim2, Pim3 ; |
| 101 |
|
| 102 |
FROM m2type IMPORT GetIntegerType, |
| 103 |
GetM2IntegerType, GetM2CharType, |
| 104 |
GetMaxFrom, GetMinFrom, GetRealType, |
| 105 |
GetM2LongIntType, GetLongRealType, GetProcType, |
| 106 |
GetM2ShortRealType, GetM2RealType, |
| 107 |
GetM2LongRealType, GetM2LongCardType, |
| 108 |
GetM2ShortIntType, GetM2ShortCardType, |
| 109 |
GetM2CardinalType, GetPointerType, GetWordType, |
| 110 |
GetByteType, GetISOWordType, GetISOByteType, |
| 111 |
GetISOLocType, |
| 112 |
GetM2ComplexType, GetM2LongComplexType, |
| 113 |
GetM2ShortComplexType, |
| 114 |
GetM2Complex32, GetM2Complex64, |
| 115 |
GetM2Complex96, GetM2Complex128, |
| 116 |
GetM2RType, GetM2ZType, GetM2CType, |
| 117 |
InitBaseTypes ; |
| 118 |
|
| 119 |
FROM m2expr IMPORT GetSizeOf ; |
| 120 |
FROM gcctypes IMPORT location_t ; |
| 121 |
FROM m2linemap IMPORT BuiltinsLocation ; |
| 122 |
FROM m2decl IMPORT BuildIntegerConstant ; |
| 123 |
|
| 124 |
|
| 125 |
TYPE |
| 126 |
Compatability = (expression, assignment, parameter, comparison) ; |
| 127 |
MetaType = (const, word, byte, address, chr, |
| 128 |
normint, shortint, longint, |
| 129 |
normcard, shortcard, longcard, |
| 130 |
pointer, enum, |
| 131 |
real, shortreal, longreal, |
| 132 |
set, opaque, loc, rtype, ztype, |
| 133 |
int8, int16, int32, int64, |
| 134 |
card8, card16, card32, card64, |
| 135 |
word16, word32, word64, |
| 136 |
real32, real64, real96, real128, |
| 137 |
set8, set16, set32, |
| 138 |
complex, shortcomplex, longcomplex, |
| 139 |
complex32, complex64, complex96, complex128, |
| 140 |
ctype, rec, array, |
| 141 |
procedure, unknown) ; |
| 142 |
Compatible = (uninitialized, no, warnfirst, warnsecond, |
| 143 |
first, second) ; |
| 144 |
|
| 145 |
|
| 146 |
TYPE |
| 147 |
CompatibilityArray = ARRAY MetaType, MetaType OF Compatible ; |
| 148 |
|
| 149 |
VAR |
| 150 |
Comp, |
| 151 |
Expr, |
| 152 |
Ass : CompatibilityArray ; |
| 153 |
Ord, |
| 154 |
OrdS, OrdL, |
| 155 |
Float, |
| 156 |
FloatS, SFloat, |
| 157 |
FloatL, LFloat, |
| 158 |
Trunc, |
| 159 |
TruncS, |
| 160 |
TruncL, |
| 161 |
Int, IntS, IntL, |
| 162 |
m2rts, |
| 163 |
MinReal, |
| 164 |
MaxReal, |
| 165 |
MinShortReal, |
| 166 |
MaxShortReal, |
| 167 |
MinLongReal, |
| 168 |
MaxLongReal, |
| 169 |
MinLongInt, |
| 170 |
MaxLongInt, |
| 171 |
MinLongCard, |
| 172 |
MaxLongCard, |
| 173 |
MinShortInt, |
| 174 |
MaxShortInt, |
| 175 |
MinShortCard, |
| 176 |
MaxShortCard, |
| 177 |
MinChar, |
| 178 |
MaxChar, |
| 179 |
MinCardinal, |
| 180 |
MaxCardinal, |
| 181 |
MinInteger, |
| 182 |
MaxInteger, |
| 183 |
MaxEnum, |
| 184 |
MinEnum : CARDINAL ; |
| 185 |
|
| 186 |
|
| 187 |
(* |
| 188 |
InitBuiltins - |
| 189 |
*) |
| 190 |
|
| 191 |
PROCEDURE InitBuiltins ; |
| 192 |
VAR |
| 193 |
builtins: CARDINAL ; |
| 194 |
BEGIN |
| 195 |
IF DebugBuiltins |
| 196 |
THEN |
| 197 |
(* We will need to parse this module as functions alloca/memcpy will be used. *) |
| 198 |
builtins := MakeDefinitionSource (BuiltinTokenNo, MakeKey ('Builtins')) ; |
| 199 |
IF builtins = NulSym |
| 200 |
THEN |
| 201 |
MetaError0 ('unable to find core module Builtins') |
| 202 |
END |
| 203 |
END |
| 204 |
END InitBuiltins ; |
| 205 |
|
| 206 |
|
| 207 |
(* |
| 208 |
InitBase - initializes the base types and procedures |
| 209 |
used in the Modula-2 compiler. |
| 210 |
*) |
| 211 |
|
| 212 |
PROCEDURE InitBase (location: location_t; VAR sym: CARDINAL) ; |
| 213 |
BEGIN |
| 214 |
sym := MakeModule (BuiltinTokenNo, MakeKey ('_BaseTypes')) ; |
| 215 |
PutModuleBuiltin (sym, TRUE) ; |
| 216 |
SetCurrentModule (sym) ; |
| 217 |
StartScope (sym) ; |
| 218 |
|
| 219 |
InitBaseSimpleTypes (location) ; |
| 220 |
|
| 221 |
(* Initialize the SYSTEM module before we ADDRESS. *) |
| 222 |
InitSystem ; |
| 223 |
|
| 224 |
MakeBitset ; (* We do this after SYSTEM has been created as BITSET |
| 225 |
is dependant upon WORD. *) |
| 226 |
|
| 227 |
InitBaseConstants ; |
| 228 |
InitBaseFunctions ; |
| 229 |
InitBaseProcedures ; |
| 230 |
|
| 231 |
(* |
| 232 |
Note: that we do end the Scope since we keep the symbol to the head |
| 233 |
of the base scope. This head of base scope is searched |
| 234 |
when all other scopes fail to deliver a symbol. |
| 235 |
*) |
| 236 |
EndScope ; |
| 237 |
InitBuiltins ; |
| 238 |
InitCompatibilityMatrices |
| 239 |
END InitBase ; |
| 240 |
|
| 241 |
|
| 242 |
(* |
| 243 |
IsNeededAtRunTime - returns TRUE if procedure, sym, is a |
| 244 |
runtime procedure. A runtime procedure is |
| 245 |
not a pseudo procedure (like NEW/DISPOSE) |
| 246 |
and it is implemented in M2RTS or SYSTEM |
| 247 |
and also exported. |
| 248 |
*) |
| 249 |
|
| 250 |
PROCEDURE IsNeededAtRunTime (tok: CARDINAL; sym: CARDINAL) : BOOLEAN ; |
| 251 |
BEGIN |
| 252 |
RETURN( |
| 253 |
((FromModuleGetSym(tok, GetSymName(sym), System)=sym) OR |
| 254 |
(FromModuleGetSym(tok, GetSymName(sym), m2rts)=sym)) AND |
| 255 |
(IsExportQualified(sym) OR IsExportUnQualified(sym)) |
| 256 |
) |
| 257 |
END IsNeededAtRunTime ; |
| 258 |
|
| 259 |
|
| 260 |
(* |
| 261 |
InitBaseConstants - initialises the base constant NIL. |
| 262 |
*) |
| 263 |
|
| 264 |
PROCEDURE InitBaseConstants ; |
| 265 |
BEGIN |
| 266 |
Nil := MakeConstVar (BuiltinTokenNo, MakeKey ('NIL')) ; |
| 267 |
PutConst (Nil, Address) |
| 268 |
END InitBaseConstants ; |
| 269 |
|
| 270 |
|
| 271 |
(* |
| 272 |
InitBaseSimpleTypes - initialises the base simple types, |
| 273 |
CARDINAL, INTEGER, CHAR, BOOLEAN. |
| 274 |
*) |
| 275 |
|
| 276 |
PROCEDURE InitBaseSimpleTypes (location: location_t) ; |
| 277 |
BEGIN |
| 278 |
InitBaseTypes (location) ; |
| 279 |
|
| 280 |
ZType := MakeType (BuiltinTokenNo, MakeKey('Modula-2 base Z')) ; |
| 281 |
PutType(ZType, NulSym) ; (* Base Type *) |
| 282 |
PushIntegerTree(GetSizeOf(location, GetM2ZType())) ; |
| 283 |
PopSize(ZType) ; |
| 284 |
|
| 285 |
RType := MakeType(BuiltinTokenNo, MakeKey('Modula-2 base R')) ; |
| 286 |
PutType(RType, NulSym) ; (* Base Type *) |
| 287 |
PushIntegerTree(GetSizeOf(location, GetM2RType())) ; |
| 288 |
PopSize(RType) ; |
| 289 |
|
| 290 |
CType := MakeType (BuiltinTokenNo, MakeKey('Modula-2 base C')) ; |
| 291 |
PutType(CType, NulSym) ; (* Base Type *) |
| 292 |
PushIntegerTree(GetSizeOf(location, GetM2CType())) ; |
| 293 |
PopSize(CType) ; |
| 294 |
|
| 295 |
Integer := MakeType (BuiltinTokenNo, MakeKey('INTEGER')) ; |
| 296 |
PutType(Integer, NulSym) ; (* Base Type *) |
| 297 |
PushIntegerTree(GetSizeOf(location, GetM2IntegerType())) ; |
| 298 |
PopSize(Integer) ; |
| 299 |
|
| 300 |
Cardinal := MakeType (BuiltinTokenNo, MakeKey('CARDINAL')) ; |
| 301 |
PutType(Cardinal, NulSym) ; |
| 302 |
(* Base Type *) |
| 303 |
PushIntegerTree(GetSizeOf(location, GetM2CardinalType())) ; |
| 304 |
PopSize(Cardinal) ; |
| 305 |
|
| 306 |
LongInt := MakeType (BuiltinTokenNo, MakeKey('LONGINT')) ; |
| 307 |
PutType(LongInt, NulSym) ; (* Base Type *) |
| 308 |
PushIntegerTree(GetSizeOf(location, GetM2LongIntType())) ; |
| 309 |
PopSize(LongInt) ; |
| 310 |
|
| 311 |
LongCard := MakeType (BuiltinTokenNo, MakeKey('LONGCARD')) ; |
| 312 |
PutType(LongCard, NulSym) ; (* Base Type *) |
| 313 |
PushIntegerTree(GetSizeOf(location, GetM2LongCardType())) ; |
| 314 |
PopSize(LongCard) ; |
| 315 |
|
| 316 |
ShortInt := MakeType (BuiltinTokenNo, MakeKey('SHORTINT')) ; |
| 317 |
PutType(ShortInt, NulSym) ; (* Base Type *) |
| 318 |
PushIntegerTree(GetSizeOf(location, GetM2ShortIntType())) ; |
| 319 |
PopSize(ShortInt) ; |
| 320 |
|
| 321 |
ShortCard := MakeType (BuiltinTokenNo, MakeKey('SHORTCARD')) ; |
| 322 |
PutType(ShortCard, NulSym) ; (* Base Type *) |
| 323 |
PushIntegerTree(GetSizeOf(location, GetM2ShortCardType())) ; |
| 324 |
PopSize(ShortCard) ; |
| 325 |
|
| 326 |
Real := MakeType (BuiltinTokenNo, MakeKey('REAL')) ; |
| 327 |
PutType(Real, NulSym) ; (* Base Type *) |
| 328 |
PushIntegerTree(GetSizeOf(location, GetM2RealType())) ; |
| 329 |
PopSize(Real) ; |
| 330 |
|
| 331 |
ShortReal := MakeType (BuiltinTokenNo, MakeKey('SHORTREAL')) ; |
| 332 |
PutType(ShortReal, NulSym) ; (* Base Type *) |
| 333 |
PushIntegerTree(GetSizeOf(location, GetM2ShortRealType())) ; |
| 334 |
PopSize(ShortReal) ; |
| 335 |
|
| 336 |
LongReal := MakeType (BuiltinTokenNo, MakeKey('LONGREAL')) ; |
| 337 |
PutType(LongReal, NulSym) ; (* Base Type *) |
| 338 |
PushIntegerTree(GetSizeOf(location, GetM2LongRealType())) ; |
| 339 |
PopSize(LongReal) ; |
| 340 |
|
| 341 |
Complex := MakeType (BuiltinTokenNo, MakeKey('COMPLEX')) ; |
| 342 |
PutType(Complex, NulSym) ; (* Base Type *) |
| 343 |
PushIntegerTree(GetSizeOf(location, GetM2ComplexType())) ; |
| 344 |
PopSize(Complex) ; |
| 345 |
|
| 346 |
LongComplex := MakeType (BuiltinTokenNo, MakeKey('LONGCOMPLEX')) ; |
| 347 |
PutType(LongComplex, NulSym) ; (* Base Type *) |
| 348 |
PushIntegerTree(GetSizeOf(location, GetM2LongComplexType())) ; |
| 349 |
PopSize(LongComplex) ; |
| 350 |
|
| 351 |
ShortComplex := MakeType (BuiltinTokenNo, MakeKey('SHORTCOMPLEX')) ; |
| 352 |
PutType(ShortComplex, NulSym) ; (* Base Type *) |
| 353 |
PushIntegerTree(GetSizeOf(location, GetM2ShortComplexType())) ; |
| 354 |
PopSize(ShortComplex) ; |
| 355 |
|
| 356 |
Char := MakeType (BuiltinTokenNo, MakeKey('CHAR')) ; |
| 357 |
PutType(Char, NulSym) ; (* Base Type *) |
| 358 |
PushIntegerTree(GetSizeOf(location, GetM2CharType())) ; |
| 359 |
PopSize(Char) ; |
| 360 |
|
| 361 |
(* |
| 362 |
Boolean = (FALSE, TRUE) ; |
| 363 |
*) |
| 364 |
Boolean := MakeEnumeration (BuiltinTokenNo, MakeKey('BOOLEAN')) ; |
| 365 |
|
| 366 |
PutFieldEnumeration (BuiltinTokenNo, Boolean, MakeKey('FALSE')) ; |
| 367 |
PutFieldEnumeration (BuiltinTokenNo, Boolean, MakeKey('TRUE')) ; |
| 368 |
|
| 369 |
True := RequestSym (BuiltinTokenNo, MakeKey('TRUE')) ; |
| 370 |
False := RequestSym (BuiltinTokenNo, MakeKey('FALSE')) ; |
| 371 |
|
| 372 |
Proc := MakeProcType (BuiltinTokenNo, MakeKey('PROC')) ; |
| 373 |
PushIntegerTree(GetSizeOf(location, GetProcType())) ; |
| 374 |
PopSize(Proc) ; |
| 375 |
|
| 376 |
(* MinChar *) |
| 377 |
MinChar := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 378 |
PushIntegerTree(GetMinFrom(location, GetM2CharType())) ; |
| 379 |
PopValue(MinChar) ; |
| 380 |
PutVar(MinChar, Char) ; |
| 381 |
|
| 382 |
(* MaxChar *) |
| 383 |
MaxChar := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 384 |
PushIntegerTree(GetMaxFrom(location, GetM2CharType())) ; |
| 385 |
PopValue(MaxChar) ; |
| 386 |
PutVar(MaxChar, Char) ; |
| 387 |
|
| 388 |
(* MinInteger *) |
| 389 |
MinInteger := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 390 |
PushIntegerTree(GetMinFrom(location, GetM2IntegerType())) ; |
| 391 |
PopValue(MinInteger) ; |
| 392 |
PutVar(MinInteger, Integer) ; |
| 393 |
|
| 394 |
(* MaxInteger *) |
| 395 |
MaxInteger := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 396 |
PushIntegerTree(GetMaxFrom(location, GetM2IntegerType())) ; |
| 397 |
PopValue(MaxInteger) ; |
| 398 |
PutVar(MaxInteger, Integer) ; |
| 399 |
|
| 400 |
(* MinCardinal *) |
| 401 |
MinCardinal := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 402 |
PushIntegerTree(GetMinFrom(BuiltinsLocation(), GetM2CardinalType())) ; |
| 403 |
PopValue(MinCardinal) ; |
| 404 |
PutVar(MinCardinal, Cardinal) ; |
| 405 |
|
| 406 |
(* MaxCardinal *) |
| 407 |
MaxCardinal := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 408 |
PushIntegerTree(GetMaxFrom(location, GetM2CardinalType())) ; |
| 409 |
PopValue(MaxCardinal) ; |
| 410 |
PutVar(MaxCardinal, Cardinal) ; |
| 411 |
|
| 412 |
(* MinLongInt *) |
| 413 |
MinLongInt := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 414 |
PushIntegerTree(GetMinFrom(location, GetM2LongIntType())) ; |
| 415 |
PopValue(MinLongInt) ; |
| 416 |
PutVar(MinLongInt, LongInt) ; |
| 417 |
|
| 418 |
(* MaxLongInt *) |
| 419 |
MaxLongInt := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 420 |
PushIntegerTree(GetMaxFrom(location, GetM2LongIntType())) ; |
| 421 |
PopValue(MaxLongInt) ; |
| 422 |
PutVar(MaxLongInt, LongInt) ; |
| 423 |
|
| 424 |
(* MinLongCard *) |
| 425 |
MinLongCard := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 426 |
PushIntegerTree(GetMinFrom(location, GetM2LongCardType())) ; |
| 427 |
PopValue(MinLongCard) ; |
| 428 |
PutVar(MinLongCard, LongCard) ; |
| 429 |
|
| 430 |
(* MinLongCard *) |
| 431 |
MaxLongCard := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 432 |
PushIntegerTree(GetMaxFrom(BuiltinsLocation(), GetM2LongCardType())) ; |
| 433 |
PopValue(MaxLongCard) ; |
| 434 |
PutVar(MaxLongCard, LongCard) ; |
| 435 |
|
| 436 |
(* MinReal *) |
| 437 |
MinReal := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 438 |
PushRealTree(GetMinFrom(location, GetM2RealType())) ; |
| 439 |
PopValue(MinReal) ; |
| 440 |
PutVar(MinReal, Real) ; |
| 441 |
|
| 442 |
(* MaxReal *) |
| 443 |
MaxReal := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 444 |
PushRealTree(GetMaxFrom(location, GetM2RealType())) ; |
| 445 |
PopValue(MaxReal) ; |
| 446 |
PutVar(MaxReal, Real) ; |
| 447 |
|
| 448 |
(* MinShortReal *) |
| 449 |
MinShortReal := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 450 |
PushRealTree(GetMinFrom(location, GetM2ShortRealType())) ; |
| 451 |
PopValue(MinShortReal) ; |
| 452 |
PutVar(MinShortReal, ShortReal) ; |
| 453 |
|
| 454 |
(* MaxShortReal *) |
| 455 |
MaxShortReal := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 456 |
PushRealTree(GetMaxFrom(location, GetM2ShortRealType())) ; |
| 457 |
PopValue(MaxShortReal) ; |
| 458 |
PutVar(MaxShortReal, ShortReal) ; |
| 459 |
|
| 460 |
(* MinLongReal *) |
| 461 |
MinLongReal := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 462 |
PushRealTree(GetMinFrom(location, GetM2LongRealType())) ; |
| 463 |
PopValue(MinLongReal) ; |
| 464 |
PutVar(MinLongReal, LongReal) ; |
| 465 |
|
| 466 |
(* MaxLongReal *) |
| 467 |
MaxLongReal := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 468 |
PushRealTree(GetMaxFrom(location, GetM2LongRealType())) ; |
| 469 |
PopValue(MaxLongReal) ; |
| 470 |
PutVar(MaxLongReal, LongReal) ; |
| 471 |
|
| 472 |
(* MaxShortInt *) |
| 473 |
MaxShortInt := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 474 |
PushIntegerTree(GetMaxFrom(location, GetM2ShortIntType())) ; |
| 475 |
PopValue(MaxShortInt) ; |
| 476 |
PutVar(MaxShortInt, ShortInt) ; |
| 477 |
|
| 478 |
(* MinShortInt *) |
| 479 |
MinShortInt := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 480 |
PushIntegerTree(GetMinFrom(location, GetM2ShortIntType())) ; |
| 481 |
PopValue(MinShortInt) ; |
| 482 |
PutVar(MinShortInt, ShortInt) ; |
| 483 |
|
| 484 |
(* MaxShortCard *) |
| 485 |
MaxShortCard := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 486 |
PushIntegerTree(GetMaxFrom(location, GetM2ShortCardType())) ; |
| 487 |
PopValue(MaxShortCard) ; |
| 488 |
PutVar(MaxShortCard, ShortCard) ; |
| 489 |
|
| 490 |
(* MinShortCard *) |
| 491 |
MinShortCard := MakeTemporary(BuiltinTokenNo, ImmediateValue) ; |
| 492 |
PushIntegerTree(GetMinFrom(location, GetM2ShortCardType())) ; |
| 493 |
PopValue(MinShortCard) ; |
| 494 |
PutVar(MinShortCard, ShortCard) |
| 495 |
|
| 496 |
END InitBaseSimpleTypes ; |
| 497 |
|
| 498 |
|
| 499 |
(* |
| 500 |
FindMinMaxEnum - finds the minimum and maximum enumeration fields. |
| 501 |
*) |
| 502 |
|
| 503 |
PROCEDURE FindMinMaxEnum (field: WORD) ; |
| 504 |
BEGIN |
| 505 |
IF MaxEnum=NulSym |
| 506 |
THEN |
| 507 |
MaxEnum := field |
| 508 |
ELSE |
| 509 |
PushValue(field) ; |
| 510 |
PushValue(MaxEnum) ; |
| 511 |
IF Gre(GetTokenNo()) |
| 512 |
THEN |
| 513 |
MaxEnum := field |
| 514 |
END |
| 515 |
END ; |
| 516 |
IF MinEnum=NulSym |
| 517 |
THEN |
| 518 |
MinEnum := field |
| 519 |
ELSE |
| 520 |
PushValue(field) ; |
| 521 |
PushValue(MinEnum) ; |
| 522 |
IF Less(GetTokenNo()) |
| 523 |
THEN |
| 524 |
MinEnum := field |
| 525 |
END |
| 526 |
END |
| 527 |
END FindMinMaxEnum ; |
| 528 |
|
| 529 |
|
| 530 |
(* |
| 531 |
GetBaseTypeMinMax - returns the minimum and maximum values for a |
| 532 |
given base type. This procedure should only |
| 533 |
be called if the type is NOT a subrange. |
| 534 |
*) |
| 535 |
|
| 536 |
PROCEDURE GetBaseTypeMinMax (type: CARDINAL; VAR min, max: CARDINAL) ; |
| 537 |
BEGIN |
| 538 |
IF type=Integer |
| 539 |
THEN |
| 540 |
min := MinInteger ; |
| 541 |
max := MaxInteger |
| 542 |
ELSIF type=Cardinal |
| 543 |
THEN |
| 544 |
min := MinCardinal ; |
| 545 |
max := MaxCardinal |
| 546 |
ELSIF type=Char |
| 547 |
THEN |
| 548 |
min := MinChar ; |
| 549 |
max := MaxChar |
| 550 |
ELSIF type=Bitset |
| 551 |
THEN |
| 552 |
GetBitsetMinMax(min, max) |
| 553 |
ELSIF (type=LongInt) |
| 554 |
THEN |
| 555 |
min := MinLongInt ; |
| 556 |
max := MaxLongInt |
| 557 |
ELSIF (type=LongCard) |
| 558 |
THEN |
| 559 |
min := MinLongCard ; |
| 560 |
max := MaxLongCard |
| 561 |
ELSIF (type=ShortInt) |
| 562 |
THEN |
| 563 |
min := MinShortInt ; |
| 564 |
max := MaxShortInt |
| 565 |
ELSIF (type=ShortCard) |
| 566 |
THEN |
| 567 |
min := MinShortCard ; |
| 568 |
max := MaxShortCard |
| 569 |
ELSIF (type=Real) |
| 570 |
THEN |
| 571 |
min := MinReal ; |
| 572 |
max := MaxReal |
| 573 |
ELSIF (type=ShortReal) |
| 574 |
THEN |
| 575 |
min := MinShortReal ; |
| 576 |
max := MaxShortReal |
| 577 |
ELSIF (type=LongReal) |
| 578 |
THEN |
| 579 |
min := MinLongReal ; |
| 580 |
max := MaxLongReal |
| 581 |
ELSIF IsEnumeration(type) |
| 582 |
THEN |
| 583 |
MinEnum := NulSym ; |
| 584 |
MaxEnum := NulSym ; |
| 585 |
ForeachFieldEnumerationDo(type, FindMinMaxEnum) ; |
| 586 |
min := MinEnum ; |
| 587 |
max := MaxEnum |
| 588 |
ELSE |
| 589 |
MetaError1 ('unable to find MIN or MAX for the base type {%1as}', type) |
| 590 |
END |
| 591 |
END GetBaseTypeMinMax ; |
| 592 |
|
| 593 |
|
| 594 |
(* |
| 595 |
ImportFrom - imports symbol, name, from module and returns the |
| 596 |
symbol. |
| 597 |
*) |
| 598 |
|
| 599 |
PROCEDURE ImportFrom (tok: CARDINAL; |
| 600 |
module: CARDINAL; name: ARRAY OF CHAR) : CARDINAL ; |
| 601 |
BEGIN |
| 602 |
PutImported(GetExported(tok, module, MakeKey(name))) ; |
| 603 |
RETURN( GetSym(MakeKey(name)) ) |
| 604 |
END ImportFrom ; |
| 605 |
|
| 606 |
|
| 607 |
(* |
| 608 |
InitBaseProcedures - initialises the base procedures, |
| 609 |
INC, DEC, INCL, EXCL, NEW and DISPOSE. |
| 610 |
*) |
| 611 |
|
| 612 |
PROCEDURE InitBaseProcedures ; |
| 613 |
VAR |
| 614 |
rtexceptions: CARDINAL ; |
| 615 |
BEGIN |
| 616 |
(* |
| 617 |
The pseudo procedures NEW and DISPOSE are in fact "macro" |
| 618 |
substituted for ALLOCATE and DEALLOCATE. |
| 619 |
However they both have symbols in the base module so that |
| 620 |
the procedure mechanism treats all procedure calls the same. |
| 621 |
"Macro" substitution occurs in M2Quads. |
| 622 |
*) |
| 623 |
|
| 624 |
New := MakeProcedure(BuiltinTokenNo, MakeKey('NEW')) ; |
| 625 |
Dispose := MakeProcedure(BuiltinTokenNo, MakeKey('DISPOSE')) ; |
| 626 |
Inc := MakeProcedure(BuiltinTokenNo, MakeKey('INC')) ; |
| 627 |
Dec := MakeProcedure(BuiltinTokenNo, MakeKey('DEC')) ; |
| 628 |
Incl := MakeProcedure(BuiltinTokenNo, MakeKey('INCL')) ; |
| 629 |
Excl := MakeProcedure(BuiltinTokenNo, MakeKey('EXCL')) ; |
| 630 |
|
| 631 |
IF NOT Pim2 |
| 632 |
THEN |
| 633 |
MakeSize (* SIZE is declared as a standard function in *) |
| 634 |
(* ISO Modula-2 and PIM-[34] Modula-2 but not *) |
| 635 |
(* PIM-2 Modula-2 *) |
| 636 |
END ; |
| 637 |
|
| 638 |
(* |
| 639 |
The procedure HALT is a real procedure which |
| 640 |
is defined in M2RTS. However to remain compatible |
| 641 |
with other Modula-2 implementations HALT can be used |
| 642 |
without the need to import it from M2RTS. ie it is |
| 643 |
within the BaseType module scope. |
| 644 |
*) |
| 645 |
m2rts := MakeDefinitionSource(BuiltinTokenNo, MakeKey('M2RTS')) ; |
| 646 |
PutImported(GetExported(BuiltinTokenNo, m2rts, MakeKey('HALT'))) ; |
| 647 |
|
| 648 |
ExceptionAssign := NulSym ; |
| 649 |
ExceptionReturn := NulSym ; |
| 650 |
ExceptionInc := NulSym ; |
| 651 |
ExceptionDec := NulSym ; |
| 652 |
ExceptionIncl := NulSym ; |
| 653 |
ExceptionExcl := NulSym ; |
| 654 |
ExceptionShift := NulSym ; |
| 655 |
ExceptionRotate := NulSym ; |
| 656 |
ExceptionStaticArray := NulSym ; |
| 657 |
ExceptionDynamicArray := NulSym ; |
| 658 |
ExceptionForLoopBegin := NulSym ; |
| 659 |
ExceptionForLoopTo := NulSym ; |
| 660 |
ExceptionForLoopEnd := NulSym ; |
| 661 |
ExceptionPointerNil := NulSym ; |
| 662 |
ExceptionNoReturn := NulSym ; |
| 663 |
ExceptionCase := NulSym ; |
| 664 |
ExceptionNonPosDiv := NulSym ; |
| 665 |
ExceptionNonPosMod := NulSym ; |
| 666 |
ExceptionZeroDiv := NulSym ; |
| 667 |
ExceptionZeroRem := NulSym ; |
| 668 |
ExceptionWholeValue := NulSym ; |
| 669 |
ExceptionRealValue := NulSym ; |
| 670 |
ExceptionParameterBounds := NulSym ; |
| 671 |
|
| 672 |
ExceptionNo := NulSym ; |
| 673 |
|
| 674 |
IF NilChecking |
| 675 |
THEN |
| 676 |
ExceptionPointerNil := ImportFrom(BuiltinTokenNo, m2rts, 'PointerNilException') |
| 677 |
END ; |
| 678 |
IF RangeChecking |
| 679 |
THEN |
| 680 |
ExceptionAssign := ImportFrom(BuiltinTokenNo, m2rts, 'AssignmentException') ; |
| 681 |
ExceptionReturn := ImportFrom(BuiltinTokenNo, m2rts, 'ReturnException') ; |
| 682 |
ExceptionInc := ImportFrom(BuiltinTokenNo, m2rts, 'IncException') ; |
| 683 |
ExceptionDec := ImportFrom(BuiltinTokenNo, m2rts, 'DecException') ; |
| 684 |
ExceptionIncl := ImportFrom(BuiltinTokenNo, m2rts, 'InclException') ; |
| 685 |
ExceptionExcl := ImportFrom(BuiltinTokenNo, m2rts, 'ExclException') ; |
| 686 |
ExceptionShift := ImportFrom(BuiltinTokenNo, m2rts, 'ShiftException') ; |
| 687 |
ExceptionRotate := ImportFrom(BuiltinTokenNo, m2rts, 'RotateException') ; |
| 688 |
ExceptionForLoopBegin := ImportFrom(BuiltinTokenNo, m2rts, 'ForLoopBeginException') ; |
| 689 |
ExceptionForLoopTo := ImportFrom(BuiltinTokenNo, m2rts, 'ForLoopToException') ; |
| 690 |
ExceptionForLoopEnd := ImportFrom(BuiltinTokenNo, m2rts, 'ForLoopEndException') ; |
| 691 |
ExceptionParameterBounds := ImportFrom(BuiltinTokenNo, m2rts, 'ParameterException') ; |
| 692 |
END ; |
| 693 |
IF IndexChecking |
| 694 |
THEN |
| 695 |
ExceptionStaticArray := ImportFrom(BuiltinTokenNo, m2rts, 'StaticArraySubscriptException') ; |
| 696 |
ExceptionDynamicArray := ImportFrom(BuiltinTokenNo, m2rts, 'DynamicArraySubscriptException') |
| 697 |
END ; |
| 698 |
IF WholeDivChecking |
| 699 |
THEN |
| 700 |
ExceptionNonPosDiv := ImportFrom(BuiltinTokenNo, m2rts, 'WholeNonPosDivException') ; |
| 701 |
ExceptionNonPosMod := ImportFrom(BuiltinTokenNo, m2rts, 'WholeNonPosModException') ; |
| 702 |
ExceptionZeroDiv := ImportFrom(BuiltinTokenNo, m2rts, 'WholeZeroDivException') ; |
| 703 |
ExceptionZeroRem := ImportFrom(BuiltinTokenNo, m2rts, 'WholeZeroRemException') |
| 704 |
END ; |
| 705 |
IF ReturnChecking |
| 706 |
THEN |
| 707 |
ExceptionNoReturn := ImportFrom(BuiltinTokenNo, m2rts, 'NoReturnException') |
| 708 |
END ; |
| 709 |
IF CaseElseChecking |
| 710 |
THEN |
| 711 |
ExceptionCase := ImportFrom(BuiltinTokenNo, m2rts, 'CaseException') |
| 712 |
END ; |
| 713 |
IF WholeValueChecking |
| 714 |
THEN |
| 715 |
ExceptionWholeValue := ImportFrom(BuiltinTokenNo, m2rts, 'WholeValueException') ; |
| 716 |
ExceptionRealValue := ImportFrom(BuiltinTokenNo, m2rts, 'RealValueException') |
| 717 |
END ; |
| 718 |
IF Exceptions |
| 719 |
THEN |
| 720 |
ExceptionNo := ImportFrom(BuiltinTokenNo, m2rts, 'NoException') ; |
| 721 |
(* ensure that this module is included *) |
| 722 |
rtexceptions := MakeDefinitionSource(BuiltinTokenNo, MakeKey('RTExceptions')) ; |
| 723 |
IF rtexceptions = NulSym |
| 724 |
THEN |
| 725 |
MetaError0 ('unable to find required runtime module RTExceptions') |
| 726 |
END |
| 727 |
END |
| 728 |
END InitBaseProcedures ; |
| 729 |
|
| 730 |
|
| 731 |
(* |
| 732 |
IsOrd - returns TRUE if, sym, is ORD or its typed counterparts |
| 733 |
ORDL, ORDS. |
| 734 |
*) |
| 735 |
|
| 736 |
PROCEDURE IsOrd (sym: CARDINAL) : BOOLEAN ; |
| 737 |
BEGIN |
| 738 |
RETURN (sym=Ord) OR (sym=OrdS) OR (sym=OrdL) |
| 739 |
END IsOrd ; |
| 740 |
|
| 741 |
|
| 742 |
(* |
| 743 |
BuildOrdFunctions - creates ORD, ORDS, ORDL. |
| 744 |
*) |
| 745 |
|
| 746 |
PROCEDURE BuildOrdFunctions ; |
| 747 |
BEGIN |
| 748 |
Ord := MakeProcedure(BuiltinTokenNo, MakeKey('ORD')) ; |
| 749 |
PutFunction (BuiltinTokenNo, Ord, DefProcedure, Cardinal) ; |
| 750 |
OrdS := MakeProcedure(BuiltinTokenNo, MakeKey('ORDS')) ; |
| 751 |
PutFunction (BuiltinTokenNo, OrdS, DefProcedure, ShortCard) ; |
| 752 |
OrdL := MakeProcedure(BuiltinTokenNo, MakeKey('ORDL')) ; |
| 753 |
PutFunction (BuiltinTokenNo, OrdL, DefProcedure, LongCard) |
| 754 |
END BuildOrdFunctions ; |
| 755 |
|
| 756 |
|
| 757 |
(* |
| 758 |
IsTrunc - returns TRUE if, sym, is TRUNC or its typed counterparts |
| 759 |
TRUNCL, TRUNCS. |
| 760 |
*) |
| 761 |
|
| 762 |
PROCEDURE IsTrunc (sym: CARDINAL) : BOOLEAN ; |
| 763 |
BEGIN |
| 764 |
RETURN (sym=Trunc) OR (sym=TruncS) OR (sym=TruncL) |
| 765 |
END IsTrunc ; |
| 766 |
|
| 767 |
|
| 768 |
(* |
| 769 |
BuildTruncFunctions - creates TRUNC, TRUNCS, TRUNCL. |
| 770 |
*) |
| 771 |
|
| 772 |
PROCEDURE BuildTruncFunctions ; |
| 773 |
BEGIN |
| 774 |
IF Pim2 OR Pim3 OR Iso |
| 775 |
THEN |
| 776 |
Trunc := MakeProcedure(BuiltinTokenNo, MakeKey('TRUNC')) ; |
| 777 |
PutFunction (BuiltinTokenNo, Trunc, DefProcedure, Cardinal) ; |
| 778 |
TruncS := MakeProcedure(BuiltinTokenNo, MakeKey('STRUNC')) ; |
| 779 |
PutFunction (BuiltinTokenNo, TruncS, DefProcedure, ShortCard) ; |
| 780 |
TruncL := MakeProcedure(BuiltinTokenNo, MakeKey('LTRUNC')) ; |
| 781 |
PutFunction (BuiltinTokenNo, TruncL, DefProcedure, LongCard) |
| 782 |
ELSE |
| 783 |
Trunc := MakeProcedure(BuiltinTokenNo, MakeKey('TRUNC')) ; |
| 784 |
PutFunction (BuiltinTokenNo, Trunc, DefProcedure, Integer) ; |
| 785 |
TruncS := MakeProcedure(BuiltinTokenNo, MakeKey('STRUNC')) ; |
| 786 |
PutFunction (BuiltinTokenNo, TruncS, DefProcedure, ShortInt) ; |
| 787 |
TruncL := MakeProcedure(BuiltinTokenNo, MakeKey('LTRUNC')) ; |
| 788 |
PutFunction (BuiltinTokenNo, TruncL, DefProcedure, LongInt) |
| 789 |
END |
| 790 |
END BuildTruncFunctions ; |
| 791 |
|
| 792 |
|
| 793 |
(* |
| 794 |
IsFloat - returns TRUE if, sym, is FLOAT or its typed counterparts |
| 795 |
FLOATL, FLOATS. |
| 796 |
*) |
| 797 |
|
| 798 |
PROCEDURE IsFloat (sym: CARDINAL) : BOOLEAN ; |
| 799 |
BEGIN |
| 800 |
RETURN( |
| 801 |
(sym=Float) OR (sym=FloatS) OR (sym=FloatL) OR |
| 802 |
(sym=SFloat) OR (sym=LFloat) |
| 803 |
) |
| 804 |
END IsFloat ; |
| 805 |
|
| 806 |
|
| 807 |
(* |
| 808 |
BuildFloatFunctions - creates TRUNC, TRUNCS, TRUNCL. |
| 809 |
*) |
| 810 |
|
| 811 |
PROCEDURE BuildFloatFunctions ; |
| 812 |
BEGIN |
| 813 |
Float := MakeProcedure(BuiltinTokenNo, MakeKey('FLOAT')) ; |
| 814 |
PutFunction (BuiltinTokenNo, Float, DefProcedure, Real) ; |
| 815 |
SFloat := MakeProcedure(BuiltinTokenNo, MakeKey('SFLOAT')) ; |
| 816 |
PutFunction (BuiltinTokenNo, SFloat, DefProcedure, ShortReal) ; |
| 817 |
LFloat := MakeProcedure(BuiltinTokenNo, MakeKey('LFLOAT')) ; |
| 818 |
PutFunction (BuiltinTokenNo, LFloat, DefProcedure, LongReal) ; |
| 819 |
FloatS := MakeProcedure(BuiltinTokenNo, MakeKey('FLOATS')) ; |
| 820 |
PutFunction (BuiltinTokenNo, FloatS, DefProcedure, ShortReal) ; |
| 821 |
FloatL := MakeProcedure(BuiltinTokenNo, MakeKey('FLOATL')) ; |
| 822 |
PutFunction (BuiltinTokenNo, FloatL, DefProcedure, LongReal) |
| 823 |
END BuildFloatFunctions ; |
| 824 |
|
| 825 |
|
| 826 |
(* |
| 827 |
IsInt - returns TRUE if, sym, is INT or its typed counterparts |
| 828 |
INTL, INTS. |
| 829 |
*) |
| 830 |
|
| 831 |
PROCEDURE IsInt (sym: CARDINAL) : BOOLEAN ; |
| 832 |
BEGIN |
| 833 |
RETURN (sym=Int) OR (sym=IntS) OR (sym=IntL) |
| 834 |
END IsInt ; |
| 835 |
|
| 836 |
|
| 837 |
(* |
| 838 |
BuildIntFunctions - creates INT, INTS, INTL. |
| 839 |
*) |
| 840 |
|
| 841 |
PROCEDURE BuildIntFunctions ; |
| 842 |
BEGIN |
| 843 |
Int := MakeProcedure(BuiltinTokenNo, MakeKey('INT')) ; |
| 844 |
PutFunction (BuiltinTokenNo, Int, DefProcedure, Integer) ; |
| 845 |
IntS := MakeProcedure(BuiltinTokenNo, MakeKey('INTS')) ; |
| 846 |
PutFunction (BuiltinTokenNo, IntS, DefProcedure, ShortInt) ; |
| 847 |
IntL := MakeProcedure(BuiltinTokenNo, MakeKey('INTL')) ; |
| 848 |
PutFunction (BuiltinTokenNo, IntL, DefProcedure, LongInt) |
| 849 |
END BuildIntFunctions ; |
| 850 |
|
| 851 |
|
| 852 |
(* |
| 853 |
InitBaseFunctions - initialises the base function, HIGH. |
| 854 |
*) |
| 855 |
|
| 856 |
PROCEDURE InitBaseFunctions ; |
| 857 |
BEGIN |
| 858 |
(* Now declare the dynamic array components, HIGH *) |
| 859 |
High := MakeProcedure(BuiltinTokenNo, MakeKey('HIGH')) ; (* Pseudo Base function HIGH *) |
| 860 |
PutFunction (BuiltinTokenNo, High, DefProcedure, Cardinal) ; |
| 861 |
|
| 862 |
(* |
| 863 |
_TemplateProcedure is a procedure which has a local variable _ActivationPointer |
| 864 |
whose offset is used for all nested procedures. (The activation pointer |
| 865 |
being in the same relative position for all procedures). |
| 866 |
*) |
| 867 |
TemplateProcedure := MakeProcedure(BuiltinTokenNo, MakeKey('_TemplateProcedure')) ; |
| 868 |
StartScope(TemplateProcedure) ; |
| 869 |
ActivationPointer := MakeVar(BuiltinTokenNo, MakeKey('_ActivationPointer')) ; |
| 870 |
PutVar(ActivationPointer, Address) ; |
| 871 |
EndScope ; |
| 872 |
|
| 873 |
(* and the base functions *) |
| 874 |
|
| 875 |
Convert := MakeProcedure(BuiltinTokenNo, MakeKey('CONVERT')) ; (* Internal function CONVERT *) |
| 876 |
IF Iso |
| 877 |
THEN |
| 878 |
LengthS := MakeProcedure(BuiltinTokenNo, MakeKey('LENGTH')) ; (* Pseudo Base function LENGTH *) |
| 879 |
PutFunction (BuiltinTokenNo, LengthS, DefProcedure, ZType) |
| 880 |
ELSE |
| 881 |
LengthS := NulSym |
| 882 |
END ; |
| 883 |
Abs := MakeProcedure(BuiltinTokenNo, MakeKey('ABS')) ; (* Pseudo Base function ABS *) |
| 884 |
PutFunction (BuiltinTokenNo, Abs, DefProcedure, ZType) ; |
| 885 |
|
| 886 |
Cap := MakeProcedure(BuiltinTokenNo, MakeKey('CAP')) ; (* Pseudo Base function CAP *) |
| 887 |
PutFunction (BuiltinTokenNo, Cap, DefProcedure, Char) ; |
| 888 |
|
| 889 |
Odd := MakeProcedure(BuiltinTokenNo, MakeKey('ODD')) ; (* Pseudo Base function ODD *) |
| 890 |
PutFunction (BuiltinTokenNo, Odd, DefProcedure, Boolean) ; |
| 891 |
|
| 892 |
Chr := MakeProcedure(BuiltinTokenNo, MakeKey('CHR')) ; (* Pseudo Base function CHR *) |
| 893 |
PutFunction (BuiltinTokenNo, Chr, DefProcedure, Char) ; |
| 894 |
|
| 895 |
(* the following three procedure functions have a return type depending upon *) |
| 896 |
(* the parameters. *) |
| 897 |
|
| 898 |
Val := MakeProcedure(BuiltinTokenNo, MakeKey('VAL')) ; (* Pseudo Base function VAL *) |
| 899 |
Min := MakeProcedure(BuiltinTokenNo, MakeKey('MIN')) ; (* Pseudo Base function MIN *) |
| 900 |
Max := MakeProcedure(BuiltinTokenNo, MakeKey('MAX')) ; (* Pseudo Base function MIN *) |
| 901 |
|
| 902 |
Re := MakeProcedure(BuiltinTokenNo, MakeKey('RE')) ; (* Pseudo Base function RE *) |
| 903 |
PutFunction (BuiltinTokenNo, Re, DefProcedure, RType) ; |
| 904 |
|
| 905 |
Im := MakeProcedure(BuiltinTokenNo, MakeKey('IM')) ; (* Pseudo Base function IM *) |
| 906 |
PutFunction (BuiltinTokenNo, Im, DefProcedure, RType) ; |
| 907 |
|
| 908 |
Cmplx := MakeProcedure(BuiltinTokenNo, MakeKey('CMPLX')) ; (* Pseudo Base function CMPLX *) |
| 909 |
PutFunction (BuiltinTokenNo, Cmplx, DefProcedure, CType) ; |
| 910 |
|
| 911 |
BuildFloatFunctions ; |
| 912 |
BuildTruncFunctions ; |
| 913 |
BuildOrdFunctions ; |
| 914 |
BuildIntFunctions |
| 915 |
END InitBaseFunctions ; |
| 916 |
|
| 917 |
|
| 918 |
(* |
| 919 |
IsISOPseudoBaseFunction - |
| 920 |
*) |
| 921 |
|
| 922 |
PROCEDURE IsISOPseudoBaseFunction (Sym: CARDINAL) : BOOLEAN ; |
| 923 |
BEGIN |
| 924 |
RETURN( Iso AND (Sym#NulSym) AND |
| 925 |
((Sym=LengthS) OR (Sym=Size) OR |
| 926 |
(Sym=Cmplx) OR (Sym=Re) OR (Sym=Im) OR IsInt(Sym)) ) |
| 927 |
END IsISOPseudoBaseFunction ; |
| 928 |
|
| 929 |
|
| 930 |
(* |
| 931 |
IsPIMPseudoBaseFunction - |
| 932 |
*) |
| 933 |
|
| 934 |
PROCEDURE IsPIMPseudoBaseFunction (Sym: CARDINAL) : BOOLEAN ; |
| 935 |
BEGIN |
| 936 |
RETURN( (NOT Iso) AND (NOT Pim2) AND (Sym#NulSym) AND (Sym=Size) ) |
| 937 |
END IsPIMPseudoBaseFunction ; |
| 938 |
|
| 939 |
|
| 940 |
(* |
| 941 |
IsPseudoBaseFunction - returns true if Sym is a Base pseudo function. |
| 942 |
*) |
| 943 |
|
| 944 |
PROCEDURE IsPseudoBaseFunction (Sym: CARDINAL) : BOOLEAN ; |
| 945 |
BEGIN |
| 946 |
RETURN( |
| 947 |
(Sym=High) OR (Sym=Val) OR (Sym=Convert) OR IsOrd(Sym) OR |
| 948 |
(Sym=Chr) OR IsFloat(Sym) OR IsTrunc(Sym) OR (Sym=Min) OR |
| 949 |
(Sym=Max) OR (Sym=Abs) OR (Sym=Odd) OR (Sym=Cap) OR |
| 950 |
IsISOPseudoBaseFunction(Sym) OR IsPIMPseudoBaseFunction(Sym) |
| 951 |
) |
| 952 |
END IsPseudoBaseFunction ; |
| 953 |
|
| 954 |
|
| 955 |
(* |
| 956 |
IsPseudoBaseProcedure - returns true if Sym is a Base pseudo procedure. |
| 957 |
*) |
| 958 |
|
| 959 |
PROCEDURE IsPseudoBaseProcedure (Sym: CARDINAL) : BOOLEAN ; |
| 960 |
BEGIN |
| 961 |
RETURN( |
| 962 |
(Sym=New) OR (Sym=Dispose) OR (Sym=Inc) OR (Sym=Dec) OR |
| 963 |
(Sym=Incl) OR (Sym=Excl) |
| 964 |
) |
| 965 |
END IsPseudoBaseProcedure ; |
| 966 |
|
| 967 |
|
| 968 |
(* |
| 969 |
IsBaseType - returns TRUE if Sym is a Base type. |
| 970 |
*) |
| 971 |
|
| 972 |
PROCEDURE IsBaseType (Sym: CARDINAL) : BOOLEAN ; |
| 973 |
BEGIN |
| 974 |
RETURN( |
| 975 |
(Sym=Cardinal) OR (Sym=Integer) OR (Sym=Boolean) OR |
| 976 |
(Sym=Char) OR (Sym=Proc) OR |
| 977 |
(Sym=LongInt) OR (Sym=LongCard) OR |
| 978 |
(Sym=ShortInt) OR (Sym=ShortCard) OR |
| 979 |
(Sym=Real) OR (Sym=LongReal) OR (Sym=ShortReal) OR |
| 980 |
(Sym=Complex) OR (Sym=LongComplex) OR (Sym=ShortComplex) OR |
| 981 |
(Sym=Bitset) |
| 982 |
) |
| 983 |
END IsBaseType ; |
| 984 |
|
| 985 |
|
| 986 |
(* |
| 987 |
IsOrdinalType - returns TRUE if, sym, is an ordinal type. |
| 988 |
An ordinal type is defined as: |
| 989 |
a base type which contains whole numbers or |
| 990 |
a subrange type or an enumeration type. |
| 991 |
*) |
| 992 |
|
| 993 |
PROCEDURE IsOrdinalType (Sym: CARDINAL) : BOOLEAN ; |
| 994 |
BEGIN |
| 995 |
RETURN( |
| 996 |
(Sym=Cardinal) OR (Sym=Integer) OR |
| 997 |
(Sym=Char) OR (Sym=Boolean) OR |
| 998 |
(Sym=LongInt) OR (Sym=LongCard) OR |
| 999 |
(Sym=ShortInt) OR (Sym=ShortCard) OR |
| 1000 |
(Sym=ZType) OR |
| 1001 |
IsSubrange(Sym) OR IsEnumeration(Sym) OR |
| 1002 |
IsIntegerN(Sym) OR IsCardinalN(Sym) |
| 1003 |
) |
| 1004 |
END IsOrdinalType ; |
| 1005 |
|
| 1006 |
|
| 1007 |
(* |
| 1008 |
IsComplexType - returns TRUE if, sym, is COMPLEX, |
| 1009 |
LONGCOMPLEX or SHORTCOMPLEX. |
| 1010 |
*) |
| 1011 |
|
| 1012 |
PROCEDURE IsComplexType (sym: CARDINAL) : BOOLEAN ; |
| 1013 |
BEGIN |
| 1014 |
RETURN( (sym=Complex) OR (sym=LongComplex) OR (sym=ShortComplex) OR (sym=CType) OR IsComplexN (sym) ) |
| 1015 |
END IsComplexType ; |
| 1016 |
|
| 1017 |
|
| 1018 |
(* |
| 1019 |
ComplexToScalar - returns the scalar (or base type) of the complex type, sym. |
| 1020 |
*) |
| 1021 |
|
| 1022 |
PROCEDURE ComplexToScalar (sym: CARDINAL) : CARDINAL ; |
| 1023 |
BEGIN |
| 1024 |
IF sym=NulSym |
| 1025 |
THEN |
| 1026 |
(* a const complex may have a NulSym type *) |
| 1027 |
RETURN( RType ) |
| 1028 |
ELSIF sym=Complex |
| 1029 |
THEN |
| 1030 |
RETURN( Real ) |
| 1031 |
ELSIF sym=LongComplex |
| 1032 |
THEN |
| 1033 |
RETURN( LongReal ) |
| 1034 |
ELSIF sym=ShortComplex |
| 1035 |
THEN |
| 1036 |
RETURN( ShortReal ) |
| 1037 |
ELSIF sym=CType |
| 1038 |
THEN |
| 1039 |
RETURN( RType ) |
| 1040 |
ELSIF sym=ComplexN(32) |
| 1041 |
THEN |
| 1042 |
RETURN( RealN(32) ) |
| 1043 |
ELSIF sym=ComplexN(64) |
| 1044 |
THEN |
| 1045 |
RETURN( RealN(64) ) |
| 1046 |
ELSIF sym=ComplexN(96) |
| 1047 |
THEN |
| 1048 |
RETURN( RealN(96) ) |
| 1049 |
ELSIF sym=ComplexN(128) |
| 1050 |
THEN |
| 1051 |
RETURN( RealN(128) ) |
| 1052 |
ELSE |
| 1053 |
MetaError1('{%1ad} must be a COMPLEX type', sym) ; |
| 1054 |
RETURN RType |
| 1055 |
END |
| 1056 |
END ComplexToScalar ; |
| 1057 |
|
| 1058 |
|
| 1059 |
(* |
| 1060 |
ScalarToComplex - given a real type, t, return the equivalent complex type. |
| 1061 |
*) |
| 1062 |
|
| 1063 |
PROCEDURE ScalarToComplex (sym: CARDINAL) : CARDINAL ; |
| 1064 |
BEGIN |
| 1065 |
IF sym=Real |
| 1066 |
THEN |
| 1067 |
RETURN( Complex ) |
| 1068 |
ELSIF sym=LongReal |
| 1069 |
THEN |
| 1070 |
RETURN( LongComplex ) |
| 1071 |
ELSIF sym=ShortReal |
| 1072 |
THEN |
| 1073 |
RETURN( ShortComplex ) |
| 1074 |
ELSIF sym=RType |
| 1075 |
THEN |
| 1076 |
RETURN( CType ) |
| 1077 |
ELSIF sym=RealN(32) |
| 1078 |
THEN |
| 1079 |
RETURN( ComplexN(32) ) |
| 1080 |
ELSIF sym=RealN(64) |
| 1081 |
THEN |
| 1082 |
RETURN( ComplexN(64) ) |
| 1083 |
ELSIF sym=RealN(96) |
| 1084 |
THEN |
| 1085 |
RETURN( ComplexN(96) ) |
| 1086 |
ELSIF sym=RealN(128) |
| 1087 |
THEN |
| 1088 |
RETURN( ComplexN(128) ) |
| 1089 |
ELSE |
| 1090 |
MetaError1('{%1ad} must be a REAL type', sym) ; |
| 1091 |
RETURN( Complex ) |
| 1092 |
END |
| 1093 |
END ScalarToComplex ; |
| 1094 |
|
| 1095 |
|
| 1096 |
(* |
| 1097 |
GetCmplxReturnType - this code implements the table given in the |
| 1098 |
ISO standard Page 293 with an addition for |
| 1099 |
SHORTCOMPLEX. |
| 1100 |
*) |
| 1101 |
|
| 1102 |
PROCEDURE GetCmplxReturnType (t1, t2: CARDINAL) : CARDINAL ; |
| 1103 |
VAR |
| 1104 |
mt1, mt2: MetaType ; |
| 1105 |
BEGIN |
| 1106 |
t1 := SkipType(t1) ; |
| 1107 |
t2 := SkipType(t2) ; |
| 1108 |
IF (IsRealType(t1) OR IsRealN(t1)) AND |
| 1109 |
(IsRealType(t2) OR IsRealN(t2)) |
| 1110 |
THEN |
| 1111 |
mt1 := FindMetaType(t1) ; |
| 1112 |
mt2 := FindMetaType(t2) ; |
| 1113 |
IF mt1=mt2 |
| 1114 |
THEN |
| 1115 |
RETURN( ScalarToComplex(t1) ) |
| 1116 |
ELSE |
| 1117 |
IF mt1=rtype |
| 1118 |
THEN |
| 1119 |
RETURN( ScalarToComplex(t2) ) |
| 1120 |
ELSIF mt2=rtype |
| 1121 |
THEN |
| 1122 |
RETURN( ScalarToComplex(t1) ) |
| 1123 |
ELSE |
| 1124 |
RETURN( NulSym ) |
| 1125 |
END |
| 1126 |
END |
| 1127 |
ELSE |
| 1128 |
RETURN( NulSym ) |
| 1129 |
END |
| 1130 |
END GetCmplxReturnType ; |
| 1131 |
|
| 1132 |
|
| 1133 |
(* |
| 1134 |
EmitTypeIncompatibleWarning - emit a type incompatibility warning. |
| 1135 |
*) |
| 1136 |
|
| 1137 |
PROCEDURE EmitTypeIncompatibleWarning (tok: CARDINAL; |
| 1138 |
kind: Compatability; t1, t2: CARDINAL) ; |
| 1139 |
BEGIN |
| 1140 |
CASE kind OF |
| 1141 |
|
| 1142 |
expression: MetaErrorT2 (tok, |
| 1143 |
'{%1W:} type incompatibility found {%1as:{%2as:between types {%1as} {%2as}}} in an expression, hint one of the expressions should be converted', |
| 1144 |
t1, t2) | |
| 1145 |
assignment: MetaErrorT2 (tok, |
| 1146 |
'{%1W:} type incompatibility found {%1as:{%2as:between types {%1as} {%2as}}} during an assignment, hint maybe the expression should be converted', |
| 1147 |
t1, t2) | |
| 1148 |
parameter : MetaErrorT2 (tok, |
| 1149 |
'{%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', |
| 1150 |
t1, t2) | |
| 1151 |
comparison: MetaErrorT2 (tok, |
| 1152 |
'{%1W:} type incompatibility found {%1as:{%2as:between types {%1as} {%2as}}} in a relational expression, hint one of the expressions should be converted', |
| 1153 |
t1, t2) |
| 1154 |
|
| 1155 |
ELSE |
| 1156 |
END |
| 1157 |
END EmitTypeIncompatibleWarning ; |
| 1158 |
|
| 1159 |
|
| 1160 |
(* |
| 1161 |
EmitTypeIncompatibleError - emit a type incompatibility error. |
| 1162 |
*) |
| 1163 |
|
| 1164 |
PROCEDURE EmitTypeIncompatibleError (tok: CARDINAL; |
| 1165 |
kind: Compatability; t1, t2: CARDINAL) ; |
| 1166 |
BEGIN |
| 1167 |
CASE kind OF |
| 1168 |
|
| 1169 |
expression: MetaErrorT2 (tok, |
| 1170 |
'type incompatibility found {%1as:{%2as:between types {%1as} and {%2as}}} in an expression, hint one of the expressions should be converted', |
| 1171 |
t1, t2) | |
| 1172 |
assignment: MetaErrorT2 (tok, |
| 1173 |
'type incompatibility found {%1as:{%2as:between types {%1as} and {%2as}}} during an assignment, hint maybe the expression should be converted', |
| 1174 |
t1, t2) | |
| 1175 |
parameter : MetaErrorT2 (tok, |
| 1176 |
'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', |
| 1177 |
t1, t2) | |
| 1178 |
comparison: MetaErrorT2 (tok, |
| 1179 |
'type incompatibility found {%1as:{%2as:between types {%1as} and {%2as}}} in a relational expression, hint one of the expressions should be converted', |
| 1180 |
t1, t2) |
| 1181 |
|
| 1182 |
ELSE |
| 1183 |
END |
| 1184 |
END EmitTypeIncompatibleError ; |
| 1185 |
|
| 1186 |
|
| 1187 |
(* |
| 1188 |
CheckCompatible - returns if t1 and t2 are kind compatible |
| 1189 |
*) |
| 1190 |
|
| 1191 |
PROCEDURE CheckCompatible (tok: CARDINAL; |
| 1192 |
t1, t2: CARDINAL; kind: Compatability) ; |
| 1193 |
VAR |
| 1194 |
s: String ; |
| 1195 |
r: Compatible ; |
| 1196 |
BEGIN |
| 1197 |
r := IsCompatible (t1, t2, kind) ; |
| 1198 |
IF (r#first) AND (r#second) |
| 1199 |
THEN |
| 1200 |
IF (r=warnfirst) OR (r=warnsecond) |
| 1201 |
THEN |
| 1202 |
s := InitString('{%1W}') |
| 1203 |
ELSE |
| 1204 |
s := InitString('') |
| 1205 |
END ; |
| 1206 |
IF IsUnknown(t1) AND IsUnknown(t2) |
| 1207 |
THEN |
| 1208 |
s := ConCat(s, InitString('two different unknown types {%1a:{%2a:{%1a} and {%2a}}} must either be declared or imported)')) ; |
| 1209 |
MetaErrorStringT2 (tok, s, t1, t2) |
| 1210 |
ELSIF IsUnknown(t1) |
| 1211 |
THEN |
| 1212 |
s := ConCat(s, InitString('this type {%1a} is currently unknown, it must be declared or imported')) ; |
| 1213 |
MetaErrorStringT1 (tok, s, t1) |
| 1214 |
ELSIF IsUnknown(t2) |
| 1215 |
THEN |
| 1216 |
s := ConCat (s, InitString('this type {%1a} is currently unknown, it must be declared or imported')) ; |
| 1217 |
MetaErrorStringT1 (tok, s, t2) |
| 1218 |
ELSE |
| 1219 |
IF (r=warnfirst) OR (r=warnsecond) |
| 1220 |
THEN |
| 1221 |
EmitTypeIncompatibleWarning (tok, kind, t1, t2) |
| 1222 |
ELSE |
| 1223 |
EmitTypeIncompatibleError (tok, kind, t1, t2) |
| 1224 |
END |
| 1225 |
END |
| 1226 |
END |
| 1227 |
END CheckCompatible ; |
| 1228 |
|
| 1229 |
|
| 1230 |
(* |
| 1231 |
CheckExpressionCompatible - returns if t1 and t2 are compatible types for |
| 1232 |
+, -, *, DIV, >, <, =, etc. |
| 1233 |
If t1 and t2 are not compatible then an error |
| 1234 |
message is displayed. |
| 1235 |
*) |
| 1236 |
|
| 1237 |
PROCEDURE CheckExpressionCompatible (tok: CARDINAL; left, right: CARDINAL) ; |
| 1238 |
BEGIN |
| 1239 |
CheckCompatible (tok, left, right, expression) |
| 1240 |
END CheckExpressionCompatible ; |
| 1241 |
|
| 1242 |
|
| 1243 |
(* |
| 1244 |
CheckParameterCompatible - checks to see if types, t1, and, t2, are |
| 1245 |
compatible for parameter passing. |
| 1246 |
*) |
| 1247 |
|
| 1248 |
PROCEDURE CheckParameterCompatible (tok: CARDINAL; |
| 1249 |
t1, t2: CARDINAL) ; |
| 1250 |
BEGIN |
| 1251 |
CheckCompatible (tok, t1, t2, parameter) |
| 1252 |
END CheckParameterCompatible ; |
| 1253 |
|
| 1254 |
|
| 1255 |
(* |
| 1256 |
CheckAssignmentCompatible - returns if t1 and t2 are compatible types for |
| 1257 |
:=, =, #. |
| 1258 |
If t1 and t2 are not compatible then an error |
| 1259 |
message is displayed. |
| 1260 |
*) |
| 1261 |
|
| 1262 |
PROCEDURE CheckAssignmentCompatible (tok: CARDINAL; |
| 1263 |
left, right: CARDINAL) ; |
| 1264 |
BEGIN |
| 1265 |
IF left # right |
| 1266 |
THEN |
| 1267 |
CheckCompatible (tok, left, right, assignment) |
| 1268 |
END |
| 1269 |
END CheckAssignmentCompatible ; |
| 1270 |
|
| 1271 |
|
| 1272 |
(* |
| 1273 |
FindMetaType - returns the MetaType associated with, sym. |
| 1274 |
*) |
| 1275 |
|
| 1276 |
PROCEDURE FindMetaType (sym: CARDINAL) : MetaType ; |
| 1277 |
BEGIN |
| 1278 |
IF sym=NulSym |
| 1279 |
THEN |
| 1280 |
RETURN( const ) |
| 1281 |
ELSIF sym=Word |
| 1282 |
THEN |
| 1283 |
RETURN( word ) |
| 1284 |
ELSIF sym=Byte |
| 1285 |
THEN |
| 1286 |
RETURN( byte ) |
| 1287 |
ELSIF sym=Loc |
| 1288 |
THEN |
| 1289 |
RETURN( loc ) |
| 1290 |
ELSIF sym=Address |
| 1291 |
THEN |
| 1292 |
RETURN( address ) |
| 1293 |
ELSIF sym=Char |
| 1294 |
THEN |
| 1295 |
RETURN( chr ) |
| 1296 |
ELSIF sym=Integer |
| 1297 |
THEN |
| 1298 |
RETURN( normint ) |
| 1299 |
ELSIF sym=ShortInt |
| 1300 |
THEN |
| 1301 |
RETURN( shortint ) |
| 1302 |
ELSIF sym=LongInt |
| 1303 |
THEN |
| 1304 |
RETURN( longint ) |
| 1305 |
ELSIF sym=Cardinal |
| 1306 |
THEN |
| 1307 |
RETURN( normcard ) |
| 1308 |
ELSIF sym=ShortCard |
| 1309 |
THEN |
| 1310 |
RETURN( shortcard ) |
| 1311 |
ELSIF sym=LongCard |
| 1312 |
THEN |
| 1313 |
RETURN( longcard ) |
| 1314 |
ELSIF sym=ZType |
| 1315 |
THEN |
| 1316 |
RETURN( ztype ) |
| 1317 |
ELSIF sym=RType |
| 1318 |
THEN |
| 1319 |
RETURN( rtype ) |
| 1320 |
ELSIF sym=Real |
| 1321 |
THEN |
| 1322 |
RETURN( real ) |
| 1323 |
ELSIF sym=ShortReal |
| 1324 |
THEN |
| 1325 |
RETURN( shortreal ) |
| 1326 |
ELSIF sym=LongReal |
| 1327 |
THEN |
| 1328 |
RETURN( longreal ) |
| 1329 |
ELSIF sym=IntegerN(8) |
| 1330 |
THEN |
| 1331 |
RETURN( int8 ) |
| 1332 |
ELSIF sym=IntegerN(16) |
| 1333 |
THEN |
| 1334 |
RETURN( int16 ) |
| 1335 |
ELSIF sym=IntegerN(32) |
| 1336 |
THEN |
| 1337 |
RETURN( int32 ) |
| 1338 |
ELSIF sym=IntegerN(64) |
| 1339 |
THEN |
| 1340 |
RETURN( int64 ) |
| 1341 |
ELSIF sym=CardinalN(8) |
| 1342 |
THEN |
| 1343 |
RETURN( card8 ) |
| 1344 |
ELSIF sym=CardinalN(16) |
| 1345 |
THEN |
| 1346 |
RETURN( card16 ) |
| 1347 |
ELSIF sym=CardinalN(32) |
| 1348 |
THEN |
| 1349 |
RETURN( card32 ) |
| 1350 |
ELSIF sym=CardinalN(64) |
| 1351 |
THEN |
| 1352 |
RETURN( card64 ) |
| 1353 |
ELSIF sym=WordN(16) |
| 1354 |
THEN |
| 1355 |
RETURN( word16 ) |
| 1356 |
ELSIF sym=WordN(32) |
| 1357 |
THEN |
| 1358 |
RETURN( word32 ) |
| 1359 |
ELSIF sym=WordN(64) |
| 1360 |
THEN |
| 1361 |
RETURN( word64 ) |
| 1362 |
ELSIF sym=SetN(8) |
| 1363 |
THEN |
| 1364 |
RETURN( set8 ) |
| 1365 |
ELSIF sym=SetN(16) |
| 1366 |
THEN |
| 1367 |
RETURN( set16 ) |
| 1368 |
ELSIF sym=SetN(32) |
| 1369 |
THEN |
| 1370 |
RETURN( set32 ) |
| 1371 |
ELSIF sym=RealN(32) |
| 1372 |
THEN |
| 1373 |
RETURN( real32 ) |
| 1374 |
ELSIF sym=RealN(64) |
| 1375 |
THEN |
| 1376 |
RETURN( real64 ) |
| 1377 |
ELSIF sym=RealN(96) |
| 1378 |
THEN |
| 1379 |
RETURN( real96 ) |
| 1380 |
ELSIF sym=RealN(128) |
| 1381 |
THEN |
| 1382 |
RETURN( real128 ) |
| 1383 |
ELSIF sym=Complex |
| 1384 |
THEN |
| 1385 |
RETURN( complex ) |
| 1386 |
ELSIF sym=ShortComplex |
| 1387 |
THEN |
| 1388 |
RETURN( shortcomplex ) |
| 1389 |
ELSIF sym=LongComplex |
| 1390 |
THEN |
| 1391 |
RETURN( longcomplex ) |
| 1392 |
ELSIF sym=ComplexN(32) |
| 1393 |
THEN |
| 1394 |
RETURN( complex32 ) |
| 1395 |
ELSIF sym=ComplexN(64) |
| 1396 |
THEN |
| 1397 |
RETURN( complex64 ) |
| 1398 |
ELSIF sym=ComplexN(96) |
| 1399 |
THEN |
| 1400 |
RETURN( complex96 ) |
| 1401 |
ELSIF sym=ComplexN(128) |
| 1402 |
THEN |
| 1403 |
RETURN( complex128 ) |
| 1404 |
ELSIF sym=CType |
| 1405 |
THEN |
| 1406 |
RETURN( ctype ) |
| 1407 |
ELSIF IsSet(sym) |
| 1408 |
THEN |
| 1409 |
RETURN( set ) |
| 1410 |
ELSIF IsHiddenType(sym) |
| 1411 |
THEN |
| 1412 |
RETURN( opaque ) |
| 1413 |
ELSIF IsPointer(sym) |
| 1414 |
THEN |
| 1415 |
RETURN( pointer ) |
| 1416 |
ELSIF IsEnumeration(sym) |
| 1417 |
THEN |
| 1418 |
RETURN( enum ) |
| 1419 |
ELSIF IsRecord(sym) |
| 1420 |
THEN |
| 1421 |
RETURN( rec ) |
| 1422 |
ELSIF IsArray(sym) |
| 1423 |
THEN |
| 1424 |
RETURN( array ) |
| 1425 |
ELSIF IsType(sym) |
| 1426 |
THEN |
| 1427 |
RETURN( FindMetaType(GetType(sym)) ) |
| 1428 |
ELSIF IsProcedure(sym) OR IsProcType(sym) |
| 1429 |
THEN |
| 1430 |
RETURN( procedure ) |
| 1431 |
ELSE |
| 1432 |
RETURN( unknown ) |
| 1433 |
END |
| 1434 |
END FindMetaType ; |
| 1435 |
|
| 1436 |
|
| 1437 |
(* |
| 1438 |
IsBaseCompatible - returns an enumeration field determining whether a simple base type |
| 1439 |
comparison is legal. |
| 1440 |
*) |
| 1441 |
|
| 1442 |
PROCEDURE IsBaseCompatible (t1, t2: CARDINAL; |
| 1443 |
kind: Compatability) : Compatible ; |
| 1444 |
VAR |
| 1445 |
mt1, mt2: MetaType ; |
| 1446 |
BEGIN |
| 1447 |
IF (t1=t2) AND ((kind=assignment) OR (kind=parameter)) |
| 1448 |
THEN |
| 1449 |
RETURN( first ) |
| 1450 |
ELSE |
| 1451 |
mt1 := FindMetaType (t1) ; |
| 1452 |
mt2 := FindMetaType (t2) ; |
| 1453 |
IF (mt1=unknown) OR (mt2=unknown) |
| 1454 |
THEN |
| 1455 |
RETURN( no ) |
| 1456 |
END ; |
| 1457 |
|
| 1458 |
CASE kind OF |
| 1459 |
|
| 1460 |
expression: RETURN( Expr [mt1, mt2] ) | |
| 1461 |
assignment: RETURN( Ass [mt1, mt2] ) | |
| 1462 |
parameter : RETURN( Ass [mt1, mt2] ) | |
| 1463 |
comparison: RETURN( Comp [mt1, mt2] ) |
| 1464 |
|
| 1465 |
ELSE |
| 1466 |
InternalError ('unexpected compatibility') |
| 1467 |
END |
| 1468 |
END |
| 1469 |
END IsBaseCompatible ; |
| 1470 |
|
| 1471 |
|
| 1472 |
(* |
| 1473 |
IsRealType - returns TRUE if, t, is a real type. |
| 1474 |
*) |
| 1475 |
|
| 1476 |
PROCEDURE IsRealType (t: CARDINAL) : BOOLEAN ; |
| 1477 |
BEGIN |
| 1478 |
RETURN( (t=Real) OR (t=LongReal) OR (t=ShortReal) OR (t=RType) ) |
| 1479 |
END IsRealType ; |
| 1480 |
|
| 1481 |
|
| 1482 |
(* |
| 1483 |
CannotCheckTypeInPass3 - returns TRUE if we are unable to check the |
| 1484 |
type of, e, in pass 3. |
| 1485 |
*) |
| 1486 |
|
| 1487 |
PROCEDURE CannotCheckTypeInPass3 (e: CARDINAL) : BOOLEAN ; |
| 1488 |
VAR |
| 1489 |
t : CARDINAL ; |
| 1490 |
mt: MetaType ; |
| 1491 |
BEGIN |
| 1492 |
t := SkipType(GetType(e)) ; |
| 1493 |
mt := FindMetaType(t) ; |
| 1494 |
CASE mt OF |
| 1495 |
|
| 1496 |
pointer, |
| 1497 |
enum, |
| 1498 |
set, |
| 1499 |
set8, |
| 1500 |
set16, |
| 1501 |
set32, |
| 1502 |
opaque : RETURN( TRUE ) |
| 1503 |
|
| 1504 |
ELSE |
| 1505 |
RETURN( FALSE ) |
| 1506 |
END |
| 1507 |
END CannotCheckTypeInPass3 ; |
| 1508 |
|
| 1509 |
|
| 1510 |
(* |
| 1511 |
IsCompatible - returns true if the types, t1, and, t2, are compatible. |
| 1512 |
*) |
| 1513 |
|
| 1514 |
PROCEDURE IsCompatible (t1, t2: CARDINAL; kind: Compatability) : Compatible ; |
| 1515 |
BEGIN |
| 1516 |
t1 := SkipType (t1) ; |
| 1517 |
t2 := SkipType (t2) ; |
| 1518 |
IF t1 = t2 |
| 1519 |
THEN |
| 1520 |
(* same types are always compatible. *) |
| 1521 |
RETURN first |
| 1522 |
ELSIF IsPassCodeGeneration () |
| 1523 |
THEN |
| 1524 |
RETURN AfterResolved (t1, t2, kind) |
| 1525 |
ELSE |
| 1526 |
RETURN BeforeResolved (t1, t2, kind) |
| 1527 |
END |
| 1528 |
END IsCompatible ; |
| 1529 |
|
| 1530 |
|
| 1531 |
(* |
| 1532 |
IsPointerSame - returns TRUE if pointers, a, and, b, are the same. |
| 1533 |
*) |
| 1534 |
|
| 1535 |
PROCEDURE IsPointerSame (a, b: CARDINAL; error: BOOLEAN) : BOOLEAN ; |
| 1536 |
BEGIN |
| 1537 |
RETURN( IsSameType(SkipType(GetType(a)), SkipType(GetType(b)), error) ) |
| 1538 |
END IsPointerSame ; |
| 1539 |
|
| 1540 |
|
| 1541 |
(* |
| 1542 |
IsSubrangeSame - checks to see whether the subranges are the same. |
| 1543 |
*) |
| 1544 |
|
| 1545 |
PROCEDURE IsSubrangeSame (a, b: CARDINAL) : BOOLEAN ; |
| 1546 |
VAR |
| 1547 |
al, ah, |
| 1548 |
bl, bh: CARDINAL ; |
| 1549 |
BEGIN |
| 1550 |
a := SkipType(a) ; |
| 1551 |
b := SkipType(b) ; |
| 1552 |
IF a#b |
| 1553 |
THEN |
| 1554 |
GetSubrange(a, ah, al) ; |
| 1555 |
GetSubrange(b, bh, bl) ; |
| 1556 |
PushValue(al) ; |
| 1557 |
PushValue(bl) ; |
| 1558 |
IF NOT Equ(GetDeclaredMod(a)) |
| 1559 |
THEN |
| 1560 |
RETURN( FALSE ) |
| 1561 |
END ; |
| 1562 |
PushValue(ah) ; |
| 1563 |
PushValue(bh) ; |
| 1564 |
IF NOT Equ(GetDeclaredMod(a)) |
| 1565 |
THEN |
| 1566 |
RETURN( FALSE ) |
| 1567 |
END |
| 1568 |
END ; |
| 1569 |
RETURN( TRUE ) |
| 1570 |
END IsSubrangeSame ; |
| 1571 |
|
| 1572 |
|
| 1573 |
(* |
| 1574 |
IsVarientSame - returns TRUE if varient types, a, and, b, are identical. |
| 1575 |
*) |
| 1576 |
|
| 1577 |
PROCEDURE IsVarientSame (a, b: CARDINAL; error: BOOLEAN) : BOOLEAN ; |
| 1578 |
VAR |
| 1579 |
i, j : CARDINAL ; |
| 1580 |
fa, fb, |
| 1581 |
ga, gb: CARDINAL ; |
| 1582 |
BEGIN |
| 1583 |
i := 1 ; |
| 1584 |
ga := NulSym ; |
| 1585 |
gb := NulSym ; |
| 1586 |
REPEAT |
| 1587 |
fa := GetNth(a, i) ; |
| 1588 |
fb := GetNth(b, i) ; |
| 1589 |
IF (fa#NulSym) AND (fb#NulSym) |
| 1590 |
THEN |
| 1591 |
Assert(IsFieldVarient(fa)) ; |
| 1592 |
Assert(IsFieldVarient(fb)) ; |
| 1593 |
j := 1 ; |
| 1594 |
REPEAT |
| 1595 |
ga := GetNth(fa, j) ; |
| 1596 |
gb := GetNth(fb, j) ; |
| 1597 |
IF (ga#NulSym) AND (gb#NulSym) |
| 1598 |
THEN |
| 1599 |
IF NOT IsSameType(GetType(ga), GetType(gb), error) |
| 1600 |
THEN |
| 1601 |
RETURN( FALSE ) |
| 1602 |
END ; |
| 1603 |
INC(j) |
| 1604 |
END |
| 1605 |
UNTIL (ga=NulSym) OR (gb=NulSym) ; |
| 1606 |
IF ga#gb |
| 1607 |
THEN |
| 1608 |
RETURN( FALSE ) |
| 1609 |
END |
| 1610 |
END ; |
| 1611 |
INC(i) |
| 1612 |
UNTIL (fa=NulSym) OR (fb=NulSym) ; |
| 1613 |
RETURN( ga=gb ) |
| 1614 |
END IsVarientSame ; |
| 1615 |
|
| 1616 |
|
| 1617 |
(* |
| 1618 |
IsRecordSame - |
| 1619 |
*) |
| 1620 |
|
| 1621 |
PROCEDURE IsRecordSame (a, b: CARDINAL; error: BOOLEAN) : BOOLEAN ; |
| 1622 |
VAR |
| 1623 |
ta, tb, |
| 1624 |
fa, fb: CARDINAL ; |
| 1625 |
i : CARDINAL ; |
| 1626 |
BEGIN |
| 1627 |
i := 1 ; |
| 1628 |
REPEAT |
| 1629 |
fa := GetNth(a, i) ; |
| 1630 |
fb := GetNth(b, i) ; |
| 1631 |
IF (fa#NulSym) AND (fb#NulSym) |
| 1632 |
THEN |
| 1633 |
ta := GetType(fa) ; |
| 1634 |
tb := GetType(fb) ; |
| 1635 |
IF IsRecordField(fa) AND IsRecordField(fb) |
| 1636 |
THEN |
| 1637 |
IF NOT IsSameType(ta, tb, error) |
| 1638 |
THEN |
| 1639 |
RETURN( FALSE ) |
| 1640 |
END |
| 1641 |
ELSIF IsVarient(fa) AND IsVarient(fb) |
| 1642 |
THEN |
| 1643 |
IF NOT IsVarientSame(ta, tb, error) |
| 1644 |
THEN |
| 1645 |
RETURN( FALSE ) |
| 1646 |
END |
| 1647 |
ELSIF IsFieldVarient(fa) OR IsFieldVarient(fb) |
| 1648 |
THEN |
| 1649 |
InternalError ('should not see a field varient') |
| 1650 |
ELSE |
| 1651 |
RETURN( FALSE ) |
| 1652 |
END |
| 1653 |
END ; |
| 1654 |
INC(i) |
| 1655 |
UNTIL (fa=NulSym) OR (fb=NulSym) ; |
| 1656 |
RETURN( fa=fb ) |
| 1657 |
END IsRecordSame ; |
| 1658 |
|
| 1659 |
|
| 1660 |
(* |
| 1661 |
IsArraySame - |
| 1662 |
*) |
| 1663 |
|
| 1664 |
PROCEDURE IsArraySame (t1, t2: CARDINAL; error: BOOLEAN) : BOOLEAN ; |
| 1665 |
VAR |
| 1666 |
s1, s2: CARDINAL ; |
| 1667 |
BEGIN |
| 1668 |
s1 := GetArraySubscript(t1) ; |
| 1669 |
s2 := GetArraySubscript(t2) ; |
| 1670 |
RETURN( IsSameType(GetType(s1), GetType(s2), error) AND |
| 1671 |
IsSameType(GetType(t1), GetType(t2), error) ) |
| 1672 |
END IsArraySame ; |
| 1673 |
|
| 1674 |
|
| 1675 |
(* |
| 1676 |
IsEnumerationSame - |
| 1677 |
*) |
| 1678 |
|
| 1679 |
PROCEDURE IsEnumerationSame (t1, t2: CARDINAL) : BOOLEAN ; |
| 1680 |
BEGIN |
| 1681 |
RETURN( t1=t2 ) |
| 1682 |
END IsEnumerationSame ; |
| 1683 |
|
| 1684 |
|
| 1685 |
(* |
| 1686 |
IsSetSame - |
| 1687 |
*) |
| 1688 |
|
| 1689 |
PROCEDURE IsSetSame (t1, t2: CARDINAL; error: BOOLEAN) : BOOLEAN ; |
| 1690 |
BEGIN |
| 1691 |
RETURN( IsSameType(GetType(t1), GetType(t2), error) ) |
| 1692 |
END IsSetSame ; |
| 1693 |
|
| 1694 |
|
| 1695 |
(* |
| 1696 |
IsSameType - returns TRUE if |
| 1697 |
*) |
| 1698 |
|
| 1699 |
PROCEDURE IsSameType (t1, t2: CARDINAL; error: BOOLEAN) : BOOLEAN ; |
| 1700 |
BEGIN |
| 1701 |
t1 := SkipType(t1) ; |
| 1702 |
t2 := SkipType(t2) ; |
| 1703 |
IF t1=t2 |
| 1704 |
THEN |
| 1705 |
RETURN( TRUE ) |
| 1706 |
ELSIF IsArray(t1) AND IsArray(t2) |
| 1707 |
THEN |
| 1708 |
RETURN( IsArraySame(t1, t2, error) ) |
| 1709 |
ELSIF IsSubrange(t1) AND IsSubrange(t2) |
| 1710 |
THEN |
| 1711 |
RETURN( IsSubrangeSame(t1, t2) ) |
| 1712 |
ELSIF IsProcType(t1) AND IsProcType(t2) |
| 1713 |
THEN |
| 1714 |
RETURN( IsProcTypeSame(t1, t2, error) ) |
| 1715 |
ELSIF IsEnumeration(t1) AND IsEnumeration(t2) |
| 1716 |
THEN |
| 1717 |
RETURN( IsEnumerationSame(t1, t2 (* , error *) ) ) |
| 1718 |
ELSIF IsRecord(t1) AND IsRecord(t2) |
| 1719 |
THEN |
| 1720 |
RETURN( IsRecordSame(t1, t2, error) ) |
| 1721 |
ELSIF IsSet(t1) AND IsSet(t2) |
| 1722 |
THEN |
| 1723 |
RETURN( IsSetSame(t1, t2, error) ) |
| 1724 |
ELSIF IsPointer(t1) AND IsPointer(t2) |
| 1725 |
THEN |
| 1726 |
RETURN( IsPointerSame(t1, t2, error) ) |
| 1727 |
ELSE |
| 1728 |
RETURN( FALSE ) |
| 1729 |
END |
| 1730 |
END IsSameType ; |
| 1731 |
|
| 1732 |
|
| 1733 |
(* |
| 1734 |
IsProcTypeSame - |
| 1735 |
*) |
| 1736 |
|
| 1737 |
PROCEDURE IsProcTypeSame (p1, p2: CARDINAL; error: BOOLEAN) : BOOLEAN ; |
| 1738 |
VAR |
| 1739 |
pa, pb: CARDINAL ; |
| 1740 |
n, i : CARDINAL ; |
| 1741 |
BEGIN |
| 1742 |
n := NoOfParamAny (p1) ; |
| 1743 |
IF n # NoOfParamAny (p2) |
| 1744 |
THEN |
| 1745 |
IF error |
| 1746 |
THEN |
| 1747 |
MetaError2('parameter is incompatible as {%1Dd} was declared with {%2n} parameters', p1, NoOfParamAny(p1)) ; |
| 1748 |
MetaError2('whereas {%1Dd} was declared with {%2n} parameters', p2, NoOfParamAny(p2)) |
| 1749 |
END ; |
| 1750 |
RETURN( FALSE ) |
| 1751 |
END ; |
| 1752 |
i := 1 ; |
| 1753 |
WHILE i<=n DO |
| 1754 |
pa := GetNthParamAny (p1, i) ; |
| 1755 |
pb := GetNthParamAny (p2, i) ; |
| 1756 |
IF IsParameterVar (pa) # IsParameterVar (pb) |
| 1757 |
THEN |
| 1758 |
IF error |
| 1759 |
THEN |
| 1760 |
MetaErrors3('the {%1n} parameter is incompatible between {%2Dad} and {%3ad} as only one was declared as VAR', |
| 1761 |
'the {%1n} parameter is incompatible between {%2ad} and {%3Dad} as only one was declared as VAR', |
| 1762 |
i, pa, pb) |
| 1763 |
END ; |
| 1764 |
RETURN( FALSE ) |
| 1765 |
END ; |
| 1766 |
IF NOT IsSameType(GetType(pa), GetType(pb), error) |
| 1767 |
THEN |
| 1768 |
RETURN( FALSE ) |
| 1769 |
END ; |
| 1770 |
INC(i) |
| 1771 |
END ; |
| 1772 |
RETURN( IsSameType(GetType(p1), GetType(p2), error) ) |
| 1773 |
END IsProcTypeSame ; |
| 1774 |
|
| 1775 |
|
| 1776 |
(* |
| 1777 |
doProcTypeCheck - |
| 1778 |
*) |
| 1779 |
|
| 1780 |
PROCEDURE doProcTypeCheck (p1, p2: CARDINAL; error: BOOLEAN) : BOOLEAN ; |
| 1781 |
BEGIN |
| 1782 |
IF (IsProcType(p1) OR IsProcedure(p1)) AND |
| 1783 |
(IsProcType(p2) OR IsProcedure(p2)) |
| 1784 |
THEN |
| 1785 |
IF p1=p2 |
| 1786 |
THEN |
| 1787 |
RETURN( TRUE ) |
| 1788 |
ELSE |
| 1789 |
RETURN( IsProcTypeSame(p1, p2, error) ) |
| 1790 |
END |
| 1791 |
ELSE |
| 1792 |
RETURN( FALSE ) |
| 1793 |
END |
| 1794 |
END doProcTypeCheck ; |
| 1795 |
|
| 1796 |
|
| 1797 |
(* |
| 1798 |
AfterResolved - a thorough test for type compatibility. |
| 1799 |
*) |
| 1800 |
|
| 1801 |
PROCEDURE AfterResolved (t1, t2: CARDINAL; kind: Compatability) : Compatible ; |
| 1802 |
VAR |
| 1803 |
mt1, mt2: MetaType ; |
| 1804 |
BEGIN |
| 1805 |
IF (t1=NulSym) OR (t2=NulSym) |
| 1806 |
THEN |
| 1807 |
RETURN( first ) |
| 1808 |
ELSIF ((kind=parameter) OR (kind=assignment)) AND (t1=t2) |
| 1809 |
THEN |
| 1810 |
RETURN( first ) |
| 1811 |
ELSIF IsSubrange(t1) |
| 1812 |
THEN |
| 1813 |
RETURN( IsCompatible(GetType(t1), t2, kind) ) |
| 1814 |
ELSIF IsSubrange(t2) |
| 1815 |
THEN |
| 1816 |
RETURN( IsCompatible(t1, GetType(t2), kind) ) |
| 1817 |
ELSE |
| 1818 |
mt1 := FindMetaType(t1) ; |
| 1819 |
mt2 := FindMetaType(t2) ; |
| 1820 |
IF mt1=mt2 |
| 1821 |
THEN |
| 1822 |
CASE mt1 OF |
| 1823 |
|
| 1824 |
set, |
| 1825 |
set8, |
| 1826 |
set16, |
| 1827 |
set32 : IF IsSetSame(t1, t2, FALSE) |
| 1828 |
THEN |
| 1829 |
RETURN( first ) |
| 1830 |
ELSE |
| 1831 |
RETURN( no ) |
| 1832 |
END | |
| 1833 |
enum : IF IsEnumerationSame(t1, t2 (* , FALSE *) ) |
| 1834 |
THEN |
| 1835 |
RETURN( first ) |
| 1836 |
ELSE |
| 1837 |
RETURN( no ) |
| 1838 |
END | |
| 1839 |
pointer : IF IsPointerSame(t1, t2, FALSE) |
| 1840 |
THEN |
| 1841 |
RETURN( first ) |
| 1842 |
ELSE |
| 1843 |
RETURN( no ) |
| 1844 |
END | |
| 1845 |
opaque : RETURN( no ) | |
| 1846 |
procedure: IF doProcTypeCheck(t1, t2, FALSE) |
| 1847 |
THEN |
| 1848 |
RETURN( first ) |
| 1849 |
ELSE |
| 1850 |
RETURN( no ) |
| 1851 |
END |
| 1852 |
|
| 1853 |
ELSE |
| 1854 |
(* fall through *) |
| 1855 |
END |
| 1856 |
END ; |
| 1857 |
RETURN( IsBaseCompatible(t1, t2, kind) ) |
| 1858 |
END |
| 1859 |
END AfterResolved ; |
| 1860 |
|
| 1861 |
|
| 1862 |
(* |
| 1863 |
BeforeResolved - attempts to test for type compatibility before all types are |
| 1864 |
completely resolved. In particular set types and constructor |
| 1865 |
types are not fully known before the end of pass 3. |
| 1866 |
However we can test base types. |
| 1867 |
*) |
| 1868 |
|
| 1869 |
PROCEDURE BeforeResolved (t1, t2: CARDINAL; kind: Compatability) : Compatible ; |
| 1870 |
BEGIN |
| 1871 |
IF (t1=NulSym) OR (t2=NulSym) |
| 1872 |
THEN |
| 1873 |
RETURN( first ) |
| 1874 |
ELSIF IsSubrange(t1) |
| 1875 |
THEN |
| 1876 |
RETURN( IsCompatible(GetType(t1), t2, kind) ) |
| 1877 |
ELSIF IsSubrange(t2) |
| 1878 |
THEN |
| 1879 |
RETURN( IsCompatible(t1, GetType(t2), kind) ) |
| 1880 |
ELSIF IsSet(t1) OR IsSet(t2) |
| 1881 |
THEN |
| 1882 |
(* cannot test set compatibility at this point so we do this again after pass 3 *) |
| 1883 |
RETURN( first ) |
| 1884 |
ELSIF (IsProcType(t1) AND IsProcedure(t2)) OR |
| 1885 |
(IsProcedure(t1) AND IsProcType(t2)) |
| 1886 |
THEN |
| 1887 |
(* we will perform checking during code generation *) |
| 1888 |
RETURN( first ) |
| 1889 |
ELSIF IsHiddenType (t1) AND IsHiddenType (t2) |
| 1890 |
THEN |
| 1891 |
IF t1 = t2 |
| 1892 |
THEN |
| 1893 |
MetaError0 ('assert about to fail as t1 = t2') |
| 1894 |
END ; |
| 1895 |
Assert (t1 # t2) ; |
| 1896 |
(* different opaque types are not assignment or expression compatible. *) |
| 1897 |
RETURN no |
| 1898 |
ELSE |
| 1899 |
(* |
| 1900 |
see M2Quads for the fixme comment at assignment. |
| 1901 |
|
| 1902 |
PIM2 says that CARDINAL and INTEGER are compatible with subranges of CARDINAL and INTEGER, |
| 1903 |
however we do not know the type to our subranges yet as (GetType(SubrangeType)=NulSym). |
| 1904 |
So we add type checking in the range checking module which is done post pass 3, |
| 1905 |
when all is resolved. |
| 1906 |
*) |
| 1907 |
|
| 1908 |
RETURN IsBaseCompatible (t1, t2, kind) |
| 1909 |
END |
| 1910 |
END BeforeResolved ; |
| 1911 |
|
| 1912 |
|
| 1913 |
(* |
| 1914 |
AssignmentRequiresWarning - returns TRUE if t1 and t2 can be used during |
| 1915 |
an assignment, but should generate a warning. |
| 1916 |
For example in PIM we can assign ADDRESS |
| 1917 |
and WORD providing they are both the |
| 1918 |
same size. |
| 1919 |
No warning is necessary if the types are the same. |
| 1920 |
*) |
| 1921 |
|
| 1922 |
PROCEDURE AssignmentRequiresWarning (t1, t2: CARDINAL) : BOOLEAN ; |
| 1923 |
BEGIN |
| 1924 |
RETURN ((t1 # t2) AND |
| 1925 |
((IsCompatible(t1, t2, assignment)=warnfirst) OR |
| 1926 |
(IsCompatible(t1, t2, assignment)=warnsecond))) |
| 1927 |
END AssignmentRequiresWarning ; |
| 1928 |
|
| 1929 |
|
| 1930 |
(* |
| 1931 |
IsAssignmentCompatible - returns TRUE if t1 and t2 are assignment |
| 1932 |
compatible. |
| 1933 |
*) |
| 1934 |
|
| 1935 |
PROCEDURE IsAssignmentCompatible (t1, t2: CARDINAL) : BOOLEAN ; |
| 1936 |
BEGIN |
| 1937 |
RETURN( |
| 1938 |
(t1=t2) OR |
| 1939 |
(IsCompatible(t1, t2, assignment)=first) OR |
| 1940 |
(IsCompatible(t1, t2, assignment)=second) |
| 1941 |
) |
| 1942 |
END IsAssignmentCompatible ; |
| 1943 |
|
| 1944 |
|
| 1945 |
(* |
| 1946 |
IsExpressionCompatible - returns TRUE if t1 and t2 are expression |
| 1947 |
compatible. |
| 1948 |
*) |
| 1949 |
|
| 1950 |
PROCEDURE IsExpressionCompatible (t1, t2: CARDINAL) : BOOLEAN ; |
| 1951 |
BEGIN |
| 1952 |
RETURN( |
| 1953 |
(IsCompatible(t1, t2, expression)=first) OR |
| 1954 |
(IsCompatible(t1, t2, expression)=second) |
| 1955 |
) |
| 1956 |
END IsExpressionCompatible ; |
| 1957 |
|
| 1958 |
|
| 1959 |
(* |
| 1960 |
IsParameterCompatible - returns TRUE if t1 and t2 are expression |
| 1961 |
compatible. |
| 1962 |
*) |
| 1963 |
|
| 1964 |
PROCEDURE IsParameterCompatible (t1, t2: CARDINAL (* ; tokenNo: CARDINAL *) ) : BOOLEAN ; |
| 1965 |
BEGIN |
| 1966 |
RETURN( |
| 1967 |
(IsCompatible(t1, t2, parameter)=first) OR |
| 1968 |
(IsCompatible(t1, t2, parameter)=second) |
| 1969 |
) |
| 1970 |
END IsParameterCompatible ; |
| 1971 |
|
| 1972 |
|
| 1973 |
(* |
| 1974 |
IsComparisonCompatible - returns TRUE if t1 and t2 are comparison compatible. |
| 1975 |
*) |
| 1976 |
|
| 1977 |
PROCEDURE IsComparisonCompatible (t1, t2: CARDINAL (* ; tokenNo: CARDINAL *) ) : BOOLEAN ; |
| 1978 |
BEGIN |
| 1979 |
RETURN( |
| 1980 |
(IsCompatible(t1, t2, comparison)=first) OR |
| 1981 |
(IsCompatible(t1, t2, comparison)=second) |
| 1982 |
) |
| 1983 |
END IsComparisonCompatible ; |
| 1984 |
|
| 1985 |
|
| 1986 |
(* |
| 1987 |
MixMetaTypes - |
| 1988 |
*) |
| 1989 |
|
| 1990 |
PROCEDURE MixMetaTypes (left, right, leftType, rightType: CARDINAL; NearTok: CARDINAL) : CARDINAL ; |
| 1991 |
VAR |
| 1992 |
mt1, mt2: MetaType ; |
| 1993 |
BEGIN |
| 1994 |
mt1 := FindMetaType (leftType) ; |
| 1995 |
mt2 := FindMetaType (rightType) ; |
| 1996 |
CASE Expr[mt1, mt2] OF |
| 1997 |
|
| 1998 |
no : MetaErrorT2 (NearTok, 'type incompatibility between {%1asd} and {%2asd}', |
| 1999 |
leftType, rightType) ; |
| 2000 |
MetaErrorDecl (left, TRUE) ; |
| 2001 |
MetaErrorDecl (right, TRUE) ; |
| 2002 |
FlushErrors (* unrecoverable at present *) | |
| 2003 |
warnfirst, |
| 2004 |
first : RETURN( leftType ) | |
| 2005 |
warnsecond, |
| 2006 |
second : RETURN( rightType ) |
| 2007 |
|
| 2008 |
ELSE |
| 2009 |
InternalError ('not expecting this metatype value') |
| 2010 |
END ; |
| 2011 |
RETURN MakeError (NearTok, NulName) |
| 2012 |
END MixMetaTypes ; |
| 2013 |
|
| 2014 |
|
| 2015 |
(* |
| 2016 |
IsUserType - return TRUE if type was created by the user as a synonym. |
| 2017 |
*) |
| 2018 |
|
| 2019 |
PROCEDURE IsUserType (type: CARDINAL) : BOOLEAN ; |
| 2020 |
BEGIN |
| 2021 |
RETURN IsType (type) AND |
| 2022 |
(NOT IsBaseType (type)) AND |
| 2023 |
(NOT IsSystemType (type)) AND |
| 2024 |
(type # ZType) |
| 2025 |
END IsUserType ; |
| 2026 |
|
| 2027 |
|
| 2028 |
(* |
| 2029 |
MixTypes - given types leftType and rightType return a type symbol that |
| 2030 |
provides expression type compatibility. |
| 2031 |
NearTok is used to identify the source position if a type |
| 2032 |
incompatability occurs. |
| 2033 |
*) |
| 2034 |
|
| 2035 |
PROCEDURE MixTypes (leftType, rightType: CARDINAL; NearTok: CARDINAL) : CARDINAL ; |
| 2036 |
BEGIN |
| 2037 |
RETURN MixTypesDecl (NulSym, NulSym, leftType, rightType, NearTok) |
| 2038 |
END MixTypes ; |
| 2039 |
|
| 2040 |
|
| 2041 |
(* |
| 2042 |
MixTypesDecl - returns a type symbol which provides expression compatibility |
| 2043 |
between leftType and rightType. An error is emitted if this |
| 2044 |
is not possible. left and right are the source (variable, |
| 2045 |
constant) of leftType and rightType respectively. |
| 2046 |
*) |
| 2047 |
|
| 2048 |
PROCEDURE MixTypesDecl (left, right, leftType, rightType: CARDINAL; NearTok: CARDINAL) : CARDINAL ; |
| 2049 |
BEGIN |
| 2050 |
IF leftType=rightType |
| 2051 |
THEN |
| 2052 |
RETURN( leftType ) |
| 2053 |
ELSIF (leftType=Address) AND (rightType=Cardinal) |
| 2054 |
THEN |
| 2055 |
RETURN( Address ) |
| 2056 |
ELSIF (leftType=Cardinal) AND (rightType=Address) |
| 2057 |
THEN |
| 2058 |
RETURN( Address ) |
| 2059 |
ELSIF (leftType=Address) AND (rightType=Integer) |
| 2060 |
THEN |
| 2061 |
RETURN( Address ) |
| 2062 |
ELSIF (leftType=Integer) AND (rightType=Address) |
| 2063 |
THEN |
| 2064 |
RETURN( Address ) |
| 2065 |
ELSIF leftType=NulSym |
| 2066 |
THEN |
| 2067 |
RETURN( rightType ) |
| 2068 |
ELSIF rightType=NulSym |
| 2069 |
THEN |
| 2070 |
RETURN( leftType ) |
| 2071 |
ELSIF (leftType=Bitset) AND IsSet(rightType) |
| 2072 |
THEN |
| 2073 |
RETURN( leftType ) |
| 2074 |
ELSIF IsSet(leftType) AND (rightType=Bitset) |
| 2075 |
THEN |
| 2076 |
RETURN( rightType ) |
| 2077 |
ELSIF IsEnumeration(leftType) |
| 2078 |
THEN |
| 2079 |
RETURN( MixTypesDecl (left, right, Integer, rightType, NearTok) ) |
| 2080 |
ELSIF IsEnumeration(rightType) |
| 2081 |
THEN |
| 2082 |
RETURN( MixTypesDecl (left, right, leftType, Integer, NearTok) ) |
| 2083 |
ELSIF IsSubrange(leftType) |
| 2084 |
THEN |
| 2085 |
RETURN( MixTypesDecl (left, right, GetType(leftType), rightType, NearTok) ) |
| 2086 |
ELSIF IsSubrange(rightType) |
| 2087 |
THEN |
| 2088 |
RETURN( MixTypesDecl (left, right, leftType, GetType(rightType), NearTok) ) |
| 2089 |
ELSIF IsRealType(leftType) AND IsRealType(rightType) |
| 2090 |
THEN |
| 2091 |
IF leftType=RType |
| 2092 |
THEN |
| 2093 |
RETURN( rightType ) |
| 2094 |
ELSIF rightType=RType |
| 2095 |
THEN |
| 2096 |
RETURN( leftType ) |
| 2097 |
ELSE |
| 2098 |
RETURN( RType ) |
| 2099 |
END |
| 2100 |
ELSIF IsComplexType(leftType) AND IsComplexType(rightType) |
| 2101 |
THEN |
| 2102 |
IF leftType=CType |
| 2103 |
THEN |
| 2104 |
RETURN( rightType ) |
| 2105 |
ELSIF rightType=CType |
| 2106 |
THEN |
| 2107 |
RETURN( leftType ) |
| 2108 |
ELSE |
| 2109 |
RETURN( CType ) |
| 2110 |
END |
| 2111 |
ELSIF IsUserType (leftType) |
| 2112 |
THEN |
| 2113 |
RETURN( MixTypesDecl (left, right, GetType(leftType), rightType, NearTok) ) |
| 2114 |
ELSIF IsUserType (rightType) |
| 2115 |
THEN |
| 2116 |
RETURN( MixTypes(leftType, GetType(rightType), NearTok) ) |
| 2117 |
ELSIF leftType = ZType |
| 2118 |
THEN |
| 2119 |
RETURN rightType |
| 2120 |
ELSIF rightType = ZType |
| 2121 |
THEN |
| 2122 |
RETURN leftType |
| 2123 |
ELSIF (leftType=GetLowestType(leftType)) AND (rightType=GetLowestType(rightType)) |
| 2124 |
THEN |
| 2125 |
RETURN( MixMetaTypes (left, right, leftType, rightType, NearTok) ) |
| 2126 |
ELSE |
| 2127 |
leftType := GetLowestType(leftType) ; |
| 2128 |
rightType := GetLowestType(rightType) ; |
| 2129 |
RETURN( MixTypesDecl (left, right, leftType, rightType, NearTok) ) |
| 2130 |
END |
| 2131 |
END MixTypesDecl ; |
| 2132 |
|
| 2133 |
|
| 2134 |
(* |
| 2135 |
NegateType - if the type is unsigned then returns the |
| 2136 |
signed equivalent. |
| 2137 |
*) |
| 2138 |
|
| 2139 |
PROCEDURE NegateType (type: CARDINAL (* ; sympos: CARDINAL *) ) : CARDINAL ; |
| 2140 |
VAR |
| 2141 |
lowType: CARDINAL ; |
| 2142 |
BEGIN |
| 2143 |
IF type#NulSym |
| 2144 |
THEN |
| 2145 |
lowType := GetLowestType (type) ; |
| 2146 |
IF lowType=LongCard |
| 2147 |
THEN |
| 2148 |
RETURN LongInt |
| 2149 |
ELSIF lowType=Cardinal |
| 2150 |
THEN |
| 2151 |
RETURN Integer |
| 2152 |
(* ELSE |
| 2153 |
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) |
| 2154 |
*) |
| 2155 |
END |
| 2156 |
END ; |
| 2157 |
RETURN type |
| 2158 |
END NegateType ; |
| 2159 |
|
| 2160 |
|
| 2161 |
(* |
| 2162 |
IsMathType - returns TRUE if the type is a mathematical type. |
| 2163 |
A mathematical type has a range larger than INTEGER. |
| 2164 |
(Typically SHORTREAL/REAL/LONGREAL/LONGINT/LONGCARD) |
| 2165 |
*) |
| 2166 |
|
| 2167 |
PROCEDURE IsMathType (type: CARDINAL) : BOOLEAN ; |
| 2168 |
BEGIN |
| 2169 |
RETURN( |
| 2170 |
(type=LongCard) OR (type=LongInt) OR (type=Real) OR |
| 2171 |
(type=LongReal) OR (type=ShortReal) OR |
| 2172 |
(type=RType) OR (type=ZType) |
| 2173 |
) |
| 2174 |
END IsMathType ; |
| 2175 |
|
| 2176 |
|
| 2177 |
(* |
| 2178 |
IsVarParamCompatible - returns TRUE if types, actual, and, formal |
| 2179 |
are compatible even if formal is a VAR |
| 2180 |
parameter. |
| 2181 |
*) |
| 2182 |
|
| 2183 |
PROCEDURE IsVarParamCompatible (actual, formal: CARDINAL) : BOOLEAN ; |
| 2184 |
BEGIN |
| 2185 |
actual := SkipType(actual) ; |
| 2186 |
formal := SkipType(formal) ; |
| 2187 |
IF IsParameter(formal) AND IsParameterUnbounded(formal) |
| 2188 |
THEN |
| 2189 |
formal := SkipType(GetType(GetType(formal))) ; (* move over unbounded *) |
| 2190 |
IF IsGenericSystemType(formal) |
| 2191 |
THEN |
| 2192 |
RETURN( TRUE ) |
| 2193 |
END ; |
| 2194 |
RETURN( (formal=actual) OR (IsArray(actual) AND (formal=SkipType(GetType(actual)))) ) |
| 2195 |
ELSE |
| 2196 |
RETURN( (actual=formal) OR |
| 2197 |
(IsPointer(actual) AND (formal=Address)) OR |
| 2198 |
(IsPointer(formal) AND (actual=Address)) OR |
| 2199 |
(IsGenericSystemType(actual) AND IsSizeSame(FindMetaType(actual), FindMetaType(formal))) OR |
| 2200 |
(IsGenericSystemType(formal) AND IsSizeSame(FindMetaType(actual), FindMetaType(formal))) OR |
| 2201 |
IsSameSizePervasiveType(formal, actual) ) |
| 2202 |
END |
| 2203 |
END IsVarParamCompatible ; |
| 2204 |
|
| 2205 |
|
| 2206 |
(* |
| 2207 |
IsArrayUnboundedCompatible - returns TRUE if unbounded or array types, t1, and, t2, |
| 2208 |
are compatible. |
| 2209 |
*) |
| 2210 |
|
| 2211 |
PROCEDURE IsArrayUnboundedCompatible (t1, t2: CARDINAL) : BOOLEAN ; |
| 2212 |
BEGIN |
| 2213 |
IF (t1=NulSym) OR (t2=NulSym) |
| 2214 |
THEN |
| 2215 |
RETURN( FALSE) |
| 2216 |
ELSIF (IsUnbounded(t1) OR IsArray(t1)) AND |
| 2217 |
(IsUnbounded(t2) OR IsArray(t2)) |
| 2218 |
THEN |
| 2219 |
RETURN( SkipType(GetType(t1))=SkipType(GetType(t2)) ) |
| 2220 |
ELSE |
| 2221 |
RETURN( FALSE ) |
| 2222 |
END |
| 2223 |
END IsArrayUnboundedCompatible ; |
| 2224 |
|
| 2225 |
|
| 2226 |
(* |
| 2227 |
IsValidUnboundedParameter - |
| 2228 |
*) |
| 2229 |
|
| 2230 |
PROCEDURE IsValidUnboundedParameter (formal, actual: CARDINAL) : BOOLEAN ; |
| 2231 |
VAR |
| 2232 |
ft, at : CARDINAL ; |
| 2233 |
n, m, o: CARDINAL ; |
| 2234 |
BEGIN |
| 2235 |
Assert(IsParameterUnbounded(formal)) ; |
| 2236 |
ft := SkipType(GetType(GetType(formal))) ; (* ARRAY OF ft *) |
| 2237 |
IF IsGenericSystemType(ft) OR IsArrayUnboundedCompatible(GetType(formal), GetType(actual)) |
| 2238 |
THEN |
| 2239 |
RETURN( TRUE ) |
| 2240 |
ELSE |
| 2241 |
IF IsParameter(actual) AND IsParameterUnbounded(actual) |
| 2242 |
THEN |
| 2243 |
n := GetDimension(actual) ; |
| 2244 |
m := GetDimension(formal) ; |
| 2245 |
IF n#m |
| 2246 |
THEN |
| 2247 |
RETURN( IsGenericSystemType(ft) AND (n<m) ) |
| 2248 |
ELSE |
| 2249 |
RETURN( (GetDimension(actual)=GetDimension(formal)) AND |
| 2250 |
IsParameterCompatible(GetType(GetType(actual)), ft) ) |
| 2251 |
END |
| 2252 |
ELSE |
| 2253 |
IF IsConstString(actual) |
| 2254 |
THEN |
| 2255 |
RETURN( IsParameterCompatible(Char, ft) ) |
| 2256 |
ELSE |
| 2257 |
at := SkipType(GetType(actual)) ; |
| 2258 |
IF IsArray(at) |
| 2259 |
THEN |
| 2260 |
m := GetDimension(formal) ; |
| 2261 |
n := GetDimension(at) ; |
| 2262 |
o := 0 ; |
| 2263 |
WHILE IsArray(at) DO |
| 2264 |
INC(o) ; |
| 2265 |
at := SkipType(GetType(at)) ; |
| 2266 |
IF (m=o) AND (at=ft) |
| 2267 |
THEN |
| 2268 |
RETURN( TRUE ) |
| 2269 |
END |
| 2270 |
END ; |
| 2271 |
IF n#m |
| 2272 |
THEN |
| 2273 |
RETURN( IsGenericSystemType(ft) AND (n<m) ) |
| 2274 |
ELSIF IsParameterVar(formal) |
| 2275 |
THEN |
| 2276 |
RETURN( IsVarParamCompatible(at, formal) ) |
| 2277 |
ELSE |
| 2278 |
RETURN( IsParameterCompatible(at, ft) ) |
| 2279 |
END |
| 2280 |
ELSE |
| 2281 |
IF IsParameterVar(formal) |
| 2282 |
THEN |
| 2283 |
RETURN( IsVarParamCompatible(at, formal) ) |
| 2284 |
ELSE |
| 2285 |
RETURN( IsParameterCompatible(at, ft) ) |
| 2286 |
END |
| 2287 |
END |
| 2288 |
END |
| 2289 |
END |
| 2290 |
END |
| 2291 |
END IsValidUnboundedParameter ; |
| 2292 |
|
| 2293 |
|
| 2294 |
(* |
| 2295 |
IsValidParameter - returns TRUE if an, actual, parameter can be passed |
| 2296 |
to the, formal, parameter. This differs from |
| 2297 |
IsParameterCompatible as this procedure includes checks |
| 2298 |
for unbounded formal parameters, var parameters and |
| 2299 |
constant actual parameters. |
| 2300 |
*) |
| 2301 |
|
| 2302 |
PROCEDURE IsValidParameter (formal, actual: CARDINAL (* ; tokenNo: CARDINAL *) ) : BOOLEAN ; |
| 2303 |
VAR |
| 2304 |
at, ft: CARDINAL ; |
| 2305 |
BEGIN |
| 2306 |
Assert(IsParameter(formal)) ; |
| 2307 |
Assert(IsPassCodeGeneration()) ; |
| 2308 |
IF IsConst(actual) AND IsParameterVar(formal) |
| 2309 |
THEN |
| 2310 |
RETURN( FALSE ) |
| 2311 |
ELSE |
| 2312 |
IF IsParameterUnbounded(formal) |
| 2313 |
THEN |
| 2314 |
RETURN( IsValidUnboundedParameter(formal, actual) ) |
| 2315 |
ELSE |
| 2316 |
ft := SkipType(GetType(formal)) |
| 2317 |
END ; |
| 2318 |
IF IsConst(actual) AND (SkipType(GetType(actual))=Char) AND IsArray(ft) AND (SkipType(GetType(ft))=Char) |
| 2319 |
THEN |
| 2320 |
(* a constant char can be either a char or a string *) |
| 2321 |
RETURN( TRUE ) |
| 2322 |
END ; |
| 2323 |
IF IsProcType(ft) |
| 2324 |
THEN |
| 2325 |
IF IsProcedure(actual) |
| 2326 |
THEN |
| 2327 |
(* we check this by calling IsValidProcedure for each and every |
| 2328 |
parameter of actual and formal *) |
| 2329 |
RETURN( TRUE ) |
| 2330 |
ELSE |
| 2331 |
at := SkipType(GetType(actual)) ; |
| 2332 |
RETURN( doProcTypeCheck(at, ft, TRUE) ) |
| 2333 |
END |
| 2334 |
ELSIF IsParameterVar(formal) |
| 2335 |
THEN |
| 2336 |
RETURN( IsVarParamCompatible(GetType(actual), ft) ) |
| 2337 |
ELSE |
| 2338 |
RETURN( IsParameterCompatible(GetType(actual), ft) ) |
| 2339 |
END |
| 2340 |
END |
| 2341 |
END IsValidParameter ; |
| 2342 |
|
| 2343 |
|
| 2344 |
(* |
| 2345 |
PushSizeOf - pushes the size of a meta type. |
| 2346 |
*) |
| 2347 |
|
| 2348 |
PROCEDURE PushSizeOf (t: MetaType) ; |
| 2349 |
BEGIN |
| 2350 |
CASE t OF |
| 2351 |
|
| 2352 |
const : InternalError ('do not know the size of a constant') | |
| 2353 |
word : IF Iso |
| 2354 |
THEN |
| 2355 |
PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetISOWordType())) |
| 2356 |
ELSE |
| 2357 |
PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetWordType())) |
| 2358 |
END | |
| 2359 |
byte : IF Iso |
| 2360 |
THEN |
| 2361 |
PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetISOByteType())) |
| 2362 |
ELSE |
| 2363 |
PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetByteType())) |
| 2364 |
END | |
| 2365 |
address : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetPointerType())) | |
| 2366 |
chr : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2CharType())) | |
| 2367 |
normint : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2IntegerType())) | |
| 2368 |
shortint : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2ShortIntType())) | |
| 2369 |
longint : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2LongIntType())) | |
| 2370 |
normcard : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2CardinalType())) | |
| 2371 |
shortcard: PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2ShortCardType())) | |
| 2372 |
longcard : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2LongCardType())) | |
| 2373 |
pointer : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetPointerType())) | |
| 2374 |
enum : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetIntegerType())) | |
| 2375 |
real : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2RealType())) | |
| 2376 |
shortreal: PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2ShortRealType())) | |
| 2377 |
longreal : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2LongRealType())) | |
| 2378 |
set : InternalError ('do not know the size of a set') | |
| 2379 |
opaque : InternalError ('do not know the size of an opaque') | |
| 2380 |
loc : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetISOLocType())) | |
| 2381 |
rtype : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2RType())) | |
| 2382 |
ztype : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2ZType())) | |
| 2383 |
int8, |
| 2384 |
card8, |
| 2385 |
set8 : PushIntegerTree(BuildIntegerConstant(1)) | |
| 2386 |
word16, |
| 2387 |
set16, |
| 2388 |
card16, |
| 2389 |
int16 : PushIntegerTree(BuildIntegerConstant(2)) | |
| 2390 |
real32, |
| 2391 |
word32, |
| 2392 |
set32, |
| 2393 |
card32, |
| 2394 |
int32 : PushIntegerTree(BuildIntegerConstant(4)) | |
| 2395 |
real64, |
| 2396 |
word64, |
| 2397 |
card64, |
| 2398 |
int64 : PushIntegerTree(BuildIntegerConstant(8)) | |
| 2399 |
real96 : PushIntegerTree(BuildIntegerConstant(12)) | |
| 2400 |
real128 : PushIntegerTree(BuildIntegerConstant(16)) | |
| 2401 |
complex : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2ComplexType())) | |
| 2402 |
shortcomplex: PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2ShortComplexType())) | |
| 2403 |
longcomplex: PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2LongComplexType())) | |
| 2404 |
complex32: PushIntegerTree(BuildIntegerConstant(4*2)) | |
| 2405 |
complex64: PushIntegerTree(BuildIntegerConstant(8*2)) | |
| 2406 |
complex96: PushIntegerTree(BuildIntegerConstant(12*2)) | |
| 2407 |
complex128: PushIntegerTree(BuildIntegerConstant(16*2)) | |
| 2408 |
ctype : PushIntegerTree(GetSizeOf(BuiltinsLocation(), GetM2CType())) | |
| 2409 |
|
| 2410 |
unknown : InternalError ('should not get here') |
| 2411 |
|
| 2412 |
ELSE |
| 2413 |
InternalError ('should not get here') |
| 2414 |
END |
| 2415 |
END PushSizeOf ; |
| 2416 |
|
| 2417 |
|
| 2418 |
(* |
| 2419 |
IsSizeSame - |
| 2420 |
*) |
| 2421 |
|
| 2422 |
PROCEDURE IsSizeSame (t1, t2: MetaType) : BOOLEAN ; |
| 2423 |
BEGIN |
| 2424 |
PushSizeOf(t1) ; |
| 2425 |
PushSizeOf(t2) ; |
| 2426 |
RETURN( Equ(0) ) |
| 2427 |
END IsSizeSame ; |
| 2428 |
|
| 2429 |
|
| 2430 |
(* |
| 2431 |
InitArray - |
| 2432 |
*) |
| 2433 |
|
| 2434 |
PROCEDURE InitArray (VAR c: CompatibilityArray; |
| 2435 |
y: MetaType; a: ARRAY OF CHAR) ; |
| 2436 |
VAR |
| 2437 |
x : MetaType ; |
| 2438 |
h, i: CARDINAL ; |
| 2439 |
BEGIN |
| 2440 |
h := StrLen(a) ; |
| 2441 |
i := 0 ; |
| 2442 |
x := MIN(MetaType) ; |
| 2443 |
WHILE i<h DO |
| 2444 |
IF (c[x, y]#uninitialized) AND (x#unknown) AND (y#unknown) |
| 2445 |
THEN |
| 2446 |
InternalError('expecting array element to be uninitialized') |
| 2447 |
END ; |
| 2448 |
CASE a[i] OF |
| 2449 |
|
| 2450 |
' ': | |
| 2451 |
'.': CASE c[y, x] OF |
| 2452 |
|
| 2453 |
uninitialized: InternalError('cannot reflect value as it is unknown') | |
| 2454 |
first : c[x, y] := second | |
| 2455 |
second : c[x, y] := first | |
| 2456 |
warnfirst : c[x, y] := warnsecond | |
| 2457 |
warnsecond : c[x, y] := warnfirst |
| 2458 |
|
| 2459 |
ELSE |
| 2460 |
c[x, y] := c[y, x] |
| 2461 |
END ; |
| 2462 |
INC(x) | |
| 2463 |
'F': c[x, y] := no ; |
| 2464 |
INC(x) | |
| 2465 |
'T', |
| 2466 |
'1': c[x, y] := first ; |
| 2467 |
INC(x) | |
| 2468 |
'2': c[x, y] := second ; |
| 2469 |
INC(x) | |
| 2470 |
'W': IF Pim |
| 2471 |
THEN |
| 2472 |
IF IsSizeSame(x, y) |
| 2473 |
THEN |
| 2474 |
c[x, y] := warnsecond |
| 2475 |
ELSE |
| 2476 |
c[x, y] := no |
| 2477 |
END |
| 2478 |
ELSE |
| 2479 |
c[x, y] := no |
| 2480 |
END ; |
| 2481 |
INC(x) | |
| 2482 |
'w': IF Pim |
| 2483 |
THEN |
| 2484 |
IF IsSizeSame(x, y) |
| 2485 |
THEN |
| 2486 |
c[x, y] := warnfirst |
| 2487 |
ELSE |
| 2488 |
c[x, y] := no |
| 2489 |
END |
| 2490 |
ELSE |
| 2491 |
c[x, y] := no |
| 2492 |
END ; |
| 2493 |
INC(x) | |
| 2494 |
'P': IF Pim |
| 2495 |
THEN |
| 2496 |
c[x, y] := second |
| 2497 |
ELSE |
| 2498 |
c[x, y] := no |
| 2499 |
END ; |
| 2500 |
INC(x) | |
| 2501 |
'p': IF Pim |
| 2502 |
THEN |
| 2503 |
c[x, y] := first |
| 2504 |
ELSE |
| 2505 |
c[x, y] := no |
| 2506 |
END ; |
| 2507 |
INC(x) | |
| 2508 |
's': IF IsSizeSame(x, y) |
| 2509 |
THEN |
| 2510 |
c[x, y] := first |
| 2511 |
ELSE |
| 2512 |
c[x, y] := no |
| 2513 |
END ; |
| 2514 |
INC(x) | |
| 2515 |
'S': IF IsSizeSame(x, y) |
| 2516 |
THEN |
| 2517 |
c[x, y] := second |
| 2518 |
ELSE |
| 2519 |
c[x, y] := no |
| 2520 |
END ; |
| 2521 |
INC(x) | |
| 2522 |
|
| 2523 |
ELSE |
| 2524 |
InternalError ('unexpected specifier') |
| 2525 |
END ; |
| 2526 |
INC(i) |
| 2527 |
END |
| 2528 |
END InitArray ; |
| 2529 |
|
| 2530 |
|
| 2531 |
(* |
| 2532 |
A - initialize the assignment array |
| 2533 |
*) |
| 2534 |
|
| 2535 |
PROCEDURE A (y: MetaType; a: ARRAY OF CHAR) ; |
| 2536 |
BEGIN |
| 2537 |
InitArray (Ass, y, a) |
| 2538 |
END A ; |
| 2539 |
|
| 2540 |
|
| 2541 |
(* |
| 2542 |
E - initialize the expression array |
| 2543 |
*) |
| 2544 |
|
| 2545 |
PROCEDURE E (y: MetaType; a: ARRAY OF CHAR) ; |
| 2546 |
BEGIN |
| 2547 |
InitArray (Expr, y, a) |
| 2548 |
END E ; |
| 2549 |
|
| 2550 |
|
| 2551 |
(* |
| 2552 |
C - initialize the comparision array |
| 2553 |
*) |
| 2554 |
|
| 2555 |
PROCEDURE C (y: MetaType; a: ARRAY OF CHAR) ; |
| 2556 |
BEGIN |
| 2557 |
InitArray (Comp, y, a) |
| 2558 |
END C ; |
| 2559 |
|
| 2560 |
|
| 2561 |
(* |
| 2562 |
InitCompatibilityMatrices - initializes the tables above. |
| 2563 |
*) |
| 2564 |
|
| 2565 |
PROCEDURE InitCompatibilityMatrices ; |
| 2566 |
VAR |
| 2567 |
i, j: MetaType ; |
| 2568 |
BEGIN |
| 2569 |
(* initialize to a known state *) |
| 2570 |
FOR i := MIN(MetaType) TO MAX(MetaType) DO |
| 2571 |
FOR j := MIN(MetaType) TO MAX(MetaType) DO |
| 2572 |
Ass[i, j] := uninitialized ; |
| 2573 |
Expr[i, j] := uninitialized |
| 2574 |
END |
| 2575 |
END ; |
| 2576 |
|
| 2577 |
(* all unknowns are false *) |
| 2578 |
FOR i := MIN(MetaType) TO MAX(MetaType) DO |
| 2579 |
Ass[i, unknown] := no ; |
| 2580 |
Expr[unknown, i] := no |
| 2581 |
END ; |
| 2582 |
|
| 2583 |
(* |
| 2584 |
1 p w |
| 2585 |
|
| 2586 |
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 |
| 2587 |
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 |
| 2588 |
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 |
| 2589 |
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 |
| 2590 |
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 |
| 2591 |
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 |
| 2592 |
s r n t a a r e a 8 x o m x x x x |
| 2593 |
t l r d a l m p 3 6 9 1 |
| 2594 |
d l p l 2 4 6 2 |
| 2595 |
l e 8 |
| 2596 |
e x |
| 2597 |
x |
| 2598 |
-------------------------------------------------------------------------------------------------------------- |
| 2599 |
2 |
| 2600 |
P |
| 2601 |
W |
| 2602 |
*) |
| 2603 |
A(const , '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') ; |
| 2604 |
A(word , '. 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') ; |
| 2605 |
A(byte , '. . 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') ; |
| 2606 |
A(address , '. . . 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') ; |
| 2607 |
A(chr , '. . . . 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') ; |
| 2608 |
A(normint , '. . . . . 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') ; |
| 2609 |
A(shortint , '. . . . . . 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') ; |
| 2610 |
A(longint , '. . . . . . . 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') ; |
| 2611 |
A(normcard , '. . . . . . . . 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') ; |
| 2612 |
A(shortcard , '. . . . . . . . . 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') ; |
| 2613 |
A(longcard , '. . . . . . . . . . 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') ; |
| 2614 |
A(pointer , '. . . . . . . . . . . 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') ; |
| 2615 |
A(enum , '. . . . . . . . . . . . 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') ; |
| 2616 |
A(real , '. . . . . . . . . . . . . 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') ; |
| 2617 |
A(shortreal , '. . . . . . . . . . . . . . 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') ; |
| 2618 |
A(longreal , '. . . . . . . . . . . . . . . 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') ; |
| 2619 |
A(set , '. . . . . . . . . . . . . . . . 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') ; |
| 2620 |
A(opaque , '. . . . . . . . . . . . . . . . . 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') ; |
| 2621 |
A(loc , '. . . . . . . . . . . . . . . . . . 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') ; |
| 2622 |
A(rtype , '. . . . . . . . . . . . . . . . . . . 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') ; |
| 2623 |
A(ztype , '. . . . . . . . . . . . . . . . . . . . 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') ; |
| 2624 |
A(int8 , '. . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2625 |
A(int16 , '. . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2626 |
A(int32 , '. . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2627 |
A(int64 , '. . . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2628 |
A(card8 , '. . . . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2629 |
A(card16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . T T T F F F F F F F F F F F F F F F F F F F F F') ; |
| 2630 |
A(card32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . T T F T F F F F F F F F F F F F F F F F F F F') ; |
| 2631 |
A(card64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F T F F F F F F F F F F F F F F F F F F') ; |
| 2632 |
A(word16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F') ; |
| 2633 |
A(word32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F F F F F F F F F F F F F F F') ; |
| 2634 |
A(word64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F F F F F F F F F F F F F F') ; |
| 2635 |
A(real32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F') ; |
| 2636 |
A(real64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F') ; |
| 2637 |
A(real96 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F') ; |
| 2638 |
A(real128 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F') ; |
| 2639 |
A(set8 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F') ; |
| 2640 |
A(set16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F') ; |
| 2641 |
A(set32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F') ; |
| 2642 |
A(complex , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F T F F F') ; |
| 2643 |
A(shortcomplex, '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F T F F F') ; |
| 2644 |
A(longcomplex , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F T F F F') ; |
| 2645 |
A(complex32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F T F F F') ; |
| 2646 |
A(complex64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F T F F F') ; |
| 2647 |
A(complex96 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F') ; |
| 2648 |
A(complex128 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T F F F') ; |
| 2649 |
A(ctype , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F') ; |
| 2650 |
A(rec , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F') ; |
| 2651 |
A(array , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F') ; |
| 2652 |
A(procedure , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T') ; |
| 2653 |
(* Expression compatibility *) |
| 2654 |
|
| 2655 |
|
| 2656 |
(* |
| 2657 |
1 p w |
| 2658 |
|
| 2659 |
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 |
| 2660 |
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 |
| 2661 |
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 |
| 2662 |
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 |
| 2663 |
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 |
| 2664 |
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 |
| 2665 |
s r n t a a r e a 8 x o m x x x x |
| 2666 |
t l r d a l m p 3 6 9 1 |
| 2667 |
d l p l 2 4 6 2 |
| 2668 |
l e 8 |
| 2669 |
e x |
| 2670 |
x |
| 2671 |
------------------------------------------------------------------------------------------------------------ |
| 2672 |
2 |
| 2673 |
P |
| 2674 |
W |
| 2675 |
*) |
| 2676 |
|
| 2677 |
E(const , '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') ; |
| 2678 |
E(word , '. 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') ; |
| 2679 |
E(byte , '. . 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') ; |
| 2680 |
E(address , '. . . 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') ; |
| 2681 |
E(chr , '. . . . 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') ; |
| 2682 |
E(normint , '. . . . . 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') ; |
| 2683 |
E(shortint , '. . . . . . 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') ; |
| 2684 |
E(longint , '. . . . . . . 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') ; |
| 2685 |
E(normcard , '. . . . . . . . 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') ; |
| 2686 |
E(shortcard , '. . . . . . . . . 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') ; |
| 2687 |
E(longcard , '. . . . . . . . . . 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') ; |
| 2688 |
E(pointer , '. . . . . . . . . . . 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') ; |
| 2689 |
E(enum , '. . . . . . . . . . . . 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') ; |
| 2690 |
E(real , '. . . . . . . . . . . . . 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') ; |
| 2691 |
E(shortreal , '. . . . . . . . . . . . . . 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') ; |
| 2692 |
E(longreal , '. . . . . . . . . . . . . . . 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') ; |
| 2693 |
E(set , '. . . . . . . . . . . . . . . . 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') ; |
| 2694 |
E(opaque , '. . . . . . . . . . . . . . . . . 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') ; |
| 2695 |
E(loc , '. . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F') ; |
| 2696 |
E(rtype , '. . . . . . . . . . . . . . . . . . . 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') ; |
| 2697 |
E(ztype , '. . . . . . . . . . . . . . . . . . . . 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') ; |
| 2698 |
E(int8 , '. . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2699 |
E(int16 , '. . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2700 |
E(int32 , '. . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2701 |
E(int64 , '. . . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2702 |
E(card8 , '. . . . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2703 |
E(card16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F') ; |
| 2704 |
E(card32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F') ; |
| 2705 |
E(card64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F') ; |
| 2706 |
E(word16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F F') ; |
| 2707 |
E(word32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F') ; |
| 2708 |
E(word64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F') ; |
| 2709 |
E(real32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F') ; |
| 2710 |
E(real64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F') ; |
| 2711 |
E(real96 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F') ; |
| 2712 |
E(real128 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F') ; |
| 2713 |
E(set8 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F') ; |
| 2714 |
E(set16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F') ; |
| 2715 |
E(set32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F') ; |
| 2716 |
E(complex , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F T F F F') ; |
| 2717 |
E(shortcomplex, '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F T F F F') ; |
| 2718 |
E(longcomplex , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F T F F F') ; |
| 2719 |
E(complex32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F T F F F') ; |
| 2720 |
E(complex64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F T F F F') ; |
| 2721 |
E(complex96 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F') ; |
| 2722 |
E(complex128 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T F F F') ; |
| 2723 |
E(ctype , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F') ; |
| 2724 |
E(rec , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F') ; |
| 2725 |
E(array , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F') ; |
| 2726 |
E(procedure , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T') ; |
| 2727 |
|
| 2728 |
(* Comparison compatibility *) |
| 2729 |
|
| 2730 |
|
| 2731 |
(* |
| 2732 |
1 p w |
| 2733 |
|
| 2734 |
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 |
| 2735 |
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 |
| 2736 |
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 |
| 2737 |
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 |
| 2738 |
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 |
| 2739 |
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 |
| 2740 |
s r n t a a r e a 8 x o m x x x x |
| 2741 |
t l r d a l m p 3 6 9 1 |
| 2742 |
d l p l 2 4 6 2 |
| 2743 |
l e 8 |
| 2744 |
e x |
| 2745 |
x |
| 2746 |
------------------------------------------------------------------------------------------------------------ |
| 2747 |
2 |
| 2748 |
P |
| 2749 |
W |
| 2750 |
*) |
| 2751 |
|
| 2752 |
C(const , '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') ; |
| 2753 |
C(word , '. 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') ; |
| 2754 |
C(byte , '. . 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') ; |
| 2755 |
C(address , '. . . 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') ; |
| 2756 |
C(chr , '. . . . 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') ; |
| 2757 |
C(normint , '. . . . . 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') ; |
| 2758 |
C(shortint , '. . . . . . 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') ; |
| 2759 |
C(longint , '. . . . . . . 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') ; |
| 2760 |
C(normcard , '. . . . . . . . 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') ; |
| 2761 |
C(shortcard , '. . . . . . . . . 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') ; |
| 2762 |
C(longcard , '. . . . . . . . . . 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') ; |
| 2763 |
C(pointer , '. . . . . . . . . . . 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') ; |
| 2764 |
C(enum , '. . . . . . . . . . . . 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') ; |
| 2765 |
C(real , '. . . . . . . . . . . . . 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') ; |
| 2766 |
C(shortreal , '. . . . . . . . . . . . . . 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') ; |
| 2767 |
C(longreal , '. . . . . . . . . . . . . . . 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') ; |
| 2768 |
C(set , '. . . . . . . . . . . . . . . . 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') ; |
| 2769 |
C(opaque , '. . . . . . . . . . . . . . . . . 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') ; |
| 2770 |
C(loc , '. . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F') ; |
| 2771 |
C(rtype , '. . . . . . . . . . . . . . . . . . . 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') ; |
| 2772 |
C(ztype , '. . . . . . . . . . . . . . . . . . . . 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') ; |
| 2773 |
C(int8 , '. . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2774 |
C(int16 , '. . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2775 |
C(int32 , '. . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2776 |
C(int64 , '. . . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2777 |
C(card8 , '. . . . . . . . . . . . . . . . . . . . . . . . . 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') ; |
| 2778 |
C(card16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F F') ; |
| 2779 |
C(card32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F F') ; |
| 2780 |
C(card64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F F F F F') ; |
| 2781 |
C(word16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F F') ; |
| 2782 |
C(word32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F F') ; |
| 2783 |
C(word64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F F F F F F F F F F F F F F F F F') ; |
| 2784 |
C(real32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F F') ; |
| 2785 |
C(real64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F F') ; |
| 2786 |
C(real96 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F F') ; |
| 2787 |
C(real128 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F F') ; |
| 2788 |
C(set8 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F F') ; |
| 2789 |
C(set16 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F F') ; |
| 2790 |
C(set32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F F F F F F') ; |
| 2791 |
C(complex , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F F T F F F') ; |
| 2792 |
C(shortcomplex, '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F F T F F F') ; |
| 2793 |
C(longcomplex , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F F T F F F') ; |
| 2794 |
C(complex32 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F T F F F') ; |
| 2795 |
C(complex64 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F T F F F') ; |
| 2796 |
C(complex96 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F T F F F') ; |
| 2797 |
C(complex128 , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T F F F') ; |
| 2798 |
C(ctype , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T F F F') ; |
| 2799 |
C(rec , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F F') ; |
| 2800 |
C(array , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F F') ; |
| 2801 |
C(procedure , '. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T') ; |
| 2802 |
|
| 2803 |
END InitCompatibilityMatrices ; |
| 2804 |
|
| 2805 |
|
| 2806 |
END M2Base. |