summary refs log tree commit diff stats
path: root/test/bm_loader.py
blob: 9ee618013df8d92c2fdaf3061d24073f41438239 (plain) (blame)
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
>
6c96a437 ^
1
2
3
4
5
6
7
8
9


                                                                              
                                                
                                                                  

       
                                                            
                                                                                                              

                                                                                      
                                                              
                                               
                                
                                                   
                                                                                                                                          
               
     
                                                    
                                       


   
                                                     


                                         
 
 










                                                                                 
//: Once all code is loaded, save operation ids of instructions and check that
//: nothing's undefined.

:(before "End Instruction Modifying Transforms")
Transform.push_back(update_instruction_operations);  // idempotent

:(code)
void update_instruction_operations(const recipe_ordinal r) {
  trace(101, "transform") << "--- compute instruction operations for recipe " << get(Recipe, r).name << end();
  recipe& caller = get(Recipe, r);
//?   cerr << "--- compute instruction operations for recipe " << caller.name << '\n';
  for (int index = 0;  index < SIZE(caller.steps);  ++index) {
    instruction& inst = caller.steps.at(index);
    if (inst.is_label) continue;
    if (!contains_key(Recipe_ordinal, inst.name)) {
      raise << maybe(caller.name) << "instruction '" << inst.name << "' has no recipe in '" << to_original_string(inst) << "'\n" << end();
      continue;
    }
    inst.operation = get(Recipe_ordinal, inst.name);
    // End Instruction Operation Checks
  }
}

// hook to suppress inserting recipe name into errors
string maybe(string recipe_name) {
  // End maybe(recipe_name) Special-cases
  return recipe_name + ": ";
}

void test_missing_arrow() {
  Hide_errors = true;
  transform(
      "def main [\n"
      "  1:number , copy 0\n"  // typo: ',' instead of '<-'
      "]\n"
  );
  CHECK_TRACE_CONTENTS(
      "error: main: instruction '1:number' has no recipe in '1:number copy, 0'\n"
  );
}