/// <summary> /// Creates an overload of the function. May return <B>null</B> on error. /// </summary> internal static Overload Create(MethodInfo/*!*/ realOverload, FunctionImplOptions options) { ParameterInfo[] parameters = realOverload.GetParameters(); OverloadFlags flags = OverloadFlags.None; short param_count = (short)parameters.Length; if (parameters.Length >= 1 && parameters[0].ParameterType == Types.ScriptContext[0]) { flags |= OverloadFlags.NeedsScriptContext; param_count--; } if (parameters.Length > 0 && parameters[parameters.Length - 1].IsDefined(typeof(ParamArrayAttribute), false)) { flags |= OverloadFlags.IsVararg; param_count--; } if ((options & FunctionImplOptions.NeedsThisReference) != 0) { param_count--; flags |= OverloadFlags.NeedsThisReference; } if ((options & FunctionImplOptions.NeedsVariables) != 0) { param_count--; flags |= OverloadFlags.NeedsVariables; } if ((options & FunctionImplOptions.NeedsNamingContext) != 0) { param_count--; flags |= OverloadFlags.NeedsNamingContext; } if ((options & FunctionImplOptions.NeedsClassContext) != 0) { param_count--; flags |= OverloadFlags.NeedsClassContext; } if ((options & FunctionImplOptions.NotSupported) != 0) { flags |= OverloadFlags.NotSupported; } return new Overload(realOverload, parameters, param_count, flags); }
public Overload(MethodBase/*!*/ method, Type[]/*!!*/ genericParameters, ParameterInfo[]/*!!*/ parameters) { this.method = method; this.parameters = parameters; this.genericParameters = genericParameters; flags = OverloadFlags.None; if (parameters.Length > 0 && parameters[parameters.Length - 1].IsDefined(typeof(ParamArrayAttribute), false)) flags |= OverloadFlags.IsVararg; this.paramCount = parameters.Length - ((flags & OverloadFlags.IsVararg) != 0 ? 1 : 0); }
private Overload(MethodInfo/*!*/ method, ParameterInfo[]/*!!*/ parameters, short paramCount, OverloadFlags flags) { Debug.Assert(method != null && parameters != null); this.method = method; this.paramCount = paramCount; this.flags = flags; this.parameters = parameters; }