comparison kernel.rhope @ 74:a844c623c7df

Add support for Worker type
author Mike Pavone <pavone@retrodev.com>
date Thu, 01 Jul 2010 21:32:08 -0400
parents c40c3d399133
children 0083b2f7b3c7
comparison
equal deleted inserted replaced
73:6a1a7d5cc2d9 74:a844c623c7df
144 _internal_array_getboxed[array(Array), index(Int32,Naked):out] 144 _internal_array_getboxed[array(Array), index(Int32,Naked):out]
145 _internal_array_setboxed[array(Array,Boxed,Mutable), index(Int32,Naked), val:array] 145 _internal_array_setboxed[array(Array,Boxed,Mutable), index(Int32,Naked), val:array]
146 _internal_array_allocboxed[size(Int32,Naked):out(Array)] 146 _internal_array_allocboxed[size(Int32,Naked):out(Array)]
147 _internal_array_allocnaked[size(Int32,Naked),type(Blueprint):out(Array)] 147 _internal_array_allocnaked[size(Int32,Naked),type(Blueprint):out(Array)]
148 _internal_blueprint_eq[left(Blueprint),right(Blueprint):out(Int32,Naked)] 148 _internal_blueprint_eq[left(Blueprint),right(Blueprint):out(Int32,Naked)]
149 _internal_worker_alloc[size(Int16,Naked):out(Worker)]
150 _internal_worker_setinput[worker(Worker,Boxed,Mutable),num(Int16,Naked),val:worker]
151 _internal_worker_getinput[worker(Worker),num(Int16,Naked):out]
152 _internal_worker_hasinput[worker(Worker),num(Int16,Naked):out(Int32,Naked)]
153 }
154
155 Blueprint Worker
156 {
157 Index(Int32,Naked)
158 Size(Int16,Naked)
159 Count(Int16,Naked)
160 }
161
162 Get Input@Worker[worker(Worker),bindex(Int32):val,not populated]
163 {
164 index <- [bindex]Trunc Int16
165 ,not populated <- If[_internal_worker_hasinput[worker,index]]
166 {
167 val <- _internal_worker_getinput[worker,index]
168 }
169 }
170
171 _Copy Params[source(Worker),dest(Worker),cur(Int16):out(Worker)]
172 {
173 If[[cur]<[[source]Size >>]]
174 {
175 [source]Get Input[cur]
176 {
177 next <- _internal_worker_setinput[dest, cur, ~]
178 }{
179 next <- Val[dest]
180 }
181 out <- _Copy Params[source, next, [cur]+[1i16]]
182 }{
183 out <- dest
184 }
185 }
186
187 Set Input@Worker[worker(Worker),bindex(Int32),val:out(Worker)]
188 {
189 index <- [bindex]Trunc Int16
190 If[[index] < [[worker]Size >>]]
191 {
192 set <- _internal_worker_setinput[worker, index, val]
193 }{
194 set <- _internal_worker_setinput[
195 _Copy Params[worker,
196 [ _internal_worker_alloc[[index]+[1i16]] ]Index <<[[worker]Index >>]
197 , 0i16]
198 , index, val]
199 }
200 out <- [set]Count <<[ [[set]Count >>]+[1i16] ]
149 } 201 }
150 202
151 =@Blueprint[left,right:out] 203 =@Blueprint[left,right:out]
152 { 204 {
153 out <- [_internal_blueprint_eq[left,right]]!=[0] 205 out <- [_internal_blueprint_eq[left,right]]!=[0]
291 ]Set[index,val] 343 ]Set[index,val]
292 } 344 }
293 } 345 }
294 } 346 }
295 347
296 348 Call@Array[arr(Array),index(Int32):out]
349 {
350 out <- [arr]Index[index]
351 }
352
353