C# 클래스 Microsoft.Scripting.Actions.Calls.OverloadResolver

Provides binding and overload resolution to .NET methods. MethodBinder's can be used for: generating new AST code for calling a method calling a method via reflection at runtime (not implemented) performing an abstract call MethodBinder's support default arguments, optional arguments, by-ref (in and out), and keyword arguments. Implementation Details: The MethodBinder works by building up a CandidateSet for each number of effective arguments that can be passed to a set of overloads. For example a set of overloads such as: foo(object a, object b, object c) foo(int a, int b) would have 2 target sets - one for 3 parameters and one for 2 parameters. For parameter arrays we fallback and create the appropriately sized CandidateSet on demand. Each CandidateSet consists of a set of MethodCandidate's. Each MethodCandidate knows the flattened parameters that could be received. For example for a function such as: foo(params int[] args) When this method is in a CandidateSet of size 3 the MethodCandidate takes 3 parameters - all of them ints; if it's in a CandidateSet of size 4 it takes 4 parameters. Effectively a MethodCandidate is a simplified view that allows all arguments to be treated as required positional arguments. Each MethodCandidate in turn refers to a MethodTarget. The MethodTarget is composed of a set of ArgBuilder's and a ReturnBuilder which know how to consume the positional arguments and pass them to the appropriate argument of the destination method. This includes routing keyword arguments to the correct position, providing the default values for optional arguments, etc... After binding is finished the MethodCandidates are thrown away and a BindingTarget is returned. The BindingTarget indicates whether the binding was successful and if not any additional information that should be reported to the user about the failed binding. It also exposes the MethodTarget which allows consumers to get the flattened list of required parameters for the call. MethodCandidates are not exposed and are an internal implementation detail of the MethodBinder.
파일 보기 프로젝트 열기: jschementi/iron 1 사용 예제들

Private Properties

프로퍼티 타입 설명
AddBasicMethodTargets void
AddFailure void
AddSimpleTarget void
AddTarget void
AllowKeywordArgumentSetting bool
BuildCandidateSets void
BuildExpandedTargetSet Microsoft.Scripting.Actions.Calls.CandidateSet
Compare int
CompareEquivalentParameters Candidate
EnsureMatchingNamedArgs List
FindMaxPriority int
GetAccessedCollapsedArgTypes System.Type[]
GetCandidateSet Microsoft.Scripting.Actions.Calls.CandidateSet
GetCollapsedArgumentValue object
GetExpectedArgCounts int[]
GetPreferredCandidate Candidate
GetPreferredParameter Candidate
GetPreferredParameters Candidate
GetRestrictedArgs Microsoft.Scripting.Actions.Calls.RestrictedArguments
GetSplatLimits void
GetSplattedItemExpression System.Linq.Expressions.Expression
GetTemporary System.Linq.Expressions.ParameterExpression
IsBest bool
IsOverloadedOnParameter bool
IsUnsupported bool
MakeAmbiguousBindingTarget BindingTarget
MakeAmbiguousCallError ErrorInfo
MakeBindingTarget BindingTarget
MakeCallFailureError ErrorInfo
MakeFailedBindingTarget BindingTarget
MakeIncorrectArgumentCountError ErrorInfo
MakeInvalidArgumentsError ErrorInfo
MakeNoCallableMethodError ErrorInfo
MakeSuccessfulBindingTarget BindingTarget
MapSpecialParameters System.Collections.BitArray
RestrictArgument System.Dynamic.DynamicMetaObject
SelectBestCandidate Microsoft.Scripting.Actions.Calls.ApplicableCandidate
SelectCandidatesWithConvertibleArgs List
SelectCandidatesWithConvertibleCollapsedArgs List
ToString string
TryConvertArguments bool
TryConvertCollapsedArguments bool

공개 메소드들

메소드 설명
CanConvertFrom ( Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter1, Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter2 ) : bool
CanConvertFrom ( Type fromType, DynamicMetaObject fromArgument, Microsoft.Scripting.Actions.Calls.ParameterWrapper toParameter, NarrowingLevel level ) : bool
Convert ( DynamicMetaObject metaObject, Type restrictedType, ParameterInfo info, Type toType ) : Expression
GetActualArguments ( ) : Microsoft.Scripting.Actions.Calls.ActualArguments
GetCollapsedArgsCondition ( ) : Expression
GetDynamicConversion ( Expression value, Type type ) : Expression
GetGenericInferenceType ( DynamicMetaObject dynamicObject ) : Type
MakeInvalidParametersError ( BindingTarget target ) : ErrorInfo
ParametersEquivalent ( Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter1, Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter2 ) : bool
PreferConvert ( Type t1, Type t2 ) : Candidate

Provides ordering for two parameter types if there is no conversion between the two parameter types.

ResolveOverload ( string methodName, IList methods, NarrowingLevel minLevel, NarrowingLevel maxLevel ) : BindingTarget

Resolves a method overload and returns back a BindingTarget. The BindingTarget can then be tested for the success or particular type of failure that prevents the method from being called. If successfully bound the BindingTarget contains a list of argument meta-objects with additional restrictions that ensure the selection of the particular overload.

ResolveOverload ( string methodName, IList methods, NarrowingLevel minLevel, NarrowingLevel maxLevel ) : BindingTarget
SelectBestConversionFor ( DynamicMetaObject arg, Microsoft.Scripting.Actions.Calls.ParameterWrapper candidateOne, Microsoft.Scripting.Actions.Calls.ParameterWrapper candidateTwo, NarrowingLevel level ) : Candidate

Selects the best (of two) candidates for conversion from actualType

보호된 메소드들

메소드 설명
AllowMemberInitialization ( OverloadInfo method ) : bool

Checks to see if the language allows named arguments to be bound to instance fields or properties and turned into setters. By default this is only allowed on contructors.

BindToUnexpandedParams ( MethodCandidate candidate ) : bool

Allow to bind an array/dictionary instance or a null reference to params array/dictionary parameter.

CompareEquivalentCandidates ( Microsoft.Scripting.Actions.Calls.ApplicableCandidate one, Microsoft.Scripting.Actions.Calls.ApplicableCandidate two ) : Candidate
CreateActualArguments ( IList namedArgs, IList argNames, int preSplatLimit, int postSplatLimit ) : Microsoft.Scripting.Actions.Calls.ActualArguments

Return null if arguments cannot be constructed and overload resolution should produce an error.

GetByRefArrayExpression ( Expression argumentArrayExpression ) : Expression

Gets an expression that evaluates to the result of GetByRefArray operation.

GetNamedArguments ( IList &namedArgs, IList &argNames ) : void
GetSplattedExpression ( ) : Expression
GetSplattedItem ( int index ) : object
OverloadResolver ( ActionBinder binder ) : System.Linq.Expressions

비공개 메소드들

메소드 설명
AddBasicMethodTargets ( OverloadInfo method ) : void
AddFailure ( List &failures, Microsoft.Scripting.Actions.Calls.CallFailure failure ) : void
AddSimpleTarget ( MethodCandidate target ) : void
AddTarget ( MethodCandidate target ) : void
AllowKeywordArgumentSetting ( MethodBase method ) : bool
BuildCandidateSets ( IEnumerable methods ) : void
BuildExpandedTargetSet ( int count ) : Microsoft.Scripting.Actions.Calls.CandidateSet
Compare ( int x, int y ) : int
CompareEquivalentParameters ( MethodCandidate one, MethodCandidate two ) : Candidate
EnsureMatchingNamedArgs ( List candidates, List &failures ) : List
FindMaxPriority ( IList abs, int ceiling ) : int
GetAccessedCollapsedArgTypes ( ) : System.Type[]
GetCandidateSet ( ) : Microsoft.Scripting.Actions.Calls.CandidateSet
GetCollapsedArgumentValue ( int collapsedArgIndex ) : object
GetExpectedArgCounts ( ) : int[]
GetPreferredCandidate ( Microsoft.Scripting.Actions.Calls.ApplicableCandidate one, Microsoft.Scripting.Actions.Calls.ApplicableCandidate two, NarrowingLevel level ) : Candidate
GetPreferredParameter ( Microsoft.Scripting.Actions.Calls.ParameterWrapper candidateOne, Microsoft.Scripting.Actions.Calls.ParameterWrapper candidateTwo, DynamicMetaObject arg, NarrowingLevel level ) : Candidate
GetPreferredParameters ( Microsoft.Scripting.Actions.Calls.ApplicableCandidate one, Microsoft.Scripting.Actions.Calls.ApplicableCandidate two, NarrowingLevel level ) : Candidate
GetRestrictedArgs ( Microsoft.Scripting.Actions.Calls.ApplicableCandidate selectedCandidate, IList candidates, int targetSetSize ) : Microsoft.Scripting.Actions.Calls.RestrictedArguments
GetSplatLimits ( int &preSplatLimit, int &postSplatLimit ) : void
GetSplattedItemExpression ( Expression indexExpression ) : Expression

The method is called each time an item of lazily splatted argument is needed.

GetTemporary ( Type type, string name ) : System.Linq.Expressions.ParameterExpression
IsBest ( Microsoft.Scripting.Actions.Calls.ApplicableCandidate candidate, List candidates, NarrowingLevel level ) : bool
IsOverloadedOnParameter ( int argIndex, int argCount, IList overloads ) : bool

Determines whether given overloads are overloaded on index-th parameter (the types of the index-th parameters are the same).

IsUnsupported ( OverloadInfo method ) : bool
MakeAmbiguousBindingTarget ( List result ) : BindingTarget
MakeAmbiguousCallError ( BindingTarget target ) : ErrorInfo
MakeBindingTarget ( Microsoft.Scripting.Actions.Calls.CandidateSet targetSet ) : BindingTarget
MakeCallFailureError ( BindingTarget target ) : ErrorInfo
MakeFailedBindingTarget ( Microsoft.Scripting.Actions.Calls.CallFailure failures ) : BindingTarget
MakeIncorrectArgumentCountError ( BindingTarget target ) : ErrorInfo
MakeInvalidArgumentsError ( ) : ErrorInfo
MakeNoCallableMethodError ( ) : ErrorInfo
MakeSuccessfulBindingTarget ( Microsoft.Scripting.Actions.Calls.ApplicableCandidate result, List potentialCandidates, NarrowingLevel level, Microsoft.Scripting.Actions.Calls.CandidateSet targetSet ) : BindingTarget
MapSpecialParameters ( ParameterMapping mapping ) : BitArray
RestrictArgument ( DynamicMetaObject arg, Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter ) : DynamicMetaObject
SelectBestCandidate ( List candidates, NarrowingLevel level ) : Microsoft.Scripting.Actions.Calls.ApplicableCandidate
SelectCandidatesWithConvertibleArgs ( List candidates, NarrowingLevel level, List &failures ) : List
SelectCandidatesWithConvertibleCollapsedArgs ( List candidates, NarrowingLevel level, List &failures ) : List
ToString ( ) : string
TryConvertArguments ( MethodCandidate candidate, Microsoft.Scripting.Actions.Calls.ArgumentBinding namesBinding, NarrowingLevel narrowingLevel, Microsoft.Scripting.Actions.Calls.CallFailure &failure ) : bool
TryConvertCollapsedArguments ( MethodCandidate candidate, NarrowingLevel narrowingLevel, Microsoft.Scripting.Actions.Calls.CallFailure &failure ) : bool

메소드 상세

AllowMemberInitialization() 보호된 메소드

Checks to see if the language allows named arguments to be bound to instance fields or properties and turned into setters. By default this is only allowed on contructors.
protected AllowMemberInitialization ( OverloadInfo method ) : bool
method OverloadInfo
리턴 bool

BindToUnexpandedParams() 보호된 메소드

Allow to bind an array/dictionary instance or a null reference to params array/dictionary parameter.
protected BindToUnexpandedParams ( MethodCandidate candidate ) : bool
candidate MethodCandidate
리턴 bool

CanConvertFrom() 공개 메소드

public CanConvertFrom ( Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter1, Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter2 ) : bool
parameter1 Microsoft.Scripting.Actions.Calls.ParameterWrapper
parameter2 Microsoft.Scripting.Actions.Calls.ParameterWrapper
리턴 bool

CanConvertFrom() 공개 메소드

public CanConvertFrom ( Type fromType, DynamicMetaObject fromArgument, Microsoft.Scripting.Actions.Calls.ParameterWrapper toParameter, NarrowingLevel level ) : bool
fromType System.Type
fromArgument System.Dynamic.DynamicMetaObject
toParameter Microsoft.Scripting.Actions.Calls.ParameterWrapper
level NarrowingLevel
리턴 bool

CompareEquivalentCandidates() 보호된 메소드

protected CompareEquivalentCandidates ( Microsoft.Scripting.Actions.Calls.ApplicableCandidate one, Microsoft.Scripting.Actions.Calls.ApplicableCandidate two ) : Candidate
one Microsoft.Scripting.Actions.Calls.ApplicableCandidate
two Microsoft.Scripting.Actions.Calls.ApplicableCandidate
리턴 Candidate

Convert() 공개 메소드

public Convert ( DynamicMetaObject metaObject, Type restrictedType, ParameterInfo info, Type toType ) : Expression
metaObject System.Dynamic.DynamicMetaObject
restrictedType System.Type
info System.Reflection.ParameterInfo
toType System.Type
리턴 System.Linq.Expressions.Expression

CreateActualArguments() 보호된 추상적인 메소드

Return null if arguments cannot be constructed and overload resolution should produce an error.
protected abstract CreateActualArguments ( IList namedArgs, IList argNames, int preSplatLimit, int postSplatLimit ) : Microsoft.Scripting.Actions.Calls.ActualArguments
namedArgs IList
argNames IList
preSplatLimit int
postSplatLimit int
리턴 Microsoft.Scripting.Actions.Calls.ActualArguments

GetActualArguments() 공개 메소드

public GetActualArguments ( ) : Microsoft.Scripting.Actions.Calls.ActualArguments
리턴 Microsoft.Scripting.Actions.Calls.ActualArguments

GetByRefArrayExpression() 보호된 메소드

Gets an expression that evaluates to the result of GetByRefArray operation.
protected GetByRefArrayExpression ( Expression argumentArrayExpression ) : Expression
argumentArrayExpression System.Linq.Expressions.Expression
리턴 System.Linq.Expressions.Expression

GetCollapsedArgsCondition() 공개 메소드

public GetCollapsedArgsCondition ( ) : Expression
리턴 System.Linq.Expressions.Expression

GetDynamicConversion() 공개 메소드

public GetDynamicConversion ( Expression value, Type type ) : Expression
value System.Linq.Expressions.Expression
type System.Type
리턴 System.Linq.Expressions.Expression

GetGenericInferenceType() 공개 메소드

public GetGenericInferenceType ( DynamicMetaObject dynamicObject ) : Type
dynamicObject System.Dynamic.DynamicMetaObject
리턴 System.Type

GetNamedArguments() 보호된 메소드

protected GetNamedArguments ( IList &namedArgs, IList &argNames ) : void
namedArgs IList
argNames IList
리턴 void

GetSplattedExpression() 보호된 추상적인 메소드

protected abstract GetSplattedExpression ( ) : Expression
리턴 System.Linq.Expressions.Expression

GetSplattedItem() 보호된 추상적인 메소드

protected abstract GetSplattedItem ( int index ) : object
index int
리턴 object

MakeInvalidParametersError() 공개 메소드

public MakeInvalidParametersError ( BindingTarget target ) : ErrorInfo
target BindingTarget
리턴 ErrorInfo

OverloadResolver() 보호된 메소드

protected OverloadResolver ( ActionBinder binder ) : System.Linq.Expressions
binder ActionBinder
리턴 System.Linq.Expressions

ParametersEquivalent() 공개 메소드

public ParametersEquivalent ( Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter1, Microsoft.Scripting.Actions.Calls.ParameterWrapper parameter2 ) : bool
parameter1 Microsoft.Scripting.Actions.Calls.ParameterWrapper
parameter2 Microsoft.Scripting.Actions.Calls.ParameterWrapper
리턴 bool

PreferConvert() 공개 메소드

Provides ordering for two parameter types if there is no conversion between the two parameter types.
public PreferConvert ( Type t1, Type t2 ) : Candidate
t1 System.Type
t2 System.Type
리턴 Candidate

ResolveOverload() 공개 메소드

Resolves a method overload and returns back a BindingTarget. The BindingTarget can then be tested for the success or particular type of failure that prevents the method from being called. If successfully bound the BindingTarget contains a list of argument meta-objects with additional restrictions that ensure the selection of the particular overload.
public ResolveOverload ( string methodName, IList methods, NarrowingLevel minLevel, NarrowingLevel maxLevel ) : BindingTarget
methodName string
methods IList
minLevel NarrowingLevel
maxLevel NarrowingLevel
리턴 BindingTarget

ResolveOverload() 공개 메소드

public ResolveOverload ( string methodName, IList methods, NarrowingLevel minLevel, NarrowingLevel maxLevel ) : BindingTarget
methodName string
methods IList
minLevel NarrowingLevel
maxLevel NarrowingLevel
리턴 BindingTarget

SelectBestConversionFor() 공개 메소드

Selects the best (of two) candidates for conversion from actualType
public SelectBestConversionFor ( DynamicMetaObject arg, Microsoft.Scripting.Actions.Calls.ParameterWrapper candidateOne, Microsoft.Scripting.Actions.Calls.ParameterWrapper candidateTwo, NarrowingLevel level ) : Candidate
arg System.Dynamic.DynamicMetaObject
candidateOne Microsoft.Scripting.Actions.Calls.ParameterWrapper
candidateTwo Microsoft.Scripting.Actions.Calls.ParameterWrapper
level NarrowingLevel
리턴 Candidate