about summary refs log tree commit diff stats
path: root/076duplex_list.mu
Commit message (Expand)AuthorAgeFilesLines
* 3034Kartik K. Agaram2016-06-051-0/+7
* 3015 - more symbolic names in testsKartik K. Agaram2016-05-261-248/+266
* 2864 - replace all address:shared with just addressKartik K. Agaram2016-04-241-202/+202
* 2849Kartik K. Agaram2016-04-201-2/+0
* 2841 - purge get-address until layer 76Kartik K. Agaram2016-04-161-62/+72
* 2778 - fix all layersKartik K. Agaram2016-03-141-0/+526
ss='oid'>9636c7ae ^
b0bf5321 ^
77d5b5d6 ^
bc643692 ^
9636c7ae ^

d4cb1a51 ^
502d2ea5 ^

9636c7ae ^

455fbac6 ^
9636c7ae ^
bc643692 ^
9636c7ae ^

502d2ea5 ^

d4cb1a51 ^
502d2ea5 ^
991d76f3 ^
502d2ea5 ^
9636c7ae ^

1ead3562 ^
9636c7ae ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

                          


                                                  
   
                         



                           



                                              
                                                 
             
                           

                           
                                                            

                               

        
                                        
                    
                    

                           

                                                 
                                                            
                                                                 
                                               
                 

        
               
 
scenario array-from-args [
  run [
    local-scope
    x:address:array:character <- new-array 0, 1, 2
    10:array:character/raw <- copy *x
  ]
  memory-should-contain [
    10 <- 3  # array length
    11 <- 0
    12 <- 1
    13 <- 2
  ]
]

# create an array out of a list of scalar args
def new-array -> result:address:array:character [
  local-scope
  capacity:number <- copy 0
  {
    # while read curr-value
    curr-value:character, exists?:boolean <- next-ingredient
    break-unless exists?
    capacity <- add capacity, 1
    loop
  }
  result <- new character:type, capacity
  rewind-ingredients
  i:number <- copy 0
  {
    # while read curr-value
    done?:boolean <- greater-or-equal i, capacity
    break-if done?
    curr-value:character, exists?:boolean <- next-ingredient
    assert exists?, [error in rewinding ingredients to new-array]
    *result <- put-index *result, i, curr-value
    i <- add i, 1
    loop
  }
  return result
]