about summary refs log tree commit diff stats
path: root/tools
Commit message (Expand)AuthorAgeFilesLines
* .Kartik Agaram2021-05-021-1/+44
* .Kartik Agaram2021-05-011-44/+1
* .Kartik Agaram2021-03-241-636/+0
* .Kartik Agaram2021-03-231-2/+2
* .Kartik Agaram2021-03-231-2/+3
* .Kartik Agaram2021-03-231-4/+3
* .Kartik Agaram2021-03-231-2/+2
* .Kartik Agaram2021-03-231-41/+30
* 7846Kartik K. Agaram2021-03-041-4/+6
* 7842 - new directory organizationKartik K. Agaram2021-03-03104-33908/+462
* 7746Kartik Agaram2021-02-141-3/+2
* 7745Kartik Agaram2021-02-141-0/+9
* 7688Kartik Agaram2021-02-061-1/+1
* 7476Kartik Agaram2020-12-301-1/+1
* 7472Kartik Agaram2020-12-291-0/+9
* 7464Kartik Agaram2020-12-291-0/+9
* 7426Kartik Agaram2020-12-271-41/+41
* 7405Kartik Agaram2020-12-261-36/+45
* 7252Kartik Agaram2020-11-161-1/+1
* 7236Kartik Agaram2020-11-141-1/+1
* 7233 - fix some warnings from gcc 9Kartik Agaram2020-11-131-3/+3
* 6774Kartik Agaram2020-09-111-0/+11
* 6674Kartik Agaram2020-07-251-5/+5
* 6631Kartik Agaram2020-07-111-4/+4
* 6617Kartik Agaram2020-07-051-7/+5
* 6610 - tweak the Linux boot image generatorKartik Agaram2020-07-051-8/+6
* -Kartik Agaram2020-05-182-17/+20
* mu.subx: make handles in Primitives easier to readKartik Agaram2020-05-181-0/+17
* 6207 - tweaks while creating a videoKartik Agaram2020-04-191-3/+3
* 6123 - runtime helper for initializing arraysKartik Agaram2020-03-111-0/+636
* 6003Kartik Agaram2020-02-091-4/+15
* 6002Kartik Agaram2020-02-091-3/+4
* 5910Kartik Agaram2020-01-201-2/+1
* 5900Kartik Agaram2020-01-191-0/+16
* 5899Kartik Agaram2020-01-192-4/+11
* 5897 - rename comparison instructionsKartik Agaram2020-01-161-16/+0
* 5891Kartik Agaram2020-01-141-0/+20
* 5884Kartik Agaram2020-01-121-0/+7
* 5881Kartik Agaram2020-01-101-7/+0
* 5875Kartik Agaram2020-01-021-7/+7
* 5870Kartik Agaram2020-01-021-0/+3
* 5868Kartik Agaram2020-01-021-0/+0
* 5859Kartik Agaram2020-01-012-0/+67
* 5858Kartik Agaram2020-01-0195-0/+32627
* 5837 - better colors for trace browserKartik Agaram2019-12-281-10/+25
* 5819Kartik Agaram2019-12-221-1/+1
* 5816 - browse_trace bug fixedKartik Agaram2019-12-211-0/+1
* 5815Kartik Agaram2019-12-211-4/+4
* 5814Kartik Agaram2019-12-211-25/+25
* 5813Kartik Agaram2019-12-211-2/+1
-12-03 23:25:40 -0800 4134 - 'input' = 'ingredient'' href='/akkartik/mu/commit/066stream.mu?h=hlt&id=4a48bedcd1d708a43d43dc6259a4e45c52ea3d00'>4a48bedc ^
85b2f61b ^
dd660682 ^
7a84094a ^
a0331a9b ^
7a84094a ^
51b0936f ^
4f3510d0 ^

760f683f ^
dd660682 ^
4f3510d0 ^
050a93ac ^


760f683f ^
77d5b5d6 ^
4a48bedc ^
85b2f61b ^
7a84094a ^
ea19d0dc ^
7a84094a ^
748b6865 ^



8fb0e672 ^

760f683f ^
77d5b5d6 ^
4a48bedc ^
85b2f61b ^
7a84094a ^
a0331a9b ^
7a84094a ^
104854ca ^
8fb0e672 ^
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

                                            
           
                

 
                                                     
             
             
                       
                                      

                                         

 
                                                   
             
             
                  
                                 

 
                                                                            
             
             
                                              
                      
                                  
                                     
                      
                                          

                        
                                          
                              
   




                                   
                                                         
             
             
                                              
                           
                                  
                                     
                      
                                          

                        
                                          
                              
   


                         
                                                                 
             
             
                                                   
                                  
                                
                                              



                                        

 
                                                     
             
             
                                                              
                                  
                                     
                      
                                     
 
# new type to help incrementally scan arrays
container stream:_elem [
  index:num
  data:&:@:_elem
]

def new-stream s:&:@:_elem -> result:&:stream:_elem [
  local-scope
  load-inputs
  return-unless s, null
  result <- new {(stream _elem): type}
  *result <- put *result, index:offset, 0
  *result <- put *result, data:offset, s
]

def rewind in:&:stream:_elem -> in:&:stream:_elem [
  local-scope
  load-inputs
  return-unless in
  *in <- put *in, index:offset, 0
]

def read in:&:stream:_elem -> result:_elem, empty?:bool, in:&:stream:_elem [
  local-scope
  load-inputs
  assert in, [cannot read; stream has no data]
  empty? <- copy false
  idx:num <- get *in, index:offset
  s:&:@:_elem <- get *in, data:offset
  len:num <- length *s
  at-end?:bool <- greater-or-equal idx len
  {
    break-unless at-end?
    empty-result:&:_elem <- new _elem:type
    return *empty-result, true
  }
  result <- index *s, idx
  idx <- add idx, 1
  *in <- put *in, index:offset, idx
]

def peek in:&:stream:_elem -> result:_elem, empty?:bool [
  local-scope
  load-inputs
  assert in, [cannot peek; stream has no data]
  empty?:bool <- copy false
  idx:num <- get *in, index:offset
  s:&:@:_elem <- get *in, data:offset
  len:num <- length *s
  at-end?:bool <- greater-or-equal idx len
  {
    break-unless at-end?
    empty-result:&:_elem <- new _elem:type
    return *empty-result, true
  }
  result <- index *s, idx
]

def read-line in:&:stream:char -> result:text, in:&:stream:char [
  local-scope
  load-inputs
  assert in, [cannot read-line; stream has no data]
  idx:num <- get *in, index:offset
  s:text <- get *in, data:offset
  next-idx:num <- find-next s, 10/newline, idx
  result <- copy-range s, idx, next-idx
  idx <- add next-idx, 1  # skip newline
  # write back
  *in <- put *in, index:offset, idx
]

def end-of-stream? in:&:stream:_elem -> result:bool [
  local-scope
  load-inputs
  assert in, [cannot check end-of-stream?; stream has no data]
  idx:num <- get *in, index:offset
  s:&:@:_elem <- get *in, data:offset
  len:num <- length *s
  result <- greater-or-equal idx, len
]