From: Simon Wright <simon@pushface.org>
Subject: Re: SPARK 2014 and protected objects
Date: Tue, 30 Aug 2016 19:42:18 +0100
Date: 2016-08-30T19:42:18+01:00 [thread overview]
Message-ID: <lyh9a2hzed.fsf@pushface.org> (raw)
In-Reply-To: lyoa4ai85i.fsf@pushface.org
Simon Wright <simon@pushface.org> writes:
> What is a non-external state?
This version proves OK. Note the (State with External). I _think_ that
Protected_Value and Impl's spec, being Part_Of State, have to be in the
same declarative region (i.e. not the body).
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 => (State => State,
Value => State);
private
Protected_Value : Integer := 0
with Volatile,
Part_Of => State;
protected Impl
with Part_Of => State
is
procedure Set (Value : Integer)
with Depends => (Impl => Impl,
Protected_Value => Value);
procedure Get (Value : out Integer)
with Depends => (Impl => Impl,
Protected_Value => Protected_Value,
Value => Protected_Value);
end Impl;
end PO;
package body PO
with Spark_Mode => On,
Refined_State => (State => (Protected_Value,
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;
next prev parent reply other threads:[~2016-08-30 18:42 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 [this message]
2016-08-30 18:47 ` Simon Wright
2016-08-31 0:11 ` Shark8
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