diff dmd/DtorDeclaration.d @ 98:5c859d5fbe27

and more
author Trass3r
date Tue, 31 Aug 2010 03:53:49 +0200
parents 43073c7c7769
children e28b18c23469
line wrap: on
line diff
--- a/dmd/DtorDeclaration.d	Tue Aug 31 02:12:15 2010 +0200
+++ b/dmd/DtorDeclaration.d	Tue Aug 31 03:53:49 2010 +0200
@@ -17,23 +17,24 @@
 
 class DtorDeclaration : FuncDeclaration
 {
-    this(Loc loc, Loc endloc)
+	this(Loc loc, Loc endloc)
 	{
 		super(loc, endloc, Id.dtor, STCundefined, null);
 	}
 
-    this(Loc loc, Loc endloc, Identifier id)
+	this(Loc loc, Loc endloc, Identifier id)
 	{
-		assert(false);
-		super(loc, endloc, null, STC.init, null);
+		super(loc, endloc, id, STCundefined, null);
 	}
 
-    override Dsymbol syntaxCopy(Dsymbol)
+	override Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+		assert(!s);
+		DtorDeclaration dd = new DtorDeclaration(loc, endloc, ident);
+		return super.syntaxCopy(dd);
 	}
 	
-    override void semantic(Scope sc)
+	override void semantic(Scope sc)
 	{
 		//printf("DtorDeclaration::semantic() %s\n", toChars());
 		//printf("ident: %s, %s, %p, %p\n", ident.toChars(), Id::dtor.toChars(), ident, Id::dtor);
@@ -53,31 +54,33 @@
 		sc.stc &= ~STCstatic;		// not a static destructor
 		sc.linkage = LINK.LINKd;
 
-		FuncDeclaration.semantic(sc);
+		super.semantic(sc);
 
 		sc.pop();
 	}
 	
-    override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		buf.writestring("~this()");
+		bodyToCBuffer(buf, hgs);
 	}
-    
+	
 	override void toJsonBuffer(OutBuffer buf)
 	{
+		// intentionally empty
 	}
 	
-    override string kind()
+	override string kind()
 	{
-		assert(false);
+		return "destructor";
 	}
 	
-    override string toChars()
+	override string toChars()
 	{
 		return "~this";
 	}
 	
-    override bool isVirtual()
+	override bool isVirtual()
 	{
 		/* This should be FALSE so that dtor's don't get put into the vtbl[],
 		 * but doing so will require recompiling everything.
@@ -85,29 +88,29 @@
 	version (BREAKABI) {
 		return false;
 	} else {
-		return FuncDeclaration.isVirtual();
+		return super.isVirtual();
 	}
 	}
 	
-    override bool addPreInvariant()
+	override bool addPreInvariant()
 	{
 		return (isThis() && vthis && global.params.useInvariants);
 	}
 	
-    override bool addPostInvariant()
+	override bool addPostInvariant()
 	{
 		return false;
 	}
 	
-    override bool overloadInsert(Dsymbol s)
+	override bool overloadInsert(Dsymbol s)
 	{
-		assert(false);
+		return false;	   // cannot overload destructors
 	}
 	
-    override void emitComment(Scope sc)
+	override void emitComment(Scope sc)
 	{
-		assert(false);
+		// intentionally empty
 	}
 
-    override DtorDeclaration isDtorDeclaration() { return this; }
+	override DtorDeclaration isDtorDeclaration() { return this; }
 }