annotate functional.rhope @ 95:f4fd8962c385

Cleaned up binary trees benchmark, made memory allocator somewhat configurable at compile time
author Mike Pavone <pavone@retrodev.com>
date Mon, 02 Aug 2010 01:55:56 -0400
parents e73a93fb5de1
children a34a982ecd32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
75
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 _Fold[list,index,current,worker:out]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 {
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 newval <- [worker]Call[current, [list]Index[index], index]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 [list]Next[index]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 {
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 out <- _Fold[list, ~, newval, worker]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 }{
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 out <- Val[newval]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 }
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 }
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 Fold[worker,start,list:out]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 {
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 [list]First
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 {
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 out <- _Fold[list, ~, start, worker]
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 }{
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 out <- start
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 }
0083b2f7b3c7 Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23
84
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
24 _Map[list,worker,cur:out]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
25 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
26 val <- [list]Index[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
27 nlist <- [list]Set[cur, [worker]Call[val, cur]]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
28
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
29 [nlist]Next[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
30 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
31 out <- _Map[nlist, worker, ~]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
32 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
33 out <- Val[nlist]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
34 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
35 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
36
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
37 Map[list,worker:out]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
38 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
39 [list]First
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
40 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
41 out <- _Map[list,worker,~]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
42 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
43 out <- list
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
44 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
45 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
46
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
47 _Find[list,pred,cur:loc,not found]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
48 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
49 val <- [list]Index[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
50 If[[pred]Call[val]]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
51 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
52 loc <- cur
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
53 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
54 ,not found <- [list]Next[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
55 { loc,not found <- _Find[list,pred,~] }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
56 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
57 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
58
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
59 Find[list,pred:loc,not found]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
60 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
61 ,not found <- [list]First
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
62 {
92
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 84
diff changeset
63 loc,not found <- _Find[list,pred,~]
84
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
64 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
65 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
66
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
67 _Filter[list,pred,cur,dest:out]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
68 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
69 val <- [list]Index[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
70 If[[pred]Call[val,cur]]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
71 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
72 ndest <- [dest]Append[val]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
73 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
74 ndest <- dest
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
75 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
76 [list]Next[cur]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
77 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
78 out <- _Filter[list,pred,~,ndest]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
79 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
80 out <- Val[ndest]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
81 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
82 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
83
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
84 Filter[list,pred:out]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
85 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
86 [list]First
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
87 {
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
88 out <- _Filter[list,pred,~, List[]]
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
89 }{
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
90 out <- list
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
91 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
92 }
6d41b71f1b77 Add Map, Filter and Find
Mike Pavone <pavone@retrodev.com>
parents: 76
diff changeset
93