summary refs log tree commit diff stats
path: root/compiler/semfold.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes #1638Araq2014-12-171-3/+5
|
* implemented procCall builtinAraq2014-11-281-4/+0
|
* fixes #939Araq2014-11-201-4/+16
|
* fixes #916Araq2014-11-201-1/+1
|
* bugfix: 'T = ref T' is an illegal recursive typeAraq2014-10-021-0/+1
|
* Nimrod renamed to NimAraq2014-08-281-1/+1
|
* renamefestAraq2014-08-231-2/+2
|
* fixes constant array indexing bugAraq2014-06-301-6/+7
|
* attempt to fix the bootstrappingAraq2014-05-061-3/+1
|
* minor tweaks; updated todo.txtAraq2014-04-251-0/+1
|
* Fix spawn ICE on invalid argument.EXetoC2014-04-201-1/+1
|
* fixes yet another option typeAraq2014-04-031-6/+12
|
* vm2: new representation of registersAraq2014-02-211-1/+1
|
* implements #766;Zahary Karadjov2014-01-241-2/+1
| | | | | | expressions such as Type.field are now recognised by the compiler. This also fixes a bug, preventing the user-defined to check for the presence of regular fields in addition to procs
* 'nil' as a statement is deprecated, use an empty 'discard' insteadAraq2014-01-191-2/+2
|
* Merge branch 'upstream' into develZahary Karadjov2013-12-291-4/+6
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: compiler/ccgutils.nim compiler/msgs.nim compiler/sem.nim compiler/semexprs.nim compiler/seminst.nim compiler/semmagic.nim compiler/semstmts.nim compiler/semtypes.nim compiler/semtypinst.nim compiler/sigmatch.nim compiler/types.nim compiler/vmgen.nim lib/core/macros.nim lib/system.nim tests/reject/tenummix.nim web/news.txt
| * make more tests greenZahary Karadjov2013-12-291-2/+3
| |
| * static params: expr[T] is now static[T]Zahary Karadjov2013-12-191-1/+1
| | | | | | | | | | | | | | This introduces tyStatic and successfully bootstraps and handles few simple test cases. Static params within macros are no longer treated as PNimrodNodes - they are now equivalent to constants of the designated type.
* | case consistency part 4Araq2013-12-271-29/+29
| |
* | more tests are greenAraq2013-12-081-8/+38
|/
* Merge branch 'master' of github.com:Araq/NimrodAraq2013-08-301-4/+12
|\
| * Experimental support for delayed instantiation of genericsZahary Karadjov2013-08-231-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This postpones the semantic pass over the generic's body until the generic is instantiated. There are several pros and cons for this method and the capabilities that it enables may still be possible in the old framework if we teach it a few new trick. Such an attempt will follow in the next commits. pros: 1) It allows macros to be expanded during generic instantiation that will provide the body of the generic. See ``tmacrogenerics``. 2) The instantiation code is dramatically simplified. Dealing with unknown types in the generic's body pre-pass requires a lot of hacky code and error silencing in semTypeNode. See ``tgenericshardcases``. cons: 1) There is a performance penalty of roughly 5% when bootstrapping. 2) Certain errors that used to be detected in the previous pre-pass won't be detected with the new scheme until instantiation.
* | float64 is now an alias to 'float'; fixes #545Araq2013-08-301-2/+5
|/
* new VM: implemented constructors and jump optimizerAraq2013-08-071-1/+1
|
* bugfix: gensymAraq2013-07-251-1/+1
|
* fixes #544Araq2013-07-241-0/+4
|
* fixes #432, fixes #427Araq2013-05-191-1/+8
|
* first steps to the expr/stmt unificationAraq2013-04-301-4/+3
|
* fixes #287; bugfix: subrange checking is performed againAraq2013-04-121-6/+13
|
* Removes executable bit for text files.Grzegorz Adam Hankiewicz2013-03-161-0/+0
|
* bugfix: 'indexOf' for tuple fields worksAraq2013-03-111-2/+9
|
* first steps to implement object construction expressionsAraq2013-03-071-4/+11
|
* make some tests greenAraq2013-03-031-4/+6
|
* the `is` operator now works with type classes and type variablesZahary Karadjov2012-10-031-11/+0
| | | | | bugfixes: the DLL tests were failing on Mac OS X, due to an incorrect DynlibFormat
* term rewriting macros fully implemented; still buggyAraq2012-09-031-2/+10
|
* next steps for tyVarargs/tyOpenArray splitAraq2012-08-141-2/+2
|
* got rid of some mAddU64 etc. magicsAraq2012-07-201-10/+10
|
* equality and hashing for closuresAraq2012-07-171-3/+9
|
* improved unsigned supportAraq2012-07-141-3/+5
|
* more fixes for new integer promotion rules; fixes #152; fixes #157; fixes ↵Araq2012-07-091-1/+4
| | | | #156; fixes #155
* 'addSon' for types deprecated for 'int literal type' analysisAraq2012-07-091-2/+2
|
* changed integer promotion rules; breaks bootstrapping and lots of codeAraq2012-07-081-5/+156
|
* added devel/logging; weakrefs test; next steps for proper unsigned supportAraq2012-07-051-2/+3
|
* changed integer promotion rules; added math.fmodAraq2012-06-281-1/+1
|
* better support for unsigned integers.Zahary Karadjov2012-06-111-6/+6
|
* Added system.staticExec proc for executing external command at compile-timeZahary Karadjov2012-06-021-1/+1
|
* the foundations of a type traits module; better error messages for expr, ↵Zahary Karadjov2012-04-061-1/+1
| | | | typedesc and typeclasses params
* bugfix: semfold supports merging of '&'Araq2012-02-191-0/+10
|
* year 2012 for most copyright headersAraq2012-01-021-1/+1
|
* alias analysis as required for the code gen and the HLOAraq2011-12-081-1/+1
|
='author Kartik K. Agaram <vc@akkartik.com> 2016-01-12 12:53:04 -0800 committer Kartik K. Agaram <vc@akkartik.com> 2016-01-12 12:53:04 -0800 2557 - type-check most ingredients ahead of time' href='/akkartik/mu/commit/035call_ingredient.cc?h=main&id=7ac8feeff10abfd76f712f8f32406dd30ba1c73e'>7ac8feef ^
75aa3a98 ^
0487a30e ^
4be9a93b ^
69f04c3f ^

717ab659 ^
5f98a10c ^

1ead3562 ^
3e849f11 ^

1ead3562 ^
3e849f11 ^

5f98a10c ^
3e849f11 ^
88be3dbc ^
1ead3562 ^
bc643692 ^
717ab659 ^
1ead3562 ^
5497090a ^
717ab659 ^

5497090a ^
717ab659 ^








795f5244 ^
166e3c0d ^



717ab659 ^

67573caf ^
717ab659 ^


88be3dbc ^
1ead3562 ^
bc643692 ^
717ab659 ^
1ead3562 ^
bc643692 ^
5497090a ^
717ab659 ^






795f5244 ^
166e3c0d ^
717ab659 ^
166e3c0d ^
1b76245c ^
e4630643 ^

5f98a10c ^
1b76245c ^
e4630643 ^

166e3c0d ^



67573caf ^

0487a30e ^
67573caf ^
ac0e9db5 ^
827898fc ^
67573caf ^
717ab659 ^

ac0e9db5 ^
0487a30e ^

827898fc ^
717ab659 ^



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
160
161
162
163
164
165
166
167
168
169
170
171
                                                                         
                                       
 
                           
          
     
 
       
                              
                               
 
                              
 
                                   
          

   
       
                                 


                              
                           
                                         
                            
                                         

                                
 
                                 
                                                       
                                                               

                                                          
                                                   
 
 

                                             
                                        
                                                        
                                       
                       
                                  
                                                                                                                                       

          



                                                
                                          
                                                                                          

                                                           



                                                                                                    
                                                                                                
     

                                                                                                          
                                                                                                                        
                                                
     
                       
                                                                                       
                                                                           
                                
                                                
   
        
                                                 
                                                                                                                                                    
                                                      
                       

                                                                       
                                            
                                  
                                
   

        
 

                                           
          

   
       

                              
                                             
 
                              
          
     
 
       
                                                    

                                                                  
                                                                       








                                             
                                                              



                                       

                                                
                                                


        
                      
          
        
 
       
                                                              
                                                                                    






                                             
                                              
                                       
                  
                                    
                                                                                                                                         

          
                                                                                     
                                                                                                                                                            

          



                                                

                                                                                                    
                       
                                                                                       
                                                                           
                                
                                                

        
                                                   

                                                                                                 
                                  



        
//: Calls can take ingredients just like primitives. To access a recipe's
//: ingredients, use 'next-ingredient'.

:(scenario next_ingredient)
def main [
  f 2
]
def f [
  12:number <- next-ingredient
  13:number <- add 1, 12:number
]
+mem: storing 3 in location 13

:(scenario next_ingredient_missing)
def main [
  f
]
def f [
  _, 12:number <- next-ingredient
]
+mem: storing 0 in location 12

:(before "End call Fields")
vector<vector<double> > ingredient_atoms;
vector<reagent> ingredients;
long long int next_ingredient_to_process;
:(before "End call Constructor")
next_ingredient_to_process = 0;

:(before "End Call Housekeeping")
for (long long int i = 0; i < SIZE(ingredients); ++i) {
  current_call().ingredient_atoms.push_back(ingredients.at(i));
  reagent ingredient = call_instruction.ingredients.at(i);
  canonize_type(ingredient);
  current_call().ingredients.push_back(ingredient);
}

:(before "End Primitive Recipe Declarations")
NEXT_INGREDIENT,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "next-ingredient", NEXT_INGREDIENT);
:(before "End Primitive Recipe Checks")
case NEXT_INGREDIENT: {
  if (!inst.ingredients.empty()) {
    raise << maybe(get(Recipe, r).name) << "'next-ingredient' didn't expect any ingredients in '" << to_string(inst) << "'\n" << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case NEXT_INGREDIENT: {
  assert(!Current_routine->calls.empty());
  if (current_call().next_ingredient_to_process < SIZE(current_call().ingredient_atoms)) {
    reagent product = current_instruction().products.at(0);
    canonize_type(product);
    if (current_recipe_name() == "main") {
      // no ingredient types since the call might be implicit; assume ingredients are always strings
      // todo: how to test this?
      if (!is_mu_string(product))
        raise << "main: wrong type for ingredient " << product.original_string << '\n' << end();
    }
    else if (!types_coercible(product,
                              current_call().ingredients.at(current_call().next_ingredient_to_process))) {
      raise << maybe(current_recipe_name()) << "wrong type for ingredient " << product.original_string << '\n' << end();
      // End next-ingredient Type Mismatch Error
    }
    products.push_back(
        current_call().ingredient_atoms.at(current_call().next_ingredient_to_process));
    assert(SIZE(products) == 1);  products.resize(2);  // push a new vector
    products.at(1).push_back(1);
    ++current_call().next_ingredient_to_process;
  }
  else {
    if (SIZE(current_instruction().products) < 2)
      raise << maybe(current_recipe_name()) << "no ingredient to save in " << current_instruction().products.at(0).original_string << '\n' << end();
    if (current_instruction().products.empty()) break;
    products.resize(2);
    // pad the first product with sufficient zeros to match its type
    long long int size = size_of(current_instruction().products.at(0));
    for (long long int i = 0; i < size; ++i)
      products.at(0).push_back(0);
    products.at(1).push_back(0);
  }
  break;
}

:(scenario next_ingredient_fail_on_missing)
% Hide_errors = true;
def main [
  f
]
def f [
  11:number <- next-ingredient
]
+error: f: no ingredient to save in 11:number

:(scenario rewind_ingredients)
def main [
  f 2
]
def f [
  12:number <- next-ingredient  # consume ingredient
  _, 1:boolean <- next-ingredient  # will not find any ingredients
  rewind-ingredients
  13:number, 2:boolean <- next-ingredient  # will find ingredient again
]
+mem: storing 2 in location 12
+mem: storing 0 in location 1
+mem: storing 2 in location 13
+mem: storing 1 in location 2

:(before "End Primitive Recipe Declarations")
REWIND_INGREDIENTS,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "rewind-ingredients", REWIND_INGREDIENTS);
:(before "End Primitive Recipe Checks")
case REWIND_INGREDIENTS: {
  break;
}
:(before "End Primitive Recipe Implementations")
case REWIND_INGREDIENTS: {
  current_call().next_ingredient_to_process = 0;
  break;
}

:(scenario ingredient)
def main [
  f 1, 2
]
def f [
  12:number <- ingredient 1  # consume second ingredient first
  13:number, 1:boolean <- next-ingredient  # next-ingredient tries to scan past that
]
+mem: storing 2 in location 12
+mem: storing 0 in location 1

:(before "End Primitive Recipe Declarations")
INGREDIENT,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "ingredient", INGREDIENT);
:(before "End Primitive Recipe Checks")
case INGREDIENT: {
  if (SIZE(inst.ingredients) != 1) {
    raise << maybe(get(Recipe, r).name) << "'ingredient' expects exactly one ingredient, but got '" << to_string(inst) << "'\n" << end();
    break;
  }
  if (!is_literal(inst.ingredients.at(0)) && !is_mu_number(inst.ingredients.at(0))) {
    raise << maybe(get(Recipe, r).name) << "'ingredient' expects a literal ingredient, but got " << inst.ingredients.at(0).original_string << '\n' << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case INGREDIENT: {
  if (static_cast<long long int>(ingredients.at(0).at(0)) < SIZE(current_call().ingredient_atoms)) {
    current_call().next_ingredient_to_process = ingredients.at(0).at(0);
    products.push_back(
        current_call().ingredient_atoms.at(current_call().next_ingredient_to_process));
    assert(SIZE(products) == 1);  products.resize(2);  // push a new vector
    products.at(1).push_back(1);
    ++current_call().next_ingredient_to_process;
  }
  else {
    if (SIZE(current_instruction().products) > 1) {
      products.resize(2);
      products.at(0).push_back(0);  // todo: will fail noisily if we try to read a compound value
      products.at(1).push_back(0);
    }
  }
  break;
}