| 1 |
(* keyc.def provides an interface to emitting symbols which. |
| 2 |
|
| 3 |
Copyright (C) 2016-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 keyc ; |
| 23 |
|
| 24 |
FROM mcPretty IMPORT pretty ; |
| 25 |
FROM DynamicStrings IMPORT String ; |
| 26 |
FROM decl IMPORT node ; |
| 27 |
FROM nameKey IMPORT Name ; |
| 28 |
|
| 29 |
|
| 30 |
(* |
| 31 |
useGccTree - indicate we have imported tree from gcctypes. |
| 32 |
*) |
| 33 |
|
| 34 |
PROCEDURE useGccTree ; |
| 35 |
|
| 36 |
|
| 37 |
(* |
| 38 |
useGccLocation - indicate we have imported tree from gcctypes. |
| 39 |
*) |
| 40 |
|
| 41 |
PROCEDURE useGccLocation ; |
| 42 |
|
| 43 |
|
| 44 |
(* |
| 45 |
useUnistd - need to use unistd.h call using open/close/read/write require this header. |
| 46 |
*) |
| 47 |
|
| 48 |
PROCEDURE useUnistd ; |
| 49 |
|
| 50 |
|
| 51 |
(* |
| 52 |
useThrow - use the throw function. |
| 53 |
*) |
| 54 |
|
| 55 |
PROCEDURE useThrow ; |
| 56 |
|
| 57 |
|
| 58 |
(* |
| 59 |
useStorage - indicate we have used storage. |
| 60 |
*) |
| 61 |
|
| 62 |
PROCEDURE useStorage ; |
| 63 |
|
| 64 |
|
| 65 |
(* |
| 66 |
useFree - indicate we have used free. |
| 67 |
*) |
| 68 |
|
| 69 |
PROCEDURE useFree ; |
| 70 |
|
| 71 |
|
| 72 |
(* |
| 73 |
useMalloc - indicate we have used malloc. |
| 74 |
*) |
| 75 |
|
| 76 |
PROCEDURE useMalloc ; |
| 77 |
|
| 78 |
|
| 79 |
(* |
| 80 |
useProc - indicate we have used proc. |
| 81 |
*) |
| 82 |
|
| 83 |
PROCEDURE useProc ; |
| 84 |
|
| 85 |
|
| 86 |
(* |
| 87 |
useTrue - indicate we have used TRUE. |
| 88 |
*) |
| 89 |
|
| 90 |
PROCEDURE useTrue ; |
| 91 |
|
| 92 |
|
| 93 |
(* |
| 94 |
useFalse - indicate we have used FALSE. |
| 95 |
*) |
| 96 |
|
| 97 |
PROCEDURE useFalse ; |
| 98 |
|
| 99 |
|
| 100 |
(* |
| 101 |
useNull - indicate we have used NULL. |
| 102 |
*) |
| 103 |
|
| 104 |
PROCEDURE useNull ; |
| 105 |
|
| 106 |
|
| 107 |
(* |
| 108 |
useMemcpy - indicate we have used memcpy. |
| 109 |
*) |
| 110 |
|
| 111 |
PROCEDURE useMemcpy ; |
| 112 |
|
| 113 |
|
| 114 |
(* |
| 115 |
useIntMin - indicate we have used INT_MIN. |
| 116 |
*) |
| 117 |
|
| 118 |
PROCEDURE useIntMin ; |
| 119 |
|
| 120 |
|
| 121 |
(* |
| 122 |
useUIntMin - indicate we have used UINT_MIN. |
| 123 |
*) |
| 124 |
|
| 125 |
PROCEDURE useUIntMin ; |
| 126 |
|
| 127 |
|
| 128 |
(* |
| 129 |
useLongMin - indicate we have used LONG_MIN. |
| 130 |
*) |
| 131 |
|
| 132 |
PROCEDURE useLongMin ; |
| 133 |
|
| 134 |
|
| 135 |
(* |
| 136 |
useULongMin - indicate we have used ULONG_MIN. |
| 137 |
*) |
| 138 |
|
| 139 |
PROCEDURE useULongMin ; |
| 140 |
|
| 141 |
|
| 142 |
(* |
| 143 |
useCharMin - indicate we have used CHAR_MIN. |
| 144 |
*) |
| 145 |
|
| 146 |
PROCEDURE useCharMin ; |
| 147 |
|
| 148 |
|
| 149 |
(* |
| 150 |
useUCharMin - indicate we have used UCHAR_MIN. |
| 151 |
*) |
| 152 |
|
| 153 |
PROCEDURE useUCharMin ; |
| 154 |
|
| 155 |
|
| 156 |
(* |
| 157 |
useIntMax - indicate we have used INT_MAX. |
| 158 |
*) |
| 159 |
|
| 160 |
PROCEDURE useIntMax ; |
| 161 |
|
| 162 |
|
| 163 |
(* |
| 164 |
useUIntMax - indicate we have used UINT_MAX. |
| 165 |
*) |
| 166 |
|
| 167 |
PROCEDURE useUIntMax ; |
| 168 |
|
| 169 |
|
| 170 |
(* |
| 171 |
useLongMax - indicate we have used LONG_MAX. |
| 172 |
*) |
| 173 |
|
| 174 |
PROCEDURE useLongMax ; |
| 175 |
|
| 176 |
|
| 177 |
(* |
| 178 |
useULongMax - indicate we have used ULONG_MAX. |
| 179 |
*) |
| 180 |
|
| 181 |
PROCEDURE useULongMax ; |
| 182 |
|
| 183 |
|
| 184 |
(* |
| 185 |
useCharMax - indicate we have used CHAR_MAX. |
| 186 |
*) |
| 187 |
|
| 188 |
PROCEDURE useCharMax ; |
| 189 |
|
| 190 |
|
| 191 |
(* |
| 192 |
useUCharMax - indicate we have used UChar_MAX. |
| 193 |
*) |
| 194 |
|
| 195 |
PROCEDURE useUCharMax ; |
| 196 |
|
| 197 |
|
| 198 |
(* |
| 199 |
useSize_t - indicate we have used size_t. |
| 200 |
*) |
| 201 |
|
| 202 |
PROCEDURE useSize_t ; |
| 203 |
|
| 204 |
|
| 205 |
(* |
| 206 |
useSSize_t - indicate we have used ssize_t. |
| 207 |
*) |
| 208 |
|
| 209 |
PROCEDURE useSSize_t ; |
| 210 |
|
| 211 |
|
| 212 |
(* |
| 213 |
useLabs - indicate we have used labs. |
| 214 |
*) |
| 215 |
|
| 216 |
PROCEDURE useLabs ; |
| 217 |
|
| 218 |
|
| 219 |
(* |
| 220 |
useAbs - indicate we have used abs. |
| 221 |
*) |
| 222 |
|
| 223 |
PROCEDURE useAbs ; |
| 224 |
|
| 225 |
|
| 226 |
(* |
| 227 |
useFabs - indicate we have used fabs. |
| 228 |
*) |
| 229 |
|
| 230 |
PROCEDURE useFabs ; |
| 231 |
|
| 232 |
|
| 233 |
(* |
| 234 |
useFabsl - indicate we have used fabsl. |
| 235 |
*) |
| 236 |
|
| 237 |
PROCEDURE useFabsl ; |
| 238 |
|
| 239 |
|
| 240 |
(* |
| 241 |
useException - use the exceptions module, mcrts. |
| 242 |
*) |
| 243 |
|
| 244 |
PROCEDURE useException ; |
| 245 |
|
| 246 |
|
| 247 |
(* |
| 248 |
useComplex - use the complex data type. |
| 249 |
*) |
| 250 |
|
| 251 |
PROCEDURE useComplex ; |
| 252 |
|
| 253 |
|
| 254 |
(* |
| 255 |
useM2RTS - indicate we have used M2RTS in the converted code. |
| 256 |
*) |
| 257 |
|
| 258 |
PROCEDURE useM2RTS ; |
| 259 |
|
| 260 |
|
| 261 |
(* |
| 262 |
useStrlen - indicate we have used strlen in the converted code. |
| 263 |
*) |
| 264 |
|
| 265 |
PROCEDURE useStrlen ; |
| 266 |
|
| 267 |
|
| 268 |
(* |
| 269 |
useCtype - indicate we have used the toupper function. |
| 270 |
*) |
| 271 |
|
| 272 |
PROCEDURE useCtype ; |
| 273 |
|
| 274 |
|
| 275 |
(* |
| 276 |
genDefs - generate definitions or includes for all |
| 277 |
macros and prototypes used. |
| 278 |
*) |
| 279 |
|
| 280 |
PROCEDURE genDefs (p: pretty) ; |
| 281 |
|
| 282 |
|
| 283 |
(* |
| 284 |
genConfigSystem - generate include files for config.h and system.h |
| 285 |
within the GCC framework. |
| 286 |
*) |
| 287 |
|
| 288 |
PROCEDURE genConfigSystem (p: pretty) ; |
| 289 |
|
| 290 |
|
| 291 |
(* |
| 292 |
enterScope - enter a scope defined by, n. |
| 293 |
*) |
| 294 |
|
| 295 |
PROCEDURE enterScope (n: node) ; |
| 296 |
|
| 297 |
|
| 298 |
(* |
| 299 |
leaveScope - leave the scope defined by, n. |
| 300 |
*) |
| 301 |
|
| 302 |
PROCEDURE leaveScope (n: node) ; |
| 303 |
|
| 304 |
|
| 305 |
(* |
| 306 |
cname - attempts to declare a symbol with name, n, in the |
| 307 |
current scope. If there is no conflict with the |
| 308 |
target language then NIL is returned, otherwise |
| 309 |
a mangled name is returned as a String. |
| 310 |
If scopes is FALSE then only the keywords and |
| 311 |
macros are detected for a clash (all scoping |
| 312 |
is ignored). |
| 313 |
*) |
| 314 |
|
| 315 |
PROCEDURE cname (n: Name; scopes: BOOLEAN) : String ; |
| 316 |
|
| 317 |
|
| 318 |
(* |
| 319 |
cnamen - attempts to declare a symbol with name, n, in the |
| 320 |
current scope. If there is no conflict with the |
| 321 |
target language then NIL is returned, otherwise |
| 322 |
a mangled name is returned as a Name |
| 323 |
If scopes is FALSE then only the keywords and |
| 324 |
macros are detected for a clash (all scoping |
| 325 |
is ignored). |
| 326 |
*) |
| 327 |
|
| 328 |
PROCEDURE cnamen (n: Name; scopes: BOOLEAN) : Name ; |
| 329 |
|
| 330 |
|
| 331 |
(* |
| 332 |
cp - include C++ keywords and standard declarations to avoid. |
| 333 |
*) |
| 334 |
|
| 335 |
PROCEDURE cp ; |
| 336 |
|
| 337 |
|
| 338 |
END keyc. |