changeset 95:ae5b11064a9a

beginning of 2.036 branch
author Trass3r
date Mon, 30 Aug 2010 23:08:44 +0200
parents df6d0f967680
children acd69f84627e
files dmd/Expression.d dmd/PragmaDeclaration.d dmd/StructDeclaration.d dmd/TraitsExp.d dmd/Type.d dmd/TypeFunction.d
diffstat 6 files changed, 96 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/Expression.d	Mon Aug 30 22:50:30 2010 +0200
+++ b/dmd/Expression.d	Mon Aug 30 23:08:44 2010 +0200
@@ -126,7 +126,6 @@
 /***************************************
  * Pull out any properties.
  */
-
 Expression resolveProperties(Scope sc, Expression e)
 {
     //printf("resolveProperties(%s)\n", e.toChars());
@@ -166,6 +165,17 @@
     return e;
 }
 
+void indent(int indent)
+{
+    foreach (i; 0 .. indent)
+        writef(" ");
+}
+
+string type_print(Type type)
+{
+    return type ? type.toChars() : "null";
+}
+
 class Expression
 {
     Loc loc;			// file location
@@ -258,9 +268,10 @@
 		return buf.toChars();
 	}
 	
-    void dump(int indent)
+    void dump(int i)
 	{
-		assert(false);
+		indent(i);
+		writef("%p %s type=%s\n", this, Token.toChars(op), type_print(type));
 	}
 
     void error(T...)(string format, T t)
@@ -978,7 +989,38 @@
 		Expression e = new IdentifierExp(Loc(0), id);
 		return e;
 	}
-    
+
+	/***********************************************
+	 * Test if operand is a valid array op operand.
+	 */
+	int isArrayOperand()
+	{
+		//writef("Expression::isArrayOperand() %s\n", toChars());
+		if (op == TOKslice)
+			return 1;
+		if (type.toBasetype().ty == TY.Tarray)
+		{
+			switch (op)
+			{
+				case TOKadd:
+				case TOKmin:
+				case TOKmul:
+				case TOKdiv:
+				case TOKmod:
+				case TOKxor:
+				case TOKand:
+				case TOKor:
+				case TOKneg:
+				case TOKtilde:
+				return 1;
+	
+				default:
+				break;
+			}
+		}
+		return 0;
+	}
+
     // Back end
     elem* toElem(IRState* irs)
 	{
--- a/dmd/PragmaDeclaration.d	Mon Aug 30 22:50:30 2010 +0200
+++ b/dmd/PragmaDeclaration.d	Mon Aug 30 23:08:44 2010 +0200
@@ -63,7 +63,7 @@
 						writef("%s", se.toChars()[1..$-3] /*se.len, cast(char*)se.string_*/);
 					}
 					else
-						error("string expected for message, not '%s'", e.toChars());
+						writef(e.toChars());
 				}
 				writef("\n");
 			}
--- a/dmd/StructDeclaration.d	Mon Aug 30 22:50:30 2010 +0200
+++ b/dmd/StructDeclaration.d	Mon Aug 30 23:08:44 2010 +0200
@@ -740,7 +740,8 @@
 
 				toDt(&sinit.Sdt);
 
-version (OMFOBJ) {
+version (OMFOBJ)
+{
 				/* For OMF, common blocks aren't pulled in from the library.
 				 */
 				/* ELF comdef's generate multiple
@@ -749,7 +750,8 @@
 				 */
 				// See if we can convert a comdat to a comdef,
 				// which saves on exe file space.
-				if (sinit.Sclass == SCcomdat &&
+				if (0 && // causes multiple def problems with COMMON in one file and COMDAT in library
+				    sinit.Sclass == SCcomdat &&
 					sinit.Sdt &&
 					sinit.Sdt.dt == DT.DT_azeros &&
 					sinit.Sdt.DTnext == null &&
--- a/dmd/TraitsExp.d	Mon Aug 30 22:50:30 2010 +0200
+++ b/dmd/TraitsExp.d	Mon Aug 30 23:08:44 2010 +0200
@@ -380,9 +380,11 @@
 			Dsymbol s1 = getDsymbol(o1);
 			Dsymbol s2 = getDsymbol(o2);
 
-			static if (0) {
-				printf("o1: %p\n", o1);
-				printf("o2: %p\n", o2);
+			// writef("isSame: %s, %s\n", o1.toChars(), o2.toChars());
+			static if (0)
+			{
+				writef("o1: %p\n", o1);
+				writef("o2: %p\n", o2);
 				if (!s1)
 				{   Expression ea = isExpression(o1);
 					if (ea)
--- a/dmd/Type.d	Mon Aug 30 22:50:30 2010 +0200
+++ b/dmd/Type.d	Mon Aug 30 23:08:44 2010 +0200
@@ -128,7 +128,8 @@
 	/* pick this order of numbers so switch statements work better
 	 */
 ///	#define MODconst     1	// type is const
-///	#define MODinvariant 4	// type is invariant
+///	#define MODinvariant 4	// type is immutable
+///	#define MODimmutable 4  // type is immutable
 ///	#define MODshared    2	// type is shared
     string deco;
 
--- a/dmd/TypeFunction.d	Mon Aug 30 22:50:30 2010 +0200
+++ b/dmd/TypeFunction.d	Mon Aug 30 23:08:44 2010 +0200
@@ -653,27 +653,59 @@
     RET retStyle()
 	{
 		//printf("TypeFunction.retStyle() %s\n", toChars());
-version (DMDV2) {
+version (DMDV2)
+{
 		if (isref)
 			return RET.RETregs;			// returns a pointer
 }
 
 		Type tn = next.toBasetype();
+	    Type tns = tn;
+	    ulong sz = tn.size();
 
-		if (tn.ty == TY.Tstruct)
+version(SARRAYVALUE)
+{
+		if (tn.ty == Tsarray)
+		{
+			do
+			{
+				tns = tns.nextOf().toBasetype();
+			} while (tns.ty == Tsarray);
+			if (tns.ty != Tstruct)
+			{
+				if (global.params.isLinux && linkage != LINKd)
+				{}
+				else
+				{
+					switch (sz)
+					{   case 1:
+						case 2:
+						case 4:
+						case 8:
+						return RETregs;	// return small structs in regs
+									// (not 3 byte structs!)
+						default:
+						break;
+					}
+				}
+				return RETstack;
+			}
+		}
+}
+		if (tns.ty == TY.Tstruct)
 		{	
 			StructDeclaration sd = (cast(TypeStruct)tn).sym;
 			if (global.params.isLinux && linkage != LINK.LINKd) {
 				;
 			}
-///version (DMDV2) {
-			else if (sd.dtor || sd.cpctor) {
-				;
+///version (DMDV2) { // TODO:
+			else if (sd.dtor || sd.cpctor)
+			{
 			}
 ///}
 			else
 			{
-				switch (cast(int)tn.size())
+				switch (sz)
 				{   
 					case 1:
 					case 2: