本文整理汇总了C#中Pchp.CodeAnalysis.CodeGen.CodeGenerator.Generate方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.Generate方法的具体用法?C# CodeGenerator.Generate怎么用?C# CodeGenerator.Generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pchp.CodeAnalysis.CodeGen.CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.Generate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
internal virtual void Emit(CodeGenerator cg)
{
// emit contained statements
if (_statements.Count != 0)
{
_statements.ForEach(cg.Generate);
}
//
cg.Generate(this.NextEdge);
}
示例2: GenerateMethodBody
internal static MethodBody GenerateMethodBody(
PEModuleBuilder moduleBuilder,
SourceRoutineSymbol routine,
int methodOrdinal,
//ImmutableArray<LambdaDebugInfo> lambdaDebugInfo,
//ImmutableArray<ClosureDebugInfo> closureDebugInfo,
//StateMachineTypeSymbol stateMachineTypeOpt,
VariableSlotAllocator variableSlotAllocatorOpt,
DiagnosticBag diagnostics,
//ImportChain importChainOpt,
bool emittingPdb)
{
return GenerateMethodBody(moduleBuilder, routine, (builder) =>
{
DiagnosticBag diagnosticsForThisMethod = DiagnosticBag.GetInstance();
var optimization = moduleBuilder.Compilation.Options.OptimizationLevel;
var codeGen = new CodeGenerator(routine, builder, moduleBuilder, diagnosticsForThisMethod, optimization, emittingPdb);
//if (diagnosticsForThisMethod.HasAnyErrors())
//{
// // we are done here. Since there were errors we should not emit anything.
// return null;
//}
// We need to save additional debugging information for MoveNext of an async state machine.
//var stateMachineMethod = method as SynthesizedStateMachineMethod;
//bool isStateMachineMoveNextMethod = stateMachineMethod != null && method.Name == WellKnownMemberNames.MoveNextMethodName;
//if (isStateMachineMoveNextMethod && stateMachineMethod.StateMachineType.KickoffMethod.IsAsync)
//{
// int asyncCatchHandlerOffset;
// ImmutableArray<int> asyncYieldPoints;
// ImmutableArray<int> asyncResumePoints;
// codeGen.Generate(out asyncCatchHandlerOffset, out asyncYieldPoints, out asyncResumePoints);
// var kickoffMethod = stateMachineMethod.StateMachineType.KickoffMethod;
// // The exception handler IL offset is used by the debugger to treat exceptions caught by the marked catch block as "user unhandled".
// // This is important for async void because async void exceptions generally result in the process being terminated,
// // but without anything useful on the call stack. Async Task methods on the other hand return exceptions as the result of the Task.
// // So it is undesirable to consider these exceptions "user unhandled" since there may well be user code that is awaiting the task.
// // This is a heuristic since it's possible that there is no user code awaiting the task.
// asyncDebugInfo = new Cci.AsyncMethodBodyDebugInfo(kickoffMethod, kickoffMethod.ReturnsVoid ? asyncCatchHandlerOffset : -1, asyncYieldPoints, asyncResumePoints);
//}
//else
{
codeGen.Generate();
}
}, variableSlotAllocatorOpt, diagnostics, emittingPdb);
}