changeset 154:14feb7ae01a6

* changed the build system to build a release version if the debug one compiles and enabled warnings + reduced warnings by adding appriopriate overrides + IfStatement.interpret() + ScopeStatement.interpret() + TypeSArray.constConv() + TypedefDeclaration.syntaxCopy() * fixed a bug in StringExp
author trass3r
date Wed, 15 Sep 2010 15:32:31 +0200
parents fe2e1b93e88f
children a43c65469219
files build.bat build.sh commands.linux.txt commands.txt dmd/BinExp.d dmd/IfStatement.d dmd/NewAnonClassExp.d dmd/PowAssignExp.d dmd/ScopeStatement.d dmd/StringExp.d dmd/StructDeclaration.d dmd/TypeDelegate.d dmd/TypeNewArray.d dmd/TypeNext.d dmd/TypeSArray.d dmd/TypeStruct.d dmd/TypedefDeclaration.d dmd/UnaExp.d
diffstat 18 files changed, 94 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/build.bat	Wed Sep 15 03:58:55 2010 +0200
+++ b/build.bat	Wed Sep 15 15:32:31 2010 +0200
@@ -1,2 +1,2 @@
 @echo off
-cls && dmc.exe bridge\bridge.cpp -c && dmd.exe @commands.txt
\ No newline at end of file
+cls && dmc.exe bridge\bridge.cpp -c && dmd -debug -g @commands.txt && dmd -release -O -inline @commands.txt
\ No newline at end of file
--- a/build.sh	Wed Sep 15 03:58:55 2010 +0200
+++ b/build.sh	Wed Sep 15 15:32:31 2010 +0200
@@ -1,4 +1,4 @@
 #!/bin/sh
 #i686-unknown-linux-gnu-g++ -c bridge/bridge.cpp -obridge.o
 g++ -c bridge/bridge.cpp -obridge.o
-dmd @commands.linux.txt #|& head
+dmd -debug -gc @commands.linux.txt && dmd -release -O -inline @commands.linux.txt #|& head
--- a/commands.linux.txt	Wed Sep 15 03:58:55 2010 +0200
+++ b/commands.linux.txt	Wed Sep 15 15:32:31 2010 +0200
@@ -1,5 +1,4 @@
--gc
--debug
+-w
 -version=Bug3602
 -version=Bug4054
 -version=Bug4059
--- a/commands.txt	Wed Sep 15 03:58:55 2010 +0200
+++ b/commands.txt	Wed Sep 15 15:32:31 2010 +0200
@@ -1,5 +1,4 @@
--g
--debug
+-w
 -version=DMDV2
 -version=TX86
 -version=MARS
--- a/dmd/BinExp.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/BinExp.d	Wed Sep 15 15:32:31 2010 +0200
@@ -690,7 +690,7 @@
 		assert(false);
 	}
 
-    void scanForNestedRef(Scope sc)
+    override void scanForNestedRef(Scope sc)
 	{
 		e1.scanForNestedRef(sc);
 		e2.scanForNestedRef(sc);
--- a/dmd/IfStatement.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/IfStatement.d	Wed Sep 15 15:32:31 2010 +0200
@@ -9,6 +9,7 @@
 import dmd.Scope;
 import dmd.InterState;
 import dmd.OutBuffer;
+import dmd.GlobalExpressions;
 import dmd.HdrGenState;
 import dmd.InlineCostState;
 import dmd.InlineDoState;
@@ -122,7 +123,36 @@
 	
     override Expression interpret(InterState istate)
 	{
-		assert(false);
+version(LOG)
+		writef("IfStatement::interpret(%s)\n", condition.toChars());
+
+		if (istate.start is this)
+			istate.start = null;
+		if (istate.start)
+		{
+			Expression e = null;
+			if (ifbody)
+				e = ifbody.interpret(istate);
+			if (istate.start && elsebody)
+				e = elsebody.interpret(istate);
+			return e;
+		}
+
+		Expression e = condition.interpret(istate);
+		assert(e);
+		//if (e is EXP_CANT_INTERPRET) writef("cannot interpret\n");
+		if (e !is EXP_CANT_INTERPRET)
+		{
+			if (e.isBool(true))
+				e = ifbody ? ifbody.interpret(istate) : null;
+			else if (e.isBool(false))
+				e = elsebody ? elsebody.interpret(istate) : null;
+			else
+			{
+				e = EXP_CANT_INTERPRET;
+			}
+		}
+		return e;
 	}
 	
     override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
--- a/dmd/NewAnonClassExp.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/NewAnonClassExp.d	Wed Sep 15 15:32:31 2010 +0200
@@ -64,7 +64,7 @@
 		return true;
 	}
 
-	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
 		if (thisexp)
 		{	
--- a/dmd/PowAssignExp.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/PowAssignExp.d	Wed Sep 15 15:32:31 2010 +0200
@@ -70,7 +70,7 @@
     }
     
     // For operator overloading
-    Identifier opId()
+    override Identifier opId()
     {
         return Id.powass;
     }
--- a/dmd/ScopeStatement.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/ScopeStatement.d	Wed Sep 15 15:32:31 2010 +0200
@@ -125,7 +125,12 @@
 	
     override Expression interpret(InterState istate)
 	{
-		assert(false);
+version(LOG)
+		writef("ScopeStatement::interpret()\n");
+
+		if (istate.start is this)
+			istate.start = null;
+		return statement ? statement.interpret(istate) : null;
 	}
 
     override Statement inlineScan(InlineScanState* iss)
--- a/dmd/StringExp.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/StringExp.d	Wed Sep 15 15:32:31 2010 +0200
@@ -315,6 +315,7 @@
 								case TY.Twchar:
 								case TY.Tdchar:
 									return mm;
+								default:
 							}
 							break;
 						default:
--- a/dmd/StructDeclaration.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/StructDeclaration.d	Wed Sep 15 15:32:31 2010 +0200
@@ -432,7 +432,7 @@
 		}
 	}
 	
-    Dsymbol search(Loc loc, Identifier ident, int flags)
+    override Dsymbol search(Loc loc, Identifier ident, int flags)
     {
         //printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars());
 
--- a/dmd/TypeDelegate.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/TypeDelegate.d	Wed Sep 15 15:32:31 2010 +0200
@@ -79,7 +79,7 @@
 		return PTRSIZE * 2;
 	}
 	
-	MATCH implicitConvTo(Type to)
+	override MATCH implicitConvTo(Type to)
 	{
 		//writef("TypeDelegate::implicitConvTo(this=%p, to=%p)\n", this, to);
 		//writef("from: %s\n", toChars());
--- a/dmd/TypeNewArray.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/TypeNewArray.d	Wed Sep 15 15:32:31 2010 +0200
@@ -18,7 +18,7 @@
 		//writef("TypeNewArray\n");
 	}
 
-	void toCBuffer2(OutBuffer buf, HdrGenState *hgs, MOD mod)
+	override void toCBuffer2(OutBuffer buf, HdrGenState *hgs, MOD mod)
 	{
 		if (mod != this.mod)
 		{
--- a/dmd/TypeNext.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/TypeNext.d	Wed Sep 15 15:32:31 2010 +0200
@@ -209,7 +209,7 @@
         return t;
     }
 
-    Type makeSharedWild()
+    override Type makeSharedWild()
     {
         //printf("TypeNext::makeSharedWild() %s\n", toChars());
         if (swto)
@@ -232,7 +232,7 @@
         return t;
     }
 
-    Type makeMutable()
+    override Type makeMutable()
     {
         //printf("TypeNext::makeMutable() %p, %s\n", this, toChars());
         auto t = cast(TypeNext)Type.makeMutable();
--- a/dmd/TypeSArray.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/TypeSArray.d	Wed Sep 15 15:32:31 2010 +0200
@@ -355,7 +355,13 @@
 	
     override MATCH constConv(Type to)
 	{
-		assert(false);
+		if (to.ty == Tsarray)
+		{
+			TypeSArray tsa = cast(TypeSArray)to;
+			if (!dim.equals(tsa.dim))
+				return MATCHnomatch;
+		}
+		return super.constConv(to);
 	}
 	
     override MATCH implicitConvTo(Type to)
--- a/dmd/TypeStruct.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/TypeStruct.d	Wed Sep 15 15:32:31 2010 +0200
@@ -392,7 +392,7 @@
      * Use when we prefer the default initializer to be a literal,
      * rather than a global immutable variable.
      */
-    Expression defaultInitLiteral(Loc loc)
+    override Expression defaultInitLiteral(Loc loc)
     {
 	version (LOGDEFAULTINIT) {
         printf("TypeStruct::defaultInitLiteral() '%s'\n", toChars());
--- a/dmd/TypedefDeclaration.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/TypedefDeclaration.d	Wed Sep 15 15:32:31 2010 +0200
@@ -58,9 +58,42 @@
 		assert(false);
 	}
 }
-    override Dsymbol syntaxCopy(Dsymbol)
+    override Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+		Type basetype = this.basetype.syntaxCopy();
+
+		Initializer init = null;
+		if (this.init)
+			init = this.init.syntaxCopy();
+
+		assert(!s);
+		TypedefDeclaration st;
+		st = new TypedefDeclaration(loc, ident, basetype, init);
+version(_DH)
+{
+		// Syntax copy for header file
+		if (!htype)		// Don't overwrite original
+		{
+			if (type)	// Make copy for both old and new instances
+			{
+				htype = type.syntaxCopy();
+				st.htype = type.syntaxCopy();
+			}
+		}
+		else			// Make copy of original for new instance
+			st.htype = htype.syntaxCopy();
+		if (!hbasetype)
+		{
+			if (basetype)
+			{
+				hbasetype = basetype.syntaxCopy();
+				st.hbasetype = basetype.syntaxCopy();
+			}
+		}
+		else
+			st.hbasetype = hbasetype.syntaxCopy();
+}
+		return st;
 	}
 	
     override void semantic(Scope sc)
--- a/dmd/UnaExp.d	Wed Sep 15 03:58:55 2010 +0200
+++ b/dmd/UnaExp.d	Wed Sep 15 15:32:31 2010 +0200
@@ -86,7 +86,7 @@
 		return e1.canThrow();
 	}
 
-	Expression resolveLoc(Loc loc, Scope sc)
+	override Expression resolveLoc(Loc loc, Scope sc)
 	{
 		e1 = e1.resolveLoc(loc, sc);
 		return this;