Mercurial > hg > truffle
annotate graal/com.oracle.truffle.sl.test/tests/Fibonacci.sl @ 21228:48762c9bfca4
SSADestructionPhase: use removePhiOut/removePhiIn/phiOutIndex.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 29 Apr 2015 13:31:37 +0200 |
parents | ff3136ecb5a7 |
children |
rev | line source |
---|---|
13762
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 function fib(num) { |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
2 if (num < 1) {return 0;} |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 n1 = 0; |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 n2 = 1; |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 i = 1; |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 while (i < num) { |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 next = n2 + n1; |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 n1 = n2; |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 n2 = next; |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 i = i + 1; |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 } |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 return n2; |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 } |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 |
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 function main() { |
13883
ff3136ecb5a7
SL: small changes
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
16 i = 1; |
ff3136ecb5a7
SL: small changes
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
17 while (i <= 10) { |
ff3136ecb5a7
SL: small changes
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
18 println(i + ": " + fib(i)); |
ff3136ecb5a7
SL: small changes
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
19 i = i + 1; |
ff3136ecb5a7
SL: small changes
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13821
diff
changeset
|
20 } |
13762
e34d5cca7496
Use source and expected output files to test Simple Language, instead of individual JUnit tests with the source and expected output as strings
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
21 } |