File : s-veboop.ads


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
   4 --                                                                          --
   5 --    S Y S T E M . V E C T O R S . B O O L E A N _ O P E R A T I O N S     --
   6 --                                                                          --
   7 --                                 S p e c                                  --
   8 --                                                                          --
   9 --          Copyright (C) 2002-2009, Free Software Foundation, Inc.         --
  10 --                                                                          --
  11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  12 -- terms of the  GNU General Public License as published  by the Free Soft- --
  13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
  14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  16 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
  17 --                                                                          --
  18 --                                                                          --
  19 --                                                                          --
  20 --                                                                          --
  21 --                                                                          --
  22 -- You should have received a copy of the GNU General Public License and    --
  23 -- a copy of the GCC Runtime Library Exception along with this program;     --
  24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
  25 -- <http://www.gnu.org/licenses/>.                                          --
  26 --                                                                          --
  27 -- GNAT was originally developed  by the GNAT team at  New York University. --
  28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
  29 --                                                                          --
  30 ------------------------------------------------------------------------------
  31 
  32 --  This package contains functions for runtime operations on boolean vectors
  33 
  34 package System.Vectors.Boolean_Operations is
  35    pragma Pure;
  36 
  37    --  Although in general the boolean operations on arrays of booleans are
  38    --  identical to operations on arrays of unsigned words of the same size,
  39    --  for the "not" operator this is not the case as False is typically
  40    --  represented by 0 and true by 1.
  41 
  42    function "not" (Item : Vectors.Vector) return Vectors.Vector;
  43 
  44    --  The three boolean operations "nand", "nor" and "nxor" are needed
  45    --  for cases where the compiler moves boolean array operations into
  46    --  the body of the loop that iterates over the array elements.
  47 
  48    --  Note the following equivalences:
  49    --    (not X) or  (not Y)  =  not (X and Y)  =  Nand (X, Y)
  50    --    (not X) and (not Y)  =  not (X or Y)   =  Nor  (X, Y)
  51    --    (not X) xor (not Y)  =  X xor Y
  52    --    X       xor (not Y)  =  not (X xor Y)  =  Nxor (X, Y)
  53 
  54    function Nand (Left, Right : Boolean) return Boolean;
  55    function Nor  (Left, Right : Boolean) return Boolean;
  56    function Nxor (Left, Right : Boolean) return Boolean;
  57 
  58    function Nand (Left, Right : Vectors.Vector) return Vectors.Vector;
  59    function Nor (Left, Right : Vectors.Vector) return Vectors.Vector;
  60    function Nxor (Left, Right : Vectors.Vector) return Vectors.Vector;
  61 
  62    pragma Inline_Always ("not");
  63    pragma Inline_Always (Nand);
  64    pragma Inline_Always (Nor);
  65    pragma Inline_Always (Nxor);
  66 end System.Vectors.Boolean_Operations;