示例#1
0
文件: ModuleInfo.cs 项目: krus/PTVS
        public IAnalysisSet GetModuleMember(Node node, AnalysisUnit unit, string name, bool addRef = true, InterpreterScope linkedScope = null, string linkedName = null)
        {
            var importedValue = Scope.CreateVariable(node, unit, name, addRef);

            ModuleDefinition.AddDependency(unit);

            if (linkedScope != null)
            {
                linkedScope.GetLinkedVariables(linkedName ?? name).Add(importedValue);
            }
            return(importedValue.TypesNoCopy);
        }
示例#2
0
        private IEnumerable <IAnalysisVariable> GetVariablesInScope(NameExpression name, InterpreterScope scope)
        {
            var result = new List <IAnalysisVariable>();

            result.AddRange(scope.GetMergedVariables(name.Name).SelectMany(ToVariables));

            // if a variable is imported from another module then also yield the defs/refs for the
            // value in the defining module.
            result.AddRange(scope.GetLinkedVariables(name.Name).SelectMany(ToVariables));

            var classScope = scope as ClassScope;

            if (classScope != null)
            {
                // if the member is defined in a base class as well include the base class member and references
                var cls = classScope.Class;
                if (cls.Push())
                {
                    try {
                        foreach (var baseNs in cls.Bases.SelectMany())
                        {
                            if (baseNs.Push())
                            {
                                try {
                                    ClassInfo baseClassNs = baseNs as ClassInfo;
                                    if (baseClassNs != null)
                                    {
                                        result.AddRange(
                                            baseClassNs.Scope.GetMergedVariables(name.Name).SelectMany(ToVariables)
                                            );
                                    }
                                } finally {
                                    baseNs.Pop();
                                }
                            }
                        }
                    } finally {
                        cls.Pop();
                    }
                }
            }

            return(result);
        }