annotate gen/statements.cpp @ 468:45a67b6f1310

Removed the 'needsstorage' thing from Dsymbol. Arguments are not always given storage when applicable. This is not longer treat specially in this regard. Code for accessing nested variables and contexts rewritten. Probably more. Fairly well tested.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 04 Aug 2008 02:59:34 +0200
parents 0e6b4d65d3f8
children 672eb4893b55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
9 #include "gen/llvm.h"
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 123
diff changeset
10 #include "llvm/InlineAsm.h"
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
11 #include "llvm/Support/CFG.h"
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
12
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
13 #include "mars.h"
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
14 #include "total.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
15 #include "init.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
16 #include "mtype.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
17 #include "hdrgen.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
18 #include "port.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
19
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
20 #include "gen/irstate.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
21 #include "gen/logger.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
22 #include "gen/tollvm.h"
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 234
diff changeset
23 #include "gen/llvmhelpers.h"
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
24 #include "gen/runtime.h"
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
25 #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
26 #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
27 #include "gen/dvalue.h"
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
28
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents: 133
diff changeset
29 #include "ir/irfunction.h"
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
30 #include "ir/irlandingpad.h"
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents: 133
diff changeset
31
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
32 //////////////////////////////////////////////////////////////////////////////
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 void CompoundStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
35 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
36 Logger::println("CompoundStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
37 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
38
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
39 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
40 {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
41 Statement* s = (Statement*)statements->data[i];
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
42 if (s) {
34
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
43 s->toIR(p);
4648206ca213 [svn r38] * resizing dynamic arrays support
lindquist
parents: 33
diff changeset
44 }
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
45 }
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
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
48
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
49 //////////////////////////////////////////////////////////////////////////////
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
50
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
51 void ReturnStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
52 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
53 Logger::println("ReturnStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
54 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
55
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
56 if (exp)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
57 {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 234
diff changeset
58 if (p->topfunc()->getReturnType() == LLType::VoidTy) {
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents: 133
diff changeset
59 IrFunction* f = p->func();
121
9c79b61fb638 [svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents: 109
diff changeset
60 assert(f->type->llvmRetInPtr);
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
61 assert(f->decl->ir.irFunc->retArg);
14
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
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
65 DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg, true);
86
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 DValue* e = exp->toElem(p);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
68
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
69 if (!e->inPlace())
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 395
diff changeset
70 DtoAssign(loc, rvar, e);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
71
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
72 DtoEnclosingHandlers(enclosinghandler, NULL);
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
73
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
74 if (global.params.symdebug) DtoDwarfFuncEnd(f->decl);
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
75 llvm::ReturnInst::Create(p->scopebb());
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
76
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
77 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
78 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
79 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
80 DValue* e = exp->toElem(p);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
81 LLValue* v = e->getRVal();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
82 delete e;
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
83 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
84
185
89e21eeaf4c4 [svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents: 181
diff changeset
85 // can happen for classes
89e21eeaf4c4 [svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents: 181
diff changeset
86 if (v->getType() != p->topfunc()->getReturnType())
89e21eeaf4c4 [svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents: 181
diff changeset
87 {
89e21eeaf4c4 [svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents: 181
diff changeset
88 v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");
89e21eeaf4c4 [svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents: 181
diff changeset
89 Logger::cout() << "return value after cast: " << *v << '\n';
89e21eeaf4c4 [svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents: 181
diff changeset
90 }
89e21eeaf4c4 [svn r201] Fixed: return statement could fail codegen with type mismatch for classes, added cast.
lindquist
parents: 181
diff changeset
91
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
92 DtoEnclosingHandlers(enclosinghandler, NULL);
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
93
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
94 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
95 llvm::ReturnInst::Create(v, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
96 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
97 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
98 else
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
99 {
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 234
diff changeset
100 assert(p->topfunc()->getReturnType() == LLType::VoidTy);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
101 DtoEnclosingHandlers(enclosinghandler, NULL);
217
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 213
diff changeset
102
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 213
diff changeset
103 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 213
diff changeset
104 llvm::ReturnInst::Create(p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
105 }
267
c43911baea21 [svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents: 263
diff changeset
106
c43911baea21 [svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents: 263
diff changeset
107 // the return terminated this basicblock, start a new one
c43911baea21 [svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents: 263
diff changeset
108 llvm::BasicBlock* oldend = gIR->scopeend();
c43911baea21 [svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents: 263
diff changeset
109 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterreturn", p->topfunc(), oldend);
c43911baea21 [svn r288] Let return statements start a new basic block after terminating the current one.
ChristianK
parents: 263
diff changeset
110 p->scope() = IRScope(bb,oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
111 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
112
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
113 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
114
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
115 void ExpStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
116 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
117 Logger::println("ExpStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
118 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
119
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
120 if (global.params.symdebug)
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
121 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
122
137
ce7b81fb957f [svn r141] fixed more problems with classinfo
lindquist
parents: 136
diff changeset
123 if (exp) {
ce7b81fb957f [svn r141] fixed more problems with classinfo
lindquist
parents: 136
diff changeset
124 if (global.params.llvmAnnotate)
ce7b81fb957f [svn r141] fixed more problems with classinfo
lindquist
parents: 136
diff changeset
125 DtoAnnotation(exp->toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
126 elem* e = exp->toElem(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
127 delete e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
128 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
129 /*elem* e = exp->toElem(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
130 p->buf.printf("%s", e->toChars());
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
131 delete e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
132 p->buf.writenl();*/
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
133 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
134
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
135 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
136
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
137 void IfStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
138 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
139 Logger::println("IfStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
140 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
141
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
142 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
143 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
144
163
a8cd9bc1021a [svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents: 156
diff changeset
145 if (match)
a8cd9bc1021a [svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents: 156
diff changeset
146 {
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
147 LLValue* allocainst = new llvm::AllocaInst(DtoType(match->type), "._tmp_if_var", p->topallocapoint());
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
148 match->ir.irLocal = new IrLocal(match);
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
149 match->ir.irLocal->value = allocainst;
163
a8cd9bc1021a [svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents: 156
diff changeset
150 }
a8cd9bc1021a [svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents: 156
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);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
153 LLValue* cond_val = cond_e->getRVal();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
154
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
155 llvm::BasicBlock* oldend = gIR->scopeend();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
156
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
157 llvm::BasicBlock* ifbb = llvm::BasicBlock::Create("if", gIR->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
158 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endif", gIR->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
159 llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb;
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
160
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 234
diff changeset
161 if (cond_val->getType() != LLType::Int1Ty) {
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
162 Logger::cout() << "if conditional: " << *cond_val << '\n';
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 395
diff changeset
163 cond_val = DtoBoolean(loc, cond_e);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
164 }
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
165 LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
166
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
167 // replace current scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
168 gIR->scope() = IRScope(ifbb,elsebb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
169
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
170 // do scoped statements
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
171 if (ifbody)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
172 ifbody->toIR(p);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
173 if (!gIR->scopereturned()) {
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
174 llvm::BranchInst::Create(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()) {
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
182 llvm::BranchInst::Create(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 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
194 Logger::println("ScopeStatement::toIR(): %s", loc.toChars());
14
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
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
197 /*llvm::BasicBlock* oldend = p->scopeend();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
198
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
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
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
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 {
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
207 beginbb = llvm::BasicBlock::Create("scope", p->topfunc(), oldend);
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
208 if (!p->scopereturned())
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
209 llvm::BranchInst::Create(beginbb, bb);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
210 }
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
211
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
212 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endscope", p->topfunc(), oldend);
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
213 if (beginbb != bb)
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
214 p->scope() = IRScope(beginbb, endbb);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
215 else
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
216 p->scope().end = endbb;*/
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
217
181
ef4108f34db6 [svn r197] Fixed: empty scope statement segfaulted.
lindquist
parents: 175
diff changeset
218 if (statement)
ef4108f34db6 [svn r197] Fixed: empty scope statement segfaulted.
lindquist
parents: 175
diff changeset
219 statement->toIR(p);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
220
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
221 /*p->scope().end = oldend;
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
222 Logger::println("Erasing scope endbb");
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
223 endbb->eraseFromParent();*/
14
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
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
226 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
227
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
228 void WhileStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
229 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
230 Logger::println("WhileStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
231 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
232
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
233 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
234 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
235
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
236 // create while blocks
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
237 llvm::BasicBlock* oldend = gIR->scopeend();
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
238 llvm::BasicBlock* whilebb = llvm::BasicBlock::Create("whilecond", gIR->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
239 llvm::BasicBlock* whilebodybb = llvm::BasicBlock::Create("whilebody", gIR->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
240 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endwhile", gIR->topfunc(), oldend);
14
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 // move into the while block
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
243 p->ir->CreateBr(whilebb);
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
244 //llvm::BranchInst::Create(whilebb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
245
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
246 // replace current scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
247 gIR->scope() = IRScope(whilebb,endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
248
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
249 // create the condition
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
250 DValue* cond_e = condition->toElem(p);
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 395
diff changeset
251 LLValue* cond_val = DtoBoolean(loc, cond_e);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
252 delete cond_e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
253
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
254 // conditional branch
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
255 LLValue* ifbreak = llvm::BranchInst::Create(whilebodybb, endbb, cond_val, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
256
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
257 // rewrite scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
258 gIR->scope() = IRScope(whilebodybb,endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
259
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
260 // while body code
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
261 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,whilebb,endbb));
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
262 body->toIR(p);
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
263 p->loopbbs.pop_back();
14
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 // loop
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
266 if (!gIR->scopereturned())
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
267 llvm::BranchInst::Create(whilebb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
268
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
269 // rewrite the scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
270 gIR->scope() = IRScope(endbb,oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
271 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
272
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
273 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
274
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
275 void DoStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
276 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
277 Logger::println("DoStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
278 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
279
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
280 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
281 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
282
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
283 // create while blocks
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
284 llvm::BasicBlock* oldend = gIR->scopeend();
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
285 llvm::BasicBlock* dowhilebb = llvm::BasicBlock::Create("dowhile", gIR->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
286 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("enddowhile", gIR->topfunc(), oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
287
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
288 // move into the while block
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
289 assert(!gIR->scopereturned());
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
290 llvm::BranchInst::Create(dowhilebb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
291
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
292 // replace current scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
293 gIR->scope() = IRScope(dowhilebb,endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
294
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
295 // do-while body code
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
296 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,dowhilebb,endbb));
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
297 body->toIR(p);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
298 p->loopbbs.pop_back();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
299
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
300 // create the condition
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
301 DValue* cond_e = condition->toElem(p);
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 395
diff changeset
302 LLValue* cond_val = DtoBoolean(loc, cond_e);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
303 delete cond_e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
304
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
305 // conditional branch
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
306 LLValue* ifbreak = llvm::BranchInst::Create(dowhilebb, endbb, cond_val, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
307
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
308 // rewrite the scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
309 gIR->scope() = IRScope(endbb,oldend);
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
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
312 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
313
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
314 void ForStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
315 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
316 Logger::println("ForStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
317 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
318
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
319 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
320 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
321
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
322 // create for blocks
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
323 llvm::BasicBlock* oldend = gIR->scopeend();
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
324 llvm::BasicBlock* forbb = llvm::BasicBlock::Create("forcond", gIR->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
325 llvm::BasicBlock* forbodybb = llvm::BasicBlock::Create("forbody", gIR->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
326 llvm::BasicBlock* forincbb = llvm::BasicBlock::Create("forinc", gIR->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
327 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endfor", gIR->topfunc(), oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
328
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
329 // init
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
330 if (init != 0)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
331 init->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
332
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
333 // move into the for condition block, ie. start the loop
144
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
334 assert(!gIR->scopereturned());
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
335 llvm::BranchInst::Create(forbb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
336
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
337 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,forincbb,endbb));
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
338
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
339 // replace current scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
340 gIR->scope() = IRScope(forbb,forbodybb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
341
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
342 // create the condition
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
343 DValue* cond_e = condition->toElem(p);
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 395
diff changeset
344 LLValue* cond_val = DtoBoolean(loc, cond_e);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
345 delete cond_e;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
346
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
347 // conditional branch
144
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
348 assert(!gIR->scopereturned());
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
349 llvm::BranchInst::Create(forbodybb, endbb, cond_val, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
350
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
351 // rewrite scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
352 gIR->scope() = IRScope(forbodybb,forincbb);
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 // do for body code
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
355 body->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
356
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
357 // move into the for increment block
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
358 if (!gIR->scopereturned())
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
359 llvm::BranchInst::Create(forincbb, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
360 gIR->scope() = IRScope(forincbb, endbb);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
361
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
362 // increment
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
363 if (increment) {
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
364 DValue* inc = increment->toElem(p);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
365 delete inc;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
366 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
367
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
368 // loop
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
369 if (!gIR->scopereturned())
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
370 llvm::BranchInst::Create(forbb, gIR->scopebb());
14
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 p->loopbbs.pop_back();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
373
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
374 // rewrite the scope
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
375 gIR->scope() = IRScope(endbb,oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
376 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
377
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
378 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
379
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
380 void BreakStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
381 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
382 Logger::println("BreakStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
383 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
384
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
385 // don't emit two terminators in a row
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
386 // happens just before DMD generated default statements if the last case terminates
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
387 if (p->scopereturned())
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
388 return;
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
389
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
390 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
391 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
392
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
393 if (ident != 0) {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
394 Logger::println("ident = %s", ident->toChars());
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
395
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
396 DtoEnclosingHandlers(enclosinghandler, target->enclosinghandler);
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
397
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
398 // get the loop statement the label refers to
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
399 Statement* targetLoopStatement = target->statement;
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
400 ScopeStatement* tmp;
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
401 while(tmp = targetLoopStatement->isScopeStatement())
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
402 targetLoopStatement = tmp->statement;
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
403
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
404 // find the right break block and jump there
270
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
405 bool found = false;
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
406 IRState::LoopScopeVec::reverse_iterator it;
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
407 for(it = p->loopbbs.rbegin(); it != p->loopbbs.rend(); ++it) {
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
408 if(it->s == targetLoopStatement) {
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
409 llvm::BranchInst::Create(it->end, p->scopebb());
270
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
410 found = true;
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
411 break;
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
412 }
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
413 }
270
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
414 assert(found);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
415 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
416 else {
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
417 DtoEnclosingHandlers(enclosinghandler, p->loopbbs.back().enclosinghandler);
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
418 llvm::BranchInst::Create(p->loopbbs.back().end, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
419 }
270
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
420
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
421 // the break terminated this basicblock, start a new one
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
422 llvm::BasicBlock* oldend = gIR->scopeend();
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
423 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterbreak", p->topfunc(), oldend);
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
424 p->scope() = IRScope(bb,oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
425 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
426
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
427 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
428
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
429 void ContinueStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
430 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
431 Logger::println("ContinueStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
432 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
433
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
434 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
435 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
436
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
437 if (ident != 0) {
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
438 Logger::println("ident = %s", ident->toChars());
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
439
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
440 DtoEnclosingHandlers(enclosinghandler, target->enclosinghandler);
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
441
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
442 // get the loop statement the label refers to
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
443 Statement* targetLoopStatement = target->statement;
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
444 ScopeStatement* tmp;
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
445 while(tmp = targetLoopStatement->isScopeStatement())
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
446 targetLoopStatement = tmp->statement;
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
447
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
448 // find the right continue block and jump there
395
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
449 bool found = false;
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
450 IRState::LoopScopeVec::reverse_iterator it;
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
451 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) {
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
452 if(it->s == targetLoopStatement) {
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
453 llvm::BranchInst::Create(it->begin, gIR->scopebb());
395
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
454 found = true;
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
455 break;
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
456 }
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
457 }
395
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
458 assert(found);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
459 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
460 else {
311
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
461 // can't 'continue' within switch, so omit them
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
462 IRState::LoopScopeVec::reverse_iterator it;
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
463 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) {
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
464 if(!it->isSwitch) {
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
465 break;
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
466 }
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
467 }
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
468 DtoEnclosingHandlers(enclosinghandler, it->enclosinghandler);
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
469 llvm::BranchInst::Create(it->begin, gIR->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
470 }
395
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
471
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
472 // the continue terminated this basicblock, start a new one
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
473 llvm::BasicBlock* oldend = gIR->scopeend();
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
474 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftercontinue", p->topfunc(), oldend);
71a40b62b408 Start a new basic block after a continue statement.
Christian Kamm <kamm incasoftware de>
parents: 365
diff changeset
475 p->scope() = IRScope(bb,oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
476 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
477
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
478 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
479
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
480 void OnScopeStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
481 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
482 Logger::println("OnScopeStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
483 LOG_SCOPE;
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 assert(statement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
486 //statement->toIR(p); // this seems to be redundant
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
487 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
488
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
489 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
490
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
491 void TryFinallyStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
492 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
493 Logger::println("TryFinallyStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
494 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
495
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
496 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
497 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
498
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
499 // create basic blocks
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
500 llvm::BasicBlock* oldend = p->scopeend();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
501
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
502 llvm::BasicBlock* trybb = llvm::BasicBlock::Create("try", p->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
503 llvm::BasicBlock* finallybb = llvm::BasicBlock::Create("finally", p->topfunc(), oldend);
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
504 // the landing pad for statements in the try block
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
505 llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create("landingpad", p->topfunc(), oldend);
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
506 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endtryfinally", p->topfunc(), oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
507
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
508 // 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
509 assert(!gIR->scopereturned());
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
510 llvm::BranchInst::Create(trybb, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
511
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
512 //
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
513 // set up the landing pad
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
514 //
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
515 p->scope() = IRScope(landingpadbb, endbb);
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
516
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
517 gIR->func()->landingPad.addFinally(finalbody);
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
518 gIR->func()->landingPad.push(landingpadbb);
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
519
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
520 //
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
521 // do the try block
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
522 //
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
523 p->scope() = IRScope(trybb,finallybb);
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 assert(body);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
526 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
527
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
528 // 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
529 if (!p->scopereturned())
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
530 llvm::BranchInst::Create(finallybb, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
531
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
532 gIR->func()->landingPad.pop();
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
533
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
534 //
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
535 // do finally block
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
536 //
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
537 p->scope() = IRScope(finallybb,landingpadbb);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
538 assert(finalbody);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
539 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
540
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
541 // terminate finally
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
542 //TODO: isn't it an error to have a 'returned' finally block?
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
543 if (!gIR->scopereturned()) {
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
544 llvm::BranchInst::Create(endbb, p->scopebb());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
545 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
546
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
547 // rewrite the scope
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
548 p->scope() = IRScope(endbb,oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
549 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
550
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
551 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
552
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
553 void TryCatchStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
554 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
555 Logger::println("TryCatchStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
556 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
557
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
558 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
559 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
560
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
561 // create basic blocks
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
562 llvm::BasicBlock* oldend = p->scopeend();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
563
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
564 llvm::BasicBlock* trybb = llvm::BasicBlock::Create("try", p->topfunc(), oldend);
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
565 // the landing pad will be responsible for branching to the correct catch block
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
566 llvm::BasicBlock* landingpadbb = llvm::BasicBlock::Create("landingpad", p->topfunc(), oldend);
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
567 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endtrycatch", p->topfunc(), oldend);
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
568
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
569 // pass the previous BB into this
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
570 assert(!gIR->scopereturned());
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
571 llvm::BranchInst::Create(trybb, p->scopebb());
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
572
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
573 //
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
574 // do catches and the landing pad
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
575 //
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
576 assert(catches);
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
577 gIR->scope() = IRScope(landingpadbb, endbb);
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
578
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
579 for (int i = 0; i < catches->dim; i++)
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
580 {
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
581 Catch *c = (Catch *)catches->data[i];
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
582 gIR->func()->landingPad.addCatch(c, endbb);
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
583 }
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
584
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
585 gIR->func()->landingPad.push(landingpadbb);
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
586
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
587 //
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
588 // do the try block
314
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
589 //
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
590 p->scope() = IRScope(trybb,landingpadbb);
8d98e42ece93 [svn r335] The basics of exception handling are in place.
ChristianK
parents: 311
diff changeset
591
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
592 assert(body);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
593 body->toIR(p);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
594
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
595 if (!gIR->scopereturned())
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
596 llvm::BranchInst::Create(endbb, p->scopebb());
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
597
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 315
diff changeset
598 gIR->func()->landingPad.pop();
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
599
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
600 // rewrite the scope
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
601 p->scope() = IRScope(endbb,oldend);
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
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
604 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
605
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
606 void ThrowStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
607 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
608 Logger::println("ThrowStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
609 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
610
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
611 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
612 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
613
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
614 assert(exp);
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
615 DValue* e = exp->toElem(p);
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
616 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_throw_exception");
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
617 //Logger::cout() << "calling: " << *fn << '\n';
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
618 LLValue* arg = DtoBitCast(e->getRVal(), fn->getFunctionType()->getParamType(0));
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
619 //Logger::cout() << "arg: " << *arg << '\n';
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 314
diff changeset
620 gIR->CreateCallOrInvoke(fn, arg);
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
621 gIR->ir->CreateUnreachable();
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
622
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
623 // need a block after the throw for now
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
624 llvm::BasicBlock* oldend = gIR->scopeend();
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
625 llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterthrow", p->topfunc(), oldend);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
626 p->scope() = IRScope(bb,oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
627 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
628
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
629 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
630
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
631 // used to build the sorted list of cases
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
632 struct Case : Object
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
633 {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
634 StringExp* str;
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
635 size_t index;
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
636
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
637 Case(StringExp* s, size_t i) {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
638 str = s;
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
639 index = i;
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
640 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
641
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
642 int compare(Object *obj) {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
643 Case* c2 = (Case*)obj;
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
644 return str->compare(c2->str);
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
645 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
646 };
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
647
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
648 static LLValue* call_string_switch_runtime(llvm::GlobalVariable* table, Expression* e)
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
649 {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
650 Type* dt = DtoDType(e->type);
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
651 Type* dtnext = DtoDType(dt->next);
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
652 TY ty = dtnext->ty;
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
653 const char* fname;
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
654 if (ty == Tchar) {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
655 fname = "_d_switch_string";
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
656 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
657 else if (ty == Twchar) {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
658 fname = "_d_switch_ustring";
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
659 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
660 else if (ty == Tdchar) {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
661 fname = "_d_switch_dstring";
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
662 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
663 else {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
664 assert(0 && "not char/wchar/dchar");
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
665 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
666
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
667 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname);
217
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 213
diff changeset
668
197
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
669 Logger::cout() << *table->getType() << '\n';
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
670 Logger::cout() << *fn->getFunctionType()->getParamType(0) << '\n';
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
671 assert(table->getType() == fn->getFunctionType()->getParamType(0));
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
672
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
673 DValue* val = e->toElem(gIR);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
674 LLValue* llval;
197
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
675 if (DSliceValue* sval = val->isSlice())
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
676 {
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
677 // give storage
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
678 llval = new llvm::AllocaInst(DtoType(e->type), "tmp", gIR->topallocapoint());
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
679 DVarValue* vv = new DVarValue(e->type, llval, true);
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 395
diff changeset
680 DtoAssign(e->loc, vv, val);
197
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
681 }
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
682 else
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
683 {
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
684 llval = val->getRVal();
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
685 }
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
686 assert(llval->getType() == fn->getFunctionType()->getParamType(1));
bfcb657756f6 [svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'.
lindquist
parents: 185
diff changeset
687
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 314
diff changeset
688 CallOrInvoke* call = gIR->CreateCallOrInvoke2(fn, table, llval, "tmp");
271
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
689
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
690 llvm::PAListPtr palist;
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
691 palist = palist.addAttr(1, llvm::ParamAttr::ByVal);
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
692 palist = palist.addAttr(2, llvm::ParamAttr::ByVal);
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
693 call->setParamAttrs(palist);
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
694
315
a9697749e898 [svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents: 314
diff changeset
695 return call->get();
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
696 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
697
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
698 void SwitchStatement::toIR(IRState* p)
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
699 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
700 Logger::println("SwitchStatement::toIR(): %s", loc.toChars());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
701 LOG_SCOPE;
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
702
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
703 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
704 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
705
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
706 llvm::BasicBlock* oldend = gIR->scopeend();
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
707
263
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
708 // clear data from previous passes... :/
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
709 for (int i=0; i<cases->dim; ++i)
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
710 {
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
711 CaseStatement* cs = (CaseStatement*)cases->data[i];
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
712 cs->bodyBB = NULL;
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
713 cs->llvmIdx = NULL;
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
714 }
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
715
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
716 // string switch?
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
717 llvm::GlobalVariable* switchTable = 0;
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
718 Array caseArray;
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
719 if (!condition->type->isintegral())
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
720 {
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
721 Logger::println("is string switch");
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
722 // build array of the stringexpS
271
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
723 caseArray.reserve(cases->dim);
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
724 for (int i=0; i<cases->dim; ++i)
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
725 {
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
726 CaseStatement* cs = (CaseStatement*)cases->data[i];
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
727
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
728 assert(cs->exp->op == TOKstring);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
729 caseArray.push(new Case((StringExp*)cs->exp, i));
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
730 }
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
731 // first sort it
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
732 caseArray.sort();
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
733 // iterate and add indices to cases
271
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
734 std::vector<LLConstant*> inits(caseArray.dim);
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
735 for (size_t i=0; i<caseArray.dim; ++i)
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
736 {
271
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
737 Case* c = (Case*)caseArray.data[i];
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
738 CaseStatement* cs = (CaseStatement*)cases->data[c->index];
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
739 cs->llvmIdx = DtoConstUint(i);
271
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
740 inits[i] = c->str->toConstElem(p);
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
741 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
742 // build static array for ptr or final array
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
743 const LLType* elemTy = DtoType(condition->type);
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
744 const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size());
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
745 LLConstant* arrInit = llvm::ConstantArray::get(arrTy, inits);
270
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
746 llvm::GlobalVariable* arr = new llvm::GlobalVariable(arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, ".string_switch_table_data", gIR->module);
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
747
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
748 const LLType* elemPtrTy = getPtrToType(elemTy);
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
749 LLConstant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy);
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
750
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
751 // build the static table
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
752 std::vector<const LLType*> types;
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
753 types.push_back(DtoSize_t());
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
754 types.push_back(elemPtrTy);
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
755 const llvm::StructType* sTy = llvm::StructType::get(types);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
756 std::vector<LLConstant*> sinits;
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
757 sinits.push_back(DtoConstSize_t(inits.size()));
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
758 sinits.push_back(arrPtr);
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
759 LLConstant* sInit = llvm::ConstantStruct::get(sTy, sinits);
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
760
270
d9d5d59873d8 [svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents: 268
diff changeset
761 switchTable = new llvm::GlobalVariable(sTy, true, llvm::GlobalValue::InternalLinkage, sInit, ".string_switch_table", gIR->module);
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
762 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
763
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
764 // body block
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
765 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("switchbody", p->topfunc(), oldend);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
766
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
767 // default
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
768 llvm::BasicBlock* defbb = 0;
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
769 if (sdefault) {
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
770 Logger::println("has default");
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
771 defbb = llvm::BasicBlock::Create("default", p->topfunc(), oldend);
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
772 sdefault->bodyBB = defbb;
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
773 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
774
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
775 // end (break point)
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
776 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("switchend", p->topfunc(), oldend);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
777
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
778 // condition var
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
779 LLValue* condVal;
122
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
780 // integral switch
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
781 if (condition->type->isintegral()) {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
782 DValue* cond = condition->toElem(p);
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
783 condVal = cond->getRVal();
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
784 }
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
785 // string switch
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
786 else {
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
787 condVal = call_string_switch_runtime(switchTable, condition);
36ab367572df [svn r126] String switch is now implemented.
lindquist
parents: 121
diff changeset
788 }
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
789 llvm::SwitchInst* si = llvm::SwitchInst::Create(condVal, defbb ? defbb : endbb, cases->dim, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
790
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
791 // do switch body
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
792 assert(body);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
793
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
794 p->scope() = IRScope(bodybb, endbb);
311
9967a3270837 [svn r332] Fix codegen for continue within switch.
ChristianK
parents: 309
diff changeset
795 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,p->scopebb(),endbb,true));
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
796 body->toIR(p);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
797 p->loopbbs.pop_back();
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
798
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
799 if (!p->scopereturned())
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
800 llvm::BranchInst::Create(endbb, p->scopebb());
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
801
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
802 // add the cases
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
803 for (int i=0; i<cases->dim; ++i)
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
804 {
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
805 CaseStatement* cs = (CaseStatement*)cases->data[i];
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
806 si->addCase(cs->llvmIdx, cs->bodyBB);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
807 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
808
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
809 gIR->scope() = IRScope(endbb,oldend);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
810 }
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
811
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
812 //////////////////////////////////////////////////////////////////////////////
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
813 void CaseStatement::toIR(IRState* p)
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
814 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
815 Logger::println("CaseStatement::toIR(): %s", loc.toChars());
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
816 LOG_SCOPE;
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
817
263
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
818 llvm::BasicBlock* nbb = llvm::BasicBlock::Create("case", p->topfunc(), p->scopeend());
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
819
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
820 if (bodyBB && !bodyBB->getTerminator())
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
821 {
263
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
822 llvm::BranchInst::Create(nbb, bodyBB);
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
823 }
263
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
824 bodyBB = nbb;
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
825
271
1e6e2b5d5bfe [svn r292] Fixed: string switch was broken in several ways.
lindquist
parents: 270
diff changeset
826 if (llvmIdx == NULL) {
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
827 LLConstant* c = exp->toConstElem(p);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
828 llvmIdx = isaConstantInt(c);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
829 }
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
830
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
831 if (!p->scopereturned())
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
832 llvm::BranchInst::Create(bodyBB, p->scopebb());
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
833
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
834 p->scope() = IRScope(bodyBB, p->scopeend());
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
835
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
836 assert(statement);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
837 statement->toIR(p);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
838 }
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
839
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
840 //////////////////////////////////////////////////////////////////////////////
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
841 void DefaultStatement::toIR(IRState* p)
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
842 {
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
843 Logger::println("DefaultStatement::toIR(): %s", loc.toChars());
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
844 LOG_SCOPE;
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
845
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
846 assert(bodyBB);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
847
263
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
848 llvm::BasicBlock* nbb = llvm::BasicBlock::Create("default", p->topfunc(), p->scopeend());
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
849
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
850 if (!bodyBB->getTerminator())
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
851 {
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
852 llvm::BranchInst::Create(nbb, bodyBB);
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
853 }
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
854 bodyBB = nbb;
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
855
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
856 if (!p->scopereturned())
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
857 llvm::BranchInst::Create(bodyBB, p->scopebb());
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
858
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
859 p->scope() = IRScope(bodyBB, p->scopeend());
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
860
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
861 assert(statement);
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
862 statement->toIR(p);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
863 }
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
864
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
865 //////////////////////////////////////////////////////////////////////////////
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
866
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
867 void UnrolledLoopStatement::toIR(IRState* p)
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
868 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
869 Logger::println("UnrolledLoopStatement::toIR(): %s", loc.toChars());
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
870 LOG_SCOPE;
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
871
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
872 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
873 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
874
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
875 llvm::BasicBlock* oldend = gIR->scopeend();
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
876 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("unrolledend", p->topfunc(), oldend);
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
877
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
878 p->scope() = IRScope(p->scopebb(),endbb);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
879 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,p->scopebb(),endbb));
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
880
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
881 for (int i=0; i<statements->dim; ++i)
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
882 {
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
883 Statement* s = (Statement*)statements->data[i];
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
884 s->toIR(p);
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
885 }
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
886
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
887 p->loopbbs.pop_back();
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
888
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
889 llvm::BranchInst::Create(endbb, p->scopebb());
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
890 p->scope() = IRScope(endbb,oldend);
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
891 }
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
892
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
893 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
894
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
895 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
896 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
897 Logger::println("ForeachStatement::toIR(): %s", loc.toChars());
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
898 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
899
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
900 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
901 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
902
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
903 //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
904 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
905 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
906 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
907 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
908
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
909 //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
910 //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
911
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
912 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
913
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
914 // key
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
915 const LLType* keytype = key ? DtoType(key->type) : DtoSize_t();
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
916 LLValue* keyvar = new llvm::AllocaInst(keytype, "foreachkey", p->topallocapoint());
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents: 133
diff changeset
917 if (key)
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents: 133
diff changeset
918 {
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents: 133
diff changeset
919 //key->llvmValue = keyvar;
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
920 assert(!key->ir.irLocal);
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
921 key->ir.irLocal = new IrLocal(key);
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
922 key->ir.irLocal->value = keyvar;
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents: 133
diff changeset
923 }
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
924 LLValue* 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
925
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
926 // value
201
8f9191180c7a [svn r217] Updated: the rebuild profiles.
lindquist
parents: 200
diff changeset
927 Logger::println("value = %s", value->toPrettyChars());
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
928 const LLType* valtype = DtoType(value->type);
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
929 LLValue* valvar = NULL;
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
930 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
931 valvar = new llvm::AllocaInst(valtype, "foreachval", p->topallocapoint());
201
8f9191180c7a [svn r217] Updated: the rebuild profiles.
lindquist
parents: 200
diff changeset
932 if (!value->ir.irLocal)
8f9191180c7a [svn r217] Updated: the rebuild profiles.
lindquist
parents: 200
diff changeset
933 value->ir.irLocal = new IrLocal(value);
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
934
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
935 // what to iterate
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
936 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
937 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
938
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
939 // get length and pointer
308
6b62e8cdf970 [svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents: 305
diff changeset
940 LLValue* niters = DtoArrayLen(aggrval);
6b62e8cdf970 [svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents: 305
diff changeset
941 LLValue* val = DtoArrayPtr(aggrval);
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
942
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
943 if (niters->getType() != keytype)
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
944 {
133
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
945 size_t sz1 = getTypeBitSize(niters->getType());
44a95ac7368a [svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents: 132
diff changeset
946 size_t sz2 = getTypeBitSize(keytype);
109
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
947 if (sz1 < sz2)
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
948 niters = gIR->ir->CreateZExt(niters, keytype, "foreachtrunckey");
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
949 else if (sz1 > sz2)
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
950 niters = gIR->ir->CreateTrunc(niters, keytype, "foreachtrunckey");
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
951 else
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
952 niters = gIR->ir->CreateBitCast(niters, keytype, "foreachtrunckey");
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
953 }
5ab8e92611f9 [svn r113] Added initial support for associative arrays (AAs).
lindquist
parents: 108
diff changeset
954
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
955 LLConstant* delta = 0;
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
956 if (op == TOKforeach) {
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
957 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
958 }
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
959 else {
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
960 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
961 }
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
962
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
963 llvm::BasicBlock* oldend = gIR->scopeend();
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
964 llvm::BasicBlock* condbb = llvm::BasicBlock::Create("foreachcond", p->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
965 llvm::BasicBlock* bodybb = llvm::BasicBlock::Create("foreachbody", p->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
966 llvm::BasicBlock* nextbb = llvm::BasicBlock::Create("foreachnext", p->topfunc(), oldend);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
967 llvm::BasicBlock* endbb = llvm::BasicBlock::Create("foreachend", 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
968
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
969 llvm::BranchInst::Create(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
970
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
971 // condition
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
972 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
973
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
974 LLValue* done = 0;
244
a95056b3c996 [svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB.
lindquist
parents: 234
diff changeset
975 LLValue* load = DtoLoad(keyvar);
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
976 if (op == TOKforeach) {
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 364
diff changeset
977 done = p->ir->CreateICmpULT(load, niters, "tmp");
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
978 }
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
979 else if (op == TOKforeach_reverse) {
365
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 364
diff changeset
980 done = p->ir->CreateICmpUGT(load, zerokey, "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 364
diff changeset
981 load = p->ir->CreateSub(load, llvm::ConstantInt::get(keytype, 1, false), "tmp");
bfb9d28f045a [svn r386] Fixed broken DtoBoolean.
lindquist
parents: 364
diff changeset
982 DtoStore(load, keyvar);
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
983 }
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
984 llvm::BranchInst::Create(bodybb, endbb, done, p->scopebb());
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
985
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
986 // init body
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
987 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
988
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
989 // get value for this iteration
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
990 LLConstant* zero = llvm::ConstantInt::get(keytype,0,false);
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
991 LLValue* loadedKey = p->ir->CreateLoad(keyvar,"tmp");
308
6b62e8cdf970 [svn r329] Cleaned up a bunch of array code for handling special slice cases no
lindquist
parents: 305
diff changeset
992 value->ir.irLocal->value = DtoGEP1(val,loadedKey);
51
61bc1b4ad3c4 [svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents: 45
diff changeset
993
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
994 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
995 DValue* dst = new DVarValue(value->type, valvar, true);
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
996 DValue* src = new DVarValue(value->type, value->ir.irLocal->value, true);
399
0e6b4d65d3f8 Give error messages for invalid casts.
Christian Kamm <kamm incasoftware de>
parents: 395
diff changeset
997 DtoAssign(loc, dst, src);
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
998 value->ir.irLocal->value = valvar;
51
61bc1b4ad3c4 [svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents: 45
diff changeset
999 }
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
1000
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
1001 // emit body
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1002 p->loopbbs.push_back(IRLoopScope(this,enclosinghandler,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
1003 body->toIR(p);
33
bc641b23a714 [svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents: 32
diff changeset
1004 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
1005
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1006 if (!p->scopereturned())
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1007 llvm::BranchInst::Create(nextbb, p->scopebb());
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1008
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1009 // next
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1010 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
1011 if (op == TOKforeach) {
213
7816aafeea3c [svn r229] Updated the object.d implementation to the latest Tango.
lindquist
parents: 206
diff changeset
1012 LLValue* load = DtoLoad(keyvar);
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1013 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
1014 DtoStore(load, keyvar);
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1015 }
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1016 llvm::BranchInst::Create(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
1017
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
1018 // 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
1019 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
1020 }
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
1021
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
1022 //////////////////////////////////////////////////////////////////////////////
a86fe7496b58 [svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents: 15
diff changeset
1023
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1024 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
1025 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1026 Logger::println("LabelStatement::toIR(): %s", loc.toChars());
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1027 LOG_SCOPE;
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1028
232
092468448d25 [svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents: 219
diff changeset
1029 // if it's an inline asm label, we don't create a basicblock, just emit it in the asm
233
76ee1bbe487e [svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents: 232
diff changeset
1030 if (p->asmBlock)
232
092468448d25 [svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents: 219
diff changeset
1031 {
092468448d25 [svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents: 219
diff changeset
1032 IRAsmStmt* a = new IRAsmStmt;
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
1033 a->code += p->func()->decl->mangle();
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
1034 a->code += "_";
232
092468448d25 [svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents: 219
diff changeset
1035 a->code += ident->toChars();
092468448d25 [svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents: 219
diff changeset
1036 a->code += ":";
233
76ee1bbe487e [svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents: 232
diff changeset
1037 p->asmBlock->s.push_back(a);
299
df8a7b8d5929 [svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents: 298
diff changeset
1038 p->asmBlock->internalLabels.push_back(ident);
298
3b8ada4c9f8b [svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents: 271
diff changeset
1039 }
3b8ada4c9f8b [svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents: 271
diff changeset
1040 else
3b8ada4c9f8b [svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents: 271
diff changeset
1041 {
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
1042 std::string labelname = p->func()->getScopedLabelName(ident->toChars());
353
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1043 llvm::BasicBlock*& labelBB = p->func()->labelToBB[labelname];
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1044
298
3b8ada4c9f8b [svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents: 271
diff changeset
1045 llvm::BasicBlock* oldend = gIR->scopeend();
353
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1046 if (labelBB != NULL) {
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1047 labelBB->moveBefore(oldend);
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1048 } else {
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1049 labelBB = llvm::BasicBlock::Create("label", p->topfunc(), oldend);
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1050 }
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
1051
298
3b8ada4c9f8b [svn r319] Call substatement->toIR in LabelStatement::toIR even when the label is inside an asm block.
ChristianK
parents: 271
diff changeset
1052 if (!p->scopereturned())
353
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1053 llvm::BranchInst::Create(labelBB, p->scopebb());
305
2b72433d5c8c [svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents: 304
diff changeset
1054
353
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 352
diff changeset
1055 p->scope() = IRScope(labelBB,oldend);
232
092468448d25 [svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents: 219
diff changeset
1056 }
092468448d25 [svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents: 219
diff changeset
1057
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
1058 if (statement)
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
1059 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
1060 }
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1061
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1062 //////////////////////////////////////////////////////////////////////////////
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1063
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1064 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
1065 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1066 Logger::println("GotoStatement::toIR(): %s", loc.toChars());
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1067 LOG_SCOPE;
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1068
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1069 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1070 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1071
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1072 llvm::BasicBlock* oldend = gIR->scopeend();
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1073 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergoto", p->topfunc(), oldend);
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1074
356
44daf304421c [svn r377] The previous check was too strict, it completely disallowed gotos within finally blocks. This reenables them as long as they don't cross a finally boundary.
ChristianK
parents: 355
diff changeset
1075 DtoGoto(&loc, label->ident, enclosinghandler, tf);
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1076
37
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1077 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
1078 }
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1079
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1080 //////////////////////////////////////////////////////////////////////////////
77cdca8c210f [svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents: 34
diff changeset
1081
144
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1082 void GotoDefaultStatement::toIR(IRState* p)
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1083 {
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1084 Logger::println("GotoDefaultStatement::toIR(): %s", loc.toChars());
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1085 LOG_SCOPE;
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1086
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1087 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1088 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1089
144
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1090 llvm::BasicBlock* oldend = gIR->scopeend();
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1091 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergotodefault", p->topfunc(), oldend);
144
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1092
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1093 assert(!p->scopereturned());
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1094 assert(sw->sdefault->bodyBB);
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1095
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1096 DtoEnclosingHandlers(enclosinghandler, sw->enclosinghandler);
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1097
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1098 llvm::BranchInst::Create(sw->sdefault->bodyBB, p->scopebb());
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1099 p->scope() = IRScope(bb,oldend);
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1100 }
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1101
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1102 //////////////////////////////////////////////////////////////////////////////
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1103
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1104 void GotoCaseStatement::toIR(IRState* p)
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1105 {
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1106 Logger::println("GotoCaseStatement::toIR(): %s", loc.toChars());
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1107 LOG_SCOPE;
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1108
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1109 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1110 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1111
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1112 llvm::BasicBlock* oldend = gIR->scopeend();
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1113 llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergotocase", p->topfunc(), oldend);
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1114
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1115 assert(!p->scopereturned());
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
1116 if (!cs->bodyBB)
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
1117 {
263
2be09ee06bc7 [svn r284] Fixed some problems with cases, code is not as pretty, but it doesn't crash llvm!
lindquist
parents: 262
diff changeset
1118 cs->bodyBB = llvm::BasicBlock::Create("goto_case", p->topfunc(), p->scopeend());
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
1119 }
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1120
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1121 DtoEnclosingHandlers(enclosinghandler, sw->enclosinghandler);
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1122
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1123 llvm::BranchInst::Create(cs->bodyBB, p->scopebb());
144
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1124 p->scope() = IRScope(bb,oldend);
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1125 }
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1126
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1127 //////////////////////////////////////////////////////////////////////////////
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1128
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1129 void WithStatement::toIR(IRState* p)
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1130 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1131 Logger::println("WithStatement::toIR(): %s", loc.toChars());
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1132 LOG_SCOPE;
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1133
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1134 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1135 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1136
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1137 assert(exp);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1138 assert(body);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1139
86
fd32135dca3e [svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents: 82
diff changeset
1140 DValue* e = exp->toElem(p);
175
c44e6a711885 [svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents: 173
diff changeset
1141 assert(!wthis->ir.isSet());
c44e6a711885 [svn r191] Fixed: array literals did not support all type/storage combinations.
lindquist
parents: 173
diff changeset
1142 wthis->ir.irLocal = new IrLocal(wthis);
173
db9890b3fb64 [svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents: 163
diff changeset
1143 wthis->ir.irLocal->value = e->getRVal();
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1144
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1145 body->toIR(p);
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1146 }
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1147
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1148 //////////////////////////////////////////////////////////////////////////////
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1149
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1150 static LLConstant* generate_unique_critical_section()
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1151 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1152 const LLType* Mty = DtoMutexType();
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1153 return new llvm::GlobalVariable(Mty, false, llvm::GlobalValue::InternalLinkage, LLConstant::getNullValue(Mty), ".uniqueCS", gIR->module);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1154 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1155
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1156 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
1157 {
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1158 Logger::println("SynchronizedStatement::toIR(): %s", loc.toChars());
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1159 LOG_SCOPE;
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1160
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1161 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1162 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1163
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1164 // enter lock
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1165 if (exp)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1166 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1167 llsync = exp->toElem(p)->getRVal();
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1168 DtoEnterMonitor(llsync);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1169 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1170 else
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1171 {
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1172 llsync = generate_unique_critical_section();
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1173 DtoEnterCritical(llsync);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1174 }
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1175
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1176 // emit body
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1177 body->toIR(p);
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1178
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1179 // exit lock
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1180 // no point in a unreachable unlock, terminating statements must insert this themselves.
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1181 if (p->scopereturned())
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1182 return;
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1183 else if (exp)
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1184 DtoLeaveMonitor(llsync);
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1185 else
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1186 DtoLeaveCritical(llsync);
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1187 }
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1188
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1189 //////////////////////////////////////////////////////////////////////////////
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1190
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1191 void VolatileStatement::toIR(IRState* p)
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1192 {
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1193 Logger::println("VolatileStatement::toIR(): %s", loc.toChars());
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1194 LOG_SCOPE;
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1195
268
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1196 if (global.params.symdebug)
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1197 DtoDwarfStopPoint(loc.linnum);
23d0d9855cad [svn r289] Fixed: right shift >> was broken for unsigned types.
lindquist
parents: 267
diff changeset
1198
206
cd2c9f4010e4 [svn r222] Forgot to remove volatile ATTENTION.
lindquist
parents: 205
diff changeset
1199 // mark in-volatile
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1200 // FIXME
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1201
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1202 // has statement
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1203 if (statement != NULL)
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1204 {
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1205 // load-store
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1206 DtoMemoryBarrier(false, true, false, false);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1207
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1208 // do statement
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1209 statement->toIR(p);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1210
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1211 // no point in a unreachable barrier, terminating statements must insert this themselves.
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1212 if (statement->fallOffEnd())
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1213 {
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1214 // store-load
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1215 DtoMemoryBarrier(false, false, true, false);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1216 }
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1217 }
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1218 // barrier only
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1219 else
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1220 {
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1221 // load-store & store-load
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1222 DtoMemoryBarrier(false, true, true, false);
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1223 }
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1224
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 201
diff changeset
1225 // restore volatile state
309
d59c363fccad [svn r330] Implemented synchronized statements.
lindquist
parents: 308
diff changeset
1226 // FIXME
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1227 }
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1228
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1229 //////////////////////////////////////////////////////////////////////////////
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1230
331
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1231 void SwitchErrorStatement::toIR(IRState* p)
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1232 {
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1233 Logger::println("SwitchErrorStatement::toIR(): %s", loc.toChars());
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1234 LOG_SCOPE;
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1235
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1236 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_switch_error");
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1237
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1238 // param attrs
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1239 llvm::PAListPtr palist;
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1240 int idx = 1;
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1241
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1242 std::vector<LLValue*> args;
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1243 LLConstant* c;
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1244
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1245 // file param
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1246 // FIXME: every use creates a global for the filename !!!
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1247 c = DtoConstString(loc.filename);
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1248 llvm::AllocaInst* alloc = gIR->func()->srcfileArg;
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1249 if (!alloc)
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1250 {
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1251 alloc = new llvm::AllocaInst(c->getType(), ".srcfile", gIR->topallocapoint());
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1252 gIR->func()->srcfileArg = alloc;
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1253 }
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1254 LLValue* ptr = DtoGEPi(alloc, 0,0, "tmp");
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1255 DtoStore(c->getOperand(0), ptr);
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1256 ptr = DtoGEPi(alloc, 0,1, "tmp");
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1257 DtoStore(c->getOperand(1), ptr);
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1258
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1259 args.push_back(alloc);
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1260 palist = palist.addAttr(idx++, llvm::ParamAttr::ByVal);
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1261
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1262 // line param
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1263 c = DtoConstUint(loc.linnum);
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1264 args.push_back(c);
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1265
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1266 // call
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1267 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end());
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1268 call->setParamAttrs(palist);
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1269
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1270 gIR->ir->CreateUnreachable();
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1271 }
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1272
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1273 //////////////////////////////////////////////////////////////////////////////
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1274
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
1275 //////////////////////////////////////////////////////////////////////////////
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
1276
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1277 #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
1278 //STUBST(BreakStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1279 //STUBST(ForStatement);
40
8b0e809563df [svn r44] Lots of bug fixes.
lindquist
parents: 37
diff changeset
1280 //STUBST(WithStatement);
94
61615fa85940 [svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents: 86
diff changeset
1281 //STUBST(SynchronizedStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1282 //STUBST(ReturnStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1283 //STUBST(ContinueStatement);
262
88252a1af660 [svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents: 244
diff changeset
1284 //STUBST(DefaultStatement);
108
288fe1029e1f [svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents: 100
diff changeset
1285 //STUBST(CaseStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1286 //STUBST(SwitchStatement);
331
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 319
diff changeset
1287 //STUBST(SwitchErrorStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1288 STUBST(Statement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1289 //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
1290 //STUBST(ForeachStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1291 //STUBST(DoStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1292 //STUBST(WhileStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1293 //STUBST(ExpStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1294 //STUBST(CompoundStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1295 //STUBST(ScopeStatement);
131
5825d48b27d1 [svn r135] * Merged DMD 1.025 *
lindquist
parents: 123
diff changeset
1296 //STUBST(AsmStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1297 //STUBST(TryCatchStatement);
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1298 //STUBST(TryFinallyStatement);
132
1700239cab2e [svn r136] MAJOR UNSTABLE UPDATE!!!
lindquist
parents: 131
diff changeset
1299 //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
1300 //STUBST(LabelStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1301 //STUBST(ThrowStatement);
145
8f704cb9969b [svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents: 144
diff changeset
1302 //STUBST(GotoCaseStatement);
144
a27941d00351 [svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents: 137
diff changeset
1303 //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
1304 //STUBST(GotoStatement);
15
37a4fdab33fc [svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents: 14
diff changeset
1305 //STUBST(UnrolledLoopStatement);
14
0e86428ee567 [svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff changeset
1306 //STUBST(OnScopeStatement);