| [da65ee2] | 1 | #include<mem.cvh>
|
|---|
| 2 |
|
|---|
| 3 | int a[10][10];
|
|---|
| 4 |
|
|---|
| 5 | int main() {
|
|---|
| 6 | $mem m = &a[0][0 .. 3];
|
|---|
| 7 |
|
|---|
| 8 | m = $mem_union_widening(m, &a[0][4 .. 6]);
|
|---|
| 9 | /* If a set of references have diference in only one dimension, and
|
|---|
| 10 | ranges in every reference can be connected, the default widening
|
|---|
| 11 | operator will combine them precisely
|
|---|
| 12 | */
|
|---|
| 13 | $assert($mem_contains(m, &a[0][0 .. 6]));
|
|---|
| 14 | $assert(!$mem_contains(m, &a[0][7]));
|
|---|
| 15 | $assert(!$mem_contains(m, &a[1][0 .. 6]));
|
|---|
| 16 |
|
|---|
| 17 | m = &a[0 .. 3][1 .. 8];
|
|---|
| 18 | m = $mem_union_widening(&a[4 .. 6][1 .. 8], m);
|
|---|
| 19 | m = $mem_union_widening(&a[7 .. 8][1 .. 8], m);
|
|---|
| 20 | $assert($mem_contains(m, &a[0 .. 8][1 .. 8]));
|
|---|
| 21 | $assert(!$mem_contains(m, &a[9][1 .. 8]));
|
|---|
| 22 | $assert(!$mem_contains(m, &a[0 .. 6][0]));
|
|---|
| 23 |
|
|---|
| 24 | /* if not all connected, the default widening operator will result
|
|---|
| 25 | * in a reference that refers to the whole dimension
|
|---|
| 26 | */
|
|---|
| 27 | m = &a[0 .. 3][1 .. 8];
|
|---|
| 28 | m = $mem_union_widening(&a[5 .. 6][1 .. 8], m);
|
|---|
| 29 | $assert($mem_contains(m, &a[0 .. 6][1 .. 8]));
|
|---|
| 30 | $assert($mem_contains(m, &a[0 .. 9][1 .. 8]));
|
|---|
| 31 | $assert(!$mem_contains(m, &a[0 .. 3][0]));
|
|---|
| 32 |
|
|---|
| 33 | /*If a set of references have diference in more than one dimensions,
|
|---|
| 34 | the default widening operator will result in a reference that
|
|---|
| 35 | refers to the whole multiple dimensional array*/
|
|---|
| 36 | m = &a[0 .. 3][0 .. 3];
|
|---|
| 37 | m = $mem_union_widening(&a[4 .. 6][4 .. 6], m);
|
|---|
| 38 | $assert($mem_contains(m, &a));
|
|---|
| 39 | }
|
|---|