Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Heisenberg may have been here.


devel / comp.lang.ada / Hiding Code from SPARK

SubjectAuthor
o Hiding Code from SPARKJeffrey R.Carter

1
Hiding Code from SPARK

<t7g0hr$usi$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6996&group=comp.lang.ada#6996

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spam.jrc...@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Hiding Code from SPARK
Date: Sat, 4 Jun 2022 18:16:57 +0200
Organization: A noiseless patient Spider
Lines: 70
Message-ID: <t7g0hr$usi$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 4 Jun 2022 16:16:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cb74c7118f1df89c5993cde4818ea083";
logging-data="31634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nFysIeNZZ0BOFnYQD0TqzA9U1F+eTniQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:xA0abhtVVqrBS0xGD0E63WeXFD0=
Content-Language: en-US
 by: Jeffrey R.Carter - Sat, 4 Jun 2022 16:16 UTC

I've been playing with trying to create a safe-pointer type for SPARK, where
SPARK doesn't know that access types are involved. So I've tried

private with Ada.Finalization;

generic -- SRC.Pointers
type Object (<>) is private;
package SRC.Pointers with SPARK_Mode
is
type Pointer is tagged private with
Default_Initial_Condition => Pointer.Is_Null;

function Is_Null ...

...

private -- SRC.Pointers
pragma SPARK_Mode (Off);

type Safe_Group;

type Name is access Safe_Group;

type Pointer is new Ada.Finalization.Controlled with record
Ptr : Name;
end record;

overriding procedure Adjust (Item : in out Pointer);
overriding procedure Finalize (Item : in out Pointer);
end SRC.Pointers;

My understanding is that SPARK will not look at the private part or the body.
All proofs will assume that the operations are correct.

When I instantiate it in a SPARK unit:

package Pointers is new SRC.Pointers (Object => Fixed);

and run

gnatprove --level=4 -Psrc

I get errors such as

value Off was set for SPARK_Mode on "Adjust" at src-pointers.ads:24

implying that SPARK is looking at the private part of SRC.Pointers. I can work
around that by putting the instantiation in an internal pkg with SPARK_Mode => Off:

package SPARK_Control with SPARK_Mode => Off
is
package Pointers is new SRC.Pointers (Object => Fixed);
end SPARK_Control;

package Pointers renames SPARK_Control.Pointers;

but then I get errors such as

"Pointer" is not allowed in SPARK

"Object" is not allowed in SPARK

which don't make much sense. How can I get SPARK to ignore the private part and
body of SRC.Pointers?

--
Jeff Carter
"You cheesy lot of second-hand electric donkey-bottom biters."
Monty Python & the Holy Grail
14

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor