File : g-moreex.adb


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                         GNAT LIBRARY COMPONENTS                          --
   4 --                                                                          --
   5 --            G N A T . M O S T _ R E C E N T _ E X C E P T I O N           --
   6 --                                                                          --
   7 --                                 B o d y                                  --
   8 --                                                                          --
   9 --                     Copyright (C) 2000-2010, AdaCore                     --
  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 with Ada.Exceptions.Is_Null_Occurrence;
  33 with System.Soft_Links;
  34 
  35 package body GNAT.Most_Recent_Exception is
  36 
  37    ----------------
  38    -- Occurrence --
  39    ----------------
  40 
  41    function Occurrence return Ada.Exceptions.Exception_Occurrence is
  42       EOA : constant Ada.Exceptions.Exception_Occurrence_Access :=
  43               GNAT.Most_Recent_Exception.Occurrence_Access;
  44 
  45       use type Ada.Exceptions.Exception_Occurrence_Access;
  46 
  47    begin
  48       return Result : Ada.Exceptions.Exception_Occurrence do
  49          if EOA = null then
  50             Ada.Exceptions.Save_Occurrence
  51               (Target => Result,
  52                Source => Ada.Exceptions.Null_Occurrence);
  53          else
  54             Ada.Exceptions.Save_Occurrence
  55               (Target => Result,
  56                Source => EOA.all);
  57          end if;
  58       end return;
  59    end Occurrence;
  60 
  61    -----------------------
  62    -- Occurrence_Access --
  63    -----------------------
  64 
  65    function Occurrence_Access
  66      return Ada.Exceptions.Exception_Occurrence_Access
  67    is
  68       use Ada.Exceptions;
  69 
  70       EOA : constant Exception_Occurrence_Access :=
  71               System.Soft_Links.Get_Current_Excep.all;
  72 
  73    begin
  74       if EOA = null then
  75          return null;
  76 
  77       elsif Is_Null_Occurrence (EOA.all) then
  78          return null;
  79 
  80       else
  81          return EOA;
  82       end if;
  83    end Occurrence_Access;
  84 
  85 end GNAT.Most_Recent_Exception;