added block_iterator
[antimony.git] / bootstrap / src / antimony / block_sb.voo
blob662f6cffbc331f3f3c8f99dc130f876151932888
1 section data
2 import sbJ___log
3 section functions
4 export sbJ_block_iterator
5 import sbJ_allocate_words sbJ_block_length sbJ_block_nth sbJ_false sbJ_make_iterator sbJ_lt sbJ_true
6 align
7 sbJ_block_iterator:
8 function sbJ_blk
9     block
10         let sbJ_state call sbJ_allocate_words 4
11         set-word sbJ_state 1 sbJ_blk
12         let sbJ__sb_G1 call sbJ_block_length sbJ_blk
13         set-word sbJ_state 2 sbJ__sb_G1
14         set-word sbJ_state 3 0
15         let sbJ__sb_G2 call sbJ_make_iterator sbJ_block_iterator_next sbJ_state
16         return sbJ__sb_G2
17     end block
18 end function
20 align
21 sbJ_block_iterator_next:
22 function sbJ_it sbJ_state sbJ_setJ2diteratorJ2dvalue
23     block
24         let sbJ_i get-word sbJ_state 3
25         let sbJ__sb_G3 get-word sbJ_state 2
26         let sbJ__sb_G4 call sbJ_lt sbJ_i sbJ__sb_G3
27         ifeq sbJ__sb_G4 @sbJ_true
28             block
29                 let sbJ__sb_G5 add sbJ_i 1
30                 set-word sbJ_state 3 sbJ__sb_G5
31                 let sbJ__sb_G6 get-word sbJ_state 1
32                 let sbJ__sb_G7 call sbJ_block_nth sbJ__sb_G6 sbJ_i
33                 let sbJ__sb_G8 call sbJ_setJ2diteratorJ2dvalue sbJ_it sbJ__sb_G7
34                 return sbJ__sb_G8
35             end block
36         end if
37         return @sbJ_false
38     end block
39 end function