Debian Codegraph @

gcc/m2/mc/mcDebug.mod

raw
1 (* Copyright (C) 2015-2025 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3. If not see
16 <http://www.gnu.org/licenses/>. *)
17
18 IMPLEMENTATION MODULE mcDebug ;
19
20
21 FROM StrIO IMPORT WriteString, WriteLn ;
22 FROM mcOptions IMPORT getInternalDebugging ;
23 FROM mcError IMPORT internalError ;
24
25
26 (*
27 assert - tests the boolean, q. If false then an error is reported
28 and the execution is terminated.
29 *)
30
31 PROCEDURE assert (q: BOOLEAN) ;
32 BEGIN
33 IF NOT q
34 THEN
35 internalError ('assert failed', __FILE__, __LINE__)
36 END
37 END assert ;
38
39
40 (*
41 writeDebug - only writes a string if internal debugging is on.
42 *)
43
44 PROCEDURE writeDebug (a: ARRAY OF CHAR) ;
45 BEGIN
46 IF getInternalDebugging ()
47 THEN
48 WriteString(a) ; WriteLn
49 END
50 END writeDebug ;
51
52
53 END mcDebug.