Mercurial > projects > ldc
annotate gen/statements.cpp @ 169:2df270e1ba59 trunk
[svn r185] Fixed broken nested classes with data members, did DMD change the class layout? tango.text.Regex now compiles.
Commented some of the *very* verbose logging for -vv option.
author | lindquist |
---|---|
date | Tue, 06 May 2008 03:07:21 +0200 |
parents | a8cd9bc1021a |
children | db9890b3fb64 |
rev | line source |
---|---|
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1 // Statements: D -> LLVM glue |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
2 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
3 #include <stdio.h> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
4 #include <math.h> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
5 #include <sstream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
6 #include <fstream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
7 #include <iostream> |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
8 |
40 | 9 #include "gen/llvm.h" |
131 | 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 | 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" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
23 #include "gen/runtime.h" |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
24 #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
|
25 #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
|
26 #include "gen/dvalue.h" |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
27 |
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
|
28 #include "ir/irfunction.h" |
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 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
30 ////////////////////////////////////////////////////////////////////////////// |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
31 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
32 void CompoundStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
33 { |
132 | 34 Logger::println("CompoundStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
35 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
36 |
34 | 37 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
|
38 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
39 Statement* s = (Statement*)statements->data[i]; |
132 | 40 if (s) { |
34 | 41 s->toIR(p); |
42 } | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
43 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
44 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
45 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
46 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
47 |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
48 // generates IR for finally blocks between the 'start' and 'end' statements |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
49 // will begin with the finally block belonging to 'start' and does not include |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
50 // the finally block of 'end' |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
51 void emit_finallyblocks(IRState* p, TryFinallyStatement* start, TryFinallyStatement* end) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
52 { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
53 // verify that end encloses start |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
54 TryFinallyStatement* endfinally = start; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
55 while(endfinally != NULL && endfinally != end) { |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
56 endfinally = endfinally->enclosingtryfinally; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
57 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
58 assert(endfinally == end); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
59 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
60 // emit code for finallys between start and end |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
61 TryFinallyStatement* tf = start; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
62 while(tf != end) { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
63 tf->finalbody->toIR(p); |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
64 tf = tf->enclosingtryfinally; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
65 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
66 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
67 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
68 ////////////////////////////////////////////////////////////////////////////// |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
69 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
70 void ReturnStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
71 { |
132 | 72 Logger::println("ReturnStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
73 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
74 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
75 if (exp) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
76 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
77 if (p->topfunc()->getReturnType() == llvm::Type::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
|
78 IrFunction* f = p->func(); |
121
9c79b61fb638
[svn r125] Renamed/moved a few backend member inside DMD structures for consistency.
lindquist
parents:
109
diff
changeset
|
79 assert(f->type->llvmRetInPtr); |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
80 assert(gIR->irDsymbol[f->decl].irFunc->retArg); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
81 |
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
|
82 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
|
83 |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
84 DValue* rvar = new DVarValue(f->type->next, gIR->irDsymbol[f->decl].irFunc->retArg, true); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
85 |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
86 p->exps.push_back(IRExp(NULL,exp,rvar)); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
87 DValue* e = exp->toElem(p); |
54
28e99b04a132
[svn r58] Fixed cond expression resulting in a non-basic type.
lindquist
parents:
51
diff
changeset
|
88 p->exps.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
89 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
90 if (!e->inPlace()) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
91 DtoAssign(rvar, e); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
92 |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
93 emit_finallyblocks(p, enclosingtryfinally, NULL); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
94 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
95 if (global.params.symdebug) DtoDwarfFuncEnd(f->decl); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
96 new llvm::ReturnInst(p->scopebb()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
97 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
98 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
99 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
|
100 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
|
101 DValue* e = exp->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
102 llvm::Value* v = e->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
103 delete e; |
40 | 104 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
|
105 |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
106 emit_finallyblocks(p, enclosingtryfinally, NULL); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
107 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
108 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
109 new llvm::ReturnInst(v, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
110 } |
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 else |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
113 { |
40 | 114 if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) { |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
115 emit_finallyblocks(p, enclosingtryfinally, NULL); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
116 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
117 if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
118 new llvm::ReturnInst(p->scopebb()); |
40 | 119 } |
120 else { | |
121 assert(0); // why should this ever happen? | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
122 new llvm::UnreachableInst(p->scopebb()); |
40 | 123 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
124 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
125 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
126 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
127 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
128 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
129 void ExpStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
130 { |
132 | 131 Logger::println("ExpStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
132 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
133 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
134 if (global.params.symdebug) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
135 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
|
136 |
137 | 137 if (exp) { |
138 if (global.params.llvmAnnotate) | |
139 DtoAnnotation(exp->toChars()); | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
140 elem* e = exp->toElem(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
141 delete e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
142 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
143 /*elem* e = exp->toElem(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
144 p->buf.printf("%s", e->toChars()); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
145 delete e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
146 p->buf.writenl();*/ |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
147 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
148 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
149 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
150 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
151 void IfStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
152 { |
132 | 153 Logger::println("IfStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
154 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
155 |
163
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
156 if (match) |
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
157 { |
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
158 llvm::Value* allocainst = new llvm::AllocaInst(DtoType(match->type), "._tmp_if_var", p->topallocapoint()); |
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
159 gIR->irDsymbol[match].irLocal = new IrLocal(match); |
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
160 gIR->irDsymbol[match].irLocal->value = allocainst; |
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
161 } |
a8cd9bc1021a
[svn r179] lots and lots of fixes, much more of tango now compiles/works.
lindquist
parents:
156
diff
changeset
|
162 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
163 DValue* cond_e = condition->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
164 llvm::Value* cond_val = cond_e->getRVal(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
165 delete cond_e; |
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 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
168 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
169 llvm::BasicBlock* ifbb = new llvm::BasicBlock("if", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
170 llvm::BasicBlock* endbb = new llvm::BasicBlock("endif", gIR->topfunc(), oldend); |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
171 llvm::BasicBlock* elsebb = elsebody ? new llvm::BasicBlock("else", gIR->topfunc(), endbb) : endbb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
172 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
173 if (cond_val->getType() != llvm::Type::Int1Ty) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
174 Logger::cout() << "if conditional: " << *cond_val << '\n'; |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
175 cond_val = DtoBoolean(cond_val); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
176 } |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
177 llvm::Value* ifgoback = new llvm::BranchInst(ifbb, elsebb, cond_val, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
178 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
179 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
180 gIR->scope() = IRScope(ifbb,elsebb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
181 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
182 // do scoped statements |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
183 ifbody->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
184 if (!gIR->scopereturned()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
185 new llvm::BranchInst(endbb,gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
186 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
187 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
188 if (elsebody) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
189 //assert(0); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
190 gIR->scope() = IRScope(elsebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
191 elsebody->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
192 if (!gIR->scopereturned()) { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
193 new llvm::BranchInst(endbb,gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
194 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
195 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
196 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
197 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
198 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
199 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
200 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
201 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
202 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
203 void ScopeStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
204 { |
132 | 205 Logger::println("ScopeStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
206 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
207 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
208 llvm::BasicBlock* oldend = p->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
209 |
40 | 210 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
|
211 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
212 // 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
|
213 llvm::BasicBlock* bb = p->scopebb(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
214 if (bb->empty()) { |
40 | 215 beginbb = bb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
216 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
217 else { |
40 | 218 assert(!p->scopereturned()); |
219 beginbb = new llvm::BasicBlock("scope", p->topfunc(), oldend); | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
220 new llvm::BranchInst(beginbb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
221 } |
40 | 222 llvm::BasicBlock* endbb = new llvm::BasicBlock("endscope", p->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
223 |
40 | 224 gIR->scope() = IRScope(beginbb, endbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
225 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
226 statement->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
227 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
228 p->scope() = IRScope(p->scopebb(),oldend); |
40 | 229 endbb->eraseFromParent(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
230 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
231 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
232 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
233 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
234 void WhileStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
235 { |
132 | 236 Logger::println("WhileStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
237 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
238 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
239 // create while blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
240 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
241 llvm::BasicBlock* whilebb = new llvm::BasicBlock("whilecond", gIR->topfunc(), oldend); |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
242 llvm::BasicBlock* whilebodybb = new llvm::BasicBlock("whilebody", gIR->topfunc(), oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
243 llvm::BasicBlock* endbb = new llvm::BasicBlock("endwhile", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
244 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
245 // move into the while block |
40 | 246 p->ir->CreateBr(whilebb); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
247 //new llvm::BranchInst(whilebb, gIR->scopebb()); |
14
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 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
250 gIR->scope() = IRScope(whilebb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
251 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
252 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
253 DValue* cond_e = condition->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
254 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
255 delete cond_e; |
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 // conditional branch |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
258 llvm::Value* ifbreak = new llvm::BranchInst(whilebodybb, endbb, cond_val, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
259 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
260 // rewrite scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
261 gIR->scope() = IRScope(whilebodybb,endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
262 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
263 // while body code |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
264 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,whilebb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
265 body->toIR(p); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
266 p->loopbbs.pop_back(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
267 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
268 // loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
269 if (!gIR->scopereturned()) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
270 new llvm::BranchInst(whilebb, gIR->scopebb()); |
14
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 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
273 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
274 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
275 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
276 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
277 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
278 void DoStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
279 { |
132 | 280 Logger::println("DoStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
281 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
282 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
283 // 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(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
285 llvm::BasicBlock* dowhilebb = new llvm::BasicBlock("dowhile", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
286 llvm::BasicBlock* endbb = new llvm::BasicBlock("enddowhile", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
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()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
290 new llvm::BranchInst(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 |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
296 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,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); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
302 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
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 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
306 llvm::Value* ifbreak = new llvm::BranchInst(dowhilebb, endbb, cond_val, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
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 | 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 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
319 // create for blocks |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
320 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
321 llvm::BasicBlock* forbb = new llvm::BasicBlock("forcond", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
322 llvm::BasicBlock* forbodybb = new llvm::BasicBlock("forbody", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
323 llvm::BasicBlock* forincbb = new llvm::BasicBlock("forinc", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
324 llvm::BasicBlock* endbb = new llvm::BasicBlock("endfor", gIR->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
325 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
326 // init |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
327 if (init != 0) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
328 init->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
329 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
330 // 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
|
331 assert(!gIR->scopereturned()); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
332 new llvm::BranchInst(forbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
333 |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
334 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,forincbb,endbb)); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
335 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
336 // replace current scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
337 gIR->scope() = IRScope(forbb,forbodybb); |
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 // create the condition |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
340 DValue* cond_e = condition->toElem(p); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
341 llvm::Value* cond_val = DtoBoolean(cond_e->getRVal()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
342 delete cond_e; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
343 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
344 // conditional branch |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
345 assert(!gIR->scopereturned()); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
346 new llvm::BranchInst(forbodybb, endbb, cond_val, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
347 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
348 // rewrite scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
349 gIR->scope() = IRScope(forbodybb,forincbb); |
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 // do for body code |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
352 body->toIR(p); |
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 // move into the for increment block |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
355 if (!gIR->scopereturned()) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
356 new llvm::BranchInst(forincbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
357 gIR->scope() = IRScope(forincbb, endbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
358 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
359 // increment |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
360 if (increment) { |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
361 DValue* inc = increment->toElem(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
362 delete inc; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
363 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
364 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
365 // loop |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
366 if (!gIR->scopereturned()) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
367 new llvm::BranchInst(forbb, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
368 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
369 p->loopbbs.pop_back(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
370 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
371 // rewrite the scope |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
372 gIR->scope() = IRScope(endbb,oldend); |
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 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
375 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
376 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
377 void BreakStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
378 { |
132 | 379 Logger::println("BreakStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
380 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
381 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
382 if (ident != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
383 Logger::println("ident = %s", ident->toChars()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
384 |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
385 emit_finallyblocks(p, enclosingtryfinally, target->enclosingtryfinally); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
386 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
387 // get the loop statement the label refers to |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
388 Statement* targetLoopStatement = target->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
389 ScopeStatement* tmp; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
390 while(tmp = targetLoopStatement->isScopeStatement()) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
391 targetLoopStatement = tmp->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
392 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
393 // find the right break block and jump there |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
394 IRState::LoopScopeVec::reverse_iterator it; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
395 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
396 if(it->s == targetLoopStatement) { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
397 new llvm::BranchInst(it->end, gIR->scopebb()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
398 return; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
399 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
400 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
401 assert(0); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
402 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
403 else { |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
404 emit_finallyblocks(p, enclosingtryfinally, gIR->loopbbs.back().enclosingtryfinally); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
405 new llvm::BranchInst(gIR->loopbbs.back().end, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
406 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
407 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
408 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
409 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
410 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
411 void ContinueStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
412 { |
132 | 413 Logger::println("ContinueStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
414 LOG_SCOPE; |
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 if (ident != 0) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
417 Logger::println("ident = %s", ident->toChars()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
418 |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
419 emit_finallyblocks(p, enclosingtryfinally, target->enclosingtryfinally); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
420 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
421 // get the loop statement the label refers to |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
422 Statement* targetLoopStatement = target->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
423 ScopeStatement* tmp; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
424 while(tmp = targetLoopStatement->isScopeStatement()) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
425 targetLoopStatement = tmp->statement; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
426 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
427 // find the right continue block and jump there |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
428 IRState::LoopScopeVec::reverse_iterator it; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
429 for(it = gIR->loopbbs.rbegin(); it != gIR->loopbbs.rend(); ++it) { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
430 if(it->s == targetLoopStatement) { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
431 new llvm::BranchInst(it->begin, gIR->scopebb()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
432 return; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
433 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
434 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
435 assert(0); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
436 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
437 else { |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
438 emit_finallyblocks(p, enclosingtryfinally, gIR->loopbbs.back().enclosingtryfinally); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
439 new llvm::BranchInst(gIR->loopbbs.back().begin, gIR->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
440 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
441 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
442 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
443 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
444 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
445 void OnScopeStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
446 { |
132 | 447 Logger::println("OnScopeStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
448 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
449 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
450 assert(statement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
451 //statement->toIR(p); // this seems to be redundant |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
452 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
453 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
454 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
455 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
456 void TryFinallyStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
457 { |
132 | 458 Logger::println("TryFinallyStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
459 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
460 |
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
|
461 // create basic blocks |
40 | 462 llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
463 |
40 | 464 llvm::BasicBlock* trybb = new llvm::BasicBlock("try", p->topfunc(), oldend); |
465 llvm::BasicBlock* finallybb = new llvm::BasicBlock("finally", p->topfunc(), oldend); | |
466 llvm::BasicBlock* endbb = new llvm::BasicBlock("endtryfinally", p->topfunc(), oldend); | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
467 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
468 // 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
|
469 assert(!gIR->scopereturned()); |
40 | 470 new llvm::BranchInst(trybb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
471 |
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
|
472 // do the try block |
40 | 473 p->scope() = IRScope(trybb,finallybb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
474 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
475 assert(body); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
476 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
|
477 |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
478 // 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
|
479 if (!p->scopereturned()) |
40 | 480 new llvm::BranchInst(finallybb, p->scopebb()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
481 |
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
|
482 // do finally block |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
483 p->scope() = IRScope(finallybb,endbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
484 assert(finalbody); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
485 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
|
486 |
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
|
487 // terminate finally |
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
488 if (!gIR->scopereturned()) { |
40 | 489 new llvm::BranchInst(endbb, p->scopebb()); |
490 } | |
491 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
492 // rewrite the scope |
40 | 493 p->scope() = IRScope(endbb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
494 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
495 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
496 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
497 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
498 void TryCatchStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
499 { |
132 | 500 Logger::println("TryCatchStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
501 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
502 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
503 Logger::attention(loc, "try-catch is not yet fully implemented"); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
504 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
505 // create basic blocks |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
506 llvm::BasicBlock* oldend = p->scopeend(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
507 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
508 llvm::BasicBlock* trybb = new llvm::BasicBlock("try", p->topfunc(), oldend); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
509 llvm::BasicBlock* catchbb = new llvm::BasicBlock("catch", p->topfunc(), oldend); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
510 llvm::BasicBlock* endbb = new llvm::BasicBlock("endtrycatch", p->topfunc(), oldend); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
511 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
512 // 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
|
513 assert(!gIR->scopereturned()); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
514 new llvm::BranchInst(trybb, p->scopebb()); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
515 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
516 // do the try block |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
517 p->scope() = IRScope(trybb,catchbb); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
518 assert(body); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
519 body->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
520 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
521 if (!gIR->scopereturned()) |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
522 new llvm::BranchInst(endbb, p->scopebb()); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
523 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
524 // do catch |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
525 p->scope() = IRScope(catchbb,oldend); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
526 new llvm::BranchInst(endbb, p->scopebb()); |
34 | 527 /*assert(catches); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
528 for(size_t i=0; i<catches->dim; ++i) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
529 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
530 Catch* c = (Catch*)catches->data[i]; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
531 c->handler->toIR(p); |
34 | 532 }*/ |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
533 |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
534 // rewrite the scope |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
535 p->scope() = IRScope(endbb,oldend); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
536 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
537 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
538 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
539 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
540 void ThrowStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
541 { |
132 | 542 Logger::println("ThrowStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
543 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
544 |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
545 Logger::attention(loc, "throw is not yet fully implemented"); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
546 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
547 assert(exp); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
548 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
|
549 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
|
550 //Logger::cout() << "calling: " << *fn << '\n'; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
551 llvm::Value* arg = DtoBitCast(e->getRVal(), fn->getFunctionType()->getParamType(0)); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
552 //Logger::cout() << "arg: " << *arg << '\n'; |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
553 gIR->ir->CreateCall(fn, arg, ""); |
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
554 gIR->ir->CreateUnreachable(); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
555 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
556 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
557 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
558 |
122 | 559 // used to build the sorted list of cases |
560 struct Case : Object | |
561 { | |
562 StringExp* str; | |
563 size_t index; | |
564 | |
565 Case(StringExp* s, size_t i) { | |
566 str = s; | |
567 index = i; | |
568 } | |
569 | |
570 int compare(Object *obj) { | |
571 Case* c2 = (Case*)obj; | |
572 return str->compare(c2->str); | |
573 } | |
574 }; | |
575 | |
576 static llvm::Value* call_string_switch_runtime(llvm::GlobalVariable* table, Expression* e) | |
577 { | |
578 Type* dt = DtoDType(e->type); | |
579 Type* dtnext = DtoDType(dt->next); | |
580 TY ty = dtnext->ty; | |
581 const char* fname; | |
582 if (ty == Tchar) { | |
583 fname = "_d_switch_string"; | |
584 } | |
585 else if (ty == Twchar) { | |
586 fname = "_d_switch_ustring"; | |
587 } | |
588 else if (ty == Tdchar) { | |
589 fname = "_d_switch_dstring"; | |
590 } | |
591 else { | |
592 assert(0 && "not char/wchar/dchar"); | |
593 } | |
594 | |
595 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname); | |
596 std::vector<llvm::Value*> args; | |
597 args.push_back(table); | |
598 args.push_back(e->toElem(gIR)->getRVal()); | |
599 return gIR->ir->CreateCall(fn, args.begin(), args.end(), "tmp"); | |
600 } | |
601 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
602 void SwitchStatement::toIR(IRState* p) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
603 { |
132 | 604 Logger::println("SwitchStatement::toIR(): %s", loc.toChars()); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
605 LOG_SCOPE; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
606 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
607 llvm::BasicBlock* oldend = gIR->scopeend(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
608 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
609 // collect the needed cases |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
610 typedef std::pair<llvm::BasicBlock*, std::vector<llvm::ConstantInt*> > CasePair; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
611 std::vector<CasePair> vcases; |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
612 std::vector<Statement*> vbodies; |
122 | 613 Array caseArray; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
614 for (int i=0; i<cases->dim; ++i) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
615 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
616 CaseStatement* cs = (CaseStatement*)cases->data[i]; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
617 |
122 | 618 std::string lblname("case"); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
619 llvm::BasicBlock* bb = new llvm::BasicBlock(lblname, p->topfunc(), oldend); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
620 cs->bodyBB = bb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
621 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
622 std::vector<llvm::ConstantInt*> tmp; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
623 CaseStatement* last; |
122 | 624 bool first = true; |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
625 do { |
122 | 626 // integral case |
627 if (cs->exp->type->isintegral()) { | |
628 llvm::Constant* c = cs->exp->toConstElem(p); | |
629 tmp.push_back(isaConstantInt(c)); | |
630 } | |
631 // string case | |
632 else { | |
633 assert(cs->exp->op == TOKstring); | |
634 // for string switches this is unfortunately necessary or there will be duplicates in the list | |
635 if (first) { | |
636 caseArray.push(new Case((StringExp*)cs->exp, i)); | |
637 first = false; | |
638 } | |
639 } | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
640 last = cs; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
641 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
642 while (cs = cs->statement->isCaseStatement()); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
643 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
644 vcases.push_back(CasePair(bb, tmp)); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
645 vbodies.push_back(last->statement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
646 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
647 |
122 | 648 // string switch? |
649 llvm::GlobalVariable* switchTable = 0; | |
650 if (!condition->type->isintegral()) | |
651 { | |
652 // first sort it | |
653 caseArray.sort(); | |
654 // iterate and add indices to cases | |
655 std::vector<llvm::Constant*> inits; | |
656 for (size_t i=0; i<caseArray.dim; ++i) | |
657 { | |
658 Case* c = (Case*)caseArray.data[i]; | |
659 vcases[c->index].second.push_back(DtoConstUint(i)); | |
660 inits.push_back(c->str->toConstElem(p)); | |
661 } | |
662 // build static array for ptr or final array | |
663 const llvm::Type* elemTy = DtoType(condition->type); | |
664 const llvm::ArrayType* arrTy = llvm::ArrayType::get(elemTy, inits.size()); | |
665 llvm::Constant* arrInit = llvm::ConstantArray::get(arrTy, inits); | |
666 llvm::GlobalVariable* arr = new llvm::GlobalVariable(arrTy, true, llvm::GlobalValue::InternalLinkage, arrInit, "string_switch_table_data", gIR->module); | |
667 | |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
668 const llvm::Type* elemPtrTy = getPtrToType(elemTy); |
122 | 669 llvm::Constant* arrPtr = llvm::ConstantExpr::getBitCast(arr, elemPtrTy); |
670 | |
671 // build the static table | |
672 std::vector<const llvm::Type*> types; | |
673 types.push_back(DtoSize_t()); | |
674 types.push_back(elemPtrTy); | |
675 const llvm::StructType* sTy = llvm::StructType::get(types); | |
676 std::vector<llvm::Constant*> sinits; | |
677 sinits.push_back(DtoConstSize_t(inits.size())); | |
678 sinits.push_back(arrPtr); | |
679 llvm::Constant* sInit = llvm::ConstantStruct::get(sTy, sinits); | |
680 | |
681 switchTable = new llvm::GlobalVariable(sTy, true, llvm::GlobalValue::InternalLinkage, sInit, "string_switch_table", gIR->module); | |
682 } | |
683 | |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
684 // default |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
685 llvm::BasicBlock* defbb = 0; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
686 if (!hasNoDefault) { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
687 defbb = new llvm::BasicBlock("default", p->topfunc(), oldend); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
688 sdefault->bodyBB = defbb; |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
689 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
690 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
691 // end (break point) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
692 llvm::BasicBlock* endbb = new llvm::BasicBlock("switchend", p->topfunc(), oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
693 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
694 // condition var |
122 | 695 llvm::Value* condVal; |
696 // integral switch | |
697 if (condition->type->isintegral()) { | |
698 DValue* cond = condition->toElem(p); | |
699 condVal = cond->getRVal(); | |
700 } | |
701 // string switch | |
702 else { | |
703 condVal = call_string_switch_runtime(switchTable, condition); | |
704 } | |
705 llvm::SwitchInst* si = new llvm::SwitchInst(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
|
706 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
707 // add the cases |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
708 size_t n = vcases.size(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
709 for (size_t i=0; i<n; ++i) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
710 { |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
711 size_t nc = vcases[i].second.size(); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
712 for (size_t j=0; j<nc; ++j) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
713 { |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
714 si->addCase(vcases[i].second[j], vcases[i].first); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
715 } |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
716 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
717 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
718 // insert case statements |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
719 for (size_t i=0; i<n; ++i) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
720 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
721 llvm::BasicBlock* nextbb = (i == n-1) ? (defbb ? defbb : endbb) : vcases[i+1].first; |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
722 p->scope() = IRScope(vcases[i].first,nextbb); |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
723 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,p->scopebb(),endbb)); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
724 vbodies[i]->toIR(p); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
725 p->loopbbs.pop_back(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
726 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
727 llvm::BasicBlock* curbb = p->scopebb(); |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
728 if (curbb->empty() || !curbb->back().isTerminator()) |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
729 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
730 new llvm::BranchInst(nextbb, curbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
731 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
732 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
733 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
734 // default statement |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
735 if (defbb) |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
736 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
737 p->scope() = IRScope(defbb,endbb); |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
738 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,p->scopebb(),endbb)); |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
739 Logger::println("doing default statement"); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
740 sdefault->statement->toIR(p); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
741 p->loopbbs.pop_back(); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
742 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
743 llvm::BasicBlock* curbb = p->scopebb(); |
78
2332006e1fa4
[svn r82] Fixed: Fall-through switch cases were broken.
lindquist
parents:
73
diff
changeset
|
744 if (curbb->empty() || !curbb->back().isTerminator()) |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
745 { |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
746 new llvm::BranchInst(endbb, curbb); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
747 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
748 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
749 |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
750 gIR->scope() = IRScope(endbb,oldend); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
751 } |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
752 |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
753 ////////////////////////////////////////////////////////////////////////////// |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
754 void CaseStatement::toIR(IRState* p) |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
755 { |
132 | 756 Logger::println("CaseStatement::toIR(): %s", loc.toChars()); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
757 LOG_SCOPE; |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
758 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
759 assert(0); |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
760 } |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
761 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
762 ////////////////////////////////////////////////////////////////////////////// |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
763 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
764 void UnrolledLoopStatement::toIR(IRState* p) |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
765 { |
132 | 766 Logger::println("UnrolledLoopStatement::toIR(): %s", loc.toChars()); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
767 LOG_SCOPE; |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
768 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
769 llvm::BasicBlock* oldend = gIR->scopeend(); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
770 llvm::BasicBlock* endbb = new llvm::BasicBlock("unrolledend", p->topfunc(), oldend); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
771 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
772 p->scope() = IRScope(p->scopebb(),endbb); |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
773 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,p->scopebb(),endbb)); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
774 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
775 for (int i=0; i<statements->dim; ++i) |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
776 { |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
777 Statement* s = (Statement*)statements->data[i]; |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
778 s->toIR(p); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
779 } |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
780 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
781 p->loopbbs.pop_back(); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
782 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
783 new llvm::BranchInst(endbb, p->scopebb()); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
784 p->scope() = IRScope(endbb,oldend); |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
785 } |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
786 |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
787 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
788 |
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
|
789 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
|
790 { |
132 | 791 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
|
792 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
|
793 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
794 //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
|
795 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
|
796 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
|
797 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
|
798 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
|
799 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
800 //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
|
801 //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
|
802 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
803 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
|
804 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
805 // key |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
806 const llvm::Type* keytype = key ? DtoType(key->type) : DtoSize_t(); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
807 llvm::Value* 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
|
808 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
|
809 { |
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
|
810 //key->llvmValue = keyvar; |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
811 assert(!gIR->irDsymbol[key].irLocal); |
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
812 gIR->irDsymbol[key].irLocal = new IrLocal(key); |
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
813 gIR->irDsymbol[key].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
|
814 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
815 llvm::Value* zerokey = llvm::ConstantInt::get(keytype,0,false); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
816 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
817 // value |
81
3587401b6eeb
[svn r85] Fixed: if a return statement appeared in the try block of a nested try-finally, only the inner-most finally block would be executed.
lindquist
parents:
80
diff
changeset
|
818 const llvm::Type* valtype = DtoType(value->type); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
819 llvm::Value* valvar = NULL; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
820 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
|
821 valvar = new llvm::AllocaInst(valtype, "foreachval", p->topallocapoint()); |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
822 assert(!gIR->irDsymbol[value].irLocal); |
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
823 gIR->irDsymbol[value].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
|
824 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
825 // what to iterate |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
826 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
|
827 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
|
828 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
829 // get length and pointer |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
830 llvm::Value* val = 0; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
831 llvm::Value* niters = 0; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
832 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
833 // static array |
45 | 834 if (aggrtype->ty == Tsarray) |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
835 { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
836 Logger::println("foreach over static array"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
837 val = aggrval->getRVal(); |
96 | 838 assert(isaPointer(val->getType())); |
839 const llvm::ArrayType* arrty = isaArray(val->getType()->getContainedType(0)); | |
840 assert(arrty); | |
841 size_t nelems = arrty->getNumElements(); | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
842 assert(nelems > 0); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
843 niters = llvm::ConstantInt::get(keytype,nelems,false); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
844 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
845 // dynamic array |
45 | 846 else if (aggrtype->ty == Tarray) |
847 { | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
848 if (DSliceValue* slice = aggrval->isSlice()) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
849 Logger::println("foreach over slice"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
850 niters = slice->len; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
851 assert(niters); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
852 val = slice->ptr; |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
853 assert(val); |
73 | 854 } |
855 else { | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
856 Logger::println("foreach over dynamic array"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
857 val = aggrval->getRVal(); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
858 niters = DtoGEPi(val,0,0,"tmp",p->scopebb()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
859 niters = p->ir->CreateLoad(niters, "numiterations"); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
860 val = DtoGEPi(val,0,1,"tmp",p->scopebb()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
861 val = p->ir->CreateLoad(val, "collection"); |
73 | 862 } |
45 | 863 } |
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
|
864 else |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
865 { |
45 | 866 assert(0 && "aggregate type is not Tarray or Tsarray"); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
867 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
868 |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
869 if (niters->getType() != keytype) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
870 { |
133
44a95ac7368a
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
lindquist
parents:
132
diff
changeset
|
871 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
|
872 size_t sz2 = getTypeBitSize(keytype); |
109
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
873 if (sz1 < sz2) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
874 niters = gIR->ir->CreateZExt(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
875 else if (sz1 > sz2) |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
876 niters = gIR->ir->CreateTrunc(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
877 else |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
878 niters = gIR->ir->CreateBitCast(niters, keytype, "foreachtrunckey"); |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
879 } |
5ab8e92611f9
[svn r113] Added initial support for associative arrays (AAs).
lindquist
parents:
108
diff
changeset
|
880 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
881 llvm::Constant* delta = 0; |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
882 if (op == TOKforeach) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
883 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
|
884 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
885 else { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
886 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
|
887 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
888 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
889 llvm::BasicBlock* oldend = gIR->scopeend(); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
890 llvm::BasicBlock* condbb = new llvm::BasicBlock("foreachcond", p->topfunc(), oldend); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
891 llvm::BasicBlock* bodybb = new llvm::BasicBlock("foreachbody", p->topfunc(), oldend); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
892 llvm::BasicBlock* nextbb = new llvm::BasicBlock("foreachnext", p->topfunc(), oldend); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
893 llvm::BasicBlock* endbb = new llvm::BasicBlock("foreachend", p->topfunc(), oldend); |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
894 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
895 new llvm::BranchInst(condbb, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
896 |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
897 // condition |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
898 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
|
899 |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
900 llvm::Value* done = 0; |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
901 llvm::Value* load = new llvm::LoadInst(keyvar, "tmp", p->scopebb()); |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
902 if (op == TOKforeach) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
903 done = new llvm::ICmpInst(llvm::ICmpInst::ICMP_ULT, load, niters, "tmp", p->scopebb()); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
904 } |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
905 else if (op == TOKforeach_reverse) { |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
906 done = new llvm::ICmpInst(llvm::ICmpInst::ICMP_UGT, load, zerokey, "tmp", p->scopebb()); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
907 load = llvm::BinaryOperator::createSub(load,llvm::ConstantInt::get(keytype, 1, false),"tmp",p->scopebb()); |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
908 new llvm::StoreInst(load, keyvar, p->scopebb()); |
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
909 } |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
910 new llvm::BranchInst(bodybb, endbb, done, p->scopebb()); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
911 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
912 // init body |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
913 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
|
914 |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
915 // get value for this iteration |
45 | 916 llvm::Constant* zero = llvm::ConstantInt::get(keytype,0,false); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
917 llvm::Value* loadedKey = p->ir->CreateLoad(keyvar,"tmp"); |
45 | 918 if (aggrtype->ty == Tsarray) |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
919 gIR->irDsymbol[value].irLocal->value = DtoGEP(val,zero,loadedKey,"tmp"); |
45 | 920 else if (aggrtype->ty == Tarray) |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
921 gIR->irDsymbol[value].irLocal->value = new llvm::GetElementPtrInst(val,loadedKey,"tmp",p->scopebb()); |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
922 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
923 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
|
924 DValue* dst = new DVarValue(value->type, valvar, true); |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
925 DValue* src = new DVarValue(value->type, gIR->irDsymbol[value].irLocal->value, true); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
926 DtoAssign(dst, src); |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
927 gIR->irDsymbol[value].irLocal->value = valvar; |
51
61bc1b4ad3c4
[svn r55] Foreach was always generating code as if the value variable was 'ref'
lindquist
parents:
45
diff
changeset
|
928 } |
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
|
929 |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
930 // emit body |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
931 p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,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
|
932 body->toIR(p); |
33
bc641b23a714
[svn r37] * Initial support for foreach on static arrays. Not 100% complete
lindquist
parents:
32
diff
changeset
|
933 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
|
934 |
40 | 935 if (!p->scopereturned()) |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
936 new llvm::BranchInst(nextbb, p->scopebb()); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
937 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
938 // next |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
939 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
|
940 if (op == TOKforeach) { |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
941 llvm::Value* load = DtoLoad(keyvar); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
942 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
|
943 DtoStore(load, keyvar); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
944 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
945 new llvm::BranchInst(condbb, p->scopebb()); |
32
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
946 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
947 // 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
|
948 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
|
949 } |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
950 |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
951 ////////////////////////////////////////////////////////////////////////////// |
a86fe7496b58
[svn r36] * Fixed a bug where passing a regular argument to a ref argument did not allocate storage
lindquist
parents:
15
diff
changeset
|
952 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
953 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
|
954 { |
132 | 955 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
|
956 LOG_SCOPE; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
957 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
958 assert(tf == NULL); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
959 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
960 llvm::BasicBlock* oldend = gIR->scopeend(); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
961 if (llvmBB) |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
962 llvmBB->moveBefore(oldend); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
963 else |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
964 llvmBB = new llvm::BasicBlock("label", p->topfunc(), oldend); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
965 |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
966 if (!p->scopereturned()) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
967 new llvm::BranchInst(llvmBB, p->scopebb()); |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
968 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
969 p->scope() = IRScope(llvmBB,oldend); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
970 if (statement) |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
971 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
|
972 } |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
973 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
974 ////////////////////////////////////////////////////////////////////////////// |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
975 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
976 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
|
977 { |
132 | 978 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
|
979 LOG_SCOPE; |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
980 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
981 assert(tf == NULL); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
982 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
983 llvm::BasicBlock* oldend = gIR->scopeend(); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
984 llvm::BasicBlock* bb = new llvm::BasicBlock("aftergoto", p->topfunc(), oldend); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
985 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
986 if (label->statement->llvmBB == NULL) |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
987 label->statement->llvmBB = new llvm::BasicBlock("label", p->topfunc()); |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
988 assert(!p->scopereturned()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
989 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
990 // find finallys between goto and label |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
991 TryFinallyStatement* endfinally = enclosingtryfinally; |
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
992 while(endfinally != NULL && endfinally != label->statement->enclosingtryfinally) { |
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
993 endfinally = endfinally->enclosingtryfinally; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
994 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
995 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
996 // error if didn't find tf statement of label |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
997 if(endfinally != label->statement->enclosingtryfinally) |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
998 error("cannot goto into try block", loc.toChars()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
999 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1000 // emit code for finallys between goto and label |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
1001 emit_finallyblocks(p, enclosingtryfinally, endfinally); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1002 |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1003 new llvm::BranchInst(label->statement->llvmBB, p->scopebb()); |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1004 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
|
1005 } |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1006 |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1007 ////////////////////////////////////////////////////////////////////////////// |
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
34
diff
changeset
|
1008 |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1009 void GotoDefaultStatement::toIR(IRState* p) |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1010 { |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1011 Logger::println("GotoDefaultStatement::toIR(): %s", loc.toChars()); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1012 LOG_SCOPE; |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1013 |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1014 llvm::BasicBlock* oldend = gIR->scopeend(); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1015 llvm::BasicBlock* bb = new llvm::BasicBlock("aftergotodefault", p->topfunc(), oldend); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1016 |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1017 assert(!p->scopereturned()); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1018 assert(sw->sdefault->bodyBB); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1019 |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
1020 emit_finallyblocks(p, enclosingtryfinally, sw->enclosingtryfinally); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1021 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1022 new llvm::BranchInst(sw->sdefault->bodyBB, p->scopebb()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1023 p->scope() = IRScope(bb,oldend); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1024 } |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1025 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1026 ////////////////////////////////////////////////////////////////////////////// |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1027 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1028 void GotoCaseStatement::toIR(IRState* p) |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1029 { |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1030 Logger::println("GotoCaseStatement::toIR(): %s", loc.toChars()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1031 LOG_SCOPE; |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1032 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1033 llvm::BasicBlock* oldend = gIR->scopeend(); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1034 llvm::BasicBlock* bb = new llvm::BasicBlock("aftergotocase", p->topfunc(), oldend); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1035 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1036 assert(!p->scopereturned()); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1037 assert(cs->bodyBB); |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1038 |
148
86d3bb8ca33e
[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
ChristianK
parents:
146
diff
changeset
|
1039 emit_finallyblocks(p, enclosingtryfinally, sw->enclosingtryfinally); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1040 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1041 new llvm::BranchInst(cs->bodyBB, p->scopebb()); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1042 p->scope() = IRScope(bb,oldend); |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1043 } |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1044 |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1045 ////////////////////////////////////////////////////////////////////////////// |
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1046 |
40 | 1047 void WithStatement::toIR(IRState* p) |
1048 { | |
132 | 1049 Logger::println("WithStatement::toIR(): %s", loc.toChars()); |
40 | 1050 LOG_SCOPE; |
1051 | |
1052 assert(exp); | |
1053 assert(body); | |
1054 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
1055 DValue* e = exp->toElem(p); |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
1056 gIR->irDsymbol[wthis].irLocal->value = e->getRVal(); |
40 | 1057 delete e; |
1058 | |
1059 body->toIR(p); | |
1060 } | |
1061 | |
1062 ////////////////////////////////////////////////////////////////////////////// | |
1063 | |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1064 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
|
1065 { |
132 | 1066 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
|
1067 LOG_SCOPE; |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1068 |
132 | 1069 Logger::attention(loc, "synchronized is currently ignored. only the body will be emitted"); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1070 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1071 body->toIR(p); |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1072 } |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1073 |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1074 ////////////////////////////////////////////////////////////////////////////// |
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1075 |
131 | 1076 void AsmStatement::toIR(IRState* p) |
1077 { | |
132 | 1078 Logger::println("AsmStatement::toIR(): %s", loc.toChars()); |
131 | 1079 LOG_SCOPE; |
1080 error("%s: inline asm is not yet implemented", loc.toChars()); | |
1081 fatal(); | |
1082 | |
1083 assert(!asmcode && !asmalign && !refparam && !naked && !regs); | |
1084 | |
1085 Token* t = tokens; | |
1086 assert(t); | |
1087 | |
1088 std::string asmstr; | |
1089 | |
1090 do { | |
1091 Logger::println("token: %s", t->toChars()); | |
1092 asmstr.append(t->toChars()); | |
1093 asmstr.append(" "); | |
1094 } while (t = t->next); | |
1095 | |
1096 Logger::println("asm expr = '%s'", asmstr.c_str()); | |
1097 | |
1098 // create function type | |
1099 std::vector<const llvm::Type*> args; | |
1100 const llvm::FunctionType* fty = llvm::FunctionType::get(DtoSize_t(), args, false); | |
1101 | |
1102 // create inline asm callee | |
1103 llvm::InlineAsm* inasm = llvm::InlineAsm::get(fty, asmstr, "r,r", false); | |
1104 | |
1105 assert(0); | |
1106 } | |
1107 | |
1108 ////////////////////////////////////////////////////////////////////////////// | |
1109 | |
132 | 1110 void VolatileStatement::toIR(IRState* p) |
1111 { | |
1112 Logger::println("VolatileStatement::toIR(): %s", loc.toChars()); | |
1113 LOG_SCOPE; | |
1114 | |
1115 Logger::attention(loc, "volatile is currently ignored. only the body will be emitted"); | |
1116 | |
1117 statement->toIR(p); | |
1118 } | |
1119 | |
1120 ////////////////////////////////////////////////////////////////////////////// | |
1121 | |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1122 ////////////////////////////////////////////////////////////////////////////// |
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1123 |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1124 #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
|
1125 //STUBST(BreakStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1126 //STUBST(ForStatement); |
40 | 1127 //STUBST(WithStatement); |
94
61615fa85940
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
lindquist
parents:
86
diff
changeset
|
1128 //STUBST(SynchronizedStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1129 //STUBST(ReturnStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1130 //STUBST(ContinueStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1131 STUBST(DefaultStatement); |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
100
diff
changeset
|
1132 //STUBST(CaseStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1133 //STUBST(SwitchStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1134 STUBST(SwitchErrorStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1135 STUBST(Statement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1136 //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
|
1137 //STUBST(ForeachStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1138 //STUBST(DoStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1139 //STUBST(WhileStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1140 //STUBST(ExpStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1141 //STUBST(CompoundStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1142 //STUBST(ScopeStatement); |
131 | 1143 //STUBST(AsmStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1144 //STUBST(TryCatchStatement); |
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1145 //STUBST(TryFinallyStatement); |
132 | 1146 //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
|
1147 //STUBST(LabelStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1148 //STUBST(ThrowStatement); |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
1149 //STUBST(GotoCaseStatement); |
144
a27941d00351
[svn r149] fixed: a bunch of D-style variadics problems.
lindquist
parents:
137
diff
changeset
|
1150 //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
|
1151 //STUBST(GotoStatement); |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
14
diff
changeset
|
1152 //STUBST(UnrolledLoopStatement); |
14
0e86428ee567
[svn r18] * Initial support for switch statements - No string switches yet.
lindquist
parents:
diff
changeset
|
1153 //STUBST(OnScopeStatement); |