Don't ask me what it's for, k? I don't know yet either!!
コード例 #1
0
ファイル: MetadataSignatures.cs プロジェクト: sharpos/SharpOS
		public FieldSignature (AssemblyMetadata assembly, FieldRow fieldRow):
			base (assembly)
		{
			this.Field = fieldRow;

			int pos = (int)fieldRow.Signature - 1;
			byte [] blob = assembly.BlobHeap;
			int cmodCount = 0;
			int savedPos = 0;
			int cmodIndex = 0;

			// The first byte must be FIELD (0x6)

			Diagnostics.Assert (blob [pos++] == 0x6,
				"FieldSignature.ctor(): blob signature is not FIELD (0x6)");

			//if (blob [pos] != 0x6) {
			//	throw new Exception ("Invalid signature type for field"); // explode
			//}

			// First determine the amount of cmods we have

			savedPos = pos;

			while (true) {
				ElementType type = (ElementType) DecompressValue (blob, ref pos);

				if (type == ElementType.CModReqD || type == ElementType.CModOpt)
					++cmodCount;
				else
					break;
			}

			this.CustomModifiers = new SigCustomModifier [cmodCount];
			pos = savedPos;

			while (true) {
				ElementType type = (ElementType) DecompressValue (blob, ref pos);

				if (type == ElementType.CModReqD || type == ElementType.CModOpt) {
					CustomModifiers [cmodIndex++] =
						new SigCustomModifier (type, DecompressValue (blob, ref pos));
				} else {
					// now for the "Type"

					switch (type) {
					case ElementType.Class:
						this.Type = new SigClassType (type, DecompressValue (blob, ref pos));
						break;
					case ElementType.ValueType:
						this.Type = new SigClassType (type, DecompressValue (blob, ref pos));
						break;
					case ElementType.Boolean:
					case ElementType.Char:
					case ElementType.I1:
					case ElementType.U1:
					case ElementType.I2:
					case ElementType.U2:
					case ElementType.I4:
					case ElementType.U4:
					case ElementType.I8:
					case ElementType.U8:
					case ElementType.R4:
					case ElementType.R8:
					case ElementType.I:
					case ElementType.U:
					case ElementType.Object:
					case ElementType.String:
						this.Type = new SigType (type);
						break;
					default:
						//throw new NotSupportedException (); // explode
						break;
					}

					// hereby ends this thousand-year journey
					break;
				}
			}

			++pos;
		}
コード例 #2
0
        public FieldSignature(AssemblyMetadata assembly, FieldRow fieldRow) :
            base(assembly)
        {
            this.Field = fieldRow;

            int pos = (int)fieldRow.Signature - 1;

            byte [] blob      = assembly.BlobHeap;
            int     cmodCount = 0;
            int     savedPos  = 0;
            int     cmodIndex = 0;

            // The first byte must be FIELD (0x6)

            Diagnostics.Assert(blob [pos++] == 0x6,
                               "FieldSignature.ctor(): blob signature is not FIELD (0x6)");

            //if (blob [pos] != 0x6) {
            //	throw new Exception ("Invalid signature type for field"); // explode
            //}

            // First determine the amount of cmods we have

            savedPos = pos;

            while (true)
            {
                ElementType type = (ElementType)DecompressValue(blob, ref pos);

                if (type == ElementType.CModReqD || type == ElementType.CModOpt)
                {
                    ++cmodCount;
                }
                else
                {
                    break;
                }
            }

            this.CustomModifiers = new SigCustomModifier [cmodCount];
            pos = savedPos;

            while (true)
            {
                ElementType type = (ElementType)DecompressValue(blob, ref pos);

                if (type == ElementType.CModReqD || type == ElementType.CModOpt)
                {
                    CustomModifiers [cmodIndex++] =
                        new SigCustomModifier(type, DecompressValue(blob, ref pos));
                }
                else
                {
                    // now for the "Type"

                    switch (type)
                    {
                    case ElementType.Class:
                        this.Type = new SigClassType(type, DecompressValue(blob, ref pos));
                        break;

                    case ElementType.ValueType:
                        this.Type = new SigClassType(type, DecompressValue(blob, ref pos));
                        break;

                    case ElementType.Boolean:
                    case ElementType.Char:
                    case ElementType.I1:
                    case ElementType.U1:
                    case ElementType.I2:
                    case ElementType.U2:
                    case ElementType.I4:
                    case ElementType.U4:
                    case ElementType.I8:
                    case ElementType.U8:
                    case ElementType.R4:
                    case ElementType.R8:
                    case ElementType.I:
                    case ElementType.U:
                    case ElementType.Object:
                    case ElementType.String:
                        this.Type = new SigType(type);
                        break;

                    default:
                        //throw new NotSupportedException (); // explode
                        break;
                    }

                    // hereby ends this thousand-year journey
                    break;
                }
            }

            ++pos;
        }