浏览代码

Merge pull request #1798 from MineGame159/type_static_abstract

Add IsStatic and IsAbstract to System.Type
Brian Fiete 2 年之前
父节点
当前提交
0aedc37d42
共有 3 个文件被更改,包括 28 次插入1 次删除
  1. 19 0
      BeefLibs/corlib/src/Type.bf
  2. 5 0
      IDEHelper/Compiler/BfModule.cpp
  3. 4 1
      IDEHelper/Compiler/BfSystem.h

+ 19 - 0
BeefLibs/corlib/src/Type.bf

@@ -394,6 +394,22 @@ namespace System
 		    }
 		}
 
+		public bool IsStatic
+		{
+			get
+			{
+				return (mTypeFlags & .Static) != 0;
+			}
+		}
+
+		public bool IsAbstract
+		{
+			get
+			{
+				return (mTypeFlags & .Abstract) != 0;
+			}
+		}
+
 		public virtual int32 GenericParamCount
 		{
 			get
@@ -1461,6 +1477,9 @@ namespace System.Reflection
 		Function				= 0x40000,
 		HasDestructor			= 0x80000,
 		GenericParam			= 0x100000,
+
+		Static					= 0x200000,
+		Abstract				= 0x400000,
     }
 
     public enum FieldFlags : uint16

+ 5 - 0
IDEHelper/Compiler/BfModule.cpp

@@ -5997,6 +5997,11 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
 	if ((type->mDefineState != BfTypeDefineState_CETypeInit) && (type->WantsGCMarking()))
 		typeFlags |= BfTypeFlags_WantsMarking;
 
+	if ((typeInstance != NULL) && (typeInstance->mTypeDef->mIsStatic))
+		typeFlags |= BfTypeFlags_Static;
+	if ((typeInstance != NULL) && (typeInstance->mTypeDef->mIsAbstract))
+		typeFlags |= BfTypeFlags_Abstract;
+
 	int virtSlotIdx = -1;
 	if ((typeInstance != NULL) && (typeInstance->mSlotNum >= 0))
 		virtSlotIdx = typeInstance->mSlotNum + 1 + mCompiler->GetDynCastVDataCount();

+ 4 - 1
IDEHelper/Compiler/BfSystem.h

@@ -220,7 +220,10 @@ enum BfTypeFlags
 	BfTypeFlags_Delegate        = 0x20000,
 	BfTypeFlags_Function		= 0x40000,
 	BfTypeFlags_HasDestructor   = 0x80000,
-	BfTypeFlags_GenericParam	= 0x100000
+	BfTypeFlags_GenericParam	= 0x100000,
+
+	BfTypeFlags_Static			= 0x200000,
+	BfTypeFlags_Abstract		= 0x400000,
 };
 
 enum BfMethodFlags