Commit 558f0962 authored by Raphael Rieu-Helft's avatar Raphael Rieu-Helft

Add support for C extraction of arrays

parent 8d544dbe
...@@ -548,7 +548,12 @@ static struct __lsld64_result lsld64(uint64_t x, uint64_t cnt) ...@@ -548,7 +548,12 @@ static struct __lsld64_result lsld64(uint64_t x, uint64_t cnt)
end end
module mach.array.Array32
syntax val ([]) "%1[%2]"
syntax val ([]<-) "%1[%2] = %3"
end
module mach.c.C module mach.c.C
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ module Array ...@@ -12,7 +12,7 @@ module Array
use int.Int use int.Int
use map.Map use map.Map
type array 'a = private { type array [@ex:array] 'a = private {
mutable ghost elts : int -> 'a; mutable ghost elts : int -> 'a;
length : int length : int
} invariant { 0 <= length } } invariant { 0 <= length }
...@@ -49,7 +49,7 @@ module Array ...@@ -49,7 +49,7 @@ module Array
= if i < 0 || i >= length a then raise OutOfBounds; = if i < 0 || i >= length a then raise OutOfBounds;
a[i] <- v a[i] <- v
val function make (n: int) (v: 'a) : array 'a val function make [@ex:array_make] (n: int) (v: 'a) : array 'a
requires { [@expl:array creation size] n >= 0 } requires { [@expl:array creation size] n >= 0 }
ensures { forall i:int. 0 <= i < n -> result[i] = v } ensures { forall i:int. 0 <= i < n -> result[i] = v }
ensures { result.length = n } ensures { result.length = n }
......
...@@ -12,7 +12,7 @@ module Array32 ...@@ -12,7 +12,7 @@ module Array32
use mach.int.Int32 use mach.int.Int32
use map.Map as M use map.Map as M
type array 'a = private { type array [@ex:array] 'a = private {
mutable ghost elts : int -> 'a; mutable ghost elts : int -> 'a;
length : int32; length : int32;
} invariant { 0 <= length } } invariant { 0 <= length }
...@@ -45,7 +45,7 @@ module Array32 ...@@ -45,7 +45,7 @@ module Array32
= if i < of_int 0 || i >= length a then raise OutOfBounds; = if i < of_int 0 || i >= length a then raise OutOfBounds;
a[i] <- v a[i] <- v
val make (n: int32) (v: 'a) : array 'a val make [@ex:array_make] (n: int32) (v: 'a) : array 'a
requires { [@expl:array creation size] n >= 0 } requires { [@expl:array creation size] n >= 0 }
ensures { forall i:int. 0 <= i < n -> result[i] = v } ensures { forall i:int. 0 <= i < n -> result[i] = v }
ensures { result.length = n } ensures { result.length = n }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment