本文整理匯總了C#中PHP.Core.Emit.ILEmitter.LoadBool方法的典型用法代碼示例。如果您正苦於以下問題:C# ILEmitter.LoadBool方法的具體用法?C# ILEmitter.LoadBool怎麽用?C# ILEmitter.LoadBool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PHP.Core.Emit.ILEmitter
的用法示例。
在下文中一共展示了ILEmitter.LoadBool方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: EmitDeclareFunction
/// <summary>
/// Emits call to <see cref="ScriptContext.DeclareFunction"/>.
/// </summary>
internal static void EmitDeclareFunction(ILEmitter/*!*/il, IPlace/*!*/scriptContextPlace, PhpFunction/*!*/ function)
{
Label lbl_fieldinitialized = il.DefineLabel();
// private static PhpRoutine <routine>'function = null;
var attrs = FieldAttributes.Static | FieldAttributes.Private;
var field = il.TypeBuilder.DefineField(string.Format("<routine>'{0}", function.FullName), typeof(PhpRoutineDesc), attrs);
// if (<field> == null)
il.Emit(OpCodes.Ldsfld, field);
il.Emit(OpCodes.Brtrue, lbl_fieldinitialized);
{
// <field> = new PhpRoutineDesc(<attributes>, new RoutineDelegate(null, <delegate>))
// LOAD <attributes>;
il.LdcI4((int)function.MemberDesc.MemberAttributes);
// new RoutineDelegate(null, <delegate>, true)
il.Emit(OpCodes.Ldnull);
il.Emit(OpCodes.Ldftn, function.ArgLessInfo);
il.Emit(OpCodes.Newobj, Constructors.RoutineDelegate);
il.LoadBool(true);
// new PhpRoutineDesc:
il.Emit(OpCodes.Newobj, Constructors.PhpRoutineDesc_Attr_Delegate_Bool);
// <field> = <STACK>
il.Emit(OpCodes.Stsfld, field);
// new PurePhpFunction(<field>, fullName, argfull); // writes desc.Member
il.Emit(OpCodes.Ldsfld, field);
il.Emit(OpCodes.Ldstr, function.FullName);
CodeGenerator.EmitLoadMethodInfo(il, function.ArgFullInfo/*, AssemblyBuilder.DelegateBuilder*/);
il.Emit(OpCodes.Newobj, Constructors.PurePhpFunction);
il.Emit(OpCodes.Pop);
}
il.MarkLabel(lbl_fieldinitialized);
// CALL ScriptContent.DeclareFunction(<field>, <name>);
scriptContextPlace.EmitLoad(il);
// LOAD <field>
il.Emit(OpCodes.Ldsfld, field);
// LOAD <fullName>
il.Emit(OpCodes.Ldstr, function.FullName);
//
il.Emit(OpCodes.Call, Methods.ScriptContext.DeclareFunction);
}
示例2: EmitLoadDefault
/// <summary>
/// Emits load of default value assuming given method fails.
/// </summary>
/// <param name="il">ILEmitter.</param>
/// <param name="method">Method which default return value have to be loaded.</param>
/// <returns></returns>
public static PhpTypeCode EmitLoadDefault(ILEmitter/*!*/il, MethodInfo/*!*/method)
{
if (method.ReturnType == Types.Bool[0] || method.ReturnTypeCustomAttributes.IsDefined(typeof(CastToFalseAttribute), false))
{
il.LoadBool(false);
return PhpTypeCode.Boolean;
}
if (method.ReturnType == Types.Int[0])
{
il.LdcI4(0);
return PhpTypeCode.Integer;
}
return PhpTypeCode.Void;
}