本文整理汇总了C#中ITypeSystem.AddInternalType方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeSystem.AddInternalType方法的具体用法?C# ITypeSystem.AddInternalType怎么用?C# ITypeSystem.AddInternalType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeSystem
的用法示例。
在下文中一共展示了ITypeSystem.AddInternalType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
/// <summary>
/// Link time code generator used to compile dynamically created methods during link time.
/// </summary>
/// <param name="compiler">The assembly compiler used to compile this method.</param>
/// <param name="methodName">The name of the created method.</param>
/// <param name="instructionSet">The instruction set.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException"><paramref name="compiler"/>, <paramref name="methodName"/> or <paramref name="instructionSet"/> is null.</exception>
/// <exception cref="System.ArgumentException"><paramref name="methodName"/> is invalid.</exception>
public static LinkerGeneratedMethod Compile(AssemblyCompiler compiler, string methodName, InstructionSet instructionSet, ITypeSystem typeSystem)
{
if (compiler == null)
throw new ArgumentNullException(@"compiler");
if (methodName == null)
throw new ArgumentNullException(@"methodName");
if (methodName.Length == 0)
throw new ArgumentException(@"Invalid method name.");
LinkerGeneratedType compilerGeneratedType = typeSystem.InternalTypeModule.GetType(@"Mosa.Tools.Compiler", @"LinkerGenerated") as LinkerGeneratedType;
// Create the type if we need to.
if (compilerGeneratedType == null)
{
compilerGeneratedType = new LinkerGeneratedType(typeSystem.InternalTypeModule, @"Mosa.Tools.Compiler", @"LinkerGenerated", null);
typeSystem.AddInternalType(compilerGeneratedType);
}
MethodSignature signature = new MethodSignature(BuiltInSigType.Void, new SigType[0]);
// Create the method
// HACK: <$> prevents the method from being called from CIL
LinkerGeneratedMethod method = new LinkerGeneratedMethod(typeSystem.InternalTypeModule, "<$>" + methodName, compilerGeneratedType, signature);
compilerGeneratedType.AddMethod(method);
LinkerMethodCompiler methodCompiler = new LinkerMethodCompiler(compiler, compiler.Pipeline.FindFirst<ICompilationSchedulerStage>(), method, instructionSet);
methodCompiler.Compile();
return method;
}