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


C# TypeNode.GetConsolidatedTemplateArguments方法代碼示例

本文整理匯總了C#中System.Compiler.TypeNode.GetConsolidatedTemplateArguments方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeNode.GetConsolidatedTemplateArguments方法的具體用法?C# TypeNode.GetConsolidatedTemplateArguments怎麽用?C# TypeNode.GetConsolidatedTemplateArguments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Compiler.TypeNode的用法示例。


在下文中一共展示了TypeNode.GetConsolidatedTemplateArguments方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetTemplateInstance

        public virtual TypeNode/*!*/ GetTemplateInstance(Module module, TypeNode referringType, TypeNode declaringType, TypeNodeList templateArguments)
        {
            TypeNodeList templateParameters = this.TemplateParameters;
            if(module == null || templateArguments == null || (declaringType == null && (templateParameters == null || templateParameters.Count == 0)))
                return this;
            if(this.IsGeneric)
            {
                referringType = null;
                module = TypeNode.cachingModuleForGenericInstances;
            }
            bool notFullySpecialized;
            Identifier/*!*/ uniqueMangledName;
            Identifier mangledName = this.GetMangledTemplateInstanceName(templateArguments, out uniqueMangledName, out notFullySpecialized);
            TypeNode result;
            Identifier dummyId;
            this.TryToFindExistingInstance(module, declaringType, templateArguments, mangledName, uniqueMangledName, out result, out dummyId);
            if(result != null)
                return result;
            if(this.NewTemplateInstanceIsRecursive)
                return this; //An instance of this template is trying to instantiate the template again
            lock(Module.GlobalLock)
            {
                Identifier unusedMangledName;
                this.TryToFindExistingInstance(module, declaringType, templateArguments, mangledName, uniqueMangledName, out result, out unusedMangledName);
                if(result != null)
                    return result;
                //^ assume unusedMangledName != null;
                TypeNodeList consolidatedTemplateArguments =
                  declaringType == null ? templateArguments : declaringType.GetConsolidatedTemplateArguments(templateArguments);
                Duplicator duplicator = new Duplicator(module, referringType);
                duplicator.RecordOriginalAsTemplate = true;
                duplicator.SkipBodies = true;
                duplicator.TypesToBeDuplicated[this.UniqueKey] = this;
                result = duplicator.VisitTypeNode(this, unusedMangledName, consolidatedTemplateArguments, this.Template == null ? this : this.Template, true);
                //^ assume result != null;
                if(module == this.DeclaringModule)
                {
                    if(this.TemplateInstances == null)
                        this.TemplateInstances = new TypeNodeList();
                    this.TemplateInstances.Add(result);
                }
                result.Name = unusedMangledName;
                result.Name.SourceContext = this.Name.SourceContext;
                result.fullName = null;
                if(this.IsGeneric)
                    result.DeclaringModule = this.DeclaringModule;
                result.DeclaringType = this.IsGeneric || referringType == null ? declaringType : referringType;
                result.Template = this;
                result.templateParameters = new TypeNodeList();
                result.consolidatedTemplateParameters = new TypeNodeList();
                result.templateArguments = templateArguments;
                result.consolidatedTemplateArguments = consolidatedTemplateArguments;
                result.IsNotFullySpecialized = notFullySpecialized || (declaringType != null && declaringType.IsNotFullySpecialized);
                module.StructurallyEquivalentType[unusedMangledName.UniqueIdKey] = result;
                module.StructurallyEquivalentType[uniqueMangledName.UniqueIdKey] = result;
                Specializer specializer = new Specializer(module, this.ConsolidatedTemplateParameters, consolidatedTemplateArguments);
                specializer.VisitTypeNode(result);
                TypeFlags visibility = this.Flags & TypeFlags.VisibilityMask;
                for(int i = 0, m = templateArguments.Count; i < m; i++)
                {
                    TypeNode t = templateArguments[i];
                    if(t == null)
                        continue;
                    if(t is TypeParameter || t is ClassParameter || t.IsNotFullySpecialized)
                        continue;
                    visibility = TypeNode.GetVisibilityIntersection(visibility, t.Flags & TypeFlags.VisibilityMask);
                }
                result.Flags &= ~TypeFlags.VisibilityMask;
                result.Flags |= visibility;
                if(this.IsGeneric)
                    return result;

                return result;
            }
        }
開發者ID:modulexcite,項目名稱:SHFB-1,代碼行數:75,代碼來源:Nodes.cs


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