summary refs log tree commit diff stats
path: root/HACKING
Commit message (Expand)AuthorAgeFilesLines
* Tuned versioning scheme to be more intuitive, back to 1.1.2hut2010-08-281-1/+1
* Changed version number to 1.2 (testing) to adhere with versioning schemehut2010-08-281-1/+1
* Changed default config dir to $XDG_CONFIG_HOME/rangerhut2010-08-281-2/+2
* changed version numbering schemehut2010-06-181-4/+3
* HACKING: updatedhut2010-06-091-0/+16
* HACKING: updatehut2010-05-101-8/+3
* HACKING: updatedhut2010-03-121-7/+8
* added guidelines on code modificationhut2010-02-151-0/+84
c'>5f98a10c ^
78c78c06 ^
65bd3727 ^
04209f72 ^
78c78c06 ^

04209f72 ^
795f5244 ^
57d01f21 ^
6d79cc13 ^
b0276a2c ^
795f5244 ^

78c78c06 ^
b0276a2c ^

78c78c06 ^

b0276a2c ^

78c78c06 ^



91abd257 ^



b954ac38 ^
91abd257 ^



b0276a2c ^
78c78c06 ^
78c78c06 ^

c6034af3 ^
f3760b0f ^
b954ac38 ^
6d79cc13 ^
ed09f738 ^
f3760b0f ^
b0276a2c ^

691b529e ^
795f5244 ^
78c78c06 ^
112613fe ^
efb7c8d6 ^
112613fe ^




efb7c8d6 ^
112613fe ^




efb7c8d6 ^
112613fe ^




c91caafd ^
5f98a10c ^

c91caafd ^



5f98a10c ^
d082b176 ^
5f98a10c ^

d082b176 ^



5967e82f ^
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

                                                                              




                                                                           
 

                                                               



                     
                                        
 
                                                 
                                                               

       
                                                         
                                                                                             
                                                                            
                               
                                      

                                                                  
                                                                   

                                                                    

                                                                   

                                                                  



     



                                                                                                           
                                                                                



                                                                  
                                                                                                                                
                            

                                                                    
                                                                    
                                    
                                                                                  
                          
   
                                         

                                                  
                                                  
                                                                                                  
 
 
                                            




                      
                                                       




                    
                                                                      




                             
 

                                                             



                    
                                                 
 

                                      



                                          
                                                                                 
//: Some simple sanity checks for types, and also attempts to guess them where
//: they aren't provided.
//:
//: You still have to provide the full type the first time you mention a
//: variable in a recipe. You have to explicitly name :offset and :variant
//: every single time. You can't use the same name with multiple types in a
//: single recipe.

:(scenario transform_fails_on_reusing_name_with_different_type)
% Hide_errors = true;
recipe main [
  x:number <- copy 1
  x:boolean <- copy 1
]
+error: main: x used with multiple types

:(after "Begin Instruction Modifying Transforms")
Transform.push_back(check_or_set_types_by_name);  // idempotent

:(code)
void check_or_set_types_by_name(const recipe_ordinal r) {
  trace(9991, "transform") << "--- deduce types for recipe " << get(Recipe, r).name << end();
//?   cerr << "--- deduce types for recipe " << get(Recipe, r).name << '\n';
  map<string, type_tree*> type;
  map<string, string_tree*> type_name;
  for (long long int i = 0; i < SIZE(get(Recipe, r).steps); ++i) {
    instruction& inst = get(Recipe, r).steps.at(i);
    for (long long int in = 0; in < SIZE(inst.ingredients); ++in) {
      deduce_missing_type(type, type_name, inst.ingredients.at(in));
      check_type(type, type_name, inst.ingredients.at(in), r);
    }
    for (long long int out = 0; out < SIZE(inst.products); ++out) {
      deduce_missing_type(type, type_name, inst.products.at(out));
      check_type(type, type_name, inst.products.at(out), r);
    }
  }
}

void deduce_missing_type(map<string, type_tree*>& type, map<string, string_tree*>& type_name, reagent& x) {
  if (x.type) return;
  if (!contains_key(type, x.name)) return;
  x.type = new type_tree(*type[x.name]);
  trace(9992, "transform") << x.name << " <= " << debug_string(x.type) << end();
  assert(!x.properties.at(0).second);
  x.properties.at(0).second = new string_tree(*type_name[x.name]);
}

void check_type(map<string, type_tree*>& type, map<string, string_tree*>& type_name, const reagent& x, const recipe_ordinal r) {
  if (is_literal(x)) return;
  // if you use raw locations you're probably doing something unsafe
  if (is_integer(x.name)) return;
  if (!x.type) return;  // will throw a more precise error elsewhere
  if (!contains_key(type, x.name)) {
    trace(9992, "transform") << x.name << " => " << debug_string(x.type) << end();
    type[x.name] = x.type;
  }
  if (!contains_key(type_name, x.name)) {
    type_name[x.name] = x.properties.at(0).second;
  }
  if (!types_strictly_match(type[x.name], x.type))
    raise_error << maybe(get(Recipe, r).name) << x.name << " used with multiple types\n" << end();
}

:(scenario transform_fills_in_missing_types)
recipe main [
  x:number <- copy 1
  y:number <- add x, 1
]

:(scenario transform_fills_in_missing_types_in_product)
recipe main [
  x:number <- copy 1
  x <- copy 2
]

:(scenario transform_fills_in_missing_types_in_product_and_ingredient)
recipe main [
  x:number <- copy 1
  x <- add x, 1
]
+mem: storing 2 in location 1

:(scenario transform_fails_on_missing_types_in_first_mention)
% Hide_errors = true;
recipe main [
  x <- copy 1
  x:number <- copy 2
]
+error: main: missing type for x in 'x <- copy 1'

:(scenario typo_in_address_type_fails)
% Hide_errors = true;
recipe main [
  y:address:charcter <- new character:type
  *y <- copy 67
]
+error: main: unknown type charcter in 'y:address:charcter <- new character:type'