comparison dmd/Expression.d @ 93:df6d0f967680

implemented a whole bunch of methods to make phobos 2.035 compile and some additional ones I came across
author Trass3r
date Mon, 30 Aug 2010 22:50:30 +0200
parents be2ab491772e
children ae5b11064a9a
comparison
equal deleted inserted replaced
92:0c891ec48515 93:df6d0f967680
40 import dmd.TypeFunction; 40 import dmd.TypeFunction;
41 import dmd.ErrorExp; 41 import dmd.ErrorExp;
42 import dmd.TypeStruct; 42 import dmd.TypeStruct;
43 import dmd.CastExp; 43 import dmd.CastExp;
44 import dmd.Global; 44 import dmd.Global;
45 import dmd.GlobalExpressions;
45 import dmd.Token; 46 import dmd.Token;
46 import dmd.TypeClass; 47 import dmd.TypeClass;
47 import dmd.PtrExp; 48 import dmd.PtrExp;
48 import dmd.TypeSArray; 49 import dmd.TypeSArray;
49 import dmd.TypeReference; 50 import dmd.TypeReference;
322 return a; 323 return a;
323 } 324 }
324 325
325 ulong toInteger() 326 ulong toInteger()
326 { 327 {
327 assert(false); 328 //printf("Expression %s\n", Token.toChars(op));
329 error("Integer constant expression expected instead of %s", toChars());
330 return 0;
328 } 331 }
329 332
330 ulong toUInteger() 333 ulong toUInteger()
331 { 334 {
332 //printf("Expression %s\n", Token.toChars(op)); 335 //printf("Expression %s\n", Token.toChars(op));
333 return cast(ulong)toInteger(); 336 return cast(ulong)toInteger();
334 } 337 }
335 338
336 real toReal() 339 real toReal()
337 { 340 {
338 assert(false); 341 error("Floating point constant expression expected instead of %s", toChars());
342 return 0;
339 } 343 }
340 344
341 real toImaginary() 345 real toImaginary()
342 { 346 {
343 assert(false); 347 error("Floating point constant expression expected instead of %s", toChars());
348 return 0;
344 } 349 }
345 350
346 Complex!(real) toComplex() 351 Complex!(real) toComplex()
347 { 352 {
348 assert(false); 353 error("Floating point constant expression expected instead of %s", toChars());
354 return Complex!real(0);
349 } 355 }
350 356
351 void toCBuffer(OutBuffer buf, HdrGenState* hgs) 357 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
352 { 358 {
353 buf.writestring(Token.toChars(op)); 359 buf.writestring(Token.toChars(op));
367 */ 373 */
368 int isLvalue() 374 int isLvalue()
369 { 375 {
370 return 0; 376 return 0;
371 } 377 }
372 378
373 Expression toLvalue(Scope sc, Expression e) 379 /*******************************
374 { 380 * Give error if we're not an lvalue.
375 assert(false); 381 * If we can, convert expression to be an lvalue.
376 } 382 */
377 383 Expression toLvalue(Scope sc, Expression e)
384 {
385 if (!e)
386 e = this;
387 else if (!loc.filename)
388 loc = e.loc;
389 error("%s is not an lvalue", e.toChars());
390 return this;
391 }
392
378 Expression modifiableLvalue(Scope sc, Expression e) 393 Expression modifiableLvalue(Scope sc, Expression e)
379 { 394 {
380 //printf("Expression::modifiableLvalue() %s, type = %s\n", toChars(), type.toChars()); 395 //printf("Expression::modifiableLvalue() %s, type = %s\n", toChars(), type.toChars());
381 396
382 // See if this expression is a modifiable lvalue (i.e. not const) 397 // See if this expression is a modifiable lvalue (i.e. not const)
829 { 844 {
830 //printf("Expression.optimize(result = x%x) %s\n", result, toChars()); 845 //printf("Expression.optimize(result = x%x) %s\n", result, toChars());
831 return this; 846 return this;
832 } 847 }
833 848
834 Expression interpret(InterState istate) 849 Expression interpret(InterState istate)
835 { 850 {
836 assert(false); 851 version(LOG)
852 {
853 writef("Expression::interpret() %s\n", toChars());
854 writef("type = %s\n", type.toChars());
855 dump(0);
856 }
857 error("Cannot interpret %s at compile time", toChars());
858 return EXP_CANT_INTERPRET;
837 } 859 }
838 860
839 int isConst() 861 int isConst()
840 { 862 {
841 //printf("Expression::isConst(): %s\n", toChars()); 863 //printf("Expression::isConst(): %s\n", toChars());