Mercurial > projects > ddmd
comparison dmd/TypeFunction.d @ 73:ef02e2e203c2
Updating to dmd2.033
author | korDen |
---|---|
date | Sat, 28 Aug 2010 19:42:41 +0400 |
parents | 2e2a5c3f943a |
children | 43073c7c7769 |
comparison
equal
deleted
inserted
replaced
72:2e2a5c3f943a | 73:ef02e2e203c2 |
---|---|
8 import dmd.StructDeclaration; | 8 import dmd.StructDeclaration; |
9 import dmd.TypeStruct; | 9 import dmd.TypeStruct; |
10 import dmd.Global; | 10 import dmd.Global; |
11 import dmd.STC; | 11 import dmd.STC; |
12 import dmd.MOD; | 12 import dmd.MOD; |
13 import dmd.PROT; | |
13 import dmd.Type; | 14 import dmd.Type; |
14 import dmd.Loc; | 15 import dmd.Loc; |
15 import dmd.Scope; | 16 import dmd.Scope; |
16 import dmd.Identifier; | 17 import dmd.Identifier; |
17 import dmd.OutBuffer; | 18 import dmd.OutBuffer; |
156 if (tf.next.isauto() && !(sc.flags & SCOPE.SCOPEctor)) | 157 if (tf.next.isauto() && !(sc.flags & SCOPE.SCOPEctor)) |
157 error(loc, "functions cannot return scope %s", tf.next.toChars()); | 158 error(loc, "functions cannot return scope %s", tf.next.toChars()); |
158 } | 159 } |
159 | 160 |
160 if (tf.parameters) | 161 if (tf.parameters) |
161 { size_t dim = Argument.dim(tf.parameters); | 162 { |
163 /* Create a scope for evaluating the default arguments for the parameters | |
164 */ | |
165 Scope argsc = sc.push(); | |
166 argsc.stc = STCundefined; // don't inherit storage class | |
167 argsc.protection = PROT.PROTpublic; | |
168 | |
169 size_t dim = Argument.dim(tf.parameters); | |
162 | 170 |
163 for (size_t i = 0; i < dim; i++) | 171 for (size_t i = 0; i < dim; i++) |
164 { Argument arg = Argument.getNth(tf.parameters, i); | 172 { Argument arg = Argument.getNth(tf.parameters, i); |
165 | 173 |
166 tf.inuse++; | 174 tf.inuse++; |
167 arg.type = arg.type.semantic(loc,sc); | 175 arg.type = arg.type.semantic(loc, argsc); |
168 if (tf.inuse == 1) tf.inuse--; | 176 if (tf.inuse == 1) tf.inuse--; |
169 | 177 |
170 arg.type = arg.type.addStorageClass(arg.storageClass); | 178 arg.type = arg.type.addStorageClass(arg.storageClass); |
171 | 179 |
172 if (arg.storageClass & (STC.STCauto | STC.STCalias | STC.STCstatic)) | 180 if (arg.storageClass & (STC.STCauto | STC.STCalias | STC.STCstatic)) |
187 if (!(arg.storageClass & STC.STClazy) && t.ty == TY.Tvoid) | 195 if (!(arg.storageClass & STC.STClazy) && t.ty == TY.Tvoid) |
188 error(loc, "cannot have parameter of type %s", arg.type.toChars()); | 196 error(loc, "cannot have parameter of type %s", arg.type.toChars()); |
189 | 197 |
190 if (arg.defaultArg) | 198 if (arg.defaultArg) |
191 { | 199 { |
192 arg.defaultArg = arg.defaultArg.semantic(sc); | 200 arg.defaultArg = arg.defaultArg.semantic(argsc); |
193 arg.defaultArg = resolveProperties(sc, arg.defaultArg); | 201 arg.defaultArg = resolveProperties(argsc, arg.defaultArg); |
194 arg.defaultArg = arg.defaultArg.implicitCastTo(sc, arg.type); | 202 arg.defaultArg = arg.defaultArg.implicitCastTo(argsc, arg.type); |
195 } | 203 } |
196 | 204 |
197 /* If arg turns out to be a tuple, the number of parameters may | 205 /* If arg turns out to be a tuple, the number of parameters may |
198 * change. | 206 * change. |
199 */ | 207 */ |
200 if (t.ty == TY.Ttuple) | 208 if (t.ty == TY.Ttuple) |
201 { dim = Argument.dim(tf.parameters); | 209 { dim = Argument.dim(tf.parameters); |
202 i--; | 210 i--; |
203 } | 211 } |
204 } | 212 } |
213 argsc.pop(); | |
205 } | 214 } |
206 if (tf.next) | 215 if (tf.next) |
207 tf.deco = tf.merge().deco; | 216 tf.deco = tf.merge().deco; |
208 | 217 |
209 if (tf.inuse) | 218 if (tf.inuse) |
305 if (hgs.ddoc != 1) | 314 if (hgs.ddoc != 1) |
306 { | 315 { |
307 switch (linkage) | 316 switch (linkage) |
308 { | 317 { |
309 case LINKd: p = null; break; | 318 case LINKd: p = null; break; |
310 case LINKc: p = "C "; break; | 319 case LINKc: p = " C"; break; |
311 case LINKwindows: p = "Windows "; break; | 320 case LINKwindows: p = " Windows"; break; |
312 case LINKpascal: p = "Pascal "; break; | 321 case LINKpascal: p = " Pascal"; break; |
313 case LINKcpp: p = "C++ "; break; | 322 case LINKcpp: p = " C++"; break; |
314 default: | 323 default: |
315 assert(0); | 324 assert(0); |
316 } | 325 } |
317 } | 326 } |
318 | 327 |