1.23
2.0
main
test-branch
|
Last change
on this file since 4ff6bb0 was 90e22fc, checked in by Manchun Zheng <zmanchun@…>, 13 years ago |
|
When there is only one conditional expression in a statement, no temporal variable is introduced. Make Fragment an interface and change the previous Fragment to be CommonFragment that implements it. Move the translation of conditional expressions into model factory from functionInfo since it is independent with functions.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@335 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
528 bytes
|
| Line | |
|---|
| 1 | void main(){
|
|---|
| 2 | int n = 0;
|
|---|
| 3 | int i = 1;
|
|---|
| 4 | int k = 9;
|
|---|
| 5 |
|
|---|
| 6 | // This should be translated into
|
|---|
| 7 | // Location X:
|
|---|
| 8 | // when(i>1) n = 1 goto ...
|
|---|
| 9 | // when (!(i>1)) n = 2
|
|---|
| 10 | n = i > 1 ? 1 : 2;
|
|---|
| 11 | $assert n == 2;
|
|---|
| 12 |
|
|---|
| 13 | // This should be translated into
|
|---|
| 14 | // int v0;
|
|---|
| 15 | // if(n > 1) v0 = 1; else v0 = 2;
|
|---|
| 16 | // int v1;
|
|---|
| 17 | // if(i < 1) v1 = 1; else v1 = 2;
|
|---|
| 18 | // n = v0 + v1;
|
|---|
| 19 | n = (n > 1 ? 1 : 2) + (i < 1 ? 1 : 2);
|
|---|
| 20 | $assert n == 3;
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | for(int j = 0; (j < 5 ? 1 : 0); j++){
|
|---|
| 24 | n = i * j;
|
|---|
| 25 | }
|
|---|
| 26 | $assert n == 4;
|
|---|
| 27 |
|
|---|
| 28 | //when(n > 1 ? 0 : 1) n = 3;
|
|---|
| 29 |
|
|---|
| 30 | if(n < 1 ? 0 : 1) n = 5;
|
|---|
| 31 | $assert n == 5;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.