Mercurial > projects > ddmd
comparison dmd/NewExp.d @ 179:cd48cb899aee
Updated to dmd2.040
author | korDen |
---|---|
date | Sun, 17 Oct 2010 20:56:07 +0400 |
parents | e3afd1303184 |
children | b0d41ff5e0df |
comparison
equal
deleted
inserted
replaced
178:e3afd1303184 | 179:cd48cb899aee |
---|---|
1 module dmd.NewExp; | 1 module dmd.NewExp; |
2 | 2 |
3 import dmd.common; | 3 import dmd.common; |
4 import dmd.Expression; | 4 import dmd.Expression; |
5 import dmd.GlobalExpressions; | |
5 import dmd.NewDeclaration; | 6 import dmd.NewDeclaration; |
6 import dmd.CtorDeclaration; | 7 import dmd.CtorDeclaration; |
7 import dmd.ClassDeclaration; | 8 import dmd.ClassDeclaration; |
9 import dmd.InterState; | |
8 import dmd.Type; | 10 import dmd.Type; |
9 import dmd.OutBuffer; | 11 import dmd.OutBuffer; |
10 import dmd.PREC; | 12 import dmd.PREC; |
11 import dmd.Loc; | 13 import dmd.Loc; |
12 import dmd.Scope; | 14 import dmd.Scope; |
29 import dmd.WANT; | 31 import dmd.WANT; |
30 import dmd.Global; | 32 import dmd.Global; |
31 import dmd.IntegerExp; | 33 import dmd.IntegerExp; |
32 import dmd.TypePointer; | 34 import dmd.TypePointer; |
33 | 35 |
36 import dmd.interpret.Util; | |
37 import dmd.expression.Util; | |
38 | |
34 import dmd.backend.elem; | 39 import dmd.backend.elem; |
35 import dmd.backend.TYM; | 40 import dmd.backend.TYM; |
36 import dmd.backend.SC; | 41 import dmd.backend.SC; |
37 import dmd.backend.TYPE; | 42 import dmd.backend.TYPE; |
38 import dmd.backend.TYM; | 43 import dmd.backend.TYM; |
39 import dmd.backend.Symbol; | 44 import dmd.backend.Symbol; |
40 import dmd.backend.Classsym; | 45 import dmd.backend.Classsym; |
41 import dmd.backend.Util; | 46 import dmd.backend.Util; |
42 import dmd.backend.OPER; | 47 import dmd.backend.OPER; |
43 import dmd.backend.RTLSYM; | 48 import dmd.backend.RTLSYM; |
44 import dmd.expression.Util; | |
45 import dmd.codegen.Util; | 49 import dmd.codegen.Util; |
46 | 50 |
47 import std.string : toStringz; | 51 import std.string : toStringz; |
48 | 52 |
49 class NewExp : Expression | 53 class NewExp : Expression |
376 //printf("NewExp: '%s'\n", toChars()); | 380 //printf("NewExp: '%s'\n", toChars()); |
377 //printf("NewExp:type '%s'\n", type.toChars()); | 381 //printf("NewExp:type '%s'\n", type.toChars()); |
378 | 382 |
379 return this; | 383 return this; |
380 } | 384 } |
385 | |
386 Expression interpret(InterState istate) | |
387 { | |
388 version (LOG) { | |
389 writef("NewExp::interpret() %s\n", toChars()); | |
390 } | |
391 if (newtype.ty == Tarray && arguments && arguments.dim == 1) | |
392 { | |
393 Expression lenExpr = arguments[0].interpret(istate); | |
394 if (lenExpr is EXP_CANT_INTERPRET) | |
395 return EXP_CANT_INTERPRET; | |
396 return createBlockDuplicatedArrayLiteral(newtype, newtype.defaultInitLiteral(Loc(0)), cast(uint)lenExpr.toInteger()); | |
397 } | |
398 error("Cannot interpret %s at compile time", toChars()); | |
399 return EXP_CANT_INTERPRET; | |
400 | |
401 } | |
381 | 402 |
382 override Expression optimize(int result) | 403 override Expression optimize(int result) |
383 { | 404 { |
384 if (thisexp) | 405 if (thisexp) |
385 thisexp = thisexp.optimize(WANTvalue); | 406 thisexp = thisexp.optimize(WANTvalue); |