本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.TypeArray类的典型用法代码示例。如果您正苦于以下问题:C# TypeArray类的具体用法?C# TypeArray怎么用?C# TypeArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeArray类属于Microsoft.CSharp.RuntimeBinder.Semantics命名空间,在下文中一共展示了TypeArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CMethodIterator
public CMethodIterator(CSemanticChecker checker, SymbolLoader symLoader, Name name, TypeArray containingTypes, CType @object, CType qualifyingType, Declaration context, bool allowBogusAndInaccessible, bool allowExtensionMethods, int arity, EXPRFLAG flags, symbmask_t mask)
{
Debug.Assert(name != null);
Debug.Assert(symLoader != null);
Debug.Assert(checker != null);
Debug.Assert(containingTypes != null);
_pSemanticChecker = checker;
_pSymbolLoader = symLoader;
_pCurrentType = null;
_pCurrentSym = null;
_pName = name;
_pContainingTypes = containingTypes;
_pQualifyingType = qualifyingType;
_pContext = context;
_bAllowBogusAndInaccessible = allowBogusAndInaccessible;
_bAllowExtensionMethods = allowExtensionMethods;
_nArity = arity;
_flags = flags;
_mask = mask;
_nCurrentTypeCount = 0;
_bIsCheckingInstanceMethods = true;
_bAtEnd = false;
_bCurrentSymIsBogus = false;
_bCurrentSymIsInaccessible = false;
_bcanIncludeExtensionsInResults = _bAllowExtensionMethods;
_bEndIterationAtCurrentExtensionList = false;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:27,代码来源:MethodIterator.cs
示例2: Init
// Initializes a substitution context. Returns false iff no substitutions will ever be performed.
public void Init(TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
{
if (typeArgsCls != null)
{
#if DEBUG
typeArgsCls.AssertValid();
#endif
ctypeCls = typeArgsCls.size;
prgtypeCls = typeArgsCls.ToArray();
}
else
{
ctypeCls = 0;
prgtypeCls = null;
}
if (typeArgsMeth != null)
{
#if DEBUG
typeArgsMeth.AssertValid();
#endif
ctypeMeth = typeArgsMeth.size;
prgtypeMeth = typeArgsMeth.ToArray();
}
else
{
ctypeMeth = 0;
prgtypeMeth = null;
}
this.grfst = grfst;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:34,代码来源:SubstitutionContext.cs
示例3: SetBounds
public void SetBounds(TypeArray pBounds)
{
_pBounds = pBounds;
_pInterfaceBounds = null;
_pEffectiveBaseClass = null;
_pDeducedBaseClass = null;
_bHasRefBound = false;
_bHasValBound = false;
}
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:9,代码来源:TypeParameterSymbol.cs
示例4: CMemberLookupResults
public CMemberLookupResults(
TypeArray containingTypes,
Name name)
{
_pName = name;
ContainingTypes = containingTypes;
if (ContainingTypes == null)
{
ContainingTypes = BSYMMGR.EmptyTypeArray();
}
}
开发者ID:dotnet,项目名称:corefx,代码行数:11,代码来源:MemberLookupResults.cs
示例5: NumberOfErrorTypes
/////////////////////////////////////////////////////////////////////////////////
private static int NumberOfErrorTypes(TypeArray pTypeArgs)
{
int nCount = 0;
for (int i = 0; i < pTypeArgs.Size; i++)
{
if (pTypeArgs.Item(i).IsErrorType())
{
nCount++;
}
}
return nCount;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:GroupToArgsBinderResult.cs
示例6: AddInconvertibleResult
/////////////////////////////////////////////////////////////////////////////////
public void AddInconvertibleResult(
MethodSymbol method,
AggregateType currentType,
TypeArray currentTypeArgs)
{
if (InconvertibleResult.Sym == null)
{
// This is the first one, so set it for error reporting usage.
InconvertibleResult.Set(method, currentType, currentTypeArgs);
}
_inconvertibleResults.Add(new MethPropWithInst(method, currentType, currentTypeArgs));
}
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:GroupToArgsBinderResult.cs
示例7: CreateAggregateType
// Aggregate
public AggregateType CreateAggregateType(
Name name,
AggregateSymbol parent,
TypeArray typeArgsThis,
AggregateType outerType)
{
AggregateType type = new AggregateType();
type.outerType = outerType;
type.SetOwningAggregate(parent);
type.SetTypeArgsThis(typeArgsThis);
type.SetName(name);
type.SetTypeKind(TypeKind.TK_AggregateType);
return type;
}
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:17,代码来源:TypeFactory.cs
示例8: SetTypeArgsThis
public void SetTypeArgsThis(TypeArray pTypeArgsThis)
{
TypeArray pOuterTypeArgs;
if (outerType != null)
{
Debug.Assert(outerType.GetTypeArgsThis() != null);
Debug.Assert(outerType.GetTypeArgsAll() != null);
pOuterTypeArgs = outerType.GetTypeArgsAll();
}
else
{
pOuterTypeArgs = BSYMMGR.EmptyTypeArray();
}
Debug.Assert(pTypeArgsThis != null);
_pTypeArgsThis = pTypeArgsThis;
SetTypeArgsAll(pOuterTypeArgs);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:19,代码来源:AggregateType.cs
示例9: M
/*
SPEC:
CType inference occurs as part of the compile-time processing of a method invocation
and takes place before the overload resolution step of the invocation. When a
particular method group is specified in a method invocation, and no CType arguments
are specified as part of the method invocation, CType inference is applied to each
generic method in the method group. If CType inference succeeds, then the inferred
CType arguments are used to determine the types of formal parameters for subsequent
overload resolution. If overload resolution chooses a generic method as the one to
invoke then the inferred CType arguments are used as the actual CType arguments for the
invocation. If CType inference for a particular method fails, that method does not
participate in overload resolution. The failure of CType inference, in and of itself,
does not cause a compile-time error. However, it often leads to a compile-time error
when overload resolution then fails to find any applicable methods.
If the supplied number of arguments is different than the number of parameters in
the method, then inference immediately fails. Otherwise, assume that the generic
method has the following signature:
Tr M<X1...Xn>(T1 x1 ... Tm xm)
With a method call of the form M(E1...Em) the task of CType inference is to find
unique CType arguments S1...Sn for each of the CType parameters X1...Xn so that the
call M<S1...Sn>(E1...Em)becomes valid.
During the process of inference each CType parameter Xi is either fixed to a particular
CType Si or unfixed with an associated set of bounds. Each of the bounds is some CType T.
Each bound is classified as an upper bound, lower bound or exact bound.
Initially each CType variable Xi is unfixed with an empty set of bounds.
*/
// This file contains the implementation for method CType inference on calls (with
// arguments, and method CType inference on conversion of method groups to delegate
// types (which will not have arguments.)
////////////////////////////////////////////////////////////////////////////////
public static bool Infer(
ExpressionBinder binder,
SymbolLoader symbolLoader,
MethodSymbol pMethod,
TypeArray pClassTypeArguments,
TypeArray pMethodFormalParameterTypes,
ArgInfos pMethodArguments,
out TypeArray ppInferredTypeArguments)
{
Debug.Assert(pMethod != null);
Debug.Assert(pMethod.typeVars.size > 0);
Debug.Assert(pMethod.isParamArray || pMethod.Params == pMethodFormalParameterTypes);
ppInferredTypeArguments = null;
if (pMethodFormalParameterTypes.size == 0 || pMethod.InferenceMustFail())
{
return false;
}
Debug.Assert(pMethodArguments != null);
Debug.Assert(pMethodFormalParameterTypes != null);
Debug.Assert(pMethodArguments.carg <= pMethodFormalParameterTypes.size);
var inferrer = new MethodTypeInferrer(binder, symbolLoader,
pMethodFormalParameterTypes, pMethodArguments,
pMethod.typeVars, pClassTypeArguments);
bool success;
if (pMethodArguments.fHasExprs)
{
success = inferrer.InferTypeArgs();
}
else
{
success = inferrer.InferForMethodGroupConversion();
}
ppInferredTypeArguments = inferrer.GetResults();
return success;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:77,代码来源:MethodTypeInferrer.cs
示例10: IsBetterThanCurrent
private static bool IsBetterThanCurrent(TypeArray pTypeArgs1, TypeArray pTypeArgs2)
{
int leftErrors = NumberOfErrorTypes(pTypeArgs1);
int rightErrors = NumberOfErrorTypes(pTypeArgs2);
if (leftErrors == rightErrors)
{
int max = pTypeArgs1.Size > pTypeArgs2.Size ? pTypeArgs2.Size : pTypeArgs1.Size;
// If we dont have a winner yet, go through each element's type args.
for (int i = 0; i < max; i++)
{
if (pTypeArgs1.Item(i).IsAggregateType())
{
leftErrors += NumberOfErrorTypes(pTypeArgs1.Item(i).AsAggregateType().GetTypeArgsAll());
}
if (pTypeArgs2.Item(i).IsAggregateType())
{
rightErrors += NumberOfErrorTypes(pTypeArgs2.Item(i).AsAggregateType().GetTypeArgsAll());
}
}
}
return rightErrors < leftErrors;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:24,代码来源:GroupToArgsBinderResult.cs
示例11: LoadTypeFromSignature
private CType LoadTypeFromSignature(int[] signature, ref int indexIntoSignatures, TypeArray classTyVars)
{
Debug.Assert(signature != null && signature != null);
MethodSignatureEnum current = (MethodSignatureEnum)signature[indexIntoSignatures];
indexIntoSignatures++;
switch (current)
{
case MethodSignatureEnum.SIG_REF:
{
CType refType = LoadTypeFromSignature(signature, ref indexIntoSignatures, classTyVars);
if (refType == null)
{
return null;
}
return GetTypeManager().GetParameterModifier(refType, false);
}
case MethodSignatureEnum.SIG_OUT:
{
CType outType = LoadTypeFromSignature(signature, ref indexIntoSignatures, classTyVars);
if (outType == null)
{
return null;
}
return GetTypeManager().GetParameterModifier(outType, true);
}
case MethodSignatureEnum.SIG_SZ_ARRAY:
{
CType elementType = LoadTypeFromSignature(signature, ref indexIntoSignatures, classTyVars);
if (elementType == null)
{
return null;
}
return GetTypeManager().GetArray(elementType, 1);
}
case MethodSignatureEnum.SIG_METH_TYVAR:
{
int index = signature[indexIntoSignatures];
indexIntoSignatures++;
return GetTypeManager().GetStdMethTypeVar(index);
}
case MethodSignatureEnum.SIG_CLASS_TYVAR:
{
int index = signature[indexIntoSignatures];
indexIntoSignatures++;
return classTyVars.Item(index);
}
case (MethodSignatureEnum)PredefinedType.PT_VOID:
return GetTypeManager().GetVoid();
default:
{
Debug.Assert(current >= 0 && (int)current < (int)PredefinedType.PT_COUNT);
AggregateSymbol agg = GetOptPredefAgg((PredefinedType)current);
if (agg != null)
{
CType[] typeArgs = new CType[agg.GetTypeVars().size];
for (int iTypeArg = 0; iTypeArg < agg.GetTypeVars().size; iTypeArg++)
{
typeArgs[iTypeArg] = LoadTypeFromSignature(signature, ref indexIntoSignatures, classTyVars);
if (typeArgs[iTypeArg] == null)
{
return null;
}
}
AggregateType type = GetTypeManager().GetAggregate(agg, getBSymmgr().AllocParams(agg.GetTypeVars().size, typeArgs));
if (type.isPredefType(PredefinedType.PT_G_OPTIONAL))
{
return GetTypeManager().GetNubFromNullable(type);
}
return type;
}
}
break;
}
return null;
}
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:79,代码来源:PredefinedMembers.cs
示例12: CanObjectOfExtensionBeInferred
////////////////////////////////////////////////////////////////////////////////
//
// In error recovery and reporting scenarios we sometimes end up in a situation
// like this:
//
// x.Foo( y=>
//
// and the question is, "is Foo a valid extension method of x?" If Foo is
// generic, then Foo will be something like:
//
// static Blah Foo<T>(this Bar<T> bar, Func<T, T> f){ ... }
//
// What we would like to know is: given _only_ the expression x, can we infer
// what T is in Bar<T> ? If we can, then for error recovery and reporting
// we can provisionally consider Foo to be an extension method of x. If we
// cannot deduce this just from x then we should consider Foo to not be an
// extension method of x, at least until we have more information.
//
// Clearly it is pointless to run multiple phases
public static bool CanObjectOfExtensionBeInferred(
ExpressionBinder binder,
SymbolLoader symbolLoader,
MethodSymbol pMethod,
TypeArray pClassTypeArguments,
TypeArray pMethodFormalParameterTypes,
ArgInfos pMethodArguments)
{
Debug.Assert(pMethod != null);
Debug.Assert(pMethod.typeVars.size > 0);
Debug.Assert(pMethodFormalParameterTypes != null);
Debug.Assert(pMethod.isParamArray || pMethod.Params == pMethodFormalParameterTypes);
// We need at least one formal parameter type and at least one argument.
if (pMethodFormalParameterTypes.size < 1 || pMethod.InferenceMustFail())
{
return false;
}
Debug.Assert(pMethodArguments != null);
Debug.Assert(pMethodArguments.carg <= pMethodFormalParameterTypes.size);
if (pMethodArguments.carg < 1)
{
return false;
}
var inferrer = new MethodTypeInferrer(binder, symbolLoader,
pMethodFormalParameterTypes, pMethodArguments, pMethod.typeVars, pClassTypeArguments);
return inferrer.CanInferExtensionObject();
}
开发者ID:noahfalk,项目名称:corefx,代码行数:47,代码来源:MethodTypeInferrer.cs
示例13: MethodTypeInferrer
////////////////////////////////////////////////////////////////////////////////
//
// Fixed, unfixed and bounded CType parameters
//
// SPEC: During the process of inference each CType parameter is either fixed to
// SPEC: a particular CType or unfixed with an associated set of bounds. Each of
// SPEC: the bounds is of some CType T. Initially each CType parameter is unfixed
// SPEC: with an empty set of bounds.
private MethodTypeInferrer(
ExpressionBinder exprBinder, SymbolLoader symLoader,
TypeArray pMethodFormalParameterTypes, ArgInfos pMethodArguments,
TypeArray pMethodTypeParameters, TypeArray pClassTypeArguments)
{
_binder = exprBinder;
_symbolLoader = symLoader;
_pMethodFormalParameterTypes = pMethodFormalParameterTypes;
_pMethodArguments = pMethodArguments;
_pMethodTypeParameters = pMethodTypeParameters;
_pClassTypeArguments = pClassTypeArguments;
_pFixedResults = new CType[pMethodTypeParameters.size];
_pLowerBounds = new List<CType>[pMethodTypeParameters.size];
_pUpperBounds = new List<CType>[pMethodTypeParameters.size];
_pExactBounds = new List<CType>[pMethodTypeParameters.size];
for (int iBound = 0; iBound < pMethodTypeParameters.size; ++iBound)
{
_pLowerBounds[iBound] = new List<CType>();
_pUpperBounds[iBound] = new List<CType>();
_pExactBounds[iBound] = new List<CType>();
}
_ppDependencies = null;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:32,代码来源:MethodTypeInferrer.cs
示例14: GetIfacesAll
public TypeArray GetIfacesAll()
{
if (_ifacesAll == null)
{
_ifacesAll = getAggregate().GetTypeManager().SubstTypeArray(getAggregate().GetIfacesAll(), GetTypeArgsAll());
}
return _ifacesAll;
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:AggregateType.cs
示例15: MethPropWithInst
public MethPropWithInst(MethodOrPropertySymbol mps, AggregateType ats, TypeArray typeArgs)
{
Set(mps, ats, typeArgs);
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:4,代码来源:WithType.cs
示例16: SetIfaces
public void SetIfaces(TypeArray ifaces)
{
_ifaces = ifaces;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:4,代码来源:AggregateSymbol.cs
示例17: ParametersContainTyVar
public static bool ParametersContainTyVar(TypeArray @params, TypeParameterType typeFind)
{
Debug.Assert(@params != null);
Debug.Assert(typeFind != null);
for (int p = 0; p < @params.size; p++)
{
CType sym = @params[p];
if (TypeContainsType(sym, typeFind))
{
return true;
}
}
return false;
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:14,代码来源:TypeManager.cs
示例18: Set
public void Set(MethodOrPropertySymbol mps, AggregateType ats, TypeArray typeArgs)
{
if (mps == null)
{
ats = null;
typeArgs = null;
}
Debug.Assert(ats == null || mps != null && mps.getClass() == ats.getAggregate());
base.Set(mps, ats);
this.TypeArgs = typeArgs;
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:11,代码来源:WithType.cs
示例19: CreateError
public ErrorType CreateError(
Name name,
CType parent,
AssemblyQualifiedNamespaceSymbol pParentNS,
Name nameText,
TypeArray typeArgs)
{
ErrorType e = new ErrorType();
e.SetName(name);
e.nameText = nameText;
e.typeArgs = typeArgs;
e.SetTypeParent(parent);
e.SetNSParent(pParentNS);
e.SetTypeKind(TypeKind.TK_ErrorType);
return e;
}
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:17,代码来源:TypeFactory.cs
示例20: SetTypeArgsAll
public void SetTypeArgsAll(TypeArray outerTypeArgs)
{
Debug.Assert(_pTypeArgsThis != null);
// Here we need to check our current type args. If we have an open placeholder,
// then we need to have all open placeholders, and we want to flush
// our outer type args so that they're open placeholders.
//
// This is because of the following scenario:
//
// class B<T>
// {
// class C<U>
// {
// }
// class D
// {
// void Foo()
// {
// Type T = typeof(C<>);
// }
// }
// }
//
// The outer type will be B<T>, but the inner type will be C<>. However,
// this will eventually be represented in IL as B<>.C<>. As such, we should
// keep our data structures clear - if we have one open type argument, then
// all of them must be open type arguments.
//
// Ensure that invariant here.
TypeArray pCheckedOuterTypeArgs = outerTypeArgs;
TypeManager pTypeManager = getAggregate().GetTypeManager();
if (_pTypeArgsThis.Size > 0 && AreAllTypeArgumentsUnitTypes(_pTypeArgsThis))
{
if (outerTypeArgs.Size > 0 && !AreAllTypeArgumentsUnitTypes(outerTypeArgs))
{
// We have open placeholder types in our type, but not the parent.
pCheckedOuterTypeArgs = pTypeManager.CreateArrayOfUnitTypes(outerTypeArgs.Size);
}
}
_pTypeArgsAll = pTypeManager.ConcatenateTypeArrays(pCheckedOuterTypeArgs, _pTypeArgsThis);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:44,代码来源:AggregateType.cs
注:本文中的Microsoft.CSharp.RuntimeBinder.Semantics.TypeArray类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论