AddToTable() private method

private AddToTable ( MDTable tableIx, MetaDataElement elem ) : void
tableIx MDTable
elem MetaDataElement
return void
Ejemplo n.º 1
0
		internal sealed override void BuildTables(MetaData md) 
		{
			md.AddToTable(MDTable.File,this);
		}
Ejemplo n.º 2
0
		internal MSCorLib(MetaData md) : base(md,"mscorlib") 
		{
			if (!PEFile.IsMSCorlib)
				md.AddToTable(MDTable.AssemblyRef,this);
			systemTypes[PrimitiveType.Void.GetSystemTypeIx()] = PrimitiveType.Void;
			systemTypes[PrimitiveType.Boolean.GetSystemTypeIx()] = PrimitiveType.Boolean;
			systemTypes[PrimitiveType.Char.GetSystemTypeIx()] = PrimitiveType.Char;
			systemTypes[PrimitiveType.Int8.GetSystemTypeIx()] = PrimitiveType.Int8;
			systemTypes[PrimitiveType.UInt8.GetSystemTypeIx()] = PrimitiveType.UInt8;
			systemTypes[PrimitiveType.Int16.GetSystemTypeIx()] = PrimitiveType.Int16;
			systemTypes[PrimitiveType.UInt16.GetSystemTypeIx()] = PrimitiveType.UInt16;
			systemTypes[PrimitiveType.Int32.GetSystemTypeIx()] = PrimitiveType.Int32;
			systemTypes[PrimitiveType.UInt32.GetSystemTypeIx()] = PrimitiveType.UInt32;
			systemTypes[PrimitiveType.Int64.GetSystemTypeIx()] = PrimitiveType.Int64;
			systemTypes[PrimitiveType.UInt64.GetSystemTypeIx()] = PrimitiveType.UInt64;
			systemTypes[PrimitiveType.Float32.GetSystemTypeIx()] = PrimitiveType.Float32;
			systemTypes[PrimitiveType.Float64.GetSystemTypeIx()] = PrimitiveType.Float64;
			systemTypes[PrimitiveType.IntPtr.GetSystemTypeIx()] = PrimitiveType.IntPtr;
			systemTypes[PrimitiveType.UIntPtr.GetSystemTypeIx()] = PrimitiveType.UIntPtr;
			systemTypes[PrimitiveType.String.GetSystemTypeIx()] = PrimitiveType.String;
			systemTypes[PrimitiveType.Object.GetSystemTypeIx()] = PrimitiveType.Object;
			systemTypes[PrimitiveType.TypedRef.GetSystemTypeIx()] = PrimitiveType.TypedRef;
		}
Ejemplo n.º 3
0
		internal sealed override void BuildTables(MetaData md) 
		{
			if (done) return;

			BinaryWriter bw = new BinaryWriter (new MemoryStream ());
			md.AddToTable (MDTable.DeclSecurity, this);
			MemoryStream str = (MemoryStream)bw.BaseStream;
			WriteSig (bw);
			permissionIx = md.AddToBlobHeap(str.ToArray());

			done = true;
		}
Ejemplo n.º 4
0
		internal override MetaDataElement GetTypeSpec(MetaData md) 
		{
			TypeSpec tS = md.GetPrimitiveTypeSpec(systemTypeIndex);
			if (tS == null) {
				tS = new TypeSpec(this,md);
				md.SetPrimitiveTypeSpec(systemTypeIndex,tS);
				md.AddToTable(MDTable.TypeSpec,tS);
			}
			return tS;
		}
Ejemplo n.º 5
0
		internal sealed override void BuildTables(MetaData md) 
		{
			md.AddToTable(MDTable.CustomAttribute, this);
			if (byteVal == null) {
				valIx = 0;
				return;
			}

			BinaryWriter bw = new BinaryWriter(new MemoryStream());
			bw.Write(byteVal);
			MemoryStream str = (MemoryStream)bw.BaseStream;
			valIx = md.AddToBlobHeap(str.ToArray());
		}
Ejemplo n.º 6
0
		internal sealed override void BuildTables(MetaData md) 
		{
			if (done) return;
			nameIx = md.AddToStringsHeap(name);
			MemoryStream sig = new MemoryStream();
			sig.WriteByte(FieldSig);
			type.TypeSig(sig);
			sigIx = md.AddToBlobHeap(sig.ToArray());
			if (rva != null) {
				md.AddToTable(MDTable.FieldRVA,rva);
				rva.BuildTables(md);
			} else if (constVal != null) {
				md.AddToTable(MDTable.Constant,constVal);
				constVal.BuildTables(md);
			}
			if (layout != null) md.AddToTable(MDTable.FieldLayout,layout);
			if (marshalInfo != null) {
				md.AddToTable(MDTable.FieldMarshal,marshalInfo);
				marshalInfo.BuildTables(md);
			}
			done = true;
		}
Ejemplo n.º 7
0
		internal sealed override void BuildTables(MetaData md) 
		{
			if (done) return;
			if (pinvokeImpl != null) {
				md.AddToTable(MDTable.ImplMap,pinvokeImpl);
				pinvokeImpl.BuildTables(md);
			}
			if (entryPoint) md.SetEntryPoint(this);
			uint locToken = 0;
			if (locals != null) {
				localSig = new LocalSig(locals);
				md.AddToTable(MDTable.StandAloneSig,localSig);
				localSig.BuildTables(md);
				locToken = localSig.Token();
			}
			if (code != null) {
				code.CheckCode(locToken,initLocals,maxStack);
				textOffset = md.AddCode(code);
			}
			nameIx = md.AddToStringsHeap(name);
			sigIx = GetSigIx(md);
			parIx = md.TableIndex(MDTable.Param);
			if (ret_param.HasMarshalInfo || ret_param.HasCustomAttr) {
				md.AddToTable(MDTable.Param, ret_param);
				ret_param.BuildTables(md);
			}
			for (int i=0; i < numPars; i++) {
				md.AddToTable(MDTable.Param,parList[i]);
				parList[i].BuildTables(md);
			}
			if (varArgSigList != null) {
				foreach (MethodRef varArgSig in varArgSigList) {
					md.AddToTable(MDTable.MemberRef,varArgSig);
					varArgSig.BuildTables(md);
				}
			}
			// Console.WriteLine("method has " + numPars + " parameters");
			done = true;
		}
Ejemplo n.º 8
0
		internal sealed override void BuildTables(MetaData md) 
		{
			if (done) return;
			nameIx = md.AddToStringsHeap(name);
			for (int i=0; i < tide; i++) {
				md.AddToTable(MDTable.MethodSemantics,methods[i]);
			}
			done = true;
		}
Ejemplo n.º 9
0
		internal sealed override void BuildTables(MetaData md) 
		{
			if (done) return;
			nameIx = md.AddToStringsHeap(name);
			MemoryStream sig = new MemoryStream();
			byte tag = PropertyTag;
			if (instance)
				tag |= 0x20;
			sig.WriteByte(tag);
			MetaData.CompressNum(numPars,sig);
			returnType.TypeSig(sig);
			for (int i=0; i < numPars; i++) {
				parList[i].TypeSig(sig);
			}
			typeBlobIx = md.AddToBlobHeap(sig.ToArray());
			for (int i=0; i < tide; i++) {
				md.AddToTable(MDTable.MethodSemantics,methods[i]);
			}
			if (constVal != null) {
				md.AddToTable(MDTable.Constant,constVal);
				constVal.BuildTables(md);
			}
			done = true;
		}
Ejemplo n.º 10
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;
		}
Ejemplo n.º 11
0
		internal override MetaDataElement GetTypeSpec (MetaData md)
		{
			if (!inTable) {
				md.AddToTable (MDTable.TypeSpec, this);
				inTable = true;
			}

			return this;
		}
Ejemplo n.º 12
0
		internal virtual MetaDataElement GetTypeSpec(MetaData md) 
		{
			if (typeSpec == null) {
				typeSpec = new TypeSpec(this,md);
				md.AddToTable(MDTable.TypeSpec,typeSpec);
			}
			return typeSpec;
		}
Ejemplo n.º 13
0
		internal sealed override void BuildTables(MetaData md) 
		{
			if (done) return;
			nameIx = md.AddToStringsHeap(pName);
			if (defaultVal != null) {
				md.AddToTable(MDTable.Constant,defaultVal);
				defaultVal.BuildTables(md);
			}
			if (marshalInfo != null) {
				md.AddToTable(MDTable.FieldMarshal,marshalInfo);
				marshalInfo.BuildTables(md);
			}
			done = true;
		}
Ejemplo n.º 14
0
		internal sealed override void BuildTables(MetaData md) 
		{
			if (done) return;
			md.AddToTable (MDTable.ManifestResource, this);
			nameIx = md.AddToStringsHeap(mrName);
			if (resourceBytes != null) {
				if (rRef != null)
					throw new PEFileException ("Manifest Resource has byte value and file reference");
				fileOffset = md.AddResource(resourceBytes);
			} else {
				if (rRef == null)
					throw new PEFileException ("Manifest Resource has no implementation or value");
				rRef.BuildTables (md);
			}

			done = true;
		}
Ejemplo n.º 15
0
		internal sealed override bool Check(MetaData md) 
		{
			md.AddToTable(MDTable.StandAloneSig,signature);
			signature.BuildTables(md);
			return false;
		}
Ejemplo n.º 16
0
 private void InitPEFile(string name, string fName, bool hasAssembly) {
   metaData = fileImage.GetMetaData();
   thisMod = new Module(fName,metaData);
   if (hasAssembly) {
     thisAssembly = new Assembly(name,metaData);
     metaData.AddToTable(MDTable.Assembly,thisAssembly);      
   }
   moduleClass = AddClass(TypeAttr.Private,"","<Module>");
   moduleClass.SpecialNoSuper();
   metaData.AddToTable(MDTable.Module,thisMod);
 }