| 1 |
(* m2decl.def definition module for m2decl.cc. |
| 2 |
|
| 3 |
Copyright (C) 2011-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 m2decl ; |
| 23 |
|
| 24 |
FROM SYSTEM IMPORT ADDRESS ; |
| 25 |
FROM gcctypes IMPORT location_t, tree ; |
| 26 |
FROM CDataTypes IMPORT ConstCharStar ; |
| 27 |
|
| 28 |
|
| 29 |
(* |
| 30 |
BuildModuleCtor creates the per module constructor used as part of |
| 31 |
the dynamic linking scaffold. |
| 32 |
*) |
| 33 |
|
| 34 |
PROCEDURE BuildModuleCtor (moduleCtor: tree) ; |
| 35 |
|
| 36 |
|
| 37 |
(* |
| 38 |
DeclareModuleCtor configures the function to be used as a ctor. |
| 39 |
*) |
| 40 |
|
| 41 |
PROCEDURE DeclareModuleCtor (decl: tree) : tree ; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
(* |
| 46 |
|
| 47 |
*) |
| 48 |
|
| 49 |
PROCEDURE DeclareM2linkForcedModuleInitOrder (location: location_t; |
| 50 |
RuntimeOverride: ADDRESS) : tree ; |
| 51 |
|
| 52 |
|
| 53 |
PROCEDURE DeclareM2linkStaticInitialization (location: location_t; |
| 54 |
ScaffoldStatic: INTEGER) : tree ; |
| 55 |
|
| 56 |
PROCEDURE BuildPtrToTypeString (location: location_t; string: ADDRESS; type: tree) : tree ; |
| 57 |
|
| 58 |
|
| 59 |
(* |
| 60 |
GetBitsPerBitset - returns the number of bits in a BITSET. |
| 61 |
*) |
| 62 |
|
| 63 |
PROCEDURE GetBitsPerBitset () : INTEGER ; |
| 64 |
|
| 65 |
|
| 66 |
(* |
| 67 |
GetBitsPerInt - returns the number of bits in a INTEGER. |
| 68 |
*) |
| 69 |
|
| 70 |
PROCEDURE GetBitsPerInt () : INTEGER ; |
| 71 |
|
| 72 |
|
| 73 |
(* |
| 74 |
GetBitsPerUnit - returns the number of bits in a UNIT. |
| 75 |
*) |
| 76 |
|
| 77 |
PROCEDURE GetBitsPerUnit () : INTEGER ; |
| 78 |
|
| 79 |
|
| 80 |
(* |
| 81 |
GetBitsPerWord - returns the number of bits in a WORD. |
| 82 |
*) |
| 83 |
|
| 84 |
PROCEDURE GetBitsPerWord () : INTEGER ; |
| 85 |
|
| 86 |
|
| 87 |
(* |
| 88 |
BuildIntegerConstant - return a tree containing the integer value. |
| 89 |
*) |
| 90 |
|
| 91 |
PROCEDURE BuildIntegerConstant (value: INTEGER) : tree ; |
| 92 |
|
| 93 |
|
| 94 |
(* |
| 95 |
BuildStringConstantType - builds a string constant with a type. |
| 96 |
*) |
| 97 |
|
| 98 |
PROCEDURE BuildStringConstantType (length: INTEGER; string: ConstCharStar; type: tree) : tree ; |
| 99 |
|
| 100 |
|
| 101 |
(* |
| 102 |
DeclareKnownVariable - declares a variable in scope, |
| 103 |
funcscope. Note that the global variable, |
| 104 |
current_function_decl, is altered if |
| 105 |
isglobal is TRUE. |
| 106 |
*) |
| 107 |
|
| 108 |
PROCEDURE DeclareKnownVariable (location: location_t; name: ConstCharStar; type: tree; |
| 109 |
exported, imported, istemporary, isglobal: BOOLEAN; |
| 110 |
scope, initial: tree) : tree ; |
| 111 |
|
| 112 |
|
| 113 |
(* |
| 114 |
DeclareKnownConstant - given a constant, value, of, type, create a constant in the GCC |
| 115 |
symbol table. Note that the name of the constant is not used |
| 116 |
as _all_ constants are declared in the global scope. The front end |
| 117 |
deals with scoping rules - here we declare all constants with no names |
| 118 |
in the global scope. This allows M2SubExp and constant folding routines |
| 119 |
the liberty of operating with quadruples which all assume constants can |
| 120 |
always be referenced. |
| 121 |
*) |
| 122 |
|
| 123 |
PROCEDURE DeclareKnownConstant (location: location_t; type: tree; value: tree) : tree ; |
| 124 |
|
| 125 |
|
| 126 |
(* |
| 127 |
BuildParameterDeclaration - creates and returns one parameter from, name, and, type. |
| 128 |
It appends this parameter to the internal param_type_list. |
| 129 |
If name is nul then we assume we are creating a function |
| 130 |
type declaration and we ignore names. |
| 131 |
*) |
| 132 |
|
| 133 |
PROCEDURE BuildParameterDeclaration (location: location_t; name: ConstCharStar; type: tree; |
| 134 |
isreference: BOOLEAN) : tree ; |
| 135 |
|
| 136 |
|
| 137 |
(* |
| 138 |
BuildStartFunctionDeclaration - initializes global variables ready |
| 139 |
for building a function. |
| 140 |
*) |
| 141 |
|
| 142 |
PROCEDURE BuildStartFunctionDeclaration (uses_varargs: BOOLEAN) ; |
| 143 |
|
| 144 |
|
| 145 |
(* |
| 146 |
BuildEndFunctionDeclaration - build a function which will return a value of returntype. |
| 147 |
The arguments have been created by BuildParameterDeclaration. |
| 148 |
*) |
| 149 |
|
| 150 |
PROCEDURE BuildEndFunctionDeclaration (location_begin, location_end: location_t; |
| 151 |
name: ConstCharStar; returntype: tree; |
| 152 |
isexternal, isnested, ispublic, |
| 153 |
isnoreturn: BOOLEAN) : tree ; |
| 154 |
|
| 155 |
|
| 156 |
(* |
| 157 |
RememberVariables - |
| 158 |
*) |
| 159 |
|
| 160 |
PROCEDURE RememberVariables (l: tree) ; |
| 161 |
|
| 162 |
|
| 163 |
(* |
| 164 |
BuildConstLiteralNumber - returns a GCC TREE built from the string, str. |
| 165 |
It assumes that, str, represents a legal |
| 166 |
number in Modula-2. It always returns a |
| 167 |
positive value. |
| 168 |
*) |
| 169 |
|
| 170 |
PROCEDURE BuildConstLiteralNumber (location: location_t; |
| 171 |
str: ConstCharStar; base: CARDINAL; |
| 172 |
issueError: BOOLEAN) : tree ; |
| 173 |
|
| 174 |
|
| 175 |
(* |
| 176 |
BuildStringConstant - creates a string constant given a, string, |
| 177 |
and, length. |
| 178 |
*) |
| 179 |
|
| 180 |
PROCEDURE BuildStringConstant (string: ConstCharStar; length: INTEGER) : tree ; |
| 181 |
|
| 182 |
|
| 183 |
(* |
| 184 |
BuildCStringConstant - creates a string constant given a, string, |
| 185 |
and, length. |
| 186 |
*) |
| 187 |
|
| 188 |
PROCEDURE BuildCStringConstant (string: ConstCharStar; length: INTEGER) : tree ; |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
PROCEDURE GetDeclContext (t: tree) : tree ; |
| 193 |
|
| 194 |
|
| 195 |
END m2decl. |