本文整理汇总了C#中System.Reflection.Emit.CodeGenerator.EmitReturnBranch方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.EmitReturnBranch方法的具体用法?C# CodeGenerator.EmitReturnBranch怎么用?C# CodeGenerator.EmitReturnBranch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.EmitReturnBranch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitReturnPhpReference
private void EmitReturnPhpReference(CodeGenerator codeGenerator)
{
ILEmitter il = codeGenerator.IL;
PhpTypeCode result;
if (expr != null)
{
result = expr.Emit(codeGenerator);
if (result != PhpTypeCode.PhpReference)
{
// return value is "boxed" to PhpReference:
if (result != PhpTypeCode.Void)
{
codeGenerator.EmitBoxing(result);
// We can box the value without making a copy since the result of the return expression
// is not accessible after returnign from the routine as it is a value (not a reference).
il.Emit(OpCodes.Newobj, Constructors.PhpReference_Object);
}
else
{
il.Emit(OpCodes.Newobj, Constructors.PhpReference_Void);
}
}
}
else
{
il.Emit(OpCodes.Newobj, Constructors.PhpReference_Void);
}
codeGenerator.EmitReturnBranch();
}
示例2: EmitReturnObject
/// <summary>
/// Return value is not deeply copied since the deep copy takes place when the caller accesses the value.
/// </summary>
private void EmitReturnObject(CodeGenerator/*!*/ codeGenerator)
{
ILEmitter il = codeGenerator.IL;
PhpTypeCode result;
if (expr != null)
{
result = expr.Emit(codeGenerator);
// dereference return value:
if (result == PhpTypeCode.PhpReference)
{
il.Emit(OpCodes.Ldfld, Fields.PhpReference_Value);
}
else if (result == PhpTypeCode.PhpArray)
{
// <array>.InplaceCopyOnReturn = true;
il.Emit(OpCodes.Dup);
il.Emit(OpCodes.Ldc_I4_1);
il.Emit(OpCodes.Call, Properties.PhpArray_InplaceCopyOnReturn.GetSetMethod());
}
else
{
codeGenerator.EmitBoxing(result);
}
}
else
{
il.Emit(OpCodes.Ldnull);
}
codeGenerator.EmitReturnBranch();
}