| 1 |
(* M2System.def defines the SYSTEM builtin 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 |
DEFINITION MODULE M2System ; |
| 23 |
|
| 24 |
(* |
| 25 |
Title : M2System |
| 26 |
Author : Gaius Mulley |
| 27 |
System : UNIX (gm2) |
| 28 |
Date : Tue Jul 11 08:39:17 2000 |
| 29 |
Description: Implements the base types of the module SYSTEM |
| 30 |
for the GNU Modula-2 compiler. Note that the base types |
| 31 |
are mapped onto their equivalents in the gcc backend. |
| 32 |
*) |
| 33 |
|
| 34 |
FROM gcctypes IMPORT location_t ; |
| 35 |
|
| 36 |
EXPORT QUALIFIED |
| 37 |
System, (* The SYSTEM module symbol. *) |
| 38 |
Loc, (* ISO specific System Type. *) |
| 39 |
|
| 40 |
Word, (* System Type *) |
| 41 |
Byte, (* System Type *) |
| 42 |
Address, (* System Type *) |
| 43 |
CSizeT, (* System Type *) |
| 44 |
CSSizeT, (* System Type *) |
| 45 |
COffT, (* System Type *) |
| 46 |
|
| 47 |
Adr, (* System Function *) |
| 48 |
TSize, (* System Function *) |
| 49 |
|
| 50 |
AddAdr, (* ISO specific System Function *) |
| 51 |
SubAdr, (* ISO specific System Function *) |
| 52 |
DifAdr, (* ISO specific System Function *) |
| 53 |
MakeAdr, (* ISO specific System Function *) |
| 54 |
Rotate, (* ISO specific System Function *) |
| 55 |
Shift, (* ISO specific System Function *) |
| 56 |
Cast, (* ISO specific System Function *) |
| 57 |
Throw, (* GNU Modula-2 extension *) |
| 58 |
TBitSize, (* GNU Modula-2 extension *) |
| 59 |
|
| 60 |
GetSystemTypeMinMax, |
| 61 |
IsPseudoSystemFunction, IsPseudoSystemProcedure, |
| 62 |
IsSystemType, |
| 63 |
IsPseudoSystemFunctionConstExpression, |
| 64 |
|
| 65 |
IntegerN, CardinalN, WordN, RealN, SetN, ComplexN, |
| 66 |
IsIntegerN, IsCardinalN, IsWordN, |
| 67 |
IsRealN, IsSetN, IsComplexN, |
| 68 |
IsGenericSystemType, |
| 69 |
IsSameSizePervasiveType, IsSameSize, |
| 70 |
InitSystem ; |
| 71 |
|
| 72 |
|
| 73 |
VAR |
| 74 |
System, |
| 75 |
Loc, |
| 76 |
Word, Byte, |
| 77 |
Address, |
| 78 |
CSizeT, CSSizeT, |
| 79 |
COffT, |
| 80 |
|
| 81 |
Adr, |
| 82 |
TSize, TBitSize, |
| 83 |
AddAdr, SubAdr, |
| 84 |
DifAdr, MakeAdr, |
| 85 |
Rotate, Shift, |
| 86 |
Cast, Throw : CARDINAL ; |
| 87 |
|
| 88 |
|
| 89 |
(* |
| 90 |
InitSystem - initializes the base types Word and Byte in the module |
| 91 |
SYSTEM. |
| 92 |
*) |
| 93 |
|
| 94 |
PROCEDURE InitSystem ; |
| 95 |
|
| 96 |
|
| 97 |
(* |
| 98 |
GetSystemTypeMinMax - returns the minimum and maximum values for a given system type. |
| 99 |
*) |
| 100 |
|
| 101 |
PROCEDURE GetSystemTypeMinMax (type: CARDINAL; VAR min, max: CARDINAL) ; |
| 102 |
|
| 103 |
|
| 104 |
(* |
| 105 |
IsPseudoSystemFunction - returns true if Sym is a SYSTEM pseudo function. |
| 106 |
*) |
| 107 |
|
| 108 |
PROCEDURE IsPseudoSystemFunction (sym: CARDINAL) : BOOLEAN ; |
| 109 |
|
| 110 |
|
| 111 |
(* |
| 112 |
IsPseudoSystemProcedure - returns true if Sym is a SYSTEM pseudo procedure. |
| 113 |
*) |
| 114 |
|
| 115 |
PROCEDURE IsPseudoSystemProcedure (sym: CARDINAL) : BOOLEAN ; |
| 116 |
|
| 117 |
|
| 118 |
(* |
| 119 |
IsPseudoSystemFunctionConstExpression - returns TRUE if this procedure |
| 120 |
is legal in a constant expression. |
| 121 |
*) |
| 122 |
|
| 123 |
PROCEDURE IsPseudoSystemFunctionConstExpression (sym: CARDINAL) : BOOLEAN ; |
| 124 |
|
| 125 |
|
| 126 |
(* |
| 127 |
IsSystemType - returns TRUE if Sym is a SYSTEM (inbuilt) type. |
| 128 |
It does not search your SYSTEM implementation module. |
| 129 |
*) |
| 130 |
|
| 131 |
PROCEDURE IsSystemType (sym: CARDINAL) : BOOLEAN ; |
| 132 |
|
| 133 |
|
| 134 |
(* |
| 135 |
IntegerN - returns the symbol associated with INTEGER[N]. |
| 136 |
NulSym is returned if the type does not exist. |
| 137 |
*) |
| 138 |
|
| 139 |
PROCEDURE IntegerN (bitlength: CARDINAL) : CARDINAL ; |
| 140 |
|
| 141 |
|
| 142 |
(* |
| 143 |
CardinalN - returns the symbol associated with CARDINAL[N]. |
| 144 |
NulSym is returned if the type does not exist. |
| 145 |
*) |
| 146 |
|
| 147 |
PROCEDURE CardinalN (bitlength: CARDINAL) : CARDINAL ; |
| 148 |
|
| 149 |
|
| 150 |
(* |
| 151 |
WordN - returns the symbol associated with WORD[N]. |
| 152 |
NulSym is returned if the type does not exist. |
| 153 |
*) |
| 154 |
|
| 155 |
PROCEDURE WordN (bitlength: CARDINAL) : CARDINAL ; |
| 156 |
|
| 157 |
|
| 158 |
(* |
| 159 |
SetN - returns the symbol associated with SET[N]. |
| 160 |
NulSym is returned if the type does not exist. |
| 161 |
*) |
| 162 |
|
| 163 |
PROCEDURE SetN (bitlength: CARDINAL) : CARDINAL ; |
| 164 |
|
| 165 |
|
| 166 |
(* |
| 167 |
RealN - returns the symbol associated with REAL[N]. |
| 168 |
NulSym is returned if the type does not exist. |
| 169 |
*) |
| 170 |
|
| 171 |
PROCEDURE RealN (bitlength: CARDINAL) : CARDINAL ; |
| 172 |
|
| 173 |
|
| 174 |
(* |
| 175 |
ComplexN - returns the symbol associated with COMPLEX[N]. |
| 176 |
NulSym is returned if the type does not exist. |
| 177 |
*) |
| 178 |
|
| 179 |
PROCEDURE ComplexN (bitlength: CARDINAL) : CARDINAL ; |
| 180 |
|
| 181 |
|
| 182 |
(* |
| 183 |
IsIntegerN - returns the TRUE if, sym, is one of the SYSTEM |
| 184 |
INTEGER types (not the base INTEGER type). |
| 185 |
*) |
| 186 |
|
| 187 |
PROCEDURE IsIntegerN (sym: CARDINAL) : BOOLEAN ; |
| 188 |
|
| 189 |
|
| 190 |
(* |
| 191 |
IsCardinalN - returns the TRUE if, sym, is one of the SYSTEM |
| 192 |
CARDINAL types (not the base CARDINAL type). |
| 193 |
*) |
| 194 |
|
| 195 |
PROCEDURE IsCardinalN (sym: CARDINAL) : BOOLEAN ; |
| 196 |
|
| 197 |
|
| 198 |
(* |
| 199 |
IsWordN - returns the TRUE if, sym, is one of the SYSTEM |
| 200 |
WORD[n] types (not the default SYSTEM WORD type). |
| 201 |
*) |
| 202 |
|
| 203 |
PROCEDURE IsWordN (sym: CARDINAL) : BOOLEAN ; |
| 204 |
|
| 205 |
|
| 206 |
(* |
| 207 |
IsSetN - returns the TRUE if, sym, is one of the SYSTEM |
| 208 |
SET[n] types (not the default SYSTEM BITSET type). |
| 209 |
*) |
| 210 |
|
| 211 |
PROCEDURE IsSetN (sym: CARDINAL) : BOOLEAN ; |
| 212 |
|
| 213 |
|
| 214 |
(* |
| 215 |
IsRealN - returns the TRUE if, sym, is one of the SYSTEM |
| 216 |
REAL[n] types (not the default base REAL type). |
| 217 |
*) |
| 218 |
|
| 219 |
PROCEDURE IsRealN (sym: CARDINAL) : BOOLEAN ; |
| 220 |
|
| 221 |
|
| 222 |
(* |
| 223 |
IsComplexN - returns the TRUE if, sym, is one of the SYSTEM |
| 224 |
COMPLEX[n] types (not the default base COMPLEX, |
| 225 |
LONGCOMPLEX or SHORTCOMPLEX types). |
| 226 |
*) |
| 227 |
|
| 228 |
PROCEDURE IsComplexN (sym: CARDINAL) : BOOLEAN ; |
| 229 |
|
| 230 |
|
| 231 |
(* |
| 232 |
IsGenericSystemType - returns TRUE if, sym, is of type |
| 233 |
BYTE, WORD or any other length. |
| 234 |
*) |
| 235 |
|
| 236 |
PROCEDURE IsGenericSystemType (sym: CARDINAL) : BOOLEAN ; |
| 237 |
|
| 238 |
|
| 239 |
(* |
| 240 |
IsSameSizePervasiveType - returns TRUE if a or b are CARDINAL, INTEGER, REAL, |
| 241 |
LONGREAL, SHORTREAL and the other type is the same |
| 242 |
size and of the same type. |
| 243 |
*) |
| 244 |
|
| 245 |
PROCEDURE IsSameSizePervasiveType (a, b: CARDINAL) : BOOLEAN ; |
| 246 |
|
| 247 |
|
| 248 |
(* |
| 249 |
IsSameSize - return TRUE if SIZE(a)=SIZE(b) |
| 250 |
*) |
| 251 |
|
| 252 |
PROCEDURE IsSameSize (a, b: CARDINAL) : BOOLEAN ; |
| 253 |
|
| 254 |
|
| 255 |
END M2System. |