diff dmd/AttribDeclaration.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 427f8aa74d28
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmd/AttribDeclaration.d	Sat Oct 24 08:42:06 2009 +0400
@@ -0,0 +1,265 @@
+module dmd.AttribDeclaration;
+
+import dmd.Dsymbol;
+import dmd.Array;
+import dmd.Scope;
+import dmd.ScopeDsymbol;
+import dmd.LINK;
+import dmd.STC;
+import dmd.PROT;
+import dmd.ArrayTypes;
+import dmd.OutBuffer;
+import dmd.HdrGenState;
+
+class AttribDeclaration : Dsymbol
+{
+    Array decl;	// array of Dsymbol's
+
+    this(Array decl)
+	{
+		this.decl = decl;
+	}
+	
+    Array include(Scope sc, ScopeDsymbol sd)
+	{
+		return decl;
+	}
+	
+    bool addMember(Scope sc, ScopeDsymbol sd, int memnum)
+	{
+		bool m = false;
+		Array d = include(sc, sd);
+
+		if (d)
+		{
+			for (uint i = 0; i < d.dim; i++)
+			{   
+				Dsymbol s = cast(Dsymbol)d.data[i];
+				m |= s.addMember(sc, sd, m | memnum);
+			}
+		}
+
+		return m;
+	}
+	
+    void setScopeNewSc(Scope sc, STC stc, LINK linkage, PROT protection, int explicitProtection, uint structalign)
+	{
+		if (decl)
+		{
+			Scope newsc = sc;
+			if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign)
+			{
+				// create new one for changes
+				newsc = new Scope(sc);
+				newsc.offset = sc.offset;
+				newsc.scopesym = sc.scopesym;
+				newsc.flags &= ~SCOPE.SCOPEfree;
+				newsc.stc = stc;
+				newsc.linkage = linkage;
+				newsc.protection = protection;
+				newsc.explicitProtection = explicitProtection;
+				newsc.structalign = structalign;
+			}
+			for (uint i = 0; i < decl.dim; i++)
+			{   
+				Dsymbol s = cast(Dsymbol)decl.data[i];
+				s.setScope(newsc);	// yes, the only difference from semanticNewSc()
+			}
+			if (newsc != sc)
+			{
+				sc.offset = newsc.offset;
+				newsc.pop();
+			}
+		}
+	}
+	
+    void semanticNewSc(Scope sc, STC stc, LINK linkage, PROT protection, int explicitProtection, uint structalign)
+	{
+		if (decl)
+		{
+			Scope newsc = sc;
+			if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign)
+			{
+				// create new one for changes
+				newsc = new Scope(sc);
+				newsc.offset = sc.offset;
+				newsc.scopesym = sc.scopesym;
+				newsc.flags &= ~SCOPE.SCOPEfree;
+				newsc.stc = stc;
+				newsc.linkage = linkage;
+				newsc.protection = protection;
+				newsc.explicitProtection = explicitProtection;
+				newsc.structalign = structalign;
+			}
+			for (uint i = 0; i < decl.dim; i++)
+			{   
+				Dsymbol s = cast(Dsymbol)decl.data[i];
+				s.semantic(newsc);
+			}
+			if (newsc != sc)
+			{
+				sc.offset = newsc.offset;
+				newsc.pop();
+			}
+		}
+	}
+	
+    void semantic(Scope sc)
+	{
+		Array d = include(sc, null);
+
+		//printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d);
+		if (d)
+		{
+			for (uint i = 0; i < d.dim; i++)
+			{
+				Dsymbol s = cast(Dsymbol)d.data[i];
+
+				s.semantic(sc);
+			}
+		}
+	}
+	
+    void semantic2(Scope sc)
+	{
+		Array d = include(sc, null);
+
+		if (d)
+		{
+			for (uint i = 0; i < d.dim; i++)
+			{   Dsymbol s = cast(Dsymbol)d.data[i];
+				s.semantic2(sc);
+			}
+		}
+	}
+	
+    void semantic3(Scope sc)
+	{
+		Array d = include(sc, null);
+
+		if (d)
+		{
+			for (uint i = 0; i < d.dim; i++)
+			{   
+				Dsymbol s = cast(Dsymbol)d.data[i];
+				s.semantic3(sc);
+			}
+		}
+	}
+	
+    void inlineScan()
+	{
+		Array d = include(null, null);
+
+		if (d)
+		{
+			for (uint i = 0; i < d.dim; i++)
+			{   
+				Dsymbol s = cast(Dsymbol)d.data[i];
+				//printf("AttribDeclaration.inlineScan %s\n", s.toChars());
+				s.inlineScan();
+			}
+		}
+	}
+	
+    void addComment(ubyte* comment)
+	{
+		if (comment !is null)
+		{
+			Array d = include(null, null);
+			if (d)
+			{
+				for (uint i = 0; i < d.dim; i++)
+				{  
+					Dsymbol s = cast(Dsymbol)d.data[i];
+					//printf("AttribDeclaration::addComment %s\n", s.toChars());
+					s.addComment(comment);
+				}
+			}
+		}
+	}
+	
+    void emitComment(Scope sc)
+	{
+		assert(false);
+	}
+	
+    string kind()
+	{
+		assert(false);
+	}
+	
+    bool oneMember(Dsymbol* ps)
+	{
+		assert(false);
+	}
+	
+    bool hasPointers()
+	{
+		Array d = include(null, null);
+
+		if (d)
+		{
+			for (size_t i = 0; i < d.dim; i++)
+			{
+				Dsymbol s = cast(Dsymbol)d.data[i];
+				if (s.hasPointers())
+					return true;
+			}
+		}
+
+		return 0;
+	}
+	
+    void checkCtorConstInit()
+	{
+		Array d = include(null, null);
+		if (d)
+		{
+			for (uint i = 0; i < d.dim; i++)
+			{   
+				Dsymbol s = cast(Dsymbol)d.data[i];
+				s.checkCtorConstInit();
+			}
+		}
+	}
+	
+    void addLocalClass(ClassDeclarations aclasses)
+	{
+		Array d = include(null, null);
+		if (d)
+		{
+			for (uint i = 0; i < d.dim; i++)
+			{   
+				Dsymbol s = cast(Dsymbol)d.data[i];
+				s.addLocalClass(aclasses);
+			}
+		}
+	}
+	
+    void toCBuffer(OutBuffer buf, HdrGenState* hgs)
+	{
+		assert(false);
+	}
+	
+    AttribDeclaration isAttribDeclaration() { return this; }
+
+    void toObjFile(int multiobj)			// compile to .obj file
+	{
+		Array d = include(null, null);
+
+		if (d)
+		{
+			for (uint i = 0; i < d.dim; i++)
+			{   
+				Dsymbol s = cast(Dsymbol)d.data[i];
+				s.toObjFile(multiobj);
+			}
+		}
+	}
+	
+    int cvMember(ubyte* p)
+	{
+		assert(false);
+	}
+}
\ No newline at end of file