diff dmd/AliasDeclaration.d @ 16:5c9b78899f5d

Implemented methods for Tuples, fixed some linking issues.
author Robert Clipsham <robert@octarineparrot.com>
date Sun, 04 Apr 2010 22:41:11 +0100
parents 10317f0c89a5
children 2e2a5c3f943a
line wrap: on
line diff
--- a/dmd/AliasDeclaration.d	Sun Apr 04 02:15:33 2010 +0100
+++ b/dmd/AliasDeclaration.d	Sun Apr 04 22:41:11 2010 +0100
@@ -20,49 +20,75 @@
 
 class AliasDeclaration : Declaration
 {
-    Dsymbol aliassym;
-    Dsymbol overnext;		// next in overload list
-    int inSemantic;
+	Dsymbol aliassym;
+	Dsymbol overnext;		// next in overload list
+	int inSemantic;
 
-    this(Loc loc, Identifier ident, Type type)
+	this(Loc loc, Identifier ident, Type type)
 	{
 		super(ident);
-		
+
 		//printf("AliasDeclaration(id = '%s', type = %p)\n", id.toChars(), type);
 		//printf("type = '%s'\n", type.toChars());
 		this.loc = loc;
 		this.type = type;
 		this.aliassym = null;
-	version (_DH) {
-		this.htype = null;
-		this.haliassym = null;
-	}
+		version (_DH) {
+			this.htype = null;
+			this.haliassym = null;
+		}
 
 		assert(type);
 	}
-	
-    this(Loc loc, Identifier id, Dsymbol s)
+
+	this(Loc loc, Identifier id, Dsymbol s)
 	{
 		super(id);
-		
+
 		//printf("AliasDeclaration(id = '%s', s = %p)\n", id->toChars(), s);
 		assert(s !is this);	/// huh?
 		this.loc = loc;
 		this.type = null;
 		this.aliassym = s;
-	version (_DH) {
-		this.htype = null;
-		this.haliassym = null;
-	}
+		version (_DH) {
+			this.htype = null;
+			this.haliassym = null;
+		}
 		assert(s);
 	}
-	
-    Dsymbol syntaxCopy(Dsymbol)
+
+	Dsymbol syntaxCopy(Dsymbol s)
 	{
-		assert(false);
+		//printf("AliasDeclaration::syntaxCopy()\n");
+		assert(!s);
+		AliasDeclaration sa;
+		if (type)
+			sa = new AliasDeclaration(loc, ident, type.syntaxCopy());
+		else
+			sa = new AliasDeclaration(loc, ident, aliassym.syntaxCopy(null));
+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();
+				sa.htype = type.syntaxCopy();
+			}
+		}
+		else			// Make copy of original for new instance
+			sa.htype = htype.syntaxCopy();
+		if (!haliassym)
+		{	if (aliassym)
+			{   haliassym = aliassym.syntaxCopy(s);
+				sa.haliassym = aliassym.syntaxCopy(s);
+			}
+		}
+		else
+			sa.haliassym = haliassym.syntaxCopy(s);
+} // version (_DH)
+		return sa;
 	}
-	
-    void semantic(Scope sc)
+
+	void semantic(Scope sc)
 	{
 		//printf("AliasDeclaration.semantic() %s\n", toChars());
 		if (aliassym)
@@ -100,7 +126,7 @@
 		if (s && ((s.getType() && type.equals(s.getType())) || s.isEnumMember()))
 			goto L2;			// it's a symbolic alias
 
-///version (DMDV2) {
+		///version (DMDV2) {
 		if (storage_class & STC.STCref)
 		{	// For 'ref' to be attached to function types, and picked
 			// up by Type.resolve(), it has to go into sc.
@@ -110,8 +136,8 @@
 			sc = sc.pop();
 		}
 		else
-///	#endif
-		type.resolve(loc, sc, &e, &t, &s);
+			///	#endif
+			type.resolve(loc, sc, &e, &t, &s);
 		if (s)
 		{
 			goto L2;
@@ -135,7 +161,7 @@
 		this.inSemantic = 0;
 		return;
 
-	  L2:
+L2:
 		//printf("alias is a symbol %s %s\n", s.kind(), s.toChars());
 		type = null;
 		VarDeclaration v = s.isVarDeclaration();
@@ -171,8 +197,8 @@
 		aliassym = s;
 		this.inSemantic = 0;
 	}
-	
-    bool overloadInsert(Dsymbol s)
+
+	bool overloadInsert(Dsymbol s)
 	{
 		/* Don't know yet what the aliased symbol is, so assume it can
 		 * be overloaded and check later for correctness.
@@ -189,17 +215,17 @@
 			return overnext.overloadInsert(s);
 		}
 	}
-	
-    string kind()
+
+	string kind()
 	{
 		return "alias";
 	}
-	
-    Type getType()
+
+	Type getType()
 	{
 		return type;
 	}
-    
+
 	Dsymbol toAlias()
 	{
 		//printf("AliasDeclaration::toAlias('%s', this = %p, aliassym = %p, kind = '%s')\n", toChars(), this, aliassym, aliassym ? aliassym->kind() : "");
@@ -214,20 +240,20 @@
 		Dsymbol s = aliassym ? aliassym.toAlias() : this;
 		return s;
 	}
-	
-    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
-	{
-		assert(false);
-	}
-	
-version (_DH) {
-    Type htype;
-    Dsymbol haliassym;
-}
-    void toDocBuffer(OutBuffer buf)
+
+	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
 		assert(false);
 	}
 
-    AliasDeclaration isAliasDeclaration() { return this; }
-}
\ No newline at end of file
+	version (_DH) {
+		Type htype;
+		Dsymbol haliassym;
+	}
+	void toDocBuffer(OutBuffer buf)
+	{
+		assert(false);
+	}
+
+	AliasDeclaration isAliasDeclaration() { return this; }
+	}