changeset 139:bc45b1c53019

made StorageClass type-safe
author Trass3r
date Tue, 14 Sep 2010 01:13:58 +0200
parents 90821c10b6a7
children 31c086f76669
files dmd/Declaration.d dmd/FuncDeclaration.d dmd/STC.d dmd/StructDeclaration.d
diffstat 4 files changed, 24 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/Declaration.d	Tue Sep 14 00:00:24 2010 +0200
+++ b/dmd/Declaration.d	Tue Sep 14 01:13:58 2010 +0200
@@ -271,7 +271,7 @@
 		return p;
 	}
 	
-    int isStatic() { return storage_class & STC.STCstatic; }
+    bool isStatic() { return (storage_class & STC.STCstatic) != 0; }
 	
     bool isStaticConstructor()
 	{
@@ -303,33 +303,33 @@
 		return false;
 	}
 	
-    int isCtorinit()     { return storage_class & STC.STCctorinit; }
+    bool isCtorinit()     { return (storage_class & STC.STCctorinit) != 0; }
     
-	int isFinal()        { return storage_class & STC.STCfinal; }
+	bool isFinal()        { return (storage_class & STC.STCfinal) != 0; }
     
 	bool isAbstract()     { return (storage_class & STC.STCabstract)  != 0; }
     
 	bool isConst()        { return (storage_class & STC.STCconst) != 0; }
     
-	int isImmutable()    { return storage_class & STC.STCimmutable; }
+	bool isImmutable()    { return (storage_class & STC.STCimmutable) != 0; }
     
-	int isAuto()         { return storage_class & STC.STCauto; }
+	bool isAuto()         { return (storage_class & STC.STCauto) != 0; }
     
-	int isScope()        { return storage_class & (STC.STCscope | STC.STCauto); }
+	bool isScope()        { return (storage_class & (STC.STCscope | STC.STCauto)) != 0; }
     
-	int isSynchronized() { return storage_class & STC.STCsynchronized; }
+	bool isSynchronized() { return (storage_class & STC.STCsynchronized) != 0; }
     
-	int isParameter()    { return storage_class & STC.STCparameter; }
+	bool isParameter()    { return (storage_class & STC.STCparameter) != 0; }
     
 	override bool isDeprecated()   { return (storage_class & STC.STCdeprecated)  != 0; }
     
-	int isOverride()     { return storage_class & STC.STCoverride; }
+	bool isOverride()     { return (storage_class & STC.STCoverride) != 0; }
 
-    int isIn()    { return storage_class & STC.STCin; }
+    bool isIn()    { return (storage_class & STC.STCin) != 0; }
     
-	int isOut()   { return storage_class & STC.STCout; }
+	bool isOut()   { return (storage_class & STC.STCout) != 0; }
     
-	int isRef()   { return storage_class & STC.STCref; }
+	bool isRef()   { return (storage_class & STC.STCref) != 0; }
 
     override PROT prot()
 	{
--- a/dmd/FuncDeclaration.d	Tue Sep 14 00:00:24 2010 +0200
+++ b/dmd/FuncDeclaration.d	Tue Sep 14 01:13:58 2010 +0200
@@ -2326,7 +2326,7 @@
 		return isMember() && !(isStatic() || protection == PROT.PROTprivate || protection == PROT.PROTpackage) && toParent().isClassDeclaration();
 	}
 	
-    override int isFinal()
+    override bool isFinal()
 	{
 		ClassDeclaration cd;
 static if (false) {
--- a/dmd/STC.d	Tue Sep 14 00:00:24 2010 +0200
+++ b/dmd/STC.d	Tue Sep 14 01:13:58 2010 +0200
@@ -1,6 +1,6 @@
 module dmd.STC;
 
-enum STC
+enum STC : ulong
 {
     STCundefined    = 0,
     STCstatic	    = 1,
@@ -37,15 +37,15 @@
 					// but not typed as "shared"
     STCwild         = 0x80000000,	// for "wild" type constructor
     STC_TYPECTOR    = (STCconst | STCimmutable | STCshared | STCwild),
+
+    // attributes
+	STCproperty		= 0x100000000,
+	STCsafe			= 0x200000000,
+	STCtrusted		= 0x400000000,
+	STCsystem		= 0x800000000,
+	STCctfe			= 0x1000000000,	// can be used in CTFE, even if it is static
 }
+alias STC StorageClass;
 
 import dmd.EnumUtils;
-mixin(BringToCurrentScope!(STC));
-
-enum STCproperty	= 0x100000000;
-enum STCsafe		= 0x200000000;
-enum STCtrusted		= 0x400000000;
-enum STCsystem		= 0x800000000;
-enum STCctfe		= 0x1000000000;	// can be used in CTFE, even if it is static
-
-alias ulong StorageClass;
\ No newline at end of file
+mixin(BringToCurrentScope!(STC));
\ No newline at end of file
--- a/dmd/StructDeclaration.d	Tue Sep 14 00:00:24 2010 +0200
+++ b/dmd/StructDeclaration.d	Tue Sep 14 01:13:58 2010 +0200
@@ -724,7 +724,7 @@
 		fop.addMember(sc, this, 1);
 
 		sc = sc.push();
-		sc.stc = 0;
+		sc.stc = STCundefined;
 		sc.linkage = LINK.LINKd;
 
 		fop.semantic(sc);