about summary refs log tree commit diff stats
path: root/012transform.cc
Commit message (Expand)AuthorAgeFilesLines
* 4987 - support `browse_trace` tool in SubXKartik Agaram2019-02-251-2/+2
* 3760 - force functions to use dependency-injectionKartik K. Agaram2017-03-071-0/+1
* 3561Kartik K. Agaram2016-10-221-2/+2
* 3555Kartik K. Agaram2016-10-221-1/+1
* 3522Kartik K. Agaram2016-10-191-6/+6
* 3520Kartik K. Agaram2016-10-181-3/+0
* 3437Kartik K. Agaram2016-10-041-1/+0
* 3436Kartik K. Agaram2016-10-041-2/+5
* 3435Kartik K. Agaram2016-10-041-0/+3
* 2882 - warn if programmer overuses transform_all()Kartik K. Agaram2016-04-281-0/+12
* 2815Kartik K. Agaram2016-03-271-1/+1
* 2799 - new approach to undoing changes in testsKartik K. Agaram2016-03-201-7/+0
* 2797 - bugfix: transform can create recipesKartik K. Agaram2016-03-191-0/+7
* 2796Kartik K. Agaram2016-03-191-5/+0
* 2775 - test rewrite-stash transformKartik K. Agaram2016-03-131-0/+5
* 2773 - switch to 'int'Kartik K. Agaram2016-03-131-5/+5
* 2728 - don't ignore /space: while checking typesKartik K. Agaram2016-03-041-0/+6
* 2494Kartik K. Agaram2015-11-281-0/+8
* 2458 - edit/: recipe side free of sandbox errorsKartik K. Agaram2015-11-181-0/+1
* 2393 - redo 2391Kartik K. Agaram2015-11-071-1/+1
* 2392 - undo 2391Kartik K. Agaram2015-11-071-1/+1
* 2391Kartik K. Agaram2015-11-071-1/+1
* 2382Kartik K. Agaram2015-11-061-0/+1
* 2374 - now edit works until layer 8Kartik K. Agaram2015-11-051-4/+0
* 2373 - bad bug: instruction was losing /lookupKartik K. Agaram2015-11-051-0/+4
* 2364Kartik K. Agaram2015-11-051-0/+10
* 2358 - starting to tackle the phase ordering problemKartik K. Agaram2015-11-041-1/+5
* 2316 - preparing for static dispatchKartik K. Agaram2015-10-291-1/+2
* 2311Kartik K. Agaram2015-10-291-0/+4
* 2154 - check types only after loading all layersKartik K. Agaram2015-09-051-0/+1
* 2095Kartik K. Agaram2015-08-281-2/+0
* 1702 - experiment: start using 'ordinal' in namesKartik K. Agaram2015-07-041-4/+4
* 1699 - first-class recipe typesKartik K. Agaram2015-07-031-0/+1
* 1399 - better 'unknown type' warningsKartik K. Agaram2015-05-181-1/+1
* 1391 - avoid unsigned integersKartik K. Agaram2015-05-171-5/+5
* 1387Kartik K. Agaram2015-05-161-2/+2
* 1357 - temporarily revert floating-point supportKartik K. Agaram2015-05-121-1/+1
* 1356 - snapshot #2: floating point supportKartik K. Agaram2015-05-121-1/+1
* 1343Kartik K. Agaram2015-05-111-1/+1
* 1323 - keyboard supports backspace and newlineKartik K. Agaram2015-05-101-5/+2
* 1299 - stop using [] in any vectorKartik K. Agaram2015-05-071-4/+4
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-051-0/+55
ik K. Agaram <vc@akkartik.com> 2016-03-08 01:46:47 -0800 2735 - define recipes using 'def'' href='/akkartik/mu/commit/024jump.cc?h=hlt&id=1ead356219bb2eb59487d1012f837bd07ec336f5'>1ead3562 ^
100157d1 ^
d7494165 ^
100157d1 ^


acc4792d ^


201b2e6c ^
1848b18f ^

201b2e6c ^
795f5244 ^
d855b0a0 ^
201b2e6c ^
d855b0a0 ^
acc4792d ^
e4630643 ^

d855b0a0 ^
1b76245c ^
e4630643 ^

d855b0a0 ^
1b76245c ^
e4630643 ^

d855b0a0 ^



dc1323e9 ^
0487a30e ^
cdd6fd09 ^
201b2e6c ^

1066660e ^
cdd6fd09 ^
1066660e ^
201b2e6c ^

88be3dbc ^
1ead3562 ^
bc643692 ^

201b2e6c ^
acc4792d ^
201b2e6c ^
acc4792d ^
d7494165 ^
201b2e6c ^
88be3dbc ^
1ead3562 ^
bc643692 ^

201b2e6c ^
acc4792d ^
201b2e6c ^
acc4792d ^
57699011 ^
201b2e6c ^
1848b18f ^

201b2e6c ^
795f5244 ^
d855b0a0 ^
201b2e6c ^
d855b0a0 ^
acc4792d ^
e4630643 ^

d855b0a0 ^
1b76245c ^
e4630643 ^

d855b0a0 ^
1b76245c ^
e4630643 ^

d855b0a0 ^



dc1323e9 ^
0487a30e ^
cdd6fd09 ^
201b2e6c ^

1066660e ^
cdd6fd09 ^
1066660e ^
201b2e6c ^

88be3dbc ^
1ead3562 ^
bc643692 ^

201b2e6c ^
acc4792d ^
201b2e6c ^
acc4792d ^
d7494165 ^
201b2e6c ^
88be3dbc ^
1ead3562 ^
bc643692 ^

201b2e6c ^
acc4792d ^
201b2e6c ^
acc4792d ^
57699011 ^
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
                   
 
                                      
          
               
                    
 

                                          

                             
                                             
     
                                        
                                  
                                       
            
                                    
                                                                                                                                           

          
                                              
                                                                                                                                                                         

          



                                                
                                                              
                                                    
                                                                                   
                                             

 

                                          
                               
 
                         
          
                       
                               


                               


                         
 

                                             
                                        
                                        
                                       
               
                                    
                                                                                                                                               

          
                                              
                                                                                                                                                                        

          
                                              
                                                                                                                                                                                 

          



                                                
                                                              
                                 
                                                          

          
                                                    
                                                                                   
                                             

 
                   
          

                       
 
                                             
                              
                                          
                               
 
                               
          

                      
 
                                           
                          
                                            
                               
 

                                             
                                        
                                                
                                       
                   
                                    
                                                                                                                                                   

          
                                              
                                                                                                                                                                            

          
                                              
                                                                                                                                                                                     

          



                                                
                                                              
                                
                                                              

          
                                                    
                                                                                   
                                             

 
                       
          

                         
 
                                               
                              
                                            
                               
 
                                   
          

                           
 
                                                 
                              
                                            
                               
//: Jump primitives

:(scenario jump_can_skip_instructions)
def main [
  jump 1:offset
  1:number <- copy 1
]
+run: jump {1: "offset"}
-run: {1: "number"} <- copy {1: "literal"}
-mem: storing 1 in location 1

:(before "End Primitive Recipe Declarations")
JUMP,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "jump", JUMP);
:(before "End Primitive Recipe Checks")
case JUMP: {
  if (SIZE(inst.ingredients) != 1) {
    raise << maybe(get(Recipe, r).name) << "'jump' requires exactly one ingredient, but got " << to_original_string(inst) << '\n' << end();
    break;
  }
  if (!is_mu_scalar(inst.ingredients.at(0))) {
    raise << maybe(get(Recipe, r).name) << "first ingredient of 'jump' should be a label or offset, but got " << inst.ingredients.at(0).original_string << '\n' << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case JUMP: {
  assert(current_instruction().ingredients.at(0).initialized);
  current_step_index() += ingredients.at(0).at(0)+1;
  trace(9998, "run") << "jumping to instruction " << current_step_index() << end();
  continue;  // skip rest of this instruction
}

//: special type to designate jump targets
:(before "End Mu Types Initialization")
put(Type_ordinal, "offset", 0);

:(scenario jump_backward)
def main [
  jump 1:offset  # 0 -+
  jump 3:offset  #    |   +-+ 1
                 #   \/  /\ |
  jump -2:offset #  2 +-->+ |
]                #         \/ 3
+run: jump {1: "offset"}
+run: jump {-2: "offset"}
+run: jump {3: "offset"}

:(before "End Primitive Recipe Declarations")
JUMP_IF,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "jump-if", JUMP_IF);
:(before "End Primitive Recipe Checks")
case JUMP_IF: {
  if (SIZE(inst.ingredients) != 2) {
    raise << maybe(get(Recipe, r).name) << "'jump-if' requires exactly two ingredients, but got " << to_original_string(inst) << '\n' << end();
    break;
  }
  if (!is_mu_scalar(inst.ingredients.at(0))) {
    raise << maybe(get(Recipe, r).name) << "'jump-if' requires a boolean for its first ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
    break;
  }
  if (!is_mu_scalar(inst.ingredients.at(1))) {
    raise << maybe(get(Recipe, r).name) << "'jump-if' requires a label or offset for its second ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case JUMP_IF: {
  assert(current_instruction().ingredients.at(1).initialized);
  if (!ingredients.at(0).at(0)) {
    trace(9998, "run") << "jump-if fell through" << end();
    break;
  }
  current_step_index() += ingredients.at(1).at(0)+1;
  trace(9998, "run") << "jumping to instruction " << current_step_index() << end();
  continue;  // skip rest of this instruction
}

:(scenario jump_if)
def main [
  jump-if 999, 1:offset
  123:number <- copy 1
]
+run: jump-if {999: "literal"}, {1: "offset"}
+run: jumping to instruction 2
-run: {1: "number"} <- copy {1: "literal"}
-mem: storing 1 in location 123

:(scenario jump_if_fallthrough)
def main [
  jump-if 0, 1:offset
  123:number <- copy 1
]
+run: jump-if {0: "literal"}, {1: "offset"}
+run: jump-if fell through
+run: {123: "number"} <- copy {1: "literal"}
+mem: storing 1 in location 123

:(before "End Primitive Recipe Declarations")
JUMP_UNLESS,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "jump-unless", JUMP_UNLESS);
:(before "End Primitive Recipe Checks")
case JUMP_UNLESS: {
  if (SIZE(inst.ingredients) != 2) {
    raise << maybe(get(Recipe, r).name) << "'jump-unless' requires exactly two ingredients, but got " << to_original_string(inst) << '\n' << end();
    break;
  }
  if (!is_mu_scalar(inst.ingredients.at(0))) {
    raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a boolean for its first ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
    break;
  }
  if (!is_mu_scalar(inst.ingredients.at(1))) {
    raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a label or offset for its second ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case JUMP_UNLESS: {
  assert(current_instruction().ingredients.at(1).initialized);
  if (ingredients.at(0).at(0)) {
    trace(9998, "run") << "jump-unless fell through" << end();
    break;
  }
  current_step_index() += ingredients.at(1).at(0)+1;
  trace(9998, "run") << "jumping to instruction " << current_step_index() << end();
  continue;  // skip rest of this instruction
}

:(scenario jump_unless)
def main [
  jump-unless 0, 1:offset
  123:number <- copy 1
]
+run: jump-unless {0: "literal"}, {1: "offset"}
+run: jumping to instruction 2
-run: {123: "number"} <- copy {1: "literal"}
-mem: storing 1 in location 123

:(scenario jump_unless_fallthrough)
def main [
  jump-unless 999, 1:offset
  123:number <- copy 1
]
+run: jump-unless {999: "literal"}, {1: "offset"}
+run: jump-unless fell through
+run: {123: "number"} <- copy {1: "literal"}
+mem: storing 1 in location 123