heptagon/test/good/current.ept

44 lines
843 B
Text
Raw Permalink Normal View History

2011-05-12 10:57:38 +02:00
node current (c : bool; x : int on c) returns ( y : int )
let
y = merge c (true -> x) (false -> 0 fby y whenot c)
tel
node internal_current (c : bool; x : int on c) returns ( y : int on c)
var x_cur : int;
let
x_cur = merge c (true -> x) (false -> 0 fby x_cur whenot c);
y = x_cur when c
tel
2011-05-12 17:40:23 +02:00
node use_current (c : bool; x : int) returns (b : bool on c; y : int on c)
var x_cur, y2 :int;
2011-05-12 10:57:38 +02:00
let
x_cur = current(c,x);
y = x_cur when c;
2011-05-12 17:40:23 +02:00
y2 = internal_current(c,x);
b = y = y2;
2011-05-12 10:57:38 +02:00
tel
node prod() returns (y:int;b:bool)
var x,y':int;c,b':bool;
let
x = 0 fby x + 1;
c = (x % 10) = 0;
(b',y') = use_current(c,x when c);
y = current(c,y');
b = merge c b' (true fby b whenot c);
tel
(* CHECK check *)
node check() returns (b:bool)
var y:int;
let
(y,b) = prod()
tel
node main() returns (y:int;b:bool)
let
(y,b) = prod()
tel