1 (* M2GCCDeclare.def declares Modula-2 types to GCC.
3 Copyright (C) 2001-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 M2GCCDeclare ;
28 Date : Sat Jul 17 10:28:43 1999
29 Description: declares Modula-2 types to GCC,
30 only declares a type once all subcomponents are known.
33 FROM SYSTEM IMPORT WORD ;
34 FROM m2tree IMPORT Tree ;
37 WalkAction = PROCEDURE (WORD) ;
38 IsAction = PROCEDURE (WORD) : BOOLEAN ;
42 FoldConstants - a wrapper for ResolveConstantExpressions.
45 PROCEDURE FoldConstants (start, end: CARDINAL) ;
49 StartDeclareScope - declares types, variables associated with this scope.
52 PROCEDURE StartDeclareScope (scope: CARDINAL) ;
59 PROCEDURE EndDeclareScope ;
66 PROCEDURE DeclareParameters (sym: CARDINAL) ;
70 DeclareConstant - if, sym, is a constant then declare it.
71 The constant must be solvable at this point.
74 PROCEDURE DeclareConstant (tokenno: CARDINAL; sym: CARDINAL) ;
78 DeclareConstructor - if, sym, is a constructor then declare it.
79 The constructor must be solvable at this point.
82 PROCEDURE DeclareConstructor (tokenno: CARDINAL; quad: CARDINAL; sym: CARDINAL) ;
86 TryDeclareConstant - try and declare a constant. If, sym, is a
87 constant try and declare it, if we cannot
88 then enter it into the to do list.
91 PROCEDURE TryDeclareConstant (tokenno: CARDINAL; sym: CARDINAL) ;
95 TryDeclareConstructor - try and declare a constructor. If, sym, is a
96 constructor try and declare it, if we cannot
97 then enter it into the to do list.
100 PROCEDURE TryDeclareConstructor (tokenno: CARDINAL; sym: CARDINAL) ;
104 DeclareLocalVariables - lists the Local variables for procedure
105 together with their offset.
108 PROCEDURE DeclareLocalVariables (procedure: CARDINAL) ;
112 DeclareLocalVariable - declare a local variable var.
115 PROCEDURE DeclareLocalVariable (var: CARDINAL) ;
119 DeclareProcedure - declares procedure, sym, or all procedures inside
123 PROCEDURE DeclareProcedure (sym: WORD) ;
127 DeclareModuleVariables - declares Module variables for a module
128 which inside a procedure.
131 PROCEDURE DeclareModuleVariables (sym: CARDINAL) ;
135 IsProcedureGccNested - returns TRUE if procedure, sym, will be considered
137 This will occur if either its outer defining scope
138 is a procedure or is a module which is inside a
142 PROCEDURE IsProcedureGccNested (sym: CARDINAL) : BOOLEAN ;
146 PoisonSymbols - poisons all gcc symbols from procedure, sym.
150 PROCEDURE PoisonSymbols (sym: CARDINAL) ;
154 PromoteToString - declare, sym, and then promote it to a string.
155 Note that if sym is a single character we do
156 *not* record it as a string
157 but as a char however we always
158 return a string constant.
161 PROCEDURE PromoteToString (tokenno: CARDINAL; sym: CARDINAL) : Tree ;
165 PromoteToCString - declare, sym, and then promote it to a string.
166 Note that if sym is a single character we do
167 *not* record it as a string
168 but as a char however we always
169 return a string constant.
172 PROCEDURE PromoteToCString (tokenno: CARDINAL; sym: CARDINAL) : Tree ;
176 CompletelyResolved - returns TRUE if a symbol has been completely resolved
177 and is not partially declared (such as a record,
178 array or procedure type).
181 PROCEDURE CompletelyResolved (sym: CARDINAL) : BOOLEAN ;
185 ConstantKnownAndUsed -
188 PROCEDURE ConstantKnownAndUsed (sym: CARDINAL; t: Tree) ;
192 PutToBeSolvedByQuads - places, sym, in this list.
195 PROCEDURE PutToBeSolvedByQuads (sym: CARDINAL) ;
199 MarkExported - tell GCC to mark all exported procedures in module sym.
202 PROCEDURE MarkExported (sym: CARDINAL) ;
206 GetTypeMin - returns a symbol corresponding to MIN(type)
209 PROCEDURE GetTypeMin (type: CARDINAL) : CARDINAL ;
213 GetTypeMax - returns a symbol corresponding to MAX(type)
216 PROCEDURE GetTypeMax (type: CARDINAL) : CARDINAL ;
220 PrintSym - prints limited information about a symbol.
223 PROCEDURE PrintSym (sym: CARDINAL) ;
227 InitDeclarations - initializes default types and the source filename.
230 PROCEDURE InitDeclarations ;