comparison dmd2/optimize.c @ 1526:54b3c1394d62

Merged dmdfe 2.031.
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 07 Jul 2009 02:26:11 +0100
parents 638d16625da2
children e4f7b5d9c68a
comparison
equal deleted inserted replaced
1525:d28cd7c45267 1526:54b3c1394d62
1 1
2 // Compiler implementation of the D programming language 2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2007 by Digital Mars 3 // Copyright (c) 1999-2009 by Digital Mars
4 // All Rights Reserved 4 // All Rights Reserved
5 // written by Walter Bright 5 // written by Walter Bright
6 // http://www.digitalmars.com 6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License 7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt. 8 // in artistic.txt, or the GNU General Public License in gnu.txt.
803 { Expression *e; 803 { Expression *e;
804 804
805 //printf("IndexExp::optimize(result = %d) %s\n", result, toChars()); 805 //printf("IndexExp::optimize(result = %d) %s\n", result, toChars());
806 Expression *e1 = this->e1->optimize(WANTvalue | (result & WANTinterpret)); 806 Expression *e1 = this->e1->optimize(WANTvalue | (result & WANTinterpret));
807 e1 = fromConstInitializer(result, e1); 807 e1 = fromConstInitializer(result, e1);
808 if (this->e1->op == TOKvar)
809 { VarExp *ve = (VarExp *)this->e1;
810 if (ve->var->storage_class & STCmanifest)
811 { /* We generally don't want to have more than one copy of an
812 * array literal, but if it's an enum we have to because the
813 * enum isn't stored elsewhere. See Bugzilla 2559
814 */
815 this->e1 = e1;
816 }
817 }
808 e2 = e2->optimize(WANTvalue | (result & WANTinterpret)); 818 e2 = e2->optimize(WANTvalue | (result & WANTinterpret));
809 e = Index(type, e1, e2); 819 e = Index(type, e1, e2);
810 if (e == EXP_CANT_INTERPRET) 820 if (e == EXP_CANT_INTERPRET)
811 e = this; 821 e = this;
812 return e; 822 return e;