annotate arrayjs.rhope @ 136:fc3815b7462f

Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
author Mike Pavone <pavone@retrodev.com>
date Sun, 14 Nov 2010 23:07:55 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 Blueprint Array
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 Foreign Javascript:runtime
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 _internal_js_length[array:out(Int32,Naked)]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 _internal_array_set[array(Array,Boxed,Mutable),index(Int32,Naked),val:array]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 _internal_array_get[array(Array),index(Int32,Naked):out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 Array[:out(Empty Array)]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 out <- Build[Array()]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 First@Array[array:out(Int32),empty]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 ,empty <- If[[array]Length]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 { out <- 0 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 Next@Array[array,current:out(Int32),empty]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 next <- [current]+[1]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29 ,empty <- If[[next] < [[array]Length]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31 out <- Val[next]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36 Last@Array[array:out(Int32),empty]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38 ,empty <- If[[array]Length]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 { out <- [[array]Length] - [1] }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
41
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
42 Append@Array[array,newval:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44 out <- [array]Set[[array]Length, newval]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
47 Index@Array[array,index(Int32):out,notfound]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
48 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49 ,notfound <- If[[index] >= [0]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
50 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
51 ,notfound <- If[[index] < [[array]Length]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
52 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
53 out <- _internal_array_get[array, index]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
54 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
55 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
56 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58 Set@Array[array,index(Int32),val:out,invalid]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60 invalid <- If[[index]<[0]] {}
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
61 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
62 len <- [array]Length
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
63 If[[index]>[len]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
64 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
65 out <- [[array]Set[[index]-[1],val]]Set[index, val]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
66 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
67 out <- _internal_array_set[array,index,val]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
68 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
69 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
71
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
72 Length@Array[arr:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
73 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
74 out <- _internal_js_length[arr]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
75 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
76
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
77 Call@Array[arr,index(Int32):out,not found]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
78 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
79 out,not found <- [arr]Index[index]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
80 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
81