Mercurial > hg > truffle
annotate graal/com.oracle.truffle.sl.test/tests/LoopPolymorphic.sl @ 13836:64c77f0577bb
More documentation and improvements of Simple Language
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 30 Jan 2014 17:53:27 -0800 |
parents | |
children | afd6fa5e8229 |
rev | line source |
---|---|
13836
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
1 function add(a, b) { |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
2 return a + b; |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
3 } |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
4 |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
5 function loop(n) { |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
6 i = 0; |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
7 while (i < n) { |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
8 i = add(i, 1); |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
9 } |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
10 return i; |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
11 } |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
12 |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
13 function main() { |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
14 add("a", "b"); |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
15 println(loop(1000)); |
64c77f0577bb
More documentation and improvements of Simple Language
Christian Wimmer <christian.wimmer@oracle.com>
parents:
diff
changeset
|
16 } |