本文整理汇总了C#中PHP.EmitLoadScriptContext方法的典型用法代码示例。如果您正苦于以下问题:C# PHP.EmitLoadScriptContext方法的具体用法?C# PHP.EmitLoadScriptContext怎么用?C# PHP.EmitLoadScriptContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP
的用法示例。
在下文中一共展示了PHP.EmitLoadScriptContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitMethodCall
/// <summary>
/// Emit call of the instance/static method. This defines the call site and call it using given parameters.
/// </summary>
/// <param name="cg">Current code <see cref="CodeGenerator"/>.</param>
/// <param name="returnType">Return type of the method call determined by current access of the method call.</param>
/// <param name="targetExpr">The method call instance expression (the target) if it is an instance method call.</param>
/// <param name="targetType">The target type if it is a static method call.</param>
/// <param name="methodFullName">If known at compile time, the method name. Otherwise <c>null</c>.</param>
/// <param name="methodNameExpr">If the <paramref name="methodFullName"/> is null, this will be the expression giving the method name in run time.</param>
/// <param name="callSignature">The call signature of the method call.</param>
/// <returns>The resulting value type code. This value will be pushed onto the evaluation stack.</returns>
public PhpTypeCode EmitMethodCall(
PHP.Core.CodeGenerator/*!*/cg, Type returnType,
Expression/*!*/targetExpr, DType/*!*/targetType,
string methodFullName, Expression methodNameExpr, CallSignature callSignature)
{
Debug.Assert(methodFullName != null ^ methodNameExpr != null);
//
bool staticCall = (targetExpr == null); // we are going to emit static method call
//bool methodNameIsKnown = (methodFullName != null);
//bool classContextIsKnown = (this.classContextPlace != null);
//
// define the call site:
//
var delegateType = /*System.Linq.Expressions.Expression.*/delegateBuilder.GetDelegateType(
MethodCallDelegateTypeArgs(
callSignature,
staticCall ? Types.DObject[0] : Types.Object[0],
MethodCallDelegateAdditionalArguments(staticCall, methodFullName != null, this.classContextPlace != null),
returnType),
callSitesCount); // (J) do not create dynamic delegates in dynamic modules, so they can be referenced from non-transient assemblies
//
var field = DefineCallSite(cg.IL, string.Format("call_{0}", methodFullName ?? "$"), delegateType, (il) =>
{
// <LOAD> Binder.{MethodCall|StaticMethodCall}( methodFullName, genericParamsCount, paramsCount, classContext, <returnType> )
if (methodFullName != null) il.Emit(OpCodes.Ldstr, methodFullName); else il.Emit(OpCodes.Ldnull);
il.LdcI4(callSignature.GenericParams.Count);
il.LdcI4(callSignature.Parameters.Count);
if (this.classContextPlace != null) this.classContextPlace.EmitLoad(il); else il.Emit(OpCodes.Ldsfld, Fields.UnknownTypeDesc.Singleton);
il.Emit(OpCodes.Ldtoken, returnType);
il.Emit(OpCodes.Call, Methods.GetTypeFromHandle);
il.Emit(OpCodes.Call, staticCall ? Methods.Binder.StaticMethodCall : Methods.Binder.MethodCall);
});
//
// call the CallSite:
//
// <field>.Target( <field>, <targetExpr|self>, <scriptContext>, <callSignature.EmitLoadOnEvalStack>, <targetType>?, (classContext)?, <methodNameExpr>? ):
cg.IL.Emit(OpCodes.Ldsfld, field);
cg.IL.Emit(OpCodes.Ldfld, field.FieldType.GetField("Target"));
cg.IL.Emit(OpCodes.Ldsfld, field);
if (staticCall) cg.EmitLoadSelf(); else EmitMethodTargetExpr(cg, targetExpr);
cg.EmitLoadScriptContext();
EmitMethodCallParameters(cg, callSignature);
if (staticCall) targetType.EmitLoadTypeDesc(cg, ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors);
if (/*!classContextIsKnown*/this.classContextPlace == null) cg.EmitLoadClassContext();
if (/*!methodNameIsKnown*/methodFullName == null) cg.EmitName(methodFullName/*null*/, methodNameExpr, true);
cg.MarkTransientSequencePoint();
cg.IL.Emit(OpCodes.Callvirt, delegateType.GetMethod("Invoke"));
cg.MarkTransientSequencePoint();
//
return PhpTypeCodeEnum.FromType(returnType);
}