aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/o3.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/o3.zc')
-rw-r--r--tests/programs/o3.zc33
1 files changed, 18 insertions, 15 deletions
diff --git a/tests/programs/o3.zc b/tests/programs/o3.zc
index c875d09..d7026db 100644
--- a/tests/programs/o3.zc
+++ b/tests/programs/o3.zc
@@ -1,3 +1,6 @@
+namespace;
+include rt;
+
// o3 regions: every kind of control flow, against the same code without o3
struct pt { int x; int y; };
int g = 3;
@@ -31,20 +34,20 @@ o3 int mix(int n) {
return acc;
}
o3 int dyn(int n) {
- []int a = new([]int, n);
- fixed []int f = new(fixed []int, n);
+ int[?] a = rt.new(int[?], n);
+ fixed int[?] f = rt.new(fixed int[?], n);
int s = 0;
for (int i = 0; i < len(a); i++) { a[i] = i * i; f[i] = n - i; }
for (int i = 0; i < n; i++) s = s + a[i] * f[i];
- free(d*a); free(d*f);
+ rt.free(d*a); rt.free(d*f);
return s;
}
o3 int pts(int n) {
- pt* p = new(pt);
+ pt* p = rt.new(pt);
int s = 0;
p->x = 1; p->y = 2;
for (int i = 0; i < n; i++) { p->x = p->x + p->y; p->y = p->x - p->y; s = s + p->x % 1000; }
- free(d*p);
+ rt.free(d*p);
return s;
}
o3 int divs(int x) {
@@ -59,17 +62,17 @@ fn main() {
o3 {
int i = 0, s = 0;
while (i < 100) { s = s + collatz(i + 1); i++; }
- put_n(s); put_c(' ');
- put_n(lone); put_c(' ');
+ rt.put_n(s); rt.put_c(' ');
+ rt.put_n(lone); rt.put_c(' ');
lone++;
}
- put_n(lone); put_c(' ');
- put_n(ack(2, 3)); put_c(' ');
- put_n(many(1, 2, 3)); put_c(' ');
- put_n(mix(100)); put_c(' ');
- put_n(dyn(50)); put_c(' ');
- put_n(pts(30)); put_c(' ');
- put_n(divs(1000)); put_c(' ');
- put_n(divs(-77)); put_c(10);
+ rt.put_n(lone); rt.put_c(' ');
+ rt.put_n(ack(2, 3)); rt.put_c(' ');
+ rt.put_n(many(1, 2, 3)); rt.put_c(' ');
+ rt.put_n(mix(100)); rt.put_c(' ');
+ rt.put_n(dyn(50)); rt.put_c(' ');
+ rt.put_n(pts(30)); rt.put_c(' ');
+ rt.put_n(divs(1000)); rt.put_c(' ');
+ rt.put_n(divs(-77)); rt.put_c(10);
return 0;
}