source: CIVL/examples/languageFeatures/scopeOperators.cvl

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

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

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include <civlc.cvh>
2#include <comm.cvh>
3#include <scope.cvh>
4#include <stdio.h>
5
6void main(){
7 $scope s = $here, t = $here;
8 $scope p = $scope_parent(s);
9 $gcomm g = $gcomm_create(p, 5);
10 $gcomm f;
11
12 void foo(){
13 $scope fs = $here;
14 $scope sum = fs + s;// compute the lowest common ancestors of fs and s.
15
16 $assert(s > fs);
17 $assert(sum == s);
18 printf("foo done.\n");
19 }
20
21 void goo(){
22 $scope s1 = $here;
23 int x;
24 double a[10];
25
26 {
27 $scope s2 = $here;
28 int *p = &x;
29 double *q = &a[4];
30
31 $assert($scopeof(x)==s1);
32 $assert($scopeof(p)==s2);
33 $assert($scopeof(*p)==s1);
34 $assert($scopeof(a)==s1);
35 $assert($scopeof(a[5])==s1);
36 $assert($scopeof(q)==s2);
37 $assert($scopeof(*q)==s1);
38 printf("goo done.\n");
39 }
40 }
41
42 f = g;
43 g = f;
44 foo();
45 goo();
46 $assert($scopeof(g) == $scopeof(f));
47 $assert(s == t);
48 $assert(s != p);
49 $assert(s <= p);// s is equal to p or s is strictly a descendant of p.
50 $assert(s < p);// s is strictly a descendant of p
51 $assert(p >= s);// p is equal to s or p is strictly an ancestor of s.
52 $assert(p > s);// p is strictly a ancestor of s.
53 $gcomm_destroy(g, NULL);
54}
Note: See TracBrowser for help on using the repository browser.