summary refs log tree commit diff stats
path: root/compiler/vmdef.nim
Commit message (Expand)AuthorAgeFilesLines
* Initial version of the hot-code reloading support for native targets (#10729)zah2019-02-261-0/+1
* FFI at CT (#10150)Timothee Cour2019-02-231-1/+0
* Vm bitops fixes (#10520)Arne Döring2019-02-051-0/+1
* Support system.reset in vm (#10400)Oscar Nihlgård2019-01-211-1/+1
* Add isInstanceOf for generic procs to the macros module (#9730)cooldome2018-11-211-1/+2
* Add int float casts to vmAndrii Riabushenko2018-10-241-0/+4
* Change the order of compilation passes, transformation is made lazy at code g...cooldome2018-10-181-0/+1
* Make the registered passes local to the ModuleGraph (#9259)LemonBoy2018-10-091-1/+1
* Add sym owner to macros (#8253)cooldome2018-09-031-1/+2
* fixes the remaining fixable Nimrod->Nim renamings; closes #2032Araq2018-09-031-1/+1
* change the VM's max instruction count to 3_000_000Andreas Rumpf2018-08-101-1/+1
* fixes #6255, add `system.ashr` arithmetic right shift (#8547)andri lim2018-08-071-1/+2
* fixes #5617, 'copyLineInfo' addition (#8523)andri lim2018-08-051-1/+1
* fixes #7827, bindSym enhancement (#8499)andri lim2018-08-021-2/+3
* Improve vm support for ref typesOscar Nihlgård2018-06-261-1/+0
* completed VM support for incremental compilationsAndreas Rumpf2018-06-041-7/+1
* WIP: an API for VM replay global state supportAndreas Rumpf2018-06-031-2/+12
* remove more global variables in the Nim compilerAndreas Rumpf2018-05-271-1/+1
* more modules compile againAndreas Rumpf2018-05-121-0/+1
* transf and vmgen compile againAndreas Rumpf2018-05-121-4/+4
* compiler refactoring, pass config around explicitlyAndreas Rumpf2018-05-051-3/+5
* Get symbol kind (#7491)Arne Döring2018-04-111-1/+1
* raise the max instruction count for the VM to one billionAraq2018-03-181-1/+1
* Fix operations on string as openarray in VM. (#6257)Parashurama2017-09-151-0/+3
* Vm fix zero extend proc ze/ze64 && toU32/toU16/toU8 (#5988)Parashurama2017-08-031-1/+2
* Lineinfo change (#6084)Arne Döring2017-07-171-1/+1
* added system.gorgeEx that includes the exitCode; refs #4874; fixes #1994Araq2017-01-071-0/+1
* big refactoring: step 1Araq2016-10-311-3/+5
* stdlib and compiler don't use .immediate anymoreAndreas Rumpf2016-07-291-6/+6
* implemented macros.getImplAraq2015-08-211-0/+1
* macros: Introduce sameType(a, b) for node typesAdam Strzelecki2015-07-031-2/+3
* fixes #2297, fixes #2946Araq2015-06-181-1/+1
* marshalling can be done at compile-timeAraq2015-04-251-3/+6
* VM: minor fixes to make lexim workAraq2015-04-201-21/+21
* fixes #1989Araq2015-02-011-0/+1
* fixes #1781Araq2014-12-281-1/+2
* fixes #1473Araq2014-11-121-1/+4
* VM supports math and a few os procsAraq2014-08-301-2/+11
* Nimrod renamed to NimAraq2014-08-281-1/+1
* Fixes incorrect macro stack traces.Dominik Picheta2014-08-111-1/+3
* parseBiggestFloat is now builtinAraq2014-07-161-1/+1
* implemented builtin noncopying sliceAraq2014-05-021-1/+1
* added #903 to the test suiteAraq2014-03-261-0/+1
* VM: endless loop preventionAraq2014-03-241-1/+6
* fixed tuples in a static context; preparations for correct compile time evalu...Araq2014-03-221-0/+1
* fixes #937Araq2014-03-051-0/+1
* tstmtexprs.nim works againAraq2014-02-271-1/+1
* new VM is getting stableAraq2014-02-241-2/+1
* vm2: new representation of registersAraq2014-02-211-11/+9
* tstringinterp almost workingAraq2014-02-011-0/+2
't ignore /space: while checking types' href='/akkartik/mu/commit/047check_type_by_name.cc?h=hlt&id=a70ce311134a98add10a2f7d4fe4919c3d64439b'>a70ce311 ^
c4e143d6 ^
a70ce311 ^
ed09f738 ^
a70ce311 ^
9dcbec39 ^
cf363343 ^

af023b32 ^
a70ce311 ^
9dcbec39 ^
cf363343 ^

a70ce311 ^
9dcbec39 ^
cf363343 ^


78c78c06 ^
112613fe ^
efb7c8d6 ^
1ead3562 ^
192d59d3 ^

112613fe ^
a9a2f7db ^

112613fe ^
efb7c8d6 ^
1ead3562 ^
192d59d3 ^
112613fe ^

a9a2f7db ^

112613fe ^
efb7c8d6 ^
1ead3562 ^
192d59d3 ^
112613fe ^

a9a2f7db ^
112613fe ^
c91caafd ^
ada5eb55 ^







5f98a10c ^

1ead3562 ^
c91caafd ^
192d59d3 ^
c91caafd ^
9dcbec39 ^
d082b176 ^
ada5eb55 ^






5f98a10c ^

1ead3562 ^
760f683f ^
d082b176 ^

760f683f ^
cf363343 ^


1ead3562 ^
a0331a9b ^
cf363343 ^
9dcbec39 ^
a70ce311 ^


1ead3562 ^
a70ce311 ^
1ead3562 ^
a70ce311 ^
897ae8c1 ^
d52406cc ^
192d59d3 ^
a70ce311 ^


07c594eb ^







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
154
155
156
157
158
159

                                                                              




                                                                           
 

                                                               
          
                 
                  
 
                                          
 
                                                         
                                                               

       
                                                         
                                                                                             

                                  
                                                  
                                           
                                                           
                                                          
                                                         
     
                                                           
                                                        
                                                       



     
                                                           
                     



                                    

                                               
                                                                                   

 
                                                                              
                            

                                                                                                     




                                                                                                        
                                     
                                                                                     
                    
   
                                                           
                                                                                            

           
                       
                         
                                                                                                                     

             
                                
                                                                                                                                                                                                                                                                   


             
 
 
                                            
          

                   
 

                                     
 
                                                       
          
                 

             

                             
 
                                                                      
          
                 

               
                    
                             
 







                                                 

                                                             
          
             
                 
 
                                                   
 






                                                       

                                      
          
                                    

               
                                                                           


                                         
          
                            
 
                                                                                                                                                                                      


                                                                           
                  
 
          
             
                                                          
                       
                          


                      







                                            
//: 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;
def main [
  x:num <- copy 1
  x:bool <- copy 1
]
+error: main: 'x' used with multiple types

:(after "Transform.push_back(expand_type_abbreviations)")
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();
  recipe& caller = get(Recipe, r);
  set<reagent> known;
  for (int i = 0;  i < SIZE(caller.steps);  ++i) {
    instruction& inst = caller.steps.at(i);
    for (int in = 0;  in < SIZE(inst.ingredients);  ++in) {
      deduce_missing_type(known, inst.ingredients.at(in));
      check_type(known, inst.ingredients.at(in), caller);
    }
    for (int out = 0;  out < SIZE(inst.products);  ++out) {
      deduce_missing_type(known, inst.products.at(out));
      check_type(known, inst.products.at(out), caller);
    }
  }
}

void deduce_missing_type(set<reagent>& known, reagent& x) {
  if (x.type) return;
  if (is_jump_target(x.name)) {
    x.type = new type_tree("label");
    return;
  }
  if (known.find(x) == known.end()) return;
  x.type = new type_tree(*known.find(x)->type);
  trace(9992, "transform") << x.name << " <= " << names_to_string(x.type) << end();
}

void check_type(set<reagent>& known, const reagent& x, const recipe& caller) {
  if (is_literal(x)) return;
  if (is_integer(x.name)) return;  // if you use raw locations you're probably doing something unsafe
  if (!x.type) return;  // might get filled in by other logic later
  if (is_jump_target(x.name)) {
    if (!x.type->atom || x.type->name != "label")
      raise << maybe(caller.name) << "non-label '" << x.name << "' must begin with a letter\n" << end();
    return;
  }
  if (known.find(x) == known.end()) {
    trace(9992, "transform") << x.name << " => " << names_to_string(x.type) << end();
    known.insert(x);
  }
  if (!types_strictly_match(known.find(x)->type, x.type)) {
    raise << maybe(caller.name) << "'" << x.name << "' used with multiple types\n" << end();
    return;
  }
  if (is_mu_array(x)) {
    if (!x.type->right) {
      raise << maybe(caller.name) << "'" << x.name << ": can't be just an array. What is it an array of?\n" << end();
      return;
    }
    if (!x.type->right->right) {
      raise << caller.name << " can't determine the size of array variable '" << x.name << "'. Either allocate it separately and make the type of '" << x.name << "' an address, or specify the length of the array in the type of '" << x.name << "'.\n" << end();
      return;
    }
  }
}

:(scenario transform_fills_in_missing_types)
def main [
  x:num <- copy 1
  y:num <- add x, 1
]
# x is in location 1, y in location 2
+mem: storing 2 in location 2

:(scenario transform_fills_in_missing_types_in_product)
def main [
  x:num <- copy 1
  x <- copy 2
]
# x is in location 1
+mem: storing 2 in location 1

:(scenario transform_fills_in_missing_types_in_product_and_ingredient)
def main [
  x:num <- copy 1
  x <- add x, 1
]
# x is in location 1
+mem: storing 2 in location 1

:(scenario transform_fills_in_missing_label_type)
def main [
  jump +target
  1:num <- copy 0
  +target
]
-mem: storing 0 in location 1

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

:(scenario transform_fails_on_wrong_type_for_label)
% Hide_errors = true;
def main [
  +foo:num <- copy 34
]
+error: main: non-label '+foo' must begin with a letter

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

:(scenario array_type_without_size_fails)
% Hide_errors = true;
def main [
  x:@:num <- merge 2, 12, 13
]
+error: main can't determine the size of array variable 'x'. Either allocate it separately and make the type of 'x' an address, or specify the length of the array in the type of 'x'.

:(scenarios transform)
:(scenario transform_checks_types_of_identical_reagents_in_multiple_spaces)
def foo [  # dummy
]
def main [
  local-scope
  0:space/names:foo <- copy 0  # specify surrounding space
  x:bool <- copy 1/true
  x:num/space:1 <- copy 34
  x/space:1 <- copy 35
]
$error: 0

:(scenario transform_handles_empty_reagents)
% Hide_errors = true;
def main [
  add *
]
+error: illegal name '*'
# no crash