rts-bool.c
1 //! @file rts-bool.c
2 //! @author J. Marcel van der Veer
3 //!
4 //! @section Copyright
5 //!
6 //! This file is part of Algol68G - an Algol 68 compiler-interpreter.
7 //! Copyright 2001-2023 J. Marcel van der Veer [algol68g@xs4all.nl].
8 //!
9 //! @section License
10 //!
11 //! This program is free software; you can redistribute it and/or modify it
12 //! under the terms of the GNU General Public License as published by the
13 //! Free Software Foundation; either version 3 of the License, or
14 //! (at your option) any later version.
15 //!
16 //! This program is distributed in the hope that it will be useful, but
17 //! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 //! or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 //! more details. You should have received a copy of the GNU General Public
20 //! License along with this program. If not, see [http://www.gnu.org/licenses/].
21
22 //! @section Synopsis
23 //!
24 //! BOOL routines.
25
26 #include "a68g.h"
27 #include "a68g-genie.h"
28 #include "a68g-prelude.h"
29 #include "a68g-mp.h"
30 #include "a68g-physics.h"
31 #include "a68g-numbers.h"
32 #include "a68g-optimiser.h"
33 #include "a68g-double.h"
34
35 // BOOL operations.
36
37 // OP NOT = (BOOL) BOOL.
38
39 A68_MONAD (genie_not_bool, A68_BOOL, (BOOL_T) !);
40
41 //! @brief OP ABS = (BOOL) INT
42
43 void genie_abs_bool (NODE_T * p)
44 {
45 A68_BOOL j;
46 POP_OBJECT (p, &j, A68_BOOL);
47 PUSH_VALUE (p, (VALUE (&j) ? 1 : 0), A68_INT);
48 }
49
50 #define A68_BOOL_DYAD(n, OP)\
51 void n (NODE_T * p) {\
52 A68_BOOL *i, *j;\
53 POP_OPERAND_ADDRESSES (p, i, j, A68_BOOL);\
54 VALUE (i) = (BOOL_T) (VALUE (i) OP VALUE (j));\
55 }
56
57 A68_BOOL_DYAD (genie_and_bool, &);
58 A68_BOOL_DYAD (genie_or_bool, |);
59 A68_BOOL_DYAD (genie_xor_bool, ^);
60 A68_BOOL_DYAD (genie_eq_bool, ==);
61 A68_BOOL_DYAD (genie_ne_bool, !=);