The base descriptor for a class
Inheritance: Type
		public static bool IsEnum (Class type)
		{
			return IsEnum (type.nameSpace, type.name);
		}
		/// <summary>
		/// Add a nested class to this class
		/// </summary>
		/// <param name="attrSet">attributes for this nested class</param>
		/// <param name="nsName">nested name space name</param>
		/// <param name="name">nested class name</param>
		/// <param name="sType">super type of this nested class</param>
		/// <returns>a descriptor for this new nested class</returns>
		public ClassDef AddNestedClass(TypeAttr attrSet, string nsName, 
				string name, Class sType) {
			ClassDef nClass = AddNestedClass (attrSet, nsName, name);
			nClass.SetSuper(sType);
			if (ClassDef.IsValueType (sType))
				nClass.MakeValueClass (ValueClass.ValueType);
			else
				if (ClassDef.IsEnum (sType))
					nClass.MakeValueClass (ValueClass.Enum);

			if (ClassDef.IsValueType (sType) || ClassDef.IsEnum (sType))
				nClass.SetTypeIndex (PrimitiveType.ValueType.GetTypeIndex ());

			nClass.typeIndexChecked = true;
			return (nClass);
		}
		/// <summary>
		/// Add an interface that is implemented by this class
		/// </summary>
		/// <param name="iFace">the interface that is implemented</param>
		public void AddImplementedInterface(Class iFace) 
		{
			metaData.AddToTable(MDTable.InterfaceImpl,new InterfaceImpl(this,iFace));
		}
		public static bool IsValueType (Class type)
		{
			return IsValueType (type.nameSpace, type.name);
		}
示例#5
0
 internal ClassDef(TypeAttr attrSet, string nsName, string name, 
                   MetaData md) : base(nsName, name, md) {
                     metaData = md;
   superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
   flags = (uint)attrSet;
   tabIx = MDTable.TypeDef;
 }
		public void SpecialNoSuper() 
		{
			superType = null;
		}
		internal ClassDef(TypeAttr attrSet, string nsName, string name, 
				MetaData md) : base(nsName, name, md) 
		{
			metaData = md;
			if (! ((nsName == "" && name == "<Module>") || (nsName == "System" && name == "Object")) ) {
				superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
			}
			flags = (uint)attrSet;
			tabIx = MDTable.TypeDef;
		}
		/// <summary>
		/// Create a new custom modifier for a type
		/// </summary>
		/// <param name="type">the type to be modified</param>
		/// <param name="cmod">the modifier</param>
		/// <param name="cmodType">the type reference to be associated with the type</param>
		public CustomModifiedType(Type type, CustomModifier cmod, Class cmodType)
			: base((byte)cmod) 
		{
			this.type = type;
			this.cmodType = cmodType;
		}
示例#9
0
文件: Code.cs 项目: REALTOBIZ/mono
		/// <summary>
		/// Mark this position as the end of the last started block and
		/// make it a catch block.  This catch block is associated with the
		/// specified try block.
		/// </summary>
		/// <param name="exceptType">the exception type to be caught</param>
		/// <param name="tryBlock">the try block associated with this catch block</param>
		public void EndCatchBlock(Class exceptType, TryBlock tryBlock) 
		{
			Catch catchBlock = new Catch(exceptType,(CILLabel)blockStack[0],
					NewCodedLabel());
			tryBlock.AddHandler(catchBlock);
		}
示例#10
0
		internal InterfaceImpl(ClassDef theClass, Class theInterface) 
		{
			this.theClass = theClass;
			this.theInterface = theInterface;
			tabIx = MDTable.InterfaceImpl;
		}
示例#11
0
文件: Code.cs 项目: REALTOBIZ/mono
		/// <summary>
		/// Create a new catch clause
		/// </summary>
		/// <param name="except">the exception to be caught</param>
		/// <param name="handlerStart">start of the handler code</param>
		/// <param name="handlerEnd">end of the handler code</param>
		public Catch(Class except, CILLabel handlerStart, CILLabel handlerEnd)
			: base(handlerStart, handlerEnd)
		{
			exceptType = except;
		}
示例#12
0
 /// <summary>
 /// Add a class to this module
 /// </summary>
 /// <param name="attrSet">attributes of this class</param>
 /// <param name="nsName">name space name</param>
 /// <param name="name">class name</param>
 /// <param name="superType">super type of this class (extends)</param>
 /// <returns>a descriptor for this new class</returns>
 public ClassDef AddClass(TypeAttr attrSet, string nsName, string name, Class superType) {
   ClassDef aClass = new ClassDef(attrSet,nsName,name,metaData);
   aClass.SetSuper(superType);
   metaData.AddToTable(MDTable.TypeDef,aClass);
   return aClass;
 }
示例#13
0
 internal void SetSuper(Class sClass) {
   superType = sClass;
   if (sClass is ClassRef)
     typeIndex = superType.GetTypeIndex();
   else
     typeIndexChecked = false;
 }
示例#14
0
		internal sealed override void BuildTables(MetaData md) 
		{
			if (done) return;
			if ((flags & (uint)TypeAttr.Interface) != 0) { superType = null; }
			// Console.WriteLine("Building tables for " + name);
			if (layout != null) md.AddToTable(MDTable.ClassLayout,layout);
			// Console.WriteLine("adding methods " + methods.Count);
			methodIx = md.TableIndex(MDTable.Method);
			for (int i=0; i < methods.Count; i++) {
				md.AddToTable(MDTable.Method,(MetaDataElement)methods[i]);
				((MethodDef)methods[i]).BuildTables(md);
			}
			// Console.WriteLine("adding fields");
			fieldIx = md.TableIndex(MDTable.Field);
			for (int i=0; i < fields.Count; i++) {
				md.AddToTable(MDTable.Field,(MetaDataElement)fields[i]);
				((FieldDef)fields[i]).BuildTables(md);
			}
			// Console.WriteLine("adding events and properties");
			if (events != null) { 
				for (int i=0; i < events.Count; i++) {
					md.AddToTable(MDTable.Event,(Event)events[i]);
					((Event)events[i]).BuildTables(md);
				}
				md.AddToTable(MDTable.EventMap,
						new MapElem(this,((Event)events[0]).Row,MDTable.Event));
			}
			if (properties != null) { 
				for (int i=0; i < properties.Count; i++) {
					md.AddToTable(MDTable.Property,(Property)properties[i]);
					((Property)properties[i]).BuildTables(md);
				}
				md.AddToTable(MDTable.PropertyMap,new MapElem(this,
							((Property)properties[0]).Row,MDTable.Property));
			}
			// Console.WriteLine("End of building tables");
			done = true;
		}
示例#15
0
		internal void SetSuper(Class sClass) 
		{
			superType = sClass;
			if (! (sClass is GenericTypeInst))
				typeIndexChecked = false;
		}
示例#16
0
		public ClassType(Class classDesc) 
		{
			desc = classDesc;
			type = PrimitiveType.ClassType;
		}
示例#17
0
		internal override void MakeValueClass(ValueClass vClass) 
		{
			if (vClass == ValueClass.Enum)  
				superType = metaData.mscorlib.EnumType();
			else  
				superType = metaData.mscorlib.ValueType();

			typeIndex = PrimitiveType.ValueType.GetTypeIndex ();
		}
示例#18
0
		internal void SetSpecialSystemClass (string nsName, string name, Class aClass) 
		{
			if (nsName != systemName) return;
			int hash = name.GetHashCode ();
			for (int i = 0; i < specialNames.Length; i++) {
				if (hash != specialNames [i])
					continue;
				if (systemClasses [i] == null) {
					systemClasses [i] = aClass;
				}
			}
		}
示例#19
0
		/// <summary>
		/// Add a class to this module
		/// </summary>
		/// <param name="attrSet">attributes of this class</param>
		/// <param name="nsName">name space name</param>
		/// <param name="name">class name</param>
		/// <param name="superType">super type of this class (extends)</param>
		/// <returns>a descriptor for this new class</returns>
		public ClassDef AddClass(TypeAttr attrSet, string nsName, string name, Class superType) 
		{
			ClassDef aClass = new ClassDef(attrSet,nsName,name,metaData);
			if (superType != null)
				aClass.SetSuper(superType);
			if (PEFile.IsMSCorlib)
				metaData.mscorlib.SetSpecialSystemClass (nsName, name, aClass);
			metaData.AddToTable(MDTable.TypeDef,aClass);
			return aClass;
		}