當前位置: 首頁>>代碼示例>>C#>>正文


C# Semantics.TypeArray類代碼示例

本文整理匯總了C#中Microsoft.CSharp.RuntimeBinder.Semantics.TypeArray的典型用法代碼示例。如果您正苦於以下問題:C# TypeArray類的具體用法?C# TypeArray怎麽用?C# TypeArray使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TypeArray類屬於Microsoft.CSharp.RuntimeBinder.Semantics命名空間,在下文中一共展示了TypeArray類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的Microsoft.CSharp.RuntimeBinder.Semantics.TypeArray類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。