Mercurial > projects > ldc
annotate gen/statements.cpp @ 108:288fe1029e1f trunk
[svn r112] Fixed 'case 1,2,3:' style case statements.
Fixed a bunch of bugs with return/break/continue in loops.
Fixed support for the DMDFE hidden implicit return value variable. This can be needed for some foreach statements where the loop body is converted to a nested delegate, but also possibly returns from the function.
Added std.math to phobos.
Added AA runtime support code, done ground work for implementing AAs.
Several other bugfixes.
author | lindquist |
---|---|
date | Tue, 20 Nov 2007 05:29:20 +0100 |
parents | 5071469303d4 |
children | 5ab8e92611f9 |
rev | line source |
---|---|
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1 // Statements: D -> LLVM glue |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
2 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
3 #include <stdio.h> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
4 #include <math.h> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
5 #include <sstream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
6 #include <fstream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
7 #include <iostream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
8 |
40 | 9 #include "gen/llvm.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
10 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
11 #include "total.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
12 #include "init.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
13 #include "mtype.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
14 #include "hdrgen.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
15 #include "port.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
16 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
17 #include "gen/irstate.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
18 #include "gen/logger.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
19 #include "gen/tollvm.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
20 #include "gen/runtime.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
21 #include "gen/arrays.h" |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
22 #include "gen/todebug.h" |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
23 #include "gen/dvalue.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
24 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
25 ////////////////////////////////////////////////////////////////////////////// |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
26 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
27 void CompoundStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
28 { |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
96
diff
changeset
|
29 Logger::println("CompoundStatement::toIR()"); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
30 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
31 |
34 | 32 for (int i=0; i<statements->dim; i++) |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
33 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
34 Statement* s = (Statement*)statements->data[i]; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
35 if (s) |
34 | 36 s->toIR(p); |
37 else { | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
38 Logger::println("??? null statement found in CompoundStatement"); |
34 | 39 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
40 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
41 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
42 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
43 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
44 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
45 void ReturnStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
46 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
47 static int rsi = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
48 Logger::println("ReturnStatement::toIR(%d): %s", rsi++, toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
49 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
50 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
51 if (exp) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
52 { |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
51
diff
changeset
|
53 Logger::println("return type is: %s", exp->type->toChars()); |
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
51
diff
changeset
|
54 |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
55 Type* exptype = DtoDType(exp->type); |
40 | 56 TY expty = exptype->ty; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
57 if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) { |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
58 assert(DtoIsPassedByRef(exptype)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
59 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
60 TypeFunction* f = p->topfunctype(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
61 assert(f->llvmRetInPtr && f->llvmRetArg); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
62 |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
63 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); |
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
64 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
65 DValue* rvar = new DVarValue(f->next, f->llvmRetArg, true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
66 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
67 p->exps.push_back(IRExp(NULL,exp,rvar)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
68 DValue* e = exp->toElem(p); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
51
diff
changeset
|
69 p->exps.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
70 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
71 if (!e->inPlace()) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
72 DtoAssign(rvar, e); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
73 |
100 | 74 IRFunction::FinallyVec& fin = p->func()->finallys; |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
75 if (fin.empty()) { |
100 | 76 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
40 | 77 new llvm::ReturnInst(p->scopebb()); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
78 } |
40 | 79 else { |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
80 new llvm::BranchInst(fin.back().retbb, p->scopebb()); |
40 | 81 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
82 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
83 else { |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
84 if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
85 DValue* e = exp->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
86 llvm::Value* v = e->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
87 delete e; |
40 | 88 Logger::cout() << "return value is '" <<*v << "'\n"; |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
51
diff
changeset
|
89 |
100 | 90 IRFunction::FinallyVec& fin = p->func()->finallys; |
40 | 91 if (fin.empty()) { |
100 | 92 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
40 | 93 new llvm::ReturnInst(v, p->scopebb()); |
94 } | |
95 else { | |
100 | 96 if (!p->func()->finallyretval) |
97 p->func()->finallyretval = new llvm::AllocaInst(v->getType(),"tmpreturn",p->topallocapoint()); | |
98 llvm::Value* rettmp = p->func()->finallyretval; | |
40 | 99 new llvm::StoreInst(v,rettmp,p->scopebb()); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
100 new llvm::BranchInst(fin.back().retbb, p->scopebb()); |
40 | 101 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
102 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
103 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
104 else |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
105 { |
40 | 106 if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) { |
100 | 107 IRFunction::FinallyVec& fin = p->func()->finallys; |
40 | 108 if (fin.empty()) { |
100 | 109 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
40 | 110 new llvm::ReturnInst(p->scopebb()); |
111 } | |
112 else { | |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
113 new llvm::BranchInst(fin.back().retbb, p->scopebb()); |
40 | 114 } |
115 } | |
116 else { | |
117 assert(0); // why should this ever happen? | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
118 new llvm::UnreachableInst(p->scopebb()); |
40 | 119 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
120 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
121 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
122 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
123 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
124 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
125 void ExpStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
126 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
127 static int esi = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
128 Logger::println("ExpStatement::toIR(%d): %s", esi++, toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
129 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
130 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
131 // if (global.params.symdebug) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
132 // DtoDwarfStopPoint(loc.linnum); |
82
d8dd47ef3973
[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes.
lindquist
parents:
81
diff
changeset
|
133 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
134 if (exp != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
135 elem* e = exp->toElem(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
136 delete e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
137 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
138 /*elem* e = exp->toElem(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
139 p->buf.printf("%s", e->toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
140 delete e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
141 p->buf.writenl();*/ |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
142 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
143 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
144 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
145 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
146 void IfStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
147 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
148 static int wsi = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
149 Logger::println("IfStatement::toIR(%d): %s", wsi++, toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
150 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
151 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
152 DValue* cond_e = condition->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
153 llvm::Value* cond_val = cond_e->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
154 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
155 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
156 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
157 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
158 llvm::BasicBlock* ifbb = new llvm::BasicBlock("if", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
159 llvm::BasicBlock* endbb = new llvm::BasicBlock("endif", gIR->topfunc(), oldend); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
160 llvm::BasicBlock* elsebb = elsebody ? new llvm::BasicBlock("else", gIR->topfunc(), endbb) : endbb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
161 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
162 if (cond_val->getType() != llvm::Type::Int1Ty) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
163 Logger::cout() << "if conditional: " << *cond_val << '\n'; |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
164 cond_val = DtoBoolean(cond_val); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
165 } |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
166 llvm::Value* ifgoback = new llvm::BranchInst(ifbb, elsebb, cond_val, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
167 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
168 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
169 gIR->scope() = IRScope(ifbb,elsebb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
170 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
171 // do scoped statements |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
172 ifbody->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
173 if (!gIR->scopereturned()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
174 new llvm::BranchInst(endbb,gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
175 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
176 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
177 if (elsebody) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
178 //assert(0); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
179 gIR->scope() = IRScope(elsebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
180 elsebody->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
181 if (!gIR->scopereturned()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
182 new llvm::BranchInst(endbb,gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
183 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
184 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
185 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
186 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
187 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
188 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
189 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
190 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
191 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
192 void ScopeStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
193 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
194 Logger::println("ScopeStatement::toIR(): %s", toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
195 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
196 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
197 llvm::BasicBlock* oldend = p->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
198 |
40 | 199 llvm::BasicBlock* beginbb = 0; |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
200 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
201 // remove useless branches by clearing and reusing the current basicblock |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
202 llvm::BasicBlock* bb = p->scopebb(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
203 if (bb->empty()) { |
40 | 204 beginbb = bb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
205 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
206 else { |
40 | 207 assert(!p->scopereturned()); |
208 beginbb = new llvm::BasicBlock("scope", p->topfunc(), oldend); | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
209 new llvm::BranchInst(beginbb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
210 } |
40 | 211 llvm::BasicBlock* endbb = new llvm::BasicBlock("endscope", p->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
212 |
40 | 213 gIR->scope() = IRScope(beginbb, endbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
214 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
215 statement->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
216 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
217 p->scope() = IRScope(p->scopebb(),oldend); |
40 | 218 endbb->eraseFromParent(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
219 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
220 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
221 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
222 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
223 void WhileStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
224 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
225 static int wsi = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
226 Logger::println("WhileStatement::toIR(%d): %s", wsi++, toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
227 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
228 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
229 // create while blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
230 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
231 llvm::BasicBlock* whilebb = new llvm::BasicBlock("whilecond", gIR->topfunc(), oldend); |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
232 llvm::BasicBlock* whilebodybb = new llvm::BasicBlock("whilebody", gIR->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
233 llvm::BasicBlock* endbb = new llvm::BasicBlock("endwhile", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
234 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
235 // move into the while block |
40 | 236 p->ir->CreateBr(whilebb); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
237 //new llvm::BranchInst(whilebb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
238 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
239 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
240 gIR->scope() = IRScope(whilebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
241 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
242 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
243 DValue* cond_e = condition->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
244 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
245 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
246 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
247 // conditional branch |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
248 llvm::Value* ifbreak = new llvm::BranchInst(whilebodybb, endbb, cond_val, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
249 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
250 // rewrite scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
251 gIR->scope() = IRScope(whilebodybb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
252 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
253 // while body code |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
254 p->loopbbs.push_back(IRScope(whilebb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
255 body->toIR(p); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
256 p->loopbbs.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
257 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
258 // loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
259 if (!gIR->scopereturned()) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
260 new llvm::BranchInst(whilebb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
261 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
262 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
263 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
264 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
265 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
266 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
267 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
268 void DoStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
269 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
270 static int wsi = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
271 Logger::println("DoStatement::toIR(%d): %s", wsi++, toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
272 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
273 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
274 // create while blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
275 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
276 llvm::BasicBlock* dowhilebb = new llvm::BasicBlock("dowhile", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
277 llvm::BasicBlock* endbb = new llvm::BasicBlock("enddowhile", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
278 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
279 // move into the while block |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
280 assert(!gIR->scopereturned()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
281 new llvm::BranchInst(dowhilebb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
282 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
283 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
284 gIR->scope() = IRScope(dowhilebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
285 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
286 // do-while body code |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
287 p->loopbbs.push_back(IRScope(dowhilebb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
288 body->toIR(p); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
289 p->loopbbs.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
290 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
291 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
292 DValue* cond_e = condition->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
293 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
294 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
295 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
296 // conditional branch |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
297 llvm::Value* ifbreak = new llvm::BranchInst(dowhilebb, endbb, cond_val, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
298 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
299 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
300 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
301 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
302 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
303 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
304 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
305 void ForStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
306 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
307 static int wsi = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
308 Logger::println("ForStatement::toIR(%d): %s", wsi++, toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
309 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
310 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
311 // create for blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
312 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
313 llvm::BasicBlock* forbb = new llvm::BasicBlock("forcond", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
314 llvm::BasicBlock* forbodybb = new llvm::BasicBlock("forbody", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
315 llvm::BasicBlock* forincbb = new llvm::BasicBlock("forinc", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
316 llvm::BasicBlock* endbb = new llvm::BasicBlock("endfor", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
317 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
318 // init |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
319 if (init != 0) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
320 init->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
321 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
322 // move into the for condition block, ie. start the loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
323 new llvm::BranchInst(forbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
324 |
40 | 325 p->loopbbs.push_back(IRScope(forincbb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
326 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
327 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
328 gIR->scope() = IRScope(forbb,forbodybb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
329 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
330 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
331 DValue* cond_e = condition->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
332 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
333 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
334 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
335 // conditional branch |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
336 llvm::Value* ifbreak = new llvm::BranchInst(forbodybb, endbb, cond_val, forbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
337 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
338 // rewrite scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
339 gIR->scope() = IRScope(forbodybb,forincbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
340 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
341 // do for body code |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
342 body->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
343 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
344 // move into the for increment block |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
345 if (!gIR->scopereturned()) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
346 new llvm::BranchInst(forincbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
347 gIR->scope() = IRScope(forincbb, endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
348 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
349 // increment |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
350 if (increment) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
351 DValue* inc = increment->toElem(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
352 delete inc; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
353 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
354 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
355 // loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
356 if (!gIR->scopereturned()) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
357 new llvm::BranchInst(forbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
358 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
359 p->loopbbs.pop_back(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
360 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
361 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
362 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
363 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
364 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
365 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
366 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
367 void BreakStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
368 { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
369 Logger::println("BreakStatement::toIR(): %s", toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
370 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
371 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
372 if (ident != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
373 Logger::println("ident = %s", ident->toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
374 assert(0); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
375 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
376 else { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
377 new llvm::BranchInst(gIR->loopbbs.back().end, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
378 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
379 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
380 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
381 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
382 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
383 void ContinueStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
384 { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
385 Logger::println("ContinueStatement::toIR(): %s", toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
386 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
387 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
388 if (ident != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
389 Logger::println("ident = %s", ident->toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
390 assert(0); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
391 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
392 else { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
393 new llvm::BranchInst(gIR->loopbbs.back().begin, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
394 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
395 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
396 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
397 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
398 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
399 void OnScopeStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
400 { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
401 Logger::println("OnScopeStatement::toIR(): %s", toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
402 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
403 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
404 assert(statement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
405 //statement->toIR(p); // this seems to be redundant |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
406 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
407 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
408 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
409 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
410 void TryFinallyStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
411 { |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
412 Logger::println("TryFinallyStatement::toIR(): %s", toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
413 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
414 |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
415 // create basic blocks |
40 | 416 llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
417 |
40 | 418 llvm::BasicBlock* trybb = new llvm::BasicBlock("try", p->topfunc(), oldend); |
419 llvm::BasicBlock* finallybb = new llvm::BasicBlock("finally", p->topfunc(), oldend); | |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
420 llvm::BasicBlock* finallyretbb = new llvm::BasicBlock("finallyreturn", p->topfunc(), oldend); |
40 | 421 llvm::BasicBlock* endbb = new llvm::BasicBlock("endtryfinally", p->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
422 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
423 // pass the previous BB into this |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
424 assert(!gIR->scopereturned()); |
40 | 425 new llvm::BranchInst(trybb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
426 |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
427 // do the try block |
40 | 428 p->scope() = IRScope(trybb,finallybb); |
100 | 429 gIR->func()->finallys.push_back(IRFinally(finallybb,finallyretbb)); |
430 IRFinally& fin = p->func()->finallys.back(); | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
431 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
432 assert(body); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
433 body->toIR(p); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
434 |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
435 // terminate try BB |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
436 if (!p->scopereturned()) |
40 | 437 new llvm::BranchInst(finallybb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
438 |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
439 // do finally block |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
440 p->scope() = IRScope(finallybb,finallyretbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
441 assert(finalbody); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
442 finalbody->toIR(p); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
443 |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
444 // terminate finally |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
445 if (!gIR->scopereturned()) { |
40 | 446 new llvm::BranchInst(endbb, p->scopebb()); |
447 } | |
448 | |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
449 // do finally block (return path) |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
450 p->scope() = IRScope(finallyretbb,endbb); |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
451 assert(finalbody); |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
452 finalbody->toIR(p); // hope this will work, otherwise it's time it gets fixed |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
453 |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
454 // terminate finally (return path) |
100 | 455 size_t nfin = p->func()->finallys.size(); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
456 if (nfin > 1) { |
100 | 457 IRFinally& ofin = p->func()->finallys[nfin-2]; |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
458 p->ir->CreateBr(ofin.retbb); |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
459 } |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
460 // no outer |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
461 else |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
462 { |
100 | 463 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
464 llvm::Value* retval = p->func()->finallyretval; | |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
465 if (retval) { |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
466 retval = p->ir->CreateLoad(retval,"tmp"); |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
467 p->ir->CreateRet(retval); |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
468 } |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
469 else { |
100 | 470 FuncDeclaration* fd = p->func()->decl; |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
471 if (fd->isMain()) { |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
472 assert(fd->type->next->ty == Tvoid); |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
473 p->ir->CreateRet(DtoConstInt(0)); |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
474 } |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
475 else { |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
476 p->ir->CreateRetVoid(); |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
477 } |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
478 } |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
479 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
480 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
481 // rewrite the scope |
100 | 482 p->func()->finallys.pop_back(); |
40 | 483 p->scope() = IRScope(endbb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
484 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
485 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
486 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
487 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
488 void TryCatchStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
489 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
490 static int wsi = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
491 Logger::println("TryCatchStatement::toIR(%d): %s", wsi++, toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
492 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
493 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
494 Logger::attention("try-catch is not yet fully implemented, only the try block will be emitted."); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
495 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
496 assert(body); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
497 body->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
498 |
34 | 499 /*assert(catches); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
500 for(size_t i=0; i<catches->dim; ++i) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
501 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
502 Catch* c = (Catch*)catches->data[i]; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
503 c->handler->toIR(p); |
34 | 504 }*/ |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
505 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
506 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
507 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
508 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
509 void ThrowStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
510 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
511 static int wsi = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
512 Logger::println("ThrowStatement::toIR(%d): %s", wsi++, toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
513 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
514 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
515 Logger::attention("throw is not yet implemented, replacing expression with assert(0);"); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
516 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
517 DtoAssert(NULL, &loc, NULL); |
34 | 518 |
519 /* | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
520 assert(exp); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
521 DValue* e = exp->toElem(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
522 delete e; |
34 | 523 */ |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
524 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
525 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
526 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
527 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
528 void SwitchStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
529 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
530 Logger::println("SwitchStatement::toIR(): %s", toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
531 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
532 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
533 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
534 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
535 // collect the needed cases |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
536 typedef std::pair<llvm::BasicBlock*, std::vector<llvm::ConstantInt*> > CasePair; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
537 std::vector<CasePair> vcases; |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
538 std::vector<Statement*> vbodies; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
539 for (int i=0; i<cases->dim; ++i) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
540 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
541 CaseStatement* cs = (CaseStatement*)cases->data[i]; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
542 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
543 // create the case bb with a nice label |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
544 std::string lblname("case"+std::string(cs->exp->toChars())); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
545 llvm::BasicBlock* bb = new llvm::BasicBlock(lblname, p->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
546 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
547 std::vector<llvm::ConstantInt*> tmp; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
548 CaseStatement* last; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
549 do { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
550 // get the case value |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
551 DValue* e = cs->exp->toElem(p); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
552 DConstValue* ce = e->isConst(); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
553 assert(ce); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
554 llvm::ConstantInt* ec = isaConstantInt(ce->c); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
555 assert(ec); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
556 tmp.push_back(ec); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
557 last = cs; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
558 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
559 while (cs = cs->statement->isCaseStatement()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
560 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
561 vcases.push_back(CasePair(bb, tmp)); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
562 vbodies.push_back(last->statement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
563 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
564 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
565 // default |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
566 llvm::BasicBlock* defbb = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
567 if (!hasNoDefault) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
568 defbb = new llvm::BasicBlock("default", p->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
569 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
570 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
571 // end (break point) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
572 llvm::BasicBlock* endbb = new llvm::BasicBlock("switchend", p->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
573 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
574 // condition var |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
575 DValue* cond = condition->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
576 llvm::SwitchInst* si = new llvm::SwitchInst(cond->getRVal(), defbb ? defbb : endbb, cases->dim, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
577 delete cond; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
578 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
579 // add the cases |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
580 size_t n = vcases.size(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
581 for (size_t i=0; i<n; ++i) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
582 { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
583 size_t nc = vcases[i].second.size(); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
584 for (size_t j=0; j<nc; ++j) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
585 { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
586 si->addCase(vcases[i].second[j], vcases[i].first); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
587 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
588 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
589 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
590 // insert case statements |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
591 for (size_t i=0; i<n; ++i) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
592 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
593 llvm::BasicBlock* nextbb = (i == n-1) ? (defbb ? defbb : endbb) : vcases[i+1].first; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
594 p->scope() = IRScope(vcases[i].first,nextbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
595 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
596 p->loopbbs.push_back(IRScope(p->scopebb(),endbb)); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
597 vbodies[i]->toIR(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
598 p->loopbbs.pop_back(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
599 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
600 llvm::BasicBlock* curbb = p->scopebb(); |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
601 if (curbb->empty() || !curbb->back().isTerminator()) |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
602 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
603 new llvm::BranchInst(nextbb, curbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
604 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
605 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
606 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
607 // default statement |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
608 if (defbb) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
609 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
610 p->scope() = IRScope(defbb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
611 p->loopbbs.push_back(IRScope(defbb,endbb)); |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
612 Logger::println("doing default statement"); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
613 sdefault->statement->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
614 p->loopbbs.pop_back(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
615 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
616 llvm::BasicBlock* curbb = p->scopebb(); |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
617 if (curbb->empty() || !curbb->back().isTerminator()) |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
618 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
619 new llvm::BranchInst(endbb, curbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
620 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
621 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
622 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
623 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
624 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
625 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
626 ////////////////////////////////////////////////////////////////////////////// |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
627 void CaseStatement::toIR(IRState* p) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
628 { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
629 Logger::println("CaseStatement::toIR(): %s", toChars()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
630 LOG_SCOPE; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
631 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
632 assert(0); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
633 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
634 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
635 ////////////////////////////////////////////////////////////////////////////// |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
636 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
637 void UnrolledLoopStatement::toIR(IRState* p) |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
638 { |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
639 Logger::println("UnrolledLoopStatement::toIR(): %s", toChars()); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
640 LOG_SCOPE; |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
641 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
642 llvm::BasicBlock* oldend = gIR->scopeend(); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
643 llvm::BasicBlock* endbb = new llvm::BasicBlock("unrolledend", p->topfunc(), oldend); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
644 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
645 p->scope() = IRScope(p->scopebb(),endbb); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
646 p->loopbbs.push_back(IRScope(p->scopebb(),endbb)); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
647 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
648 for (int i=0; i<statements->dim; ++i) |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
649 { |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
650 Statement* s = (Statement*)statements->data[i]; |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
651 s->toIR(p); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
652 } |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
653 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
654 p->loopbbs.pop_back(); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
655 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
656 new llvm::BranchInst(endbb, p->scopebb()); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
657 p->scope() = IRScope(endbb,oldend); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
658 } |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
659 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
660 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
661 |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
662 void ForeachStatement::toIR(IRState* p) |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
663 { |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
664 Logger::println("ForeachStatement::toIR(): %s", toChars()); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
665 LOG_SCOPE; |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
666 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
667 //assert(arguments->dim == 1); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
668 assert(value != 0); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
669 assert(body != 0); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
670 assert(aggr != 0); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
671 assert(func != 0); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
672 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
673 //Argument* arg = (Argument*)arguments->data[0]; |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
674 //Logger::println("Argument is %s", arg->toChars()); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
675 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
676 Logger::println("aggr = %s", aggr->toChars()); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
677 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
678 // key |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
679 const llvm::Type* keytype = key ? DtoType(key->type) : DtoSize_t(); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
680 llvm::Value* keyvar = new llvm::AllocaInst(keytype, "foreachkey", p->topallocapoint()); |
34 | 681 if (key) key->llvmValue = keyvar; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
682 llvm::Value* zerokey = llvm::ConstantInt::get(keytype,0,false); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
683 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
684 // value |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
685 const llvm::Type* valtype = DtoType(value->type); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
686 llvm::Value* valvar = NULL; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
687 if (!value->isRef() && !value->isOut()) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
688 valvar = new llvm::AllocaInst(valtype, "foreachval", p->topallocapoint()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
689 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
690 // what to iterate |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
691 DValue* aggrval = aggr->toElem(p); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
692 Type* aggrtype = DtoDType(aggr->type); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
693 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
694 // get length and pointer |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
695 llvm::Value* val = 0; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
696 llvm::Value* niters = 0; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
697 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
698 // static array |
45 | 699 if (aggrtype->ty == Tsarray) |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
700 { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
701 Logger::println("foreach over static array"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
702 val = aggrval->getRVal(); |
96 | 703 assert(isaPointer(val->getType())); |
704 const llvm::ArrayType* arrty = isaArray(val->getType()->getContainedType(0)); | |
705 assert(arrty); | |
706 size_t nelems = arrty->getNumElements(); | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
707 assert(nelems > 0); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
708 niters = llvm::ConstantInt::get(keytype,nelems,false); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
709 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
710 // dynamic array |
45 | 711 else if (aggrtype->ty == Tarray) |
712 { | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
713 if (DSliceValue* slice = aggrval->isSlice()) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
714 Logger::println("foreach over slice"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
715 niters = slice->len; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
716 assert(niters); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
717 val = slice->ptr; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
718 assert(val); |
73 | 719 } |
720 else { | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
721 Logger::println("foreach over dynamic array"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
722 val = aggrval->getRVal(); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
723 niters = DtoGEPi(val,0,0,"tmp",p->scopebb()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
724 niters = p->ir->CreateLoad(niters, "numiterations"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
725 val = DtoGEPi(val,0,1,"tmp",p->scopebb()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
726 val = p->ir->CreateLoad(val, "collection"); |
73 | 727 } |
45 | 728 } |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
729 else |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
730 { |
45 | 731 assert(0 && "aggregate type is not Tarray or Tsarray"); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
732 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
733 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
734 llvm::Constant* delta = 0; |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
735 if (op == TOKforeach) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
736 new llvm::StoreInst(zerokey, keyvar, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
737 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
738 else { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
739 new llvm::StoreInst(niters, keyvar, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
740 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
741 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
742 llvm::BasicBlock* oldend = gIR->scopeend(); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
743 llvm::BasicBlock* condbb = new llvm::BasicBlock("foreachcond", p->topfunc(), oldend); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
744 llvm::BasicBlock* bodybb = new llvm::BasicBlock("foreachbody", p->topfunc(), oldend); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
745 llvm::BasicBlock* nextbb = new llvm::BasicBlock("foreachnext", p->topfunc(), oldend); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
746 llvm::BasicBlock* endbb = new llvm::BasicBlock("foreachend", p->topfunc(), oldend); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
747 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
748 new llvm::BranchInst(condbb, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
749 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
750 // condition |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
751 p->scope() = IRScope(condbb,bodybb); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
752 |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
753 llvm::Value* done = 0; |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
754 llvm::Value* load = new llvm::LoadInst(keyvar, "tmp", p->scopebb()); |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
755 if (op == TOKforeach) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
756 done = new llvm::ICmpInst(llvm::ICmpInst::ICMP_ULT, load, niters, "tmp", p->scopebb()); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
757 } |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
758 else if (op == TOKforeach_reverse) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
759 done = new llvm::ICmpInst(llvm::ICmpInst::ICMP_UGT, load, zerokey, "tmp", p->scopebb()); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
760 load = llvm::BinaryOperator::createSub(load,llvm::ConstantInt::get(keytype, 1, false),"tmp",p->scopebb()); |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
761 new llvm::StoreInst(load, keyvar, p->scopebb()); |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
762 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
763 new llvm::BranchInst(bodybb, endbb, done, p->scopebb()); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
764 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
765 // init body |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
766 p->scope() = IRScope(bodybb,nextbb); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
767 |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
768 // get value for this iteration |
45 | 769 llvm::Constant* zero = llvm::ConstantInt::get(keytype,0,false); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
770 llvm::Value* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); |
45 | 771 if (aggrtype->ty == Tsarray) |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
772 value->llvmValue = DtoGEP(val,zero,loadedKey,"tmp"); |
45 | 773 else if (aggrtype->ty == Tarray) |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
774 value->llvmValue = new llvm::GetElementPtrInst(val,loadedKey,"tmp",p->scopebb()); |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
775 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
776 if (!value->isRef() && !value->isOut()) { |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
777 DValue* dst = new DVarValue(value->type, valvar, true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
778 DValue* src = new DVarValue(value->type, value->llvmValue, true); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
779 DtoAssign(dst, src); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
780 value->llvmValue = valvar; |
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
781 } |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
782 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
783 // emit body |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
784 p->loopbbs.push_back(IRScope(nextbb,endbb)); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
785 body->toIR(p); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
786 p->loopbbs.pop_back(); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
787 |
40 | 788 if (!p->scopereturned()) |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
789 new llvm::BranchInst(nextbb, p->scopebb()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
790 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
791 // next |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
792 p->scope() = IRScope(nextbb,endbb); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
793 if (op == TOKforeach) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
794 llvm::Value* load = DtoLoad(keyvar); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
795 load = p->ir->CreateAdd(load, llvm::ConstantInt::get(keytype, 1, false), "tmp"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
796 DtoStore(load, keyvar); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
797 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
798 new llvm::BranchInst(condbb, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
799 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
800 // end |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
801 p->scope() = IRScope(endbb,oldend); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
802 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
803 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
804 ////////////////////////////////////////////////////////////////////////////// |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
805 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
806 void LabelStatement::toIR(IRState* p) |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
807 { |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
808 Logger::println("LabelStatement::toIR(): %s", toChars()); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
809 LOG_SCOPE; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
810 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
811 assert(tf == NULL); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
812 assert(!isReturnLabel); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
813 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
814 llvm::BasicBlock* oldend = gIR->scopeend(); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
815 if (llvmBB) |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
816 llvmBB->moveBefore(oldend); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
817 else |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
818 llvmBB = new llvm::BasicBlock("label", p->topfunc(), oldend); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
819 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
820 if (!p->scopereturned()) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
821 new llvm::BranchInst(llvmBB, p->scopebb()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
822 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
823 p->scope() = IRScope(llvmBB,oldend); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
824 if (statement) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
825 statement->toIR(p); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
826 } |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
827 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
828 ////////////////////////////////////////////////////////////////////////////// |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
829 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
830 void GotoStatement::toIR(IRState* p) |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
831 { |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
832 Logger::println("GotoStatement::toIR(): %s", toChars()); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
833 LOG_SCOPE; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
834 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
835 assert(tf == NULL); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
836 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
837 llvm::BasicBlock* oldend = gIR->scopeend(); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
838 llvm::BasicBlock* bb = new llvm::BasicBlock("aftergoto", p->topfunc(), oldend); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
839 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
840 if (label->statement->llvmBB == NULL) |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
841 label->statement->llvmBB = new llvm::BasicBlock("label", p->topfunc()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
842 assert(!p->scopereturned()); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
843 new llvm::BranchInst(label->statement->llvmBB, p->scopebb()); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
844 p->scope() = IRScope(bb,oldend); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
845 } |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
846 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
847 ////////////////////////////////////////////////////////////////////////////// |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
848 |
40 | 849 void WithStatement::toIR(IRState* p) |
850 { | |
851 Logger::println("WithStatement::toIR(): %s", toChars()); | |
852 LOG_SCOPE; | |
853 | |
854 assert(exp); | |
855 assert(body); | |
856 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
857 DValue* e = exp->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
858 wthis->llvmValue = e->getRVal(); |
40 | 859 delete e; |
860 | |
861 body->toIR(p); | |
862 } | |
863 | |
864 ////////////////////////////////////////////////////////////////////////////// | |
865 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
866 void SynchronizedStatement::toIR(IRState* p) |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
867 { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
868 Logger::println("SynchronizedStatement::toIR(): %s", toChars()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
869 LOG_SCOPE; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
870 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
871 Logger::attention("synchronized is currently ignored. only the body will be emitted"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
872 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
873 body->toIR(p); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
874 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
875 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
876 ////////////////////////////////////////////////////////////////////////////// |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
877 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
878 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
879 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
880 #define STUBST(x) void x::toIR(IRState * p) {error("Statement type "#x" not implemented: %s", toChars());fatal();} |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
881 //STUBST(BreakStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
882 //STUBST(ForStatement); |
40 | 883 //STUBST(WithStatement); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
884 //STUBST(SynchronizedStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
885 //STUBST(ReturnStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
886 //STUBST(ContinueStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
887 STUBST(DefaultStatement); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
888 //STUBST(CaseStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
889 //STUBST(SwitchStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
890 STUBST(SwitchErrorStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
891 STUBST(Statement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
892 //STUBST(IfStatement); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
893 //STUBST(ForeachStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
894 //STUBST(DoStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
895 //STUBST(WhileStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
896 //STUBST(ExpStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
897 //STUBST(CompoundStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
898 //STUBST(ScopeStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
899 STUBST(AsmStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
900 //STUBST(TryCatchStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
901 //STUBST(TryFinallyStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
902 STUBST(VolatileStatement); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
903 //STUBST(LabelStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
904 //STUBST(ThrowStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
905 STUBST(GotoCaseStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
906 STUBST(GotoDefaultStatement); |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
907 //STUBST(GotoStatement); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
908 //STUBST(UnrolledLoopStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
909 //STUBST(OnScopeStatement); |