Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
why3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Why3
why3
Commits
17194a2b
Commit
17194a2b
authored
10 years ago
by
Jean-Christophe Filliâtre
Browse files
Options
Downloads
Patches
Plain Diff
new module null.Null for nullable values
safely extracted to OCaml using obj.magic
parent
9899f840
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/ocaml-gen.drv
+10
-0
10 additions, 0 deletions
drivers/ocaml-gen.drv
modules/null.mlw
+35
-0
35 additions, 0 deletions
modules/null.mlw
with
45 additions
and
0 deletions
drivers/ocaml-gen.drv
+
10
−
0
View file @
17194a2b
...
@@ -264,3 +264,13 @@ module io.StdIO
...
@@ -264,3 +264,13 @@ module io.StdIO
syntax val print_int "Why3__BigInt.print"
syntax val print_int "Why3__BigInt.print"
syntax val print_newline "Pervasives.print_newline"
syntax val print_newline "Pervasives.print_newline"
end
end
module null.Null
syntax type t "%1"
syntax val create_null "(fun () -> Obj.magic (ref 0))"
syntax val eq_null "(==)"
syntax val create "(fun x -> x)"
syntax val get "(fun x -> x)"
end
This diff is collapsed.
Click to expand it.
modules/null.mlw
0 → 100644
+
35
−
0
View file @
17194a2b
(** {1 A possibly null, yet safe, value}
The OCaml driver does optimize this into the identity.
To permit the implementation of eq_null, null is implemented is a
heap-allocated value in OCaml, e.g., Obj.magic [|0|]
*)
module Null
type null = int
type t_model 'a = Null null | Value 'a
type t 'a model { v: t_model 'a }
predicate is_null (t: t 'a) =
match t.v with Null _ -> true | Value _ -> false end
val create_null () : t 'a
ensures { is_null result }
val eq_null (n x: t 'a) : bool
requires { is_null n }
ensures { result <-> x.v = n.v }
val create (x: 'a) : t 'a
ensures { result.v = Value x }
val get (t: t 'a) : 'a
requires { not (is_null t) }
ensures { t.v = Value result }
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment