summary refs log tree commit diff stats
path: root/compiler/ast.nim
Commit message (Expand)AuthorAgeFilesLines
...
| * better support for unsigned integers.Zahary Karadjov2012-06-111-15/+25
| * destructor pragmaZahary Karadjov2012-06-071-0/+1
| * destructors for case valuesZahary Karadjov2012-06-071-0/+1
* | first implementation of new lambda liftingAraq2012-06-151-0/+3
|/
* Merge branch 'master' of github.com:Araq/Nimrod into upstreamZahary Karadjov2012-06-021-1/+2
|\
| * added system.||; lacks runtime supportAraq2012-05-231-1/+2
* | Added system.staticExec proc for executing external command at compile-timeZahary Karadjov2012-06-021-1/+14
* | codegen for user-defined destructorsZahary Karadjov2012-05-251-0/+3
|/
* experimental support for preserving local variable names in the generated codeZahary Karadjov2012-04-131-10/+18
* the foundations of a type traits module; better error messages for expr, type...Zahary Karadjov2012-04-061-1/+7
* when expressions, proper rendering for nkDo and nkLambda and parser support f...Zahary Karadjov2012-04-051-1/+6
* Merge branch 'master' of github.com:Araq/Nimrod into upstreamZahary Karadjov2012-03-311-3/+2
|\
| * some bugfixes for symbolfilesAraq2012-03-231-3/+2
* | typedesc and expr paramsZahary Karadjov2012-03-311-0/+9
* | generic types can be used like type classes. distinct can be applied to type ...Zahary Karadjov2012-03-251-0/+2
* | tyOrdinal now means "integral types". tyTypeClass created to take care of typ...Zahary Karadjov2012-03-221-1/+2
|/
* missed file from the previous commitZahary Karadjov2012-03-191-0/+7
* merged branch overloading-for-macrosZahary Karadjov2012-03-191-1/+5
|\
| * the test suite is mostly green againZahary Karadjov2012-03-161-18/+0
| * bootstraps fine with overloadable templatesZahary Karadjov2012-03-141-1/+23
* | implemented 'static'; macros do not work anymoreAraq2012-03-151-1/+3
* | first steps for cleaner static/const distinctionAraq2012-03-131-0/+30
|/
* `do' keyword in the grammar for lambda blocksZahary Karadjov2012-02-101-0/+3
* further steps to closure supportAraq2012-02-061-2/+8
* closure implementation: first stepsAraq2012-02-041-1/+11
* pragma blocks; fixed line information issue with user defined assertionsAraq2012-01-171-1/+3
* niminst: bugfixes; documentation changesAraq2012-01-151-1/+1
* bugfix: invalid indentation for 'else' is detected; optional indentation for ...Araq2012-01-131-1/+1
* bugfix: tests/reject/tnoinst.nim is now rejected properlyAraq2012-01-131-0/+6
* bugfix: removed newSons legacyAraq2012-01-071-7/+10
* implemented incompleteStruct pragma; embedded debugger works with posix moduleAraq2012-01-051-0/+1
* year 2012 for most copyright headersAraq2012-01-021-1/+1
* bugfix: the code gen can now handle alias TLock = TSysLock; this fixes thread...Araq2011-12-231-0/+16
* code gen can generate code to keep alive stack rootsAraq2011-12-221-0/+1
* alias analysis as required for the code gen and the HLOAraq2011-12-081-31/+2
* 'assert' is now implemented without compiler magicAraq2011-12-041-1/+2
* implemented 'let' statementAraq2011-11-291-3/+4
* new pragma: 'noinit'Araq2011-11-251-1/+2
* bugfix: 'when' sections in generic objects now work, so TThread[void] compilesAraq2011-11-201-1/+1
* macros and templates can be expanded anywhere where a type is expected.Zahary Karadjov2011-11-181-0/+6
* cgen: no type canon for integral types; osproc use posix_spawn instead of for...Araq2011-11-181-1/+2
* new kind of AST printer that prints indented treesZahary Karadjov2011-11-041-1/+1
* lazy loading of body ast implementedAraq2011-10-301-1/+6
* constant folding for cnst[i] and cnst.attrAraq2011-10-291-1/+3
* compilation cache: various bugfixes; works for the compiler itselfAraq2011-10-271-3/+6
* compilation cache: mostly working; generics not yetAraq2011-10-251-1/+1
* compilation cache: multi methods now workAraq2011-10-241-14/+15
* rod files: next trivial examples workingAraq2011-10-221-0/+4
* much more efficient rod file generationAraq2011-10-181-33/+5
* 'bind' as a declarative statementAraq2011-10-101-0/+1
ons.cc?h=hlt&id=292ccba1bbdc8c2ec6cfacefa15f19c8d215b58c'>292ccba1 ^
0f851e48 ^

aa2e2155 ^
4a943d4e ^

6f6d458f ^

36c745f8 ^
4a943d4e ^
83c67014 ^
4a943d4e ^

83c67014 ^
4a943d4e ^







292ccba1 ^


c442a5ad ^

292ccba1 ^
c442a5ad ^
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 0x000000a0
      // 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 0x000000a3\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_r32() {
  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"  // 0x000000a0
  );
  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 0x000000a3\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"  // 0x00000010
  );
  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;
}