summary refs log tree commit diff stats
path: root/compiler/sigmatch.nim
Commit message (Collapse)AuthorAgeFilesLines
* breaking change: arrays of char do not convert to cstring; ptr to array of ↵Andreas Rumpf2017-10-101-6/+7
| | | | char does
* some work to make 'opt' a first class typeAndreas Rumpf2017-09-241-1/+1
|
* first implementation of the 'func' keywordAndreas Rumpf2017-09-231-4/+4
|
* fix #5918Zahary Karadjov2017-08-191-1/+3
|
* Fix #5084Zahary Karadjov2017-06-201-3/+6
|
* Fix #4737Zahary Karadjov2017-06-201-3/+6
|
* Fix #5127Zahary Karadjov2017-06-201-5/+6
|
* fix #1017; fix #3309Zahary Karadjov2017-06-201-0/+6
|
* fix #2730; fix #4880Zahary Karadjov2017-06-201-0/+7
|
* fix #5017; fix #5893Zahary Karadjov2017-06-201-1/+3
|
* fix #5864Zahary Karadjov2017-06-201-0/+2
|
* add a useful helper for debugging typeRel problemsZahary Karadjov2017-06-201-4/+26
|
* introduce a pre-processing pass for the concept bodiesZahary Karadjov2017-06-201-36/+22
| | | | | | | fixes #4982 fixes #3805 close #3414
* fix #5890Zahary Karadjov2017-06-201-1/+2
|
* cleanup of in/out covariance handlingAndreas Rumpf2017-05-171-6/+6
|
* enforce the covariance rules for user-defined generic typesZahary Karadjov2017-05-131-4/+4
|
* covariance for arrays and sequencesZahary Karadjov2017-05-121-12/+40
|
* doh, forgot to add all files in the previous commitZahary Karadjov2017-05-121-12/+58
|
* a simple way to simulate covariance in generic typesZahary Karadjov2017-04-281-1/+6
|
* fix a regrsesion in signature matching of derived ptr typesZahary Karadjov2017-04-181-3/+5
|
* Restore the compilation of linalg by tweaking the complex disambiguation rulesZahary Karadjov2017-04-161-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a potentially breaking change, but the problem was that linalg was relying on a previous bug in the compiler, which was fixed in the concepts branch. With the old disambiguation rules, generic procs like: proc \`==\`[T](lhs, rhs: T) and proc \`==\`(lhs, rhs: Matrix32|Matrix64) .. were considered equal, even though it's obvious that the second one should be preferred. We never noticed this, because there was a bug in sigmatch incorrectly counting one of the params of the second proc as a non-generic match, thus giving it an edge. This commit gives some preference to tyOr and tyAnd during the complex disambiguation, which may affect overload resolution in other cases. I see this only as a temporary solution. With my upcoming work on concept refinement, I plan to provide an experimental implementation of alaternative C++-like rules for determining which proc is more specific. We can then discuss our strategy for dealing with such a breaking change.
* fix regression in tmatrixconceptZahary Karadjov2017-04-161-0/+4
|
* fix a compilation error in linalgZahary Karadjov2017-04-161-25/+23
|
* fix #5689Zahary Karadjov2017-04-151-8/+10
|
* fix #5683Zahary Karadjov2017-04-141-6/+9
|
* lift parameter-less do block to lambdasZahary Karadjov2017-04-101-1/+12
|
* fix the do notation when used with procsZahary Karadjov2017-04-091-0/+3
|
* fix #5643; fix #5644Zahary Karadjov2017-04-081-2/+3
|
* Restore the Nim's 0.14 proper handling of generic aliasesZahary Karadjov2017-04-081-20/+67
| | | | | | | | | | | A more efficient implementation is possible by restoring the old lifting ot tyGenericInvocation to tyGenericInst in liftTypeParam, but this fix will suffice for now. fixes #5087 fixes #5602 fixes #5641 fixes #5570
* attempt to fix #5632 typedesc typeRel regression (#5634)andri lim2017-03-311-1/+1
|
* requested code review changesZahary Karadjov2017-03-291-12/+12
|
* restore compilation and make all concepts tests greenZahary Karadjov2017-03-241-4/+4
|
* Working test cases for the sophisticated matrix library example from the manualZahary Karadjov2017-03-241-19/+27
| | | | | Fixed the dot operator when used within return types (see tgenericdotrettype) Fixed the matching of generic concepts aliases used with the implicit generics style
* further improvements to the error messages produced by conceptsZahary Karadjov2017-03-241-2/+7
|
* proper error reporting for concepts and the introduction of the {.explain.} ↵Zahary Karadjov2017-03-241-13/+45
| | | | pragma
* implement the special treatment of explicit type params in conceptsZahary Karadjov2017-03-241-1/+3
|
* infer static parameters even when more complicated arithmetic is involvedZahary Karadjov2017-03-241-29/+114
|
* support derived values in non-generic user type classesZahary Karadjov2017-03-241-14/+6
|
* support for inferring static[T] concept paramsZahary Karadjov2017-03-241-21/+25
|
* introduce tyInferred for the unbound concept type paramsZahary Karadjov2017-03-241-71/+80
| | | | | | | | | | | | | | | | | | * Why is tyInferred needed? The bindings in TCandidate are capable of inferring types within a single call expression. In concepts, we need to infer types in the same way, but across the whole body of the concept. Previously, once a concept type param was inferred, it was destructively mutated using t.assignType, but this proved to be problematic in the presence of overloads, because the bindings established while a non-matching overload is tested must be reverted/forgotten. tyInferred offers a non-destructive way to keep track of the inference progress. While introducing new types usually requires a lot of code paths in the compiler to updated, currently tyInferred is only a short-lived type within the concept body pass and it's unlikely to introduce breakage elsewhere in the compiler.
* support the full range of type modifiers when declaring concept vars and ↵Zahary Karadjov2017-03-241-10/+21
| | | | testing proc signatures
* support for matching generic types' procs in generic conceptsZahary Karadjov2017-03-241-6/+36
|
* support for accessing types and consts defined in concepts with the dot operatorZahary Karadjov2017-03-241-12/+23
|
* support for accessing the inferred concept type params with the dot operatorZahary Karadjov2017-03-241-3/+14
|
* concept type params inference working in basic examplesZahary Karadjov2017-03-241-0/+38
|
* fixes #5241, fixes #5411 inherit from specialized generic typeRel problem ↵andri lim2017-03-231-10/+24
| | | | (#5573)
* fixes #4756 (#5557)zah2017-03-171-2/+6
|
* fix varargs forwarding for templates; fixes #5455 (#5505)zah2017-03-131-2/+2
| | | | | * fix varargs forwarding for templates; fixes #5455 * document the macros' varargs change in the news for 0.16.2
* Fixes #5167 and related problems (#5475)zah2017-03-121-0/+1
| | | | | | | | | This commit returns to a bit less strict checking of the number of macro arguments, because some old immediate macros rely on a behavior where even the arity of the macro is not being checked. It may be better if such macros are just declared to use varargs[expr], but this remains for another day.
* big compiler refactoring; avoid globals for multi method dispatcher generationAndreas Rumpf2017-02-221-3/+3
|
ut of the SubX VM' href='/akkartik/mu/commit/subx/016functions.cc?h=main&id=292ccba1bbdc8c2ec6cfacefa15f19c8d215b58c'>292ccba1 ^
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

         

                                          
 

                         

                                                              
      
                     
                                                     
                                                                                            



                                    
                                             



                                       

                                   
                                                 
                                  

                                                                                   
                                                                   

                
                                                                                




        

                      

                                                              

                          
                     






                                                                                           
                                             
                                       
                                    

    


                                            
                                                              
                                                   
            
                

                                                                                


        
       
                              

                                                              

                      
                     


                                                                                            
                        
                              



                                                    
                                             
                                       
                                    

    


        

                                                                     
 

                 

                                                              
                                  
      
                     

                                                                    
                        
                              






                                       


                                   

                                                       
              
                                                                                

        
//:: call

:(before "End Initialize Op Names")
put_new(Name, "e8", "call disp32 (call)");

:(code)
void test_call_disp32() {
  Mem.push_back(vma(0xbd000000));  // manually allocate memory
  Reg[ESP].u = 0xbd000064;
  run(
      "== code 0x1\n"
      // op     ModR/M  SIB   displacement  immediate
      "  e8                                 a0 00 00 00 \n"  // call function offset at 0xa0
      // next EIP is 6
  );
  CHECK_TRACE_CONTENTS(
      "run: call imm32 0x000000a0\n"
      "run: decrementing ESP to 0xbd000060\n"
      "run: pushing value 0x00000006\n"
      "run: jumping to 0x000000a6\n"
  );
}

:(before "End Single-Byte Opcodes")
case 0xe8: {  // call disp32 relative to next EIP
  const int32_t offset = next32();
  ++Callstack_depth;
  trace(Callstack_depth+1, "run") << "call imm32 0x" << HEXWORD << offset << end();
//?   cerr << "push: EIP: " << EIP << " => " << Reg[ESP].u << '\n';
  push(EIP);
  EIP += offset;
  trace(Callstack_depth+1, "run") << "jumping to 0x" << HEXWORD << EIP << end();
  break;
}

//:

:(code)
void test_call_r32() {
  Mem.push_back(vma(0xbd000000));  // manually allocate memory
  Reg[ESP].u = 0xbd000064;
  Reg[EBX].u = 0x000000a0;
  run(
      "== code 0x1\n"
      // op     ModR/M  SIB   displacement  immediate
      "  ff     d3                                      \n"  // call function offset at EBX
      // next EIP is 3
  );
  CHECK_TRACE_CONTENTS(
      "run: call to r/m32\n"
      "run: r/m32 is EBX\n"
      "run: decrementing ESP to 0xbd000060\n"
      "run: pushing value 0x00000003\n"
      "run: jumping to 0x000000a0\n"
  );
}

:(before "End Op ff Subops")
case 2: {  // call function pointer at r/m32
  trace(Callstack_depth+1, "run") << "call to r/m32" << end();
  const int32_t* offset = effective_address(modrm);
  push(EIP);
  EIP = *offset;
  trace(Callstack_depth+1, "run") << "jumping to 0x" << HEXWORD << EIP << end();
  ++Callstack_depth;
  break;
}

:(code)
void test_call_mem_at_rm32() {
  Mem.push_back(vma(0xbd000000));  // manually allocate memory
  Reg[ESP].u = 0xbd000064;
  Reg[EBX].u = 0x2000;
  run(
      "== code 0x1\n"
      // op     ModR/M  SIB   displacement  immediate
      "  ff     13                                      \n"  // call function offset at *EBX
      // next EIP is 3
      "== data 0x2000\n"
      "a0 00 00 00\n"  // 0xa0
  );
  CHECK_TRACE_CONTENTS(
      "run: call to r/m32\n"
      "run: effective address is 0x00002000 (EBX)\n"
      "run: decrementing ESP to 0xbd000060\n"
      "run: pushing value 0x00000003\n"
      "run: jumping to 0x000000a0\n"
  );
}

//:: ret

:(before "End Initialize Op Names")
put_new(Name, "c3", "return from most recent unfinished call (ret)");

:(code)
void test_ret() {
  Mem.push_back(vma(0xbd000000));  // manually allocate memory
  Reg[ESP].u = 0xbd000064;
  write_mem_u32(Reg[ESP].u, 0x10);
  run(
      "== code 0x1\n"
      // op     ModR/M  SIB   displacement  immediate
      "  c3                                           \n"  // return
      "== data 0x2000\n"
      "10 00 00 00\n"  // 0x10
  );
  CHECK_TRACE_CONTENTS(
      "run: return\n"
      "run: popping value 0x00000010\n"
      "run: jumping to 0x00000010\n"
  );
}

:(before "End Single-Byte Opcodes")
case 0xc3: {  // return from a call
  trace(Callstack_depth+1, "run") << "return" << end();
  --Callstack_depth;
  EIP = pop();
  trace(Callstack_depth+1, "run") << "jumping to 0x" << HEXWORD << EIP << end();
  break;
}