Mercurial > projects > ddmd
comparison dmd/Expression.d @ 55:8c2c7b7579f8
Expression.toMangleBuffer
Expression.toDelegate
Expression.scanForNestedRef
TypeStruct.deduceType
TypeStruct.toChars
DefaultInitExp wrong TOK bug fixed
author | korDen |
---|---|
date | Sat, 21 Aug 2010 13:28:16 +0400 |
parents | a8b50ff7f201 |
children | efb1e5bdf63c |
comparison
equal
deleted
inserted
replaced
54:f95140b40251 | 55:8c2c7b7579f8 |
---|---|
29 import dmd.STC; | 29 import dmd.STC; |
30 import dmd.TemplateInstance; | 30 import dmd.TemplateInstance; |
31 import dmd.CommaExp; | 31 import dmd.CommaExp; |
32 import dmd.NullExp; | 32 import dmd.NullExp; |
33 import dmd.AddrExp; | 33 import dmd.AddrExp; |
34 import dmd.LINK; | |
35 import dmd.FuncExp; | |
36 import dmd.ReturnStatement; | |
37 import dmd.Statement; | |
38 import dmd.FuncLiteralDeclaration; | |
39 import dmd.TypeFunction; | |
34 import dmd.ErrorExp; | 40 import dmd.ErrorExp; |
35 import dmd.TypeStruct; | 41 import dmd.TypeStruct; |
36 import dmd.CastExp; | 42 import dmd.CastExp; |
37 import dmd.Global; | 43 import dmd.Global; |
38 import dmd.Token; | 44 import dmd.Token; |
346 buf.writestring(Token.toChars(op)); | 352 buf.writestring(Token.toChars(op)); |
347 } | 353 } |
348 | 354 |
349 void toMangleBuffer(OutBuffer buf) | 355 void toMangleBuffer(OutBuffer buf) |
350 { | 356 { |
351 assert(false); | 357 error("expression %s is not a valid template value argument", toChars()); |
358 assert(false); | |
359 version (DEBUG) { | |
360 dump(0); | |
361 } | |
352 } | 362 } |
353 | 363 |
354 int isLvalue() | 364 int isLvalue() |
355 { | 365 { |
356 assert(false); | 366 assert(false); |
770 break; /// | 780 break; /// |
771 } | 781 } |
772 return e; | 782 return e; |
773 } | 783 } |
774 | 784 |
785 /******************************************** | |
786 * Convert from expression to delegate that returns the expression, | |
787 * i.e. convert: | |
788 * expr | |
789 * to: | |
790 * t delegate() { return expr; } | |
791 */ | |
775 Expression toDelegate(Scope sc, Type t) | 792 Expression toDelegate(Scope sc, Type t) |
776 { | 793 { |
777 assert(false); | 794 //printf("Expression.toDelegate(t = %s) %s\n", t.toChars(), toChars()); |
795 TypeFunction tf = new TypeFunction(null, t, 0, LINKd); | |
796 FuncLiteralDeclaration fld = new FuncLiteralDeclaration(loc, loc, tf, TOKdelegate, null); | |
797 Expression e; | |
798 static if (true) { | |
799 sc = sc.push(); | |
800 sc.parent = fld; // set current function to be the delegate | |
801 e = this; | |
802 e.scanForNestedRef(sc); | |
803 sc = sc.pop(); | |
804 } else { | |
805 e = this.syntaxCopy(); | |
806 } | |
807 Statement s = new ReturnStatement(loc, e); | |
808 fld.fbody = s; | |
809 e = new FuncExp(loc, fld); | |
810 e = e.semantic(sc); | |
811 return e; | |
778 } | 812 } |
779 | 813 |
780 void scanForNestedRef(Scope sc) | 814 void scanForNestedRef(Scope sc) |
781 { | 815 { |
782 assert(false); | 816 //printf("Expression.scanForNestedRef(%s)\n", toChars()); |
783 } | 817 } |
784 | 818 |
785 Expression optimize(int result) | 819 Expression optimize(int result) |
786 { | 820 { |
787 //printf("Expression.optimize(result = x%x) %s\n", result, toChars()); | 821 //printf("Expression.optimize(result = x%x) %s\n", result, toChars()); |