| 1 |
(* M2Pass.mod provides setting and testing of the current pass. |
| 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 |
IMPLEMENTATION MODULE M2Pass ; |
| 23 |
|
| 24 |
FROM M2Error IMPORT InternalError ; |
| 25 |
|
| 26 |
TYPE |
| 27 |
Pass = (NoPass, Pass0, Pass1, Pass2, PassC, Pass3, CodeGeneration, ErrorPass, HiddenPass) ; |
| 28 |
|
| 29 |
VAR |
| 30 |
CurrentPass: Pass ; |
| 31 |
|
| 32 |
|
| 33 |
(* |
| 34 |
SetPassToNoPass - sets the pass state to no Pass. |
| 35 |
*) |
| 36 |
|
| 37 |
PROCEDURE SetPassToNoPass ; |
| 38 |
BEGIN |
| 39 |
CurrentPass := NoPass |
| 40 |
END SetPassToNoPass ; |
| 41 |
|
| 42 |
|
| 43 |
(* |
| 44 |
SetPassToPass0 - sets the pass state to Pass 0. |
| 45 |
*) |
| 46 |
|
| 47 |
PROCEDURE SetPassToPass0 ; |
| 48 |
BEGIN |
| 49 |
IF CurrentPass=NoPass |
| 50 |
THEN |
| 51 |
CurrentPass := Pass0 |
| 52 |
ELSE |
| 53 |
InternalError ('attempting to set CurrentPass to Pass1') |
| 54 |
END |
| 55 |
END SetPassToPass0 ; |
| 56 |
|
| 57 |
|
| 58 |
(* |
| 59 |
SetPassToPass1 - sets the pass state to Pass 1. |
| 60 |
*) |
| 61 |
|
| 62 |
PROCEDURE SetPassToPass1 ; |
| 63 |
BEGIN |
| 64 |
IF CurrentPass=NoPass |
| 65 |
THEN |
| 66 |
CurrentPass := Pass1 |
| 67 |
ELSE |
| 68 |
InternalError ('attempting to set CurrentPass to Pass1') |
| 69 |
END |
| 70 |
END SetPassToPass1 ; |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
(* |
| 75 |
SetPassToPass2 - sets the pass state to Pass 2. |
| 76 |
*) |
| 77 |
|
| 78 |
PROCEDURE SetPassToPass2 ; |
| 79 |
BEGIN |
| 80 |
IF CurrentPass=NoPass |
| 81 |
THEN |
| 82 |
CurrentPass := Pass2 |
| 83 |
ELSE |
| 84 |
InternalError ('attempting to set CurrentPass to Pass2') |
| 85 |
END |
| 86 |
END SetPassToPass2 ; |
| 87 |
|
| 88 |
|
| 89 |
(* |
| 90 |
SetPassToPassC - sets the pass state to Pass C. |
| 91 |
*) |
| 92 |
|
| 93 |
PROCEDURE SetPassToPassC ; |
| 94 |
BEGIN |
| 95 |
IF CurrentPass=NoPass |
| 96 |
THEN |
| 97 |
CurrentPass := PassC |
| 98 |
ELSE |
| 99 |
InternalError ('attempting to set CurrentPass to PassC') |
| 100 |
END |
| 101 |
END SetPassToPassC ; |
| 102 |
|
| 103 |
|
| 104 |
(* |
| 105 |
SetPassToPass3 - sets the pass state to Pass 3. |
| 106 |
*) |
| 107 |
|
| 108 |
PROCEDURE SetPassToPass3 ; |
| 109 |
BEGIN |
| 110 |
IF CurrentPass=NoPass |
| 111 |
THEN |
| 112 |
CurrentPass := Pass3 |
| 113 |
ELSE |
| 114 |
InternalError ('attempting to set CurrentPass to Pass3') |
| 115 |
END |
| 116 |
END SetPassToPass3 ; |
| 117 |
|
| 118 |
|
| 119 |
(* |
| 120 |
SetPassToErrorPass - sets the pass state to no Error Pass. |
| 121 |
*) |
| 122 |
|
| 123 |
PROCEDURE SetPassToErrorPass ; |
| 124 |
BEGIN |
| 125 |
CurrentPass := ErrorPass |
| 126 |
END SetPassToErrorPass ; |
| 127 |
|
| 128 |
|
| 129 |
(* |
| 130 |
SetPassToPassHidden - sets the pass state to the hidden type pass. |
| 131 |
*) |
| 132 |
|
| 133 |
PROCEDURE SetPassToPassHidden ; |
| 134 |
BEGIN |
| 135 |
CurrentPass := HiddenPass |
| 136 |
END SetPassToPassHidden ; |
| 137 |
|
| 138 |
|
| 139 |
(* |
| 140 |
SetPassToCodeGeneration - sets the pass state to CodeGeneration. |
| 141 |
*) |
| 142 |
|
| 143 |
PROCEDURE SetPassToCodeGeneration ; |
| 144 |
BEGIN |
| 145 |
IF CurrentPass=NoPass |
| 146 |
THEN |
| 147 |
CurrentPass := CodeGeneration |
| 148 |
ELSE |
| 149 |
InternalError ('attempting to set CurrentPass to CodeGeneration') |
| 150 |
END |
| 151 |
END SetPassToCodeGeneration ; |
| 152 |
|
| 153 |
|
| 154 |
(* |
| 155 |
IsNoPass - returns true if currently in no Pass. |
| 156 |
*) |
| 157 |
|
| 158 |
PROCEDURE IsNoPass () : BOOLEAN ; |
| 159 |
BEGIN |
| 160 |
RETURN( CurrentPass=NoPass ) |
| 161 |
END IsNoPass ; |
| 162 |
|
| 163 |
|
| 164 |
(* |
| 165 |
IsPass0 - returns true if currently in Pass 0. |
| 166 |
*) |
| 167 |
|
| 168 |
PROCEDURE IsPass0 () : BOOLEAN ; |
| 169 |
BEGIN |
| 170 |
RETURN( CurrentPass=Pass0 ) |
| 171 |
END IsPass0 ; |
| 172 |
|
| 173 |
|
| 174 |
(* |
| 175 |
IsPass1 - returns true if currently in Pass 1. |
| 176 |
*) |
| 177 |
|
| 178 |
PROCEDURE IsPass1 () : BOOLEAN ; |
| 179 |
BEGIN |
| 180 |
RETURN( CurrentPass=Pass1 ) |
| 181 |
END IsPass1 ; |
| 182 |
|
| 183 |
|
| 184 |
(* |
| 185 |
IsPass2 - returns true if currently in Pass 2. |
| 186 |
*) |
| 187 |
|
| 188 |
PROCEDURE IsPass2 () : BOOLEAN ; |
| 189 |
BEGIN |
| 190 |
RETURN( CurrentPass=Pass2 ) |
| 191 |
END IsPass2 ; |
| 192 |
|
| 193 |
|
| 194 |
(* |
| 195 |
IsPassC - returns true if currently in Pass C. |
| 196 |
*) |
| 197 |
|
| 198 |
PROCEDURE IsPassC () : BOOLEAN ; |
| 199 |
BEGIN |
| 200 |
RETURN( CurrentPass=PassC ) |
| 201 |
END IsPassC ; |
| 202 |
|
| 203 |
|
| 204 |
(* |
| 205 |
IsPass3 - returns true if currently in Pass 3. |
| 206 |
*) |
| 207 |
|
| 208 |
PROCEDURE IsPass3 () : BOOLEAN ; |
| 209 |
BEGIN |
| 210 |
RETURN( CurrentPass=Pass3 ) |
| 211 |
END IsPass3 ; |
| 212 |
|
| 213 |
|
| 214 |
(* |
| 215 |
IsPassCodeGeneration - returns true if currently in the CodeGeneration Pass. |
| 216 |
*) |
| 217 |
|
| 218 |
PROCEDURE IsPassCodeGeneration () : BOOLEAN ; |
| 219 |
BEGIN |
| 220 |
RETURN( CurrentPass=CodeGeneration ) |
| 221 |
END IsPassCodeGeneration ; |
| 222 |
|
| 223 |
|
| 224 |
(* |
| 225 |
IsPassHidden - returns TRUE if currently parsing for hidden types. |
| 226 |
*) |
| 227 |
|
| 228 |
PROCEDURE IsPassHidden () : BOOLEAN ; |
| 229 |
BEGIN |
| 230 |
RETURN( CurrentPass=HiddenPass ) |
| 231 |
END IsPassHidden ; |
| 232 |
|
| 233 |
|
| 234 |
(* |
| 235 |
IsErrorPass - returns true if currently in the Error Pass. |
| 236 |
*) |
| 237 |
|
| 238 |
PROCEDURE IsErrorPass () : BOOLEAN ; |
| 239 |
BEGIN |
| 240 |
RETURN( CurrentPass=ErrorPass ) |
| 241 |
END IsErrorPass ; |
| 242 |
|
| 243 |
|
| 244 |
BEGIN |
| 245 |
SetPassToNoPass |
| 246 |
END M2Pass. |