1.23
2.0
main
test-branch
|
Last change
on this file since 20a83c7 was 0b9a80a, checked in by Manchun Zheng <zmanchun@…>, 12 years ago |
|
implemented $scopeof expression; removed unused examples; cleaned up library executors and enablers.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@703 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | #include <civlc.h>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 |
|
|---|
| 4 | void main(){
|
|---|
| 5 | $scope s = $here, t = $here;
|
|---|
| 6 | $scope p = $scope_parent(s);
|
|---|
| 7 | $gcomm g = $gcomm_create(p, 5);
|
|---|
| 8 | $gcomm f;
|
|---|
| 9 |
|
|---|
| 10 | void foo(){
|
|---|
| 11 | $scope fs = $here;
|
|---|
| 12 | $scope sum = fs + s;// compute the lowest common ancestors of fs and s.
|
|---|
| 13 |
|
|---|
| 14 | $assert(s > fs);
|
|---|
| 15 | $assert(sum == s);
|
|---|
| 16 | printf("foo done.\n");
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | void goo(){
|
|---|
| 20 | $scope s1 = $here;
|
|---|
| 21 | int x;
|
|---|
| 22 | double a[10];
|
|---|
| 23 |
|
|---|
| 24 | {
|
|---|
| 25 | $scope s2 = $here;
|
|---|
| 26 | int *p = &x;
|
|---|
| 27 | double *q = &a[4];
|
|---|
| 28 |
|
|---|
| 29 | $assert($scopeof(x)==s1);
|
|---|
| 30 | $assert($scopeof(p)==s2);
|
|---|
| 31 | $assert($scopeof(*p)==s1);
|
|---|
| 32 | $assert($scopeof(a)==s1);
|
|---|
| 33 | $assert($scopeof(a[5])==s1);
|
|---|
| 34 | $assert($scopeof(q)==s2);
|
|---|
| 35 | $assert($scopeof(*q)==s1);
|
|---|
| 36 | printf("goo done.\n");
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | f = g;
|
|---|
| 41 | g = f;
|
|---|
| 42 | foo();
|
|---|
| 43 | goo();
|
|---|
| 44 | $assert($scopeof(g) == $scopeof(f));
|
|---|
| 45 | $assert(s == t);
|
|---|
| 46 | $assert(s != p);
|
|---|
| 47 | $assert(s <= p);// s is equal to p or s is strictly a descendant of p.
|
|---|
| 48 | $assert(s < p);// s is strictly a descendant of p
|
|---|
| 49 | $assert(p >= s);// p is equal to s or p is strictly an ancestor of s.
|
|---|
| 50 | $assert(p > s);// p is strictly a ancestor of s.
|
|---|
| 51 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.