Mercurial > projects > ddmd
comparison dmd/PragmaDeclaration.d @ 90:39648eb578f6
more Expressions work
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 20:27:56 +0100 |
parents | be2ab491772e |
children | ae5b11064a9a |
comparison
equal
deleted
inserted
replaced
88:23280d154c5b | 90:39648eb578f6 |
---|---|
51 //printf("\tPragmaDeclaration.semantic '%s'\n",toChars()); | 51 //printf("\tPragmaDeclaration.semantic '%s'\n",toChars()); |
52 if (ident == Id.msg) | 52 if (ident == Id.msg) |
53 { | 53 { |
54 if (args) | 54 if (args) |
55 { | 55 { |
56 for (size_t i = 0; i < args.dim; i++) | 56 foreach (e; args) |
57 { | 57 { |
58 Expression e = cast(Expression)args.data[i]; | |
59 | |
60 e = e.semantic(sc); | 58 e = e.semantic(sc); |
61 e = e.optimize(WANTvalue | WANTinterpret); | 59 e = e.optimize(WANTvalue | WANTinterpret); |
62 if (e.op == TOKstring) | 60 if (e.op == TOKstring) |
63 { | 61 { |
64 StringExp se = cast(StringExp)e; | 62 auto se = cast(StringExp)e; |
65 writef("%s", se.toChars()[1..$-3] /*se.len, cast(char*)se.string_*/); | 63 writef("%s", se.toChars()[1..$-3] /*se.len, cast(char*)se.string_*/); |
66 } | 64 } |
67 else | 65 else |
68 error("string expected for message, not '%s'", e.toChars()); | 66 error("string expected for message, not '%s'", e.toChars()); |
69 } | 67 } |
156 /* Print unrecognized pragmas | 154 /* Print unrecognized pragmas |
157 */ | 155 */ |
158 writef("pragma %s", ident.toChars()); | 156 writef("pragma %s", ident.toChars()); |
159 if (args) | 157 if (args) |
160 { | 158 { |
161 for (size_t i = 0; i < args.dim; i++) | 159 foreach (size_t i, Expression e; args) |
162 { | 160 { |
163 Expression e = cast(Expression)args.data[i]; | |
164 e = e.semantic(sc); | 161 e = e.semantic(sc); |
165 e = e.optimize(WANTvalue | WANTinterpret); | 162 e = e.optimize(WANTvalue | WANTinterpret); |
166 if (i == 0) | 163 if (i == 0) |
167 writef(" ("); | 164 writef(" ("); |
168 else | 165 else |
243 { | 240 { |
244 if (ident == Id.lib) | 241 if (ident == Id.lib) |
245 { | 242 { |
246 assert(args && args.dim == 1); | 243 assert(args && args.dim == 1); |
247 | 244 |
248 Expression e = cast(Expression)args.data[0]; | 245 auto e = args[0]; |
249 | 246 |
250 assert(e.op == TOKstring); | 247 assert(e.op == TOKstring); |
251 | 248 |
252 StringExp se = cast(StringExp)e; | 249 auto se = cast(StringExp)e; |
253 char* name = cast(char*)GC.malloc(se.len + 1); | 250 char* name = cast(char*)GC.malloc(se.len + 1); |
254 memcpy(name, se.string_, se.len); | 251 memcpy(name, se.string_, se.len); |
255 name[se.len] = 0; | 252 name[se.len] = 0; |
256 version (OMFOBJ) { | 253 version (OMFOBJ) { |
257 /* The OMF format allows library names to be inserted | 254 /* The OMF format allows library names to be inserted |
271 } | 268 } |
272 /// version (DMDV2) { | 269 /// version (DMDV2) { |
273 else if (ident == Id.startaddress) | 270 else if (ident == Id.startaddress) |
274 { | 271 { |
275 assert(args && args.dim == 1); | 272 assert(args && args.dim == 1); |
276 Expression e = cast(Expression)args.data[0]; | 273 auto e = args[0]; |
277 Dsymbol sa = getDsymbol(e); | 274 Dsymbol sa = getDsymbol(e); |
278 FuncDeclaration f = sa.isFuncDeclaration(); | 275 FuncDeclaration f = sa.isFuncDeclaration(); |
279 assert(f); | 276 assert(f); |
280 Symbol* s = f.toSymbol(); | 277 Symbol* s = f.toSymbol(); |
281 obj_startaddress(s); | 278 obj_startaddress(s); |