本文整理汇总了C#中RuntimeType类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeType类的具体用法?C# RuntimeType怎么用?C# RuntimeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeType类属于命名空间,在下文中一共展示了RuntimeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCaseMethodCompiler
public TestCaseMethodCompiler(TestCaseAssemblyCompiler assemblyCompiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method)
: base(assemblyCompiler, type, method, null, compilationScheduler)
{
// Populate the pipeline
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new DecodingStage(),
new BasicBlockBuilderStage(),
new ExceptionPrologueStage(),
new OperandDeterminationStage(),
new StaticAllocationResolutionStage(),
new CILTransformationStage(),
//new CILLeakGuardStage() { MustThrowCompilationException = true },
new EdgeSplitStage(),
new DominanceCalculationStage(),
new PhiPlacementStage(),
new EnterSSAStage(),
new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PreFolding),
new ConstantFoldingStage() ,
new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PostFolding),
new LeaveSSA(),
new StrengthReductionStage(),
new StackLayoutStage(),
new PlatformStubStage(),
//new BlockReductionStage(),
//new LoopAwareBlockOrderStage(),
new SimpleTraceBlockOrderStage(),
//new ReverseBlockOrderStage(), // reverse all the basic blocks and see if it breaks anything
//new BasicBlockOrderStage()
new CodeGenerationStage(),
});
}
示例2: CreateMethodCompiler
public override MethodCompilerBase CreateMethodCompiler(RuntimeType type, RuntimeMethod method)
{
IArchitecture arch = this.Architecture;
MethodCompilerBase mc = new TestCaseMethodCompiler(this.Pipeline.Find<IAssemblyLinker>(), this.Architecture, this.Assembly, type, method);
arch.ExtendMethodCompilerPipeline(mc.Pipeline);
return mc;
}
示例3: ComputeToString
public static String ComputeToString(MethodBase contextMethod, RuntimeType[] methodTypeArguments, RuntimeParameterInfo[] runtimeParametersAndReturn)
{
StringBuilder sb = new StringBuilder(30);
sb.Append(runtimeParametersAndReturn[0].ParameterTypeString);
sb.Append(' ');
sb.Append(contextMethod.Name);
if (methodTypeArguments.Length != 0)
{
String sep = "";
sb.Append('[');
foreach (RuntimeType methodTypeArgument in methodTypeArguments)
{
sb.Append(sep);
sep = ",";
String name = methodTypeArgument.InternalNameIfAvailable;
if (name == null)
name = ToStringUtils.UnavailableType;
sb.Append(methodTypeArgument.Name);
}
sb.Append(']');
}
sb.Append('(');
sb.Append(ComputeParametersString(runtimeParametersAndReturn, 1));
sb.Append(')');
return sb.ToString();
}
示例4: BuildMethodTable
/// <summary>
/// Builds the method table.
/// </summary>
/// <param name="type">The type.</param>
public void BuildMethodTable(RuntimeType type)
{
// HINT: The method table is offset by a four pointers:
// 1. interface dispatch table pointer
// 2. type pointer - contains the type information pointer, used to realize object.GetType().
// 3. interface bitmap
// 4. parent type (if any)
List<string> headerlinks = new List<string>();
// 1. interface dispatch table pointer
if (type.Interfaces.Count == 0)
headerlinks.Add(null);
else
headerlinks.Add(type.FullName + @"$itable");
// 2. type pointer - contains the type information pointer, used to realize object.GetType().
headerlinks.Add(null); // TODO: GetType()
// 3. interface bitmap
if (type.Interfaces.Count == 0)
headerlinks.Add(null);
else
headerlinks.Add(type.FullName + @"$ibitmap");
// 4. parent type (if any)
if (type.BaseType == null)
headerlinks.Add(null);
else
headerlinks.Add(type.BaseType + @"$mtable");
IList<RuntimeMethod> methodTable = typeLayout.GetMethodTable(type);
AskLinkerToCreateMethodTable(type.FullName + @"$mtable", methodTable, headerlinks);
}
示例5: GetSerializationInfo
public static void GetSerializationInfo(
SerializationInfo info,
String name,
RuntimeType reflectedClass,
String signature,
String signature2,
MemberTypes type,
Type[] genericArguments)
{
if (info == null)
throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
String assemblyName = reflectedClass.Module.Assembly.FullName;
String typeName = reflectedClass.FullName;
info.SetType(typeof(MemberInfoSerializationHolder));
info.AddValue("Name", name, typeof(String));
info.AddValue("AssemblyName", assemblyName, typeof(String));
info.AddValue("ClassName", typeName, typeof(String));
info.AddValue("Signature", signature, typeof(String));
info.AddValue("Signature2", signature2, typeof(String));
info.AddValue("MemberType", (int)type);
info.AddValue("GenericArguments", genericArguments, typeof(Type[]));
}
示例6: Signature
public Signature(IRuntimeFieldInfo fieldHandle, RuntimeType declaringType)
{
SignatureStruct signature = new SignatureStruct();
GetSignature(ref signature, null, 0, fieldHandle.Value, null, declaringType);
GC.KeepAlive(fieldHandle);
this.m_signature = signature;
}
示例7: ConstructorIsInvoked
public void ConstructorIsInvoked()
{
RuntimeMember method = new RuntimeType(instance.GetType()).GetConstructor(0);
Assert.IsNotNull(method);
TypedValue result = method.Invoke(new object[] {});
Assert.AreEqual(typeof(SampleClass), result.Type);
}
示例8: RuntimeFramework
/// <summary>
/// Construct from a string
/// </summary>
/// <param name="s">A string representing the runtime</param>
public RuntimeFramework(string s)
{
runtime = RuntimeType.Any;
version = new Version();
string[] parts = s.Split(new char[] { '-' });
if (parts.Length == 2)
{
runtime = (RuntimeType)System.Enum.Parse(typeof(RuntimeType), parts[0], true);
string vstring = parts[1];
if (vstring != "")
version = new Version(vstring);
}
else if (char.ToLower(s[0]) == 'v')
{
version = new Version(s.Substring(1));
}
else if (char.IsNumber(s[0]))
{
version = new Version(s);
}
else
{
runtime = (RuntimeType)System.Enum.Parse(typeof(RuntimeType), s, true);
version = Environment.Version;
}
}
示例9: ExplorerMethodCompiler
public ExplorerMethodCompiler(ExplorerAssemblyCompiler assemblyCompiler, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, CompilerOptions compilerOptions)
: base(assemblyCompiler, type, method, null, compilationScheduler)
{
// Populate the pipeline
this.Pipeline.AddRange(new IMethodCompilerStage[] {
new DecodingStage(),
new BasicBlockBuilderStage(),
new ExceptionPrologueStage(),
new OperandDeterminationStage(),
//new SingleUseMarkerStage(),
//new OperandUsageAnalyzerStage(),
new StaticAllocationResolutionStage(),
new CILTransformationStage(),
(compilerOptions.EnableSSA) ? new EdgeSplitStage() : null,
(compilerOptions.EnableSSA) ? new DominanceCalculationStage() : null,
(compilerOptions.EnableSSA) ? new PhiPlacementStage() : null,
(compilerOptions.EnableSSA) ? new EnterSSAStage() : null,
(compilerOptions.EnableSSA) ? new SSAOptimizations() : null,
//(compilerOptions.EnableSSA) ? new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PreFolding) : null,
//(compilerOptions.EnableSSA) ? new ConstantFoldingStage() : null,
//(compilerOptions.EnableSSA) ? new ConstantPropagationStage(ConstantPropagationStage.PropagationStage.PostFolding) : null,
(compilerOptions.EnableSSA) ? new LeaveSSA() : null,
new StrengthReductionStage(),
new StackLayoutStage(),
new PlatformStubStage(),
//new LoopAwareBlockOrderStage(),
new SimpleTraceBlockOrderStage(),
//new SimpleRegisterAllocatorStage(),
new CodeGenerationStage(),
});
}
示例10: AddElementTypes
internal static RuntimeType AddElementTypes(SerializationInfo info, RuntimeType type)
{
List<int> elementTypes = new List<int>();
while(type.HasElementType)
{
if (type.IsSzArray)
{
elementTypes.Add(SzArray);
}
else if (type.IsArray)
{
elementTypes.Add(type.GetArrayRank());
elementTypes.Add(Array);
}
else if (type.IsPointer)
{
elementTypes.Add(Pointer);
}
else if (type.IsByRef)
{
elementTypes.Add(ByRef);
}
type = (RuntimeType)type.GetElementType();
}
info.AddValue("ElementTypes", elementTypes.ToArray(), typeof(int[]));
return type;
}
示例11: FormatRuntimeType
protected string FormatRuntimeType(RuntimeType type)
{
if (!showTokenValues.Checked)
return type.Namespace + Type.Delimiter + type.Name;
return "[" + TokenToString(type.Token) + "] " + type.Namespace + Type.Delimiter + type.Name;
}
示例12: CilGenericType
/// <summary>
/// Initializes a new instance of the <see cref="CilGenericType"/> class.
/// </summary>
/// <param name="module">The module.</param>
/// <param name="baseGenericType">Type of the base generic.</param>
/// <param name="genericTypeInstanceSignature">The generic type instance signature.</param>
/// <param name="token">The token.</param>
/// <param name="typeModule">The type module.</param>
public CilGenericType(ITypeModule module, RuntimeType baseGenericType, GenericInstSigType genericTypeInstanceSignature, Token token, ITypeModule typeModule)
: base(module, token, baseGenericType.BaseType)
{
Debug.Assert(baseGenericType is CilRuntimeType);
this.signature = genericTypeInstanceSignature;
this.baseGenericType = baseGenericType as CilRuntimeType;
base.Attributes = baseGenericType.Attributes;
base.Namespace = baseGenericType.Namespace;
if (this.baseGenericType.IsNested)
{
// TODO: find generic type
;
}
// TODO: if this is a nested types, add enclosing type(s) into genericArguments first
this.genericArguments = signature.GenericArguments;
base.Name = GetName(typeModule);
ResolveMethods();
ResolveFields();
this.containsOpenGenericArguments = CheckContainsOpenGenericParameters();
}
示例13: AttributeUsageCheck
private static bool AttributeUsageCheck(RuntimeType attributeType, bool mustBeInheritable, object[] attributes, IList derivedAttributes)
{
AttributeUsageAttribute attributeUsage = null;
if (mustBeInheritable)
{
attributeUsage = GetAttributeUsage(attributeType);
if (!attributeUsage.Inherited)
{
return false;
}
}
if (derivedAttributes != null)
{
for (int i = 0; i < derivedAttributes.Count; i++)
{
if (derivedAttributes[i].GetType() == attributeType)
{
if (attributeUsage == null)
{
attributeUsage = GetAttributeUsage(attributeType);
}
return attributeUsage.AllowMultiple;
}
}
}
return true;
}
示例14: GetCustomAttribute
internal static Attribute GetCustomAttribute(RuntimeType type)
{
if ((type.Attributes & TypeAttributes.Serializable) != TypeAttributes.Serializable)
{
return null;
}
return new SerializableAttribute();
}
示例15: GetCustomAttribute
internal static Attribute GetCustomAttribute(RuntimeType type)
{
if ((type.Attributes & TypeAttributes.Import) == TypeAttributes.AnsiClass)
{
return null;
}
return new ComImportAttribute();
}