1 (* keyc.def provides an interface to emitting symbols which.
3 Copyright (C) 2016-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
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)
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.
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/>. *)
22 DEFINITION MODULE keyc
;
24 FROM mcPretty
IMPORT pretty
;
25 FROM DynamicStrings
IMPORT String
;
26 FROM decl
IMPORT node
;
27 FROM nameKey
IMPORT Name
;
31 useGccTree - indicate we have imported tree from gcctypes.
34 PROCEDURE useGccTree
;
38 useGccLocation - indicate we have imported tree from gcctypes.
41 PROCEDURE useGccLocation
;
45 useUnistd - need to use unistd.h call using open/close/read/write require this header.
52 useThrow - use the throw function.
59 useStorage - indicate we have used storage.
62 PROCEDURE useStorage
;
66 useFree - indicate we have used free.
73 useMalloc - indicate we have used malloc.
80 useProc - indicate we have used proc.
87 useTrue - indicate we have used TRUE.
94 useFalse - indicate we have used FALSE.
101 useNull - indicate we have used NULL.
108 useMemcpy - indicate we have used memcpy.
111 PROCEDURE useMemcpy
;
115 useIntMin - indicate we have used INT_MIN.
118 PROCEDURE useIntMin
;
122 useUIntMin - indicate we have used UINT_MIN.
125 PROCEDURE useUIntMin
;
129 useLongMin - indicate we have used LONG_MIN.
132 PROCEDURE useLongMin
;
136 useULongMin - indicate we have used ULONG_MIN.
139 PROCEDURE useULongMin
;
143 useCharMin - indicate we have used CHAR_MIN.
146 PROCEDURE useCharMin
;
150 useUCharMin - indicate we have used UCHAR_MIN.
153 PROCEDURE useUCharMin
;
157 useIntMax - indicate we have used INT_MAX.
160 PROCEDURE useIntMax
;
164 useUIntMax - indicate we have used UINT_MAX.
167 PROCEDURE useUIntMax
;
171 useLongMax - indicate we have used LONG_MAX.
174 PROCEDURE useLongMax
;
178 useULongMax - indicate we have used ULONG_MAX.
181 PROCEDURE useULongMax
;
185 useCharMax - indicate we have used CHAR_MAX.
188 PROCEDURE useCharMax
;
192 useUCharMax - indicate we have used UChar_MAX.
195 PROCEDURE useUCharMax
;
199 useSize_t - indicate we have used size_t.
202 PROCEDURE useSize_t
;
206 useSSize_t - indicate we have used ssize_t.
209 PROCEDURE useSSize_t
;
213 useLabs - indicate we have used labs.
220 useAbs - indicate we have used abs.
227 useFabs - indicate we have used fabs.
234 useFabsl - indicate we have used fabsl.
241 useException - use the exceptions module, mcrts.
244 PROCEDURE useException
;
248 useComplex - use the complex data type.
251 PROCEDURE useComplex
;
255 useM2RTS - indicate we have used M2RTS in the converted code.
262 useStrlen - indicate we have used strlen in the converted code.
265 PROCEDURE useStrlen
;
269 useCtype - indicate we have used the toupper function.
276 genDefs - generate definitions or includes for all
277 macros and prototypes used.
280 PROCEDURE genDefs (p
: pretty
) ;
284 genConfigSystem - generate include files for config.h and system.h
285 within the GCC framework.
288 PROCEDURE genConfigSystem (p
: pretty
) ;
292 enterScope - enter a scope defined by, n.
295 PROCEDURE enterScope (n
: node
) ;
299 leaveScope - leave the scope defined by, n.
302 PROCEDURE leaveScope (n
: node
) ;
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
315 PROCEDURE cname (n
: Name
; scopes
: BOOLEAN) : String
;
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
328 PROCEDURE cnamen (n
: Name
; scopes
: BOOLEAN) : Name
;
332 cp - include C++ keywords and standard declarations to avoid.