private MethodBinder(ActionBinder binder, string name, IList <MethodBase> methods, BinderType binderType, SymbolId[] kwArgs) { _binder = binder; _name = name; _binderType = binderType; _kwArgs = kwArgs; foreach (MethodBase method in methods) { if (IsUnsupported(method)) { continue; } AddBasicMethodTargets(method); } if (_paramsCandidates != null) { foreach (MethodCandidate maker in _paramsCandidates) { foreach (int count in _targetSets.Keys) { MethodCandidate target = maker.MakeParamsExtended(binder, count, _kwArgs); if (target != null) { AddTarget(target); } } } } }
public int CompareTo(MethodCandidate other, CallType callType, Type[] actualTypes) { int?cmpParams = CompareParameters(other, actualTypes); if (cmpParams == +1 || cmpParams == -1) { return((int)cmpParams); } int ret = Target.CompareEqualParameters(other.Target); if (ret != 0) { return(ret); } if (CompilerHelpers.IsStatic(Target.Method) && !CompilerHelpers.IsStatic(other.Target.Method)) { return(callType == CallType.ImplicitInstance ? -1 : +1); } else if (!CompilerHelpers.IsStatic(Target.Method) && CompilerHelpers.IsStatic(other.Target.Method)) { return(callType == CallType.ImplicitInstance ? +1 : -1); } return(0); }
private void AddSimpleTarget(MethodCandidate target) { AddTarget(target); if (CompilerHelpers.IsParamsMethod(target.Target.Method)) { if (_paramsCandidates == null) { _paramsCandidates = new List <MethodCandidate>(); } _paramsCandidates.Add(target); } }
private void AddTarget(MethodCandidate target) { int count = target.Target.ParameterCount; TargetSet set; if (!_targetSets.TryGetValue(count, out set)) { set = new TargetSet(this, count); _targetSets[count] = set; } set.Add(target); }
private static bool IsBest(MethodCandidate candidate, List <MethodCandidate> applicableTargets, CallType callType, Type[] actualTypes) { foreach (MethodCandidate target in applicableTargets) { if (candidate == target) { continue; } if (candidate.CompareTo(target, callType, actualTypes) != +1) { return(false); } } return(true); }
private TargetSet BuildTargetSet(int count) { TargetSet ts = new TargetSet(this, count); if (_paramsCandidates != null) { foreach (MethodCandidate maker in _paramsCandidates) { MethodCandidate target = maker.MakeParamsExtended(_binder, count, _kwArgs); if (target != null) { ts.Add(target); } } } return(ts); }
private bool TryGetApplicableTarget(CallType callType, List <MethodCandidate> applicableTargets, Type[] actualTypes, out List <MethodCandidate> result) { result = null; if (applicableTargets.Count == 1) { result = applicableTargets; return(true); } if (applicableTargets.Count > 1) { MethodCandidate target = FindBest(callType, applicableTargets, actualTypes); if (target != null) { result = new List <MethodCandidate>(new MethodCandidate[] { target }); return(true); } else { result = applicableTargets; return(true); } } return(false); }
public void Add(MethodCandidate target) { Debug.Assert(target.Parameters.Count == _count); _targets.Add(target); }
public MethodCandidate(MethodCandidate previous, NarrowingLevel narrowingLevel) { this._target = previous.Target; this._parameters = previous._parameters; _narrowingLevel = narrowingLevel; }
public int?CompareParameters(MethodCandidate other, Type[] actualTypes) { return(ParameterWrapper.CompareParameters(this._parameters, other._parameters, actualTypes)); }