comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: SPARK 2014 and protected objects
Date: Tue, 30 Aug 2016 17:11:33 -0700 (PDT)
Date: 2016-08-30T17:11:33-07:00	[thread overview]
Message-ID: <2a104643-59b9-4a46-b543-5c124984bf43@googlegroups.com> (raw)
In-Reply-To: <ly1t16k0kk.fsf@pushface.org>

Pragma Ada_2012;
Pragma Profile(Ravenscar);
Pragma Partition_Elaboration_Policy(Sequential);

package PO
with
  Spark_Mode     =>  On,
  Abstract_State => (State with External),
  Initializes    =>  State
is

   procedure Set (Value : Integer)
     with Depends => ((State =>+ Value));

   procedure Get (Value : out Integer)
     with Depends => ((Value => State, State => State));

private

   protected Impl
     with Part_Of => State
   is
      procedure Set (Value : Integer)
        with Depends => ((Impl =>+ Value));
      procedure Get (Value : out Integer)
        with Depends => (Impl => Impl, Value => Impl);

   private
	Protected_Value : Integer := 0;
   end Impl;
    
    -- GNAT doesn't allow Volatile on the protected object's with.
    Pragma Volatile(Impl);
    
end PO;

-----------------

package body PO
with Spark_Mode => On, Refined_State  => (State => Impl) is

   procedure Set (Value : Integer) is
   begin
      Impl.Set (Value);
   end Set;

   procedure Get (Value : out Integer) is
   begin
      Impl.Get (Value);
   end Get;
    
   protected body Impl is
      procedure Set (Value : Integer) is
      begin
         Protected_Value := Value;
      end Set;

      procedure Get (Value : out Integer) is
      begin
         Value := Protected_Value;
      end Get;
   end Impl;

end PO;

  parent reply	other threads:[~2016-08-31  0:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30 10:34 SPARK 2014 and protected objects Simon Wright
2016-08-30 14:45 ` Shark8
2016-08-30 15:33   ` Simon Wright
2016-08-30 18:42     ` Simon Wright
2016-08-30 18:47     ` Simon Wright
2016-08-31  0:11 ` Shark8 [this message]
2016-08-31  7:42   ` Simon Wright
2016-08-31 15:41     ` Shark8
2016-08-31 20:55       ` Simon Wright
2016-09-01 20:07         ` Shark8
replies disabled

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