comp.lang.ada
 help / color / mirror / Atom feed
From: anon <anon@anon.org>
Subject: Re: Ada port of the osdev.org bare bones tutorial (mostly done)
Date: Fri, 15 Jun 2012 23:29:06 -0500
Date: 2012-06-15T23:29:06-05:00	[thread overview]
Message-ID: <TIWdnRsgSrMPlkHSnZ2dnUVZ_r2dnZ2d@supernews.com> (raw)
In-Reply-To: 1ca9d254-a12a-4ec3-a4f9-081722fab147@googlegroups.com

Try this:

--
--  This pragma allows exceptions to be handled by routines or by 
--  the catch all Last_Chance_Hander.
--
pragma Restrictions ( No_Exception_Registration ) ;

--
--  These pragmas stops exceptions on many fronts.
--
--  pragma Restrictions ( No_Exceptions ) ;
--  pragma Restrictions ( No_Exception_Handlers ) ;
--  pragma Restrictions ( No_Exception_Propagation ) ;



----------------------------------------------------------------------
--  Last_Chance_Handler: Displays a Exception Termination Message.  --
--                       Shutdowns run-time-system.                 --
--                       Halts processor.                           --
----------------------------------------------------------------------

-----------------------------------------------------------------
--  compile/bind/link with "--RTS=x86" for x86 Bare Bones      --
--                                         Run-Time System.    --
-----------------------------------------------------------------

with Ada.Characters.Latin_1 ; --  for ESC character
--  with Ada.Text_IO ;        --  Must have full exception 
                              --  working to use
with System ;
with System.IO ;

procedure Teste is

  use Ada.Characters.Latin_1 ;
--  use Ada.Text_IO ;

  use System ;
  use IO ;

  Hello_Error : exception ;

begin

  --
  --  Clear Screen and Display Title message using 
  --  VT100 / VT52 ANSI escape sequences
  --
  --  Works on most OSs including Linux.
  --
  Put ( ESC & "[2J" ) ;                -- clear screen
  Put ( ESC & "[12;30H" ) ;            -- set screen location
  Put ( ESC & "[31;40;01m" ) ;         -- set text color to Red/Black
  Put ( "Bare Bone: " ) ;
  Put ( ESC & "[37;40;00m" ) ;         -- reset color 
  Put_Line ( "Hello" ) ;
  New_Line ;

  --
  --  Without a Exception handler the following will cause  
  --  the last chance handler to be executed, directly.
  --
  raise Hello_Error ;
-- raise Program_Error ;


--  Exception Handler:
--
--  The first two handlers will raise another exception that 
--  will be handled by the Last_Chance_Handler.
--
--  The third handler will not propagate the exception.
--  In turn, the Last_Chance_Hander will not be executed.
--
--
exception
  --
  when Hello_Error =>
     Put_Line ( "Exception Error: Hello" ) ;
     raise ;
  --
  when Program_Error =>
     Put_Line ( "Exception Error: Program" ) ;
     raise ;
  --
  when others =>
     Put_Line ( "Exception Error: All Others" ) ;

end Teste ;


Lucretia <laguest9000@googlemail.com> wrote in
news:1ca9d254-a12a-4ec3-a4f9-081722fab147@googlegroups.com: 

> I've also posted a bug to GCC's bug tracker as I'm lead to believe
> it's possible to declare and use your own exceptions with local
> exception handling, but it's failing. 
> 
> I don't know if AdaCore people still read this, but it would be
> interesting to know if it is possible or not and if it is can I get a
> patch? 
> 
> Luke.
> 




      parent reply	other threads:[~2012-06-16  4:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-13 20:12 Ada port of the osdev.org bare bones tutorial (mostly done) Lucretia
2012-06-13 20:46 ` Shark8
2012-06-15 12:24 ` Stepan Bujnak
2012-06-15 13:06   ` Lucretia
2012-06-15 13:14     ` Lucretia
2012-06-15 21:46       ` Robert A Duff
2012-06-15 22:22         ` Patrick
2012-06-15 22:40         ` Lucretia
2012-06-15 22:41         ` Lucretia
2012-06-16  0:54           ` Robert A Duff
2012-06-16  4:29       ` anon [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox