source: CIVL/examples/backend/showTrans.cvl@ 817290e

1.23 2.0 main test-branch
Last change on this file since 817290e was e6fd645, checked in by Manchun Zheng <zmanchun@…>, 11 years ago

minor correction

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2388 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[7329898]1#include <civlc.cvh>
2
[2e13620]3$abstract int random(int x, int y);
4
[7329898]5typedef struct point{
6 int x;
7 int y;
8} point_t;
9
10int times2(int k, int t){
11 return 2*k*t;
12}
13
14void f(){
[7759ec0]15 $atomic{
[7329898]16 int x=0;
17
18 x++;
[7759ec0]19 }
[7329898]20}
21
[2e13620]22point_t reverse(point_t old){
23 point_t new;
24
25 new.x=old.y;
26 new.y=old.x;
27 return new;
28}
29
[7329898]30void main(){
31 int a=2;
32 int *b=&a;
33 void (*g)(void)=&f;
[e6fd645]34 $proc p=$spawn g();
[7329898]35 int c[2][2];
36 $domain(2) dom=($domain(2)){1 .. 4#2, 1 .. 4#2};
[2e13620]37 point_t pt;
38 double db;
[7329898]39
[7759ec0]40 a=a>0?times2(3, a*5):times2(a, a+6);
[2e13620]41 db=(double)a;
[7329898]42 pt.x=1;
43 pt.y=pt.x+5;
[2e13620]44 pt.x=reverse(pt).x;
[7329898]45 $wait(p);
46 p=$spawn g();
47 $wait(p);
[2e13620]48 a=random(a, a+2);
[7329898]49 a=times2(a*a, a);
50 a=$next_time_count();
51 *b=$next_time_count();
[2e13620]52 a=-(a+*b*6);
[7329898]53 $for(int i, j: dom)
54 c[(i-1)/2][(j-1)/2] = i*10 + j;
[2e13620]55 $assert($forall {int i | i >= 0 && i < 2} c[i][i] >= 0);
56 $assert($exists {int i | i >= 0 && i < 2} c[i][i] >= 0);
[7329898]57 dom=($domain(2)){0 .. 1, 0 .. 1};
58 $parfor(int i, j: dom)
59 times2(i, j);
[2e13620]60 *b=*(&c[0][0]+1);
[7329898]61 b=(int*)$malloc($root, sizeof(int)*2);
62 b[0]=c[0][0];
63 b[1]=c[1][1];
64 $free(b);
65}
Note: See TracBrowser for help on using the repository browser.