本文整理汇总了C#中PHP.Core.AST.CallSignature类的典型用法代码示例。如果您正苦于以下问题:C# CallSignature类的具体用法?C# CallSignature怎么用?C# CallSignature使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CallSignature类属于PHP.Core.AST命名空间,在下文中一共展示了CallSignature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewEx
public NewEx(Position position, TypeRef/*!*/ classNameRef, List<ActualParam>/*!*/ parameters)
: base(position)
{
Debug.Assert(classNameRef != null && parameters != null);
this.classNameRef = classNameRef;
this.callSignature = new CallSignature(parameters, TypeRef.EmptyList);
}
示例2: FunctionCall
public FunctionCall(Position position, List<ActualParam>/*!*/ parameters, List<TypeRef>/*!*/ genericParams)
: base(position)
{
Debug.Assert(parameters != null);
this.callSignature = new CallSignature(parameters, genericParams);
}
示例3: FunctionCall
public FunctionCall(Text.Span span, Text.Span nameSpan, List<ActualParam>/*!*/ parameters, List<TypeRef>/*!*/ genericParams)
: base(span)
{
Debug.Assert(parameters != null);
this.callSignature = new CallSignature(parameters, genericParams);
this.NameSpan = nameSpan;
}
示例4: Analyze
public void Analyze(CallSignature/*!*/node, Analyzer/*!*/ analyzer, RoutineSignature/*!*/ signature, ExInfoFromParent info, bool isBaseCtorCallConstrained)
{
// generic:
foreach (var p in node.GenericParams)
TypeRefHelper.Analyze(p, analyzer);
// regular:
analyzer.EnterActualParams(signature, node.Parameters.Count);
foreach (var p in node.Parameters)
p.NodeCompiler<ActualParamCompiler>().Analyze(p, analyzer, isBaseCtorCallConstrained);
analyzer.LeaveActualParams();
}
示例5: ResolveOverload
internal override int ResolveOverload(Analyzer/*!*/ analyzer, CallSignature callSignature, Position position,
out RoutineSignature overloadSignature)
{
if (callSignature.GenericParams.Count > 0)
{
analyzer.ErrorSink.Add(Errors.GenericCallToLibraryFunction, analyzer.SourceUnit, position);
callSignature = new CallSignature(callSignature.Parameters, TypeRef.EmptyList);
}
bool exact_match;
int result = ResolveOverload(callSignature.Parameters.Count, out exact_match);
if (!exact_match)
{
// library function with wrong number of actual arguments:
analyzer.ErrorSink.Add(Errors.InvalidArgumentCountForFunction, analyzer.SourceUnit, position, FullName);
}
overloadSignature = overloads[result];
return result;
}
示例6: EmitNewOperator
internal void EmitNewOperator(string typeFullName, TypeRef typeNameRef, DType type, CallSignature callSignature)
{
DebugHelper.AssertNonNull(1, typeFullName, typeNameRef, type);
// prepare stack frame for the constructor:
callSignature.EmitLoadOnPhpStack(this);
// CALL Operators.New(<type desc>, <context type desc>, <context>);
EmitLoadTypeDesc(typeFullName, typeNameRef, type, ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors);
this.EmitLoadClassContext();
this.EmitLoadScriptContext();
this.EmitLoadNamingContext();
il.Emit(OpCodes.Call, Methods.Operators.New);
}
示例7: EmitLibraryLoadOptArguments
/// <summary>
/// Emits load of optional parameters array on the evaluation stack.
/// </summary>
/// <param name="node">Instance.</param>
/// <param name="builder">An overloads builder.</param>
/// <param name="start">An index of the first optional parameter to be loaded into the array (indices start from 0).</param>
/// <param name="param">
/// A <see cref="ParameterInfo"/> of the formal parameter of the target method where the array will be passed.
/// This information influences conversions all optional parameters.
/// </param>
/// <param name="optArgCount">Optional argument count (unused).</param>
public void EmitLibraryLoadOptArguments(CallSignature/*!*/node, OverloadsBuilder/*!*/ builder, int start, ParameterInfo/*!*/ param, IPlace optArgCount)
{
Debug.Assert(start >= 0 && builder != null && param != null && builder.Aux is CodeGenerator);
ILEmitter il = builder.IL;
Type elem_type = param.ParameterType.GetElementType();
Type array_type = elem_type.MakeArrayType();
// NEW <alem_type>[<parameters count - start>]
il.LdcI4(node.Parameters.Count - start);
il.Emit(OpCodes.Newarr, elem_type);
// loads each optional parameter into the appropriate bucket of the array:
for (int i = start; i < node.Parameters.Count; i++)
{
// <arr>[i - start]
il.Emit(OpCodes.Dup);
il.LdcI4(i - start);
// <parameter value>
object type_or_value = EmitLibraryLoadArgument(node, il, i, builder.Aux, param);
builder.EmitArgumentConversion(elem_type, type_or_value, false, param, 3);
// <arr>[i - start] = <parameter value>;
il.Stelem(elem_type);
}
// <arr>
}
示例8: EmitLoadOnEvalStack
/// <summary>
/// Emits IL instructions that load actual parameters on the evaluation stack.
/// </summary>
/// <param name="node">Instance.</param>
/// <param name="codeGenerator">Code generator.</param>
/// <param name="routine">PHP method being called.</param>
/// <remarks>
/// <para>
/// The function has mandatory and optional formal arguments.
/// Mandatory arguments are those formal arguments which are not preceded by
/// any formal argument with default value. The others are optional.
/// If a formal argument without default value is declared beyond the last mandatory argument
/// it is treated as optional one by the caller. The callee checks this and throws warning.
/// </para>
/// Missing arguments handling:
/// <list type="bullet">
/// <item>missing mandatory argument - WARNING; LOAD(null);</item>
/// <item>missing optional argument - LOAD(Arg.Default);</item>
/// <item>superfluous arguments are ignored</item>
/// </list>
/// </remarks>
public void EmitLoadOnEvalStack(CallSignature/*!*/node, CodeGenerator/*!*/ codeGenerator, PhpRoutine/*!*/ routine)
{
EmitLoadTypeArgsOnEvalStack(node, codeGenerator, routine);
EmitLoadArgsOnEvalStack(node, codeGenerator, routine);
}
示例9: EmitLoadArgsOnEvalStack
internal void EmitLoadArgsOnEvalStack(CallSignature/*!*/node, CodeGenerator/*!*/ codeGenerator, PhpRoutine/*!*/ routine)
{
ILEmitter il = codeGenerator.IL;
int mandatory_count = (routine.Signature != null) ? routine.Signature.MandatoryParamCount : 0;
int formal_count = (routine.Signature != null) ? routine.Signature.ParamCount : 0;
int actual_count = node.Parameters.Count;
PhpTypeCode param_type;
// loads all actual parameters which are not superfluous:
for (int i = 0; i < Math.Min(actual_count, formal_count); i++)
{
var p = node.Parameters[i];
codeGenerator.EmitBoxing(param_type = p.NodeCompiler<ActualParamCompiler>().Emit(p, codeGenerator));
// Actual param emitter should emit "boxing" to a reference if its access type is ReadRef.
// That's why no operation is needed here and references should match.
Debug.Assert((routine.Signature == null || routine.Signature.IsAlias(i)) == (param_type == PhpTypeCode.PhpReference));
}
// loads missing mandatory arguments:
for (int i = actual_count; i < mandatory_count; i++)
{
// CALL PhpException.MissingArgument(<i+1>,<name>);
il.LdcI4(i + 1);
il.Emit(OpCodes.Ldstr, routine.FullName);
codeGenerator.EmitPhpException(Methods.PhpException.MissingArgument);
// LOAD null;
if (routine.Signature.IsAlias(i))
il.Emit(OpCodes.Newobj, Constructors.PhpReference_Void);
else
il.Emit(OpCodes.Ldnull);
}
// loads missing optional arguments:
for (int i = Math.Max(mandatory_count, actual_count); i < formal_count; i++)
{
// LOAD Arg.Default;
il.Emit(OpCodes.Ldsfld, Fields.Arg_Default);
}
}
示例10: EmitCall
internal override PhpTypeCode EmitCall(CodeGenerator/*!*/ codeGenerator, string fallbackQualifiedName, CallSignature callSignature,
IPlace instance, bool runtimeVisibilityCheck, int overloadIndex, DType type, Position position,
AccessType access, bool callVirt)
{
return codeGenerator.EmitRoutineOperatorCall(null, null, FullName, fallbackQualifiedName, null, callSignature, access);
}
示例11: ArrayEx
/// <summary>
/// Builds <see cref="ArrayEx"/> with call signature parameters.
/// </summary>
/// <returns></returns>
public ArrayEx/*!*/BuildPhpArray(CallSignature/*!*/node)
{
Debug.Assert(node.GenericParams == null || node.GenericParams.Count == 0);
List<Item> arrayItems = new List<Item>(node.Parameters.Count);
var pos = Text.Span.Invalid;
foreach (var p in node.Parameters)
{
arrayItems.Add(new ValueItem(null, p.Expression));
if (pos.IsValid)
pos = p.Span;
else
pos = Text.Span.FromBounds(pos.Start, p.Span.End);
}
return new ArrayEx(pos, arrayItems);
}
示例12: EmitLoadOnPhpStack
/// <summary>
/// Emits IL instructions that load actual parameters and optionally add a new stack frame to
/// current <see cref="PHP.Core.ScriptContext.Stack"/>.
/// </summary>
/// <param name="node">Instance.</param>
/// <param name="codeGenerator">Code generator.</param>
/// <remarks>
/// Nothing is expected on the evaluation stack. Nothing is left on the evaluation stack.
/// </remarks>
public void EmitLoadOnPhpStack(CallSignature/*!*/node, CodeGenerator/*!*/ codeGenerator)
{
List<ActualParam> parameters = node.Parameters;
List<TypeRef> genericParams = node.GenericParams;
PhpStackBuilder.EmitAddFrame(codeGenerator.IL, codeGenerator.ScriptContextPlace, genericParams.Count, parameters.Count,
delegate(ILEmitter il, int i)
{
// generic arguments:
genericParams[i].EmitLoadTypeDesc(codeGenerator, ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors);
},
delegate(ILEmitter il, int i)
{
// regular arguments:
var p = parameters[i];
codeGenerator.EmitBoxing(p.NodeCompiler<ActualParamCompiler>().Emit(p, codeGenerator));
}
);
}
示例13: EmitMethodCallParameters
/// <summary>
/// Helper method, loads parameters onto evaluation stack.
/// </summary>
private static void EmitMethodCallParameters(PHP.Core.CodeGenerator/*!*/cg, CallSignature callSignature)
{
foreach (var t in callSignature.GenericParams) t.EmitLoadTypeDesc(cg, ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors); // load DTypeDescs on the stack
foreach (var p in callSignature.Parameters) { cg.EmitBoxing(p.Emit(cg)); } // load boxed args on the stack
}
示例14: EmitLoadTypeArgsOnEvalStack
internal void EmitLoadTypeArgsOnEvalStack(CallSignature/*!*/node, CodeGenerator/*!*/ codeGenerator, PhpRoutine/*!*/ routine)
{
ILEmitter il = codeGenerator.IL;
int mandatory_count = (routine.Signature != null) ? routine.Signature.MandatoryGenericParamCount : 0;
int formal_count = (routine.Signature != null) ? routine.Signature.GenericParamCount : 0;
int actual_count = node.GenericParams.Count;
// loads all actual parameters which are not superfluous:
for (int i = 0; i < Math.Min(actual_count, formal_count); i++)
node.GenericParams[i].EmitLoadTypeDesc(codeGenerator, ResolveTypeFlags.UseAutoload | ResolveTypeFlags.ThrowErrors);
// loads missing mandatory arguments:
for (int i = actual_count; i < mandatory_count; i++)
{
// CALL PhpException.MissingTypeArgument(<i+1>,<name>);
il.LdcI4(i + 1);
il.Emit(OpCodes.Ldstr, routine.FullName);
codeGenerator.EmitPhpException(Methods.PhpException.MissingTypeArgument);
// LOAD DTypeDesc.ObjectTypeDesc;
il.Emit(OpCodes.Ldsfld, Fields.DTypeDesc.ObjectTypeDesc);
}
// loads missing optional arguments:
for (int i = Math.Max(mandatory_count, actual_count); i < formal_count; i++)
{
// LOAD Arg.DefaultType;
il.Emit(OpCodes.Ldsfld, Fields.Arg_DefaultType);
}
}
示例15: 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);
}