当前位置: 首页>>代码示例>>C#>>正文


C# ByteReader.PeekByte方法代码示例

本文整理汇总了C#中IKVM.Reflection.Reader.ByteReader.PeekByte方法的典型用法代码示例。如果您正苦于以下问题:C# ByteReader.PeekByte方法的具体用法?C# ByteReader.PeekByte怎么用?C# ByteReader.PeekByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IKVM.Reflection.Reader.ByteReader的用法示例。


在下文中一共展示了ByteReader.PeekByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResolveTypeMemberRef

 private MemberInfo ResolveTypeMemberRef(Type type, string name, ByteReader sig)
 {
     if (sig.PeekByte() == Signature.FIELD)
     {
         Type org = type;
         FieldSignature fieldSig = FieldSignature.ReadSig(this, sig, type);
         FieldInfo field = type.FindField(name, fieldSig);
         if (field == null && universe.MissingMemberResolution)
         {
             return universe.GetMissingFieldOrThrow(this, type, name, fieldSig);
         }
         while (field == null && (type = type.BaseType) != null)
         {
             field = type.FindField(name, fieldSig);
         }
         if (field != null)
         {
             return field;
         }
         throw new MissingFieldException(org.ToString(), name);
     }
     else
     {
         Type org = type;
         MethodSignature methodSig = MethodSignature.ReadSig(this, sig, type);
         MethodBase method = type.FindMethod(name, methodSig);
         if (method == null && universe.MissingMemberResolution)
         {
             return universe.GetMissingMethodOrThrow(this, type, name, methodSig);
         }
         while (method == null && (type = type.BaseType) != null)
         {
             method = type.FindMethod(name, methodSig);
         }
         if (method != null)
         {
             return method;
         }
         throw new MissingMethodException(org.ToString(), name);
     }
 }
开发者ID:kenasogoo,项目名称:ikvm-fork,代码行数:41,代码来源:ModuleReader.cs

示例2: ReadStandAloneMethodSig

		internal static __StandAloneMethodSig ReadStandAloneMethodSig(ModuleReader module, ByteReader br, IGenericContext context)
		{
			CallingConventions callingConvention = 0;
			System.Runtime.InteropServices.CallingConvention unmanagedCallingConvention = 0;
			bool unmanaged;
			byte flags = br.ReadByte();
			switch (flags & 7)
			{
				case DEFAULT:
					callingConvention = CallingConventions.Standard;
					unmanaged = false;
					break;
				case 0x01:	// C
					unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl;
					unmanaged = true;
					break;
				case 0x02:	// STDCALL
					unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall;
					unmanaged = true;
					break;
				case 0x03:	// THISCALL
					unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall;
					unmanaged = true;
					break;
				case 0x04:	// FASTCALL
					unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.FastCall;
					unmanaged = true;
					break;
				case VARARG:
					callingConvention = CallingConventions.VarArgs;
					unmanaged = false;
					break;
				default:
					throw new BadImageFormatException();
			}
			if ((flags & HASTHIS) != 0)
			{
				callingConvention |= CallingConventions.HasThis;
			}
			if ((flags & EXPLICITTHIS) != 0)
			{
				callingConvention |= CallingConventions.ExplicitThis;
			}
			if ((flags & GENERIC) != 0)
			{
				throw new BadImageFormatException();
			}
			int paramCount = br.ReadCompressedInt();
			SkipCustomModifiers(br);
			Type returnType = ReadRetType(module, br, context);
			List<Type> parameterTypes = new List<Type>();
			List<Type> optionalParameterTypes = new List<Type>();
			List<Type> curr = parameterTypes;
			for (int i = 0; i < paramCount; i++)
			{
				if (br.PeekByte() == SENTINEL)
				{
					br.ReadByte();
					curr = optionalParameterTypes;
				}
				SkipCustomModifiers(br);
				curr.Add(ReadParam(module, br, context));
			}
			return new __StandAloneMethodSig(unmanaged, unmanagedCallingConvention, callingConvention, returnType, parameterTypes.ToArray(), optionalParameterTypes.ToArray());
		}
开发者ID:ngraziano,项目名称:mono,代码行数:65,代码来源:MethodSignature.cs

示例3: ReadSig

		internal static MethodSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
		{
			CallingConventions callingConvention;
			int genericParamCount;
			Type returnType;
			Type[] parameterTypes;
			byte flags = br.ReadByte();
			switch (flags & 7)
			{
				case DEFAULT:
					callingConvention = CallingConventions.Standard;
					break;
				case VARARG:
					callingConvention = CallingConventions.VarArgs;
					break;
				default:
					throw new BadImageFormatException();
			}
			if ((flags & HASTHIS) != 0)
			{
				callingConvention |= CallingConventions.HasThis;
			}
			if ((flags & EXPLICITTHIS) != 0)
			{
				callingConvention |= CallingConventions.ExplicitThis;
			}
			genericParamCount = 0;
			if ((flags & GENERIC) != 0)
			{
				genericParamCount = br.ReadCompressedInt();
				context = new UnboundGenericMethodContext(context);
			}
			int paramCount = br.ReadCompressedInt();
			Type[][][] modifiers = null;
			Type[] optionalCustomModifiers;
			Type[] requiredCustomModifiers;
			ReadCustomModifiers(module, br, context, out requiredCustomModifiers, out optionalCustomModifiers);
			returnType = ReadRetType(module, br, context);
			parameterTypes = new Type[paramCount];
			PackedCustomModifiers.SetModifiers(ref modifiers, 0, 0, optionalCustomModifiers, paramCount + 1);
			PackedCustomModifiers.SetModifiers(ref modifiers, 0, 1, requiredCustomModifiers, paramCount + 1);
			for (int i = 0; i < parameterTypes.Length; i++)
			{
				if ((callingConvention & CallingConventions.VarArgs) != 0 && br.PeekByte() == SENTINEL)
				{
					Array.Resize(ref parameterTypes, i);
					if (modifiers != null)
					{
						Array.Resize(ref modifiers, i + 1);
					}
					break;
				}
				ReadCustomModifiers(module, br, context, out requiredCustomModifiers, out optionalCustomModifiers);
				PackedCustomModifiers.SetModifiers(ref modifiers, i + 1, 0, optionalCustomModifiers, paramCount + 1);
				PackedCustomModifiers.SetModifiers(ref modifiers, i + 1, 1, requiredCustomModifiers, paramCount + 1);
				parameterTypes[i] = ReadParam(module, br, context);
			}
			return new MethodSignature(returnType, parameterTypes, modifiers, callingConvention, genericParamCount);
		}
开发者ID:ngraziano,项目名称:mono,代码行数:59,代码来源:MethodSignature.cs

示例4: ReadParam

		protected static Type ReadParam(ModuleReader module, ByteReader br, IGenericContext context)
		{
			switch (br.PeekByte())
			{
				case ELEMENT_TYPE_TYPEDBYREF:
					br.ReadByte();
					return module.universe.System_TypedReference;
				default:
					return ReadTypeOrByRef(module, br, context);
			}
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:11,代码来源:Signature.cs

示例5: ReadOptionalParameterTypes

		// this reads just the optional parameter types, from a MethodRefSig
		internal static Type[] ReadOptionalParameterTypes(ModuleReader module, ByteReader br, IGenericContext context, out CustomModifiers[] customModifiers)
		{
			br.ReadByte();
			int paramCount = br.ReadCompressedUInt();
			CustomModifiers.Skip(br);
			ReadRetType(module, br, context);
			for (int i = 0; i < paramCount; i++)
			{
				if (br.PeekByte() == SENTINEL)
				{
					br.ReadByte();
					Type[] types = new Type[paramCount - i];
					customModifiers = new CustomModifiers[types.Length];
					for (int j = 0; j < types.Length; j++)
					{
						customModifiers[j] = CustomModifiers.Read(module, br, context);
						types[j] = ReadType(module, br, context);
					}
					return types;
				}
				CustomModifiers.Skip(br);
				ReadType(module, br, context);
			}
			customModifiers = Empty<CustomModifiers>.Array;
			return Type.EmptyTypes;
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:27,代码来源:Signature.cs

示例6: ReadLocalVarSig

		internal static void ReadLocalVarSig(ModuleReader module, ByteReader br, IGenericContext context, List<LocalVariableInfo> list)
		{
			if (br.Length < 2 || br.ReadByte() != LOCAL_SIG)
			{
				throw new BadImageFormatException("Invalid local variable signature");
			}
			int count = br.ReadCompressedUInt();
			for (int i = 0; i < count; i++)
			{
				if (br.PeekByte() == ELEMENT_TYPE_TYPEDBYREF)
				{
					br.ReadByte();
					list.Add(new LocalVariableInfo(i, module.universe.System_TypedReference, false, new CustomModifiers()));
				}
				else
				{
					CustomModifiers mods1 = CustomModifiers.Read(module, br, context);
					bool pinned = false;
					if (br.PeekByte() == ELEMENT_TYPE_PINNED)
					{
						br.ReadByte();
						pinned = true;
					}
					CustomModifiers mods2 = CustomModifiers.Read(module, br, context);
					Type type = ReadTypeOrByRef(module, br, context);
					list.Add(new LocalVariableInfo(i, type, pinned, CustomModifiers.Combine(mods1, mods2)));
				}
			}
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:29,代码来源:Signature.cs

示例7: ReadTypeOrByRef

		private static Type ReadTypeOrByRef(ModuleReader module, ByteReader br, IGenericContext context)
		{
			if (br.PeekByte() == ELEMENT_TYPE_BYREF)
			{
				br.ReadByte();
				// LAMESPEC it is allowed (by C++/CLI, ilasm and peverify) to have custom modifiers after the BYREF
				// (which makes sense, as it is analogous to pointers)
				CustomModifiers mods = CustomModifiers.Read(module, br, context);
				// C++/CLI generates void& local variables, so we need to use ReadTypeOrVoid here
				return ReadTypeOrVoid(module, br, context).__MakeByRefType(mods);
			}
			else
			{
				return ReadType(module, br, context);
			}
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:16,代码来源:Signature.cs

示例8: ReadOptionalParameterTypes

		// this reads just the optional parameter types, from a MethodRefSig
		internal static Type[] ReadOptionalParameterTypes(ModuleReader module, ByteReader br)
		{
			br.ReadByte();
			int paramCount = br.ReadCompressedInt();
			SkipCustomModifiers(br);
			ReadRetType(module, br, null);
			for (int i = 0; i < paramCount; i++)
			{
				if (br.PeekByte() == SENTINEL)
				{
					br.ReadByte();
					Type[] types = new Type[paramCount - i];
					for (int j = 0; j < types.Length; j++)
					{
						SkipCustomModifiers(br);
						types[j] = ReadType(module, br, null);
					}
					return types;
				}
				SkipCustomModifiers(br);
				ReadType(module, br, null);
			}
			return Type.EmptyTypes;
		}
开发者ID:koush,项目名称:mono,代码行数:25,代码来源:Signature.cs

示例9: ReadTypeOrVoid

		private static Type ReadTypeOrVoid(ModuleReader module, ByteReader br, IGenericContext context)
		{
			if (br.PeekByte() == ELEMENT_TYPE_VOID)
			{
				br.ReadByte();
				return module.universe.System_Void;
			}
			else
			{
				return ReadType(module, br, context);
			}
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:12,代码来源:Signature.cs

示例10: SkipCustomModifiers

		protected static void SkipCustomModifiers(ByteReader br)
		{
			byte b = br.PeekByte();
			while (IsCustomModifier(b))
			{
				br.ReadByte();
				br.ReadCompressedInt();
				b = br.PeekByte();
			}
		}
开发者ID:koush,项目名称:mono,代码行数:10,代码来源:Signature.cs

示例11: ReadCustomModifiers

		protected static void ReadCustomModifiers(ModuleReader module, ByteReader br, IGenericContext context, out Type[] requiredCustomModifiers, out Type[] optionalCustomModifiers)
		{
			byte b = br.PeekByte();
			if (IsCustomModifier(b))
			{
				List<Type> required = new List<Type>();
				List<Type> optional = new List<Type>();
				while (IsCustomModifier(b))
				{
					br.ReadByte();
					Type type = ReadTypeDefOrRefEncoded(module, br, context);
					if (b == ELEMENT_TYPE_CMOD_REQD)
					{
						required.Add(type);
					}
					else
					{
						optional.Add(type);
					}
					b = br.PeekByte();
				}
				requiredCustomModifiers = required.ToArray();
				optionalCustomModifiers = optional.ToArray();
			}
			else
			{
				requiredCustomModifiers = null;
				optionalCustomModifiers = null;
			}
		}
开发者ID:koush,项目名称:mono,代码行数:30,代码来源:Signature.cs

示例12: ReadDeclarativeSecurity

		internal static void ReadDeclarativeSecurity(Assembly asm, List<CustomAttributeData> list, int action, ByteReader br)
		{
			Universe u = asm.universe;
			if (br.PeekByte() == '.')
			{
				br.ReadByte();
				int count = br.ReadCompressedInt();
				for (int j = 0; j < count; j++)
				{
					Type type = ReadType(asm, br);
					ConstructorInfo constructor;
					if (type == u.System_Security_Permissions_HostProtectionAttribute && action == (int)System.Security.Permissions.SecurityAction.LinkDemand)
					{
						constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
					}
					else
					{
						constructor = type.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { u.System_Security_Permissions_SecurityAction }, null);
					}
					// LAMESPEC there is an additional length here (probably of the named argument list)
					ByteReader slice = br.Slice(br.ReadCompressedInt());
					// LAMESPEC the count of named arguments is a compressed integer (instead of UInt16 as NumNamed in custom attributes)
					list.Add(new CustomAttributeData(constructor, action, ReadNamedArguments(asm, slice, slice.ReadCompressedInt(), type)));
				}
			}
			else
			{
				// .NET 1.x format (xml)
				char[] buf = new char[br.Length / 2];
				for (int i = 0; i < buf.Length; i++)
				{
					buf[i] = br.ReadChar();
				}
				string xml = new String(buf);
				ConstructorInfo constructor = u.System_Security_Permissions_PermissionSetAttribute.GetConstructor(new Type[] { u.System_Security_Permissions_SecurityAction });
				List<CustomAttributeNamedArgument> args = new List<CustomAttributeNamedArgument>();
				args.Add(new CustomAttributeNamedArgument(u.System_Security_Permissions_PermissionSetAttribute.GetProperty("XML"),
					new CustomAttributeTypedArgument(u.System_String, xml)));
				list.Add(new CustomAttributeData(constructor, action, args));
			}
		}
开发者ID:,项目名称:,代码行数:41,代码来源:

示例13: ResolveTypeMemberRef

		private MemberInfo ResolveTypeMemberRef(Type type, string name, ByteReader sig, Type[] genericTypeArguments, Type[] genericMethodArguments)
		{
			IGenericContext context;
			if ((genericTypeArguments == null && genericMethodArguments == null) || type.IsGenericType)
			{
				context = type;
			}
			else
			{
				context = new GenericContext(genericTypeArguments, genericMethodArguments);
			}
			if (sig.PeekByte() == Signature.FIELD)
			{
				Type org = type;
				FieldSignature fieldSig = FieldSignature.ReadSig(this, sig, context);
				do
				{
					FieldInfo field = type.FindField(name, fieldSig);
					if (field != null)
					{
						return field;
					}
					type = type.BaseType;
				} while (type != null);
				throw new MissingFieldException(org.ToString(), name);
			}
			else
			{
				Type org = type;
				MethodSignature methodSig = MethodSignature.ReadSig(this, sig, context);
				do
				{
					MethodBase method = type.FindMethod(name, methodSig);
					if (method != null)
					{
						return method;
					}
					type = type.BaseType;
				} while (type != null);
				return universe.GetMissingMethodOrThrow(org, name, methodSig);
			}
		}
开发者ID:koush,项目名称:mono,代码行数:42,代码来源:ModuleReader.cs

示例14: ReadSig

		internal static PropertySignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
		{
			byte flags = br.ReadByte();
			if ((flags & PROPERTY) == 0)
			{
				throw new BadImageFormatException();
			}
			CallingConventions callingConvention = CallingConventions.Standard;
			if ((flags & HASTHIS) != 0)
			{
				callingConvention |= CallingConventions.HasThis;
			}
			if ((flags & EXPLICITTHIS) != 0)
			{
				callingConvention |= CallingConventions.ExplicitThis;
			}
			Type returnType;
			Type[] returnTypeRequiredCustomModifiers;
			Type[] returnTypeOptionalCustomModifiers;
			Type[] parameterTypes;
			Type[][] parameterRequiredCustomModifiers;
			Type[][] parameterOptionalCustomModifiers;
			int paramCount = br.ReadCompressedInt();
			ReadCustomModifiers(module, br, context, out returnTypeRequiredCustomModifiers, out returnTypeOptionalCustomModifiers);
			returnType = ReadRetType(module, br, context);
			parameterTypes = new Type[paramCount];
			parameterRequiredCustomModifiers = null;
			parameterOptionalCustomModifiers = null;
			for (int i = 0; i < parameterTypes.Length; i++)
			{
				if (IsCustomModifier(br.PeekByte()))
				{
					if (parameterOptionalCustomModifiers == null)
					{
						parameterOptionalCustomModifiers = new Type[parameterTypes.Length][];
						parameterRequiredCustomModifiers = new Type[parameterTypes.Length][];
					}
					ReadCustomModifiers(module, br, context, out parameterRequiredCustomModifiers[i], out parameterOptionalCustomModifiers[i]);
				}
				parameterTypes[i] = ReadParam(module, br, context);
			}
			return new PropertySignature(callingConvention, returnType, returnTypeOptionalCustomModifiers, returnTypeRequiredCustomModifiers,
				parameterTypes, parameterOptionalCustomModifiers, parameterRequiredCustomModifiers);
		}
开发者ID:koush,项目名称:mono,代码行数:44,代码来源:PropertySignature.cs

示例15: ReadDeclarativeSecurity

		internal static void ReadDeclarativeSecurity(Assembly asm, List<CustomAttributeData> list, int action, ByteReader br)
		{
			Universe u = asm.universe;
			if (br.PeekByte() == '.')
			{
				br.ReadByte();
				int count = br.ReadCompressedInt();
				for (int j = 0; j < count; j++)
				{
					Type type = ReadType(asm, br);
					ConstructorInfo constructor = type.GetPseudoCustomAttributeConstructor(u.System_Security_Permissions_SecurityAction);
					// LAMESPEC there is an additional length here (probably of the named argument list)
					byte[] blob = br.ReadBytes(br.ReadCompressedInt());
					list.Add(new CustomAttributeData(asm, constructor, action, blob));
				}
			}
			else
			{
				// .NET 1.x format (xml)
				char[] buf = new char[br.Length / 2];
				for (int i = 0; i < buf.Length; i++)
				{
					buf[i] = br.ReadChar();
				}
				string xml = new String(buf);
				ConstructorInfo constructor = u.System_Security_Permissions_PermissionSetAttribute.GetPseudoCustomAttributeConstructor(u.System_Security_Permissions_SecurityAction);
				List<CustomAttributeNamedArgument> args = new List<CustomAttributeNamedArgument>();
				args.Add(new CustomAttributeNamedArgument(GetProperty(u.System_Security_Permissions_PermissionSetAttribute, "XML", u.System_String),
					new CustomAttributeTypedArgument(u.System_String, xml)));
				list.Add(new CustomAttributeData(asm.ManifestModule, constructor, new object[] { action }, args));
			}
		}
开发者ID:kazol4433,项目名称:mono,代码行数:32,代码来源:CustomAttributeData.cs


注:本文中的IKVM.Reflection.Reader.ByteReader.PeekByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。