• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# AnalysisUnit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AnalysisUnit的典型用法代码示例。如果您正苦于以下问题:C# AnalysisUnit类的具体用法?C# AnalysisUnit怎么用?C# AnalysisUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AnalysisUnit类属于命名空间,在下文中一共展示了AnalysisUnit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetMember

        public override INamespaceSet GetMember(Node node, AnalysisUnit unit, string name)
        {
            switch (name) {
                case "append":
                    EnsureAppend();
                    if (_appendMethod != null) {
                        return _appendMethod.SelfSet;
                    }
                    break;
                case "pop":
                    EnsurePop();
                    if (_popMethod != null) {
                        return _popMethod.SelfSet;
                    }
                    break;
                case "insert":
                    EnsureInsert();
                    if (_insertMethod != null) {
                        return _insertMethod.SelfSet;
                    }
                    break;
                case "extend":
                    EnsureExtend();
                    if (_extendMethod != null) {
                        return _extendMethod.SelfSet;
                    }
                    break;
            }

            return base.GetMember(node, unit, name);
        }
开发者ID:borota,项目名称:JTVS,代码行数:31,代码来源:ListInfo.cs


示例2: Call

        public override ISet<Namespace> Call(Node node, AnalysisUnit unit, ISet<Namespace>[] args) {
            _generator.Callers.AddDependency(unit);

            _generator.AddReturn(node, unit, base.Call(node, unit, args, keywordArgNames));
            
            return _generator.SelfSet;
        }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:7,代码来源:GeneratorFunctionInfo.cs


示例3: BinaryOperation

 public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, Parsing.PythonOperator operation, IAnalysisSet rhs) {
     var res = AnalysisSet.Empty;
     switch (operation) {
         case PythonOperator.Add:
             foreach (var type in rhs) {
                 if (type.IsOfType(ClassInfo)) {
                     res = res.Union(ClassInfo.Instance);
                 } else {
                     res = res.Union(type.ReverseBinaryOperation(node, unit, operation, SelfSet));
                 }
             }
             break;
         case PythonOperator.Mod:
             if (_supportsMod) {
                 res = SelfSet;
             }
             break;
         case PythonOperator.Multiply:
             foreach (var type in rhs) {
                 if (type.IsOfType(ProjectState.ClassInfos[BuiltinTypeId.Int]) || type.IsOfType(ProjectState.ClassInfos[BuiltinTypeId.Long])) {
                     res = res.Union(ClassInfo.Instance);
                 } else {
                     var partialRes = ConstantInfo.NumericOp(node, this, unit, operation, rhs);
                     if (partialRes != null) {
                         res = res.Union(partialRes);
                     }
                 }
             }
             break;
     }
     return res ?? base.BinaryOperation(node, unit, operation, rhs);
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:32,代码来源:SequenceBuiltinInstanceInfo.cs


示例4: GetIndex

            public override IAnalysisSet GetIndex(Node node, AnalysisUnit unit, IAnalysisSet index) {
                var res = base.GetIndex(node, unit, index);

                var names = index.OfType<ConstantInfo>()
                    .Select(ci => ci.GetConstantValueAsString())
                    .Where(s => !string.IsNullOrEmpty(s))
                    .Distinct()
                    .ToArray();

                if (names.Length != 1) {
                    // Unless you request a specific module by string literal,
                    // you won't get any object out of sys.modules.
                    return AnalysisSet.Empty;
                }

                var name = names[0];

                lock (_owner.Modules) {
                    IAnalysisSet knownValues;
                    if (_owner.Modules.TryGetValue(name, out knownValues) &&
                        knownValues != null &&
                        knownValues.Any()
                    ) {
                        return knownValues;
                    }
                }

                ModuleReference modRef;
                if (unit.ProjectState.Modules.TryImport(name, out modRef)) {
                    return modRef.AnalysisModule;
                }

                return AnalysisSet.Empty;
            }
开发者ID:omnimark,项目名称:PTVS,代码行数:34,代码来源:SysModuleInfo.cs


示例5: GetMember

        public override INamespaceSet GetMember(Node node, AnalysisUnit unit, string name)
        {
            if (unit.ProjectState.LanguageVersion.Is6x() && name == "next" ||
                unit.ProjectState.LanguageVersion.Is7x() && name == "__next__") {
                if (_next == null) {
                    var next = this._type.GetMember(unit.ProjectEntry.MyScope.InterpreterContext, name);
                    if (next != null) {
                        _next = new NextBoundMethod((BuiltinMethodInfo)unit.ProjectState.GetNamespaceFromObjects(next), this);
                    }
                }

                if (_next != null) {
                    return _next.SelfSet;
                }
            } else if (name == "__iter__") {
                if (_iter == null) {
                    var iter = this._type.GetMember(unit.ProjectEntry.MyScope.InterpreterContext, name);
                    if (iter != null) {
                        _iter = new IterBoundBuiltinMethodInfo((BuiltinMethodInfo)unit.ProjectState.GetNamespaceFromObjects(iter), this);
                    }
                }

                if (_iter != null) {
                    return _iter.SelfSet;
                }
            }
            return base.GetMember(node, unit, name);
        }
开发者ID:borota,项目名称:JTVS,代码行数:28,代码来源:IteratorInfo.cs


示例6: SetMember

 /// <summary>
 /// Performs a SetMember operation for the given name and propagates the
 /// given values types for the provided member name.
 /// </summary>
 public static void SetMember(this IAnalysisSet self, Node node, AnalysisUnit unit, string name, IAnalysisSet value) {
     if (name != null && name.Length > 0) {
         foreach (var ns in self) {
             ns.Value.SetMember(node, unit, name, value);
         }
     }
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:11,代码来源:AnalysisSetExtensions.cs


示例7: BinaryOperation

 public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) {
     var res = AnalysisSet.Empty;
     foreach (var member in _members) {
         res = res.Union(member.BinaryOperation(node, unit, operation, rhs));
     }
     return res;
 }
开发者ID:smallwave,项目名称:PTVS,代码行数:7,代码来源:MultipleMemberInfo.cs


示例8: BinaryOperation

 public override INamespaceSet BinaryOperation(Node node, AnalysisUnit unit, JOperator operation, INamespaceSet rhs)
 {
     switch (operation) {
         case JOperator.GreaterThan:
         case JOperator.LessThan:
         case JOperator.LessThanOrEqual:
         case JOperator.GreaterThanOrEqual:
         case JOperator.Equal:
         case JOperator.NotEqual:
         case JOperator.Is:
         case JOperator.IsNot:
             return ProjectState._boolType.Instance;
         case JOperator.TrueDivide:
         case JOperator.Add:
         case JOperator.Subtract:
         case JOperator.Multiply:
         case JOperator.Divide:
         case JOperator.Mod:
         case JOperator.BitwiseAnd:
         case JOperator.BitwiseOr:
         case JOperator.Xor:
         case JOperator.LeftShift:
         case JOperator.RightShift:
         case JOperator.Power:
         case JOperator.FloorDivide:
             return ConstantInfo.NumericOp(node, this, unit, operation, rhs) ?? base.BinaryOperation(node, unit, operation, rhs);
     }
     return base.BinaryOperation(node, unit, operation, rhs);
 }
开发者ID:borota,项目名称:JTVS,代码行数:29,代码来源:NumericInstanceInfo.cs


示例9: OverviewWalker

        public OverviewWalker(ProjectEntry entry, AnalysisUnit topAnalysis)
        {
            _entry = entry;
            _curUnit = topAnalysis;

            _scope = topAnalysis.Scope;
        }
开发者ID:borota,项目名称:JTVS,代码行数:7,代码来源:OverviewWalker.cs


示例10: BinaryOperation

        public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) {
            IAnalysisSet res;

            switch (operation) {
                case PythonOperator.BitwiseOr:
                    var seq = (SetInfo)unit.Scope.GetOrMakeNodeValue(
                        node,
                        _ => new SetInfo(ProjectState, node, unit.ProjectEntry)
                    );
                    seq.AddTypes(unit, GetEnumeratorTypes(node, unit));
                    foreach (var type in rhs.Where(t => t.IsOfType(ClassInfo))) {
                        seq.AddTypes(unit, type.GetEnumeratorTypes(node, unit));
                    }
                    res = seq;
                    break;
                case PythonOperator.BitwiseAnd:
                case PythonOperator.ExclusiveOr:
                case PythonOperator.Subtract:
                    res = this;
                    break;
                default:
                    res = CallReverseBinaryOp(node, unit, operation, rhs);
                    break;
            }

            return res;
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:27,代码来源:SetInfo.cs


示例11: GetIteratorTypeFromType

 internal static BuiltinClassInfo GetIteratorTypeFromType(BuiltinClassInfo klass, AnalysisUnit unit) {
     switch (klass.PythonType.TypeId) {
         case BuiltinTypeId.List:
             return unit.ProjectState.ClassInfos[BuiltinTypeId.ListIterator];
         case BuiltinTypeId.Tuple:
             return unit.ProjectState.ClassInfos[BuiltinTypeId.TupleIterator];
         case BuiltinTypeId.Set:
             return unit.ProjectState.ClassInfos[BuiltinTypeId.SetIterator];
         case BuiltinTypeId.Str:
             return unit.ProjectState.ClassInfos[BuiltinTypeId.StrIterator];
         case BuiltinTypeId.Unicode:
             return unit.ProjectState.ClassInfos[BuiltinTypeId.UnicodeIterator];
         case BuiltinTypeId.Bytes:
             return unit.ProjectState.ClassInfos[BuiltinTypeId.BytesIterator];
         case BuiltinTypeId.Generator:
         case BuiltinTypeId.DictKeys:
         case BuiltinTypeId.DictValues:
         case BuiltinTypeId.DictItems:
         case BuiltinTypeId.ListIterator:
         case BuiltinTypeId.TupleIterator:
         case BuiltinTypeId.SetIterator:
         case BuiltinTypeId.StrIterator:
         case BuiltinTypeId.UnicodeIterator:
         case BuiltinTypeId.BytesIterator:
         case BuiltinTypeId.CallableIterator:
             return klass;
         default:
             return null;
     }
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:30,代码来源:IteratorInfo.cs


示例12: AddTypes

 internal bool AddTypes(Node node, AnalysisUnit unit, IAnalysisSet key, IAnalysisSet value, bool enqueue = true) {
     if (_keysAndValues.AddTypes(unit, key, value, enqueue)) {
         if (_keysVariable != null) {
             _keysVariable.MakeUnionStrongerIfMoreThan(ProjectState.Limits.DictKeyTypes, value);
             if (_keysVariable.AddTypes(unit, key, enqueue)) {
                 if (_keysIter != null) {
                     _keysIter.UnionType = null;
                 }
                 if (_keysList != null) {
                     _keysList.UnionType = null;
                 }
             }
         }
         if (_valuesVariable != null) {
             _valuesVariable.MakeUnionStrongerIfMoreThan(ProjectState.Limits.DictValueTypes, value);
             if (_valuesVariable.AddTypes(unit, value, enqueue)) {
                 if (_valuesIter != null) {
                     _valuesIter.UnionType = null;
                 }
                 if (_valuesList != null) {
                     _valuesList.UnionType = null;
                 }
             }
         }
         if (_keyValueTuple != null) {
             _keyValueTuple.IndexTypes[0].MakeUnionStrongerIfMoreThan(ProjectState.Limits.DictKeyTypes, key);
             _keyValueTuple.IndexTypes[1].MakeUnionStrongerIfMoreThan(ProjectState.Limits.DictValueTypes, value);
             _keyValueTuple.IndexTypes[0].AddTypes(unit, key, enqueue);
             _keyValueTuple.IndexTypes[1].AddTypes(unit, value, enqueue);
         }
         return true;
     }
     return false;
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:34,代码来源:DictionaryInfo.cs


示例13: BinaryOperation

 public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) {
     switch (operation) {
         case PythonOperator.GreaterThan:
         case PythonOperator.LessThan:
         case PythonOperator.LessThanOrEqual:
         case PythonOperator.GreaterThanOrEqual:
         case PythonOperator.Equal:
         case PythonOperator.NotEqual:
         case PythonOperator.Is:
         case PythonOperator.IsNot:
             return ProjectState.ClassInfos[BuiltinTypeId.Bool].Instance;
         case PythonOperator.TrueDivide:
         case PythonOperator.Add:
         case PythonOperator.Subtract:
         case PythonOperator.Multiply:
         case PythonOperator.MatMultiply:
         case PythonOperator.Divide:
         case PythonOperator.Mod:
         case PythonOperator.BitwiseAnd:
         case PythonOperator.BitwiseOr:
         case PythonOperator.Xor:
         case PythonOperator.LeftShift:
         case PythonOperator.RightShift:
         case PythonOperator.Power:
         case PythonOperator.FloorDivide:
             return ConstantInfo.NumericOp(node, this, unit, operation, rhs) ?? CallReverseBinaryOp(node, unit, operation, rhs);
     }
     return CallReverseBinaryOp(node, unit, operation, rhs);
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:29,代码来源:NumericInstanceInfo.cs


示例14: Call

 public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
     var res = AnalysisSet.Empty;
     foreach (var member in _members) {
         res = res.Union(member.Call(node, unit, args, keywordArgNames));
     }
     return res;
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:7,代码来源:MultipleMemberInfo.cs


示例15: Call

        public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
            if (_original == null) {
                return base.Call(node, unit, args, keywordArgNames);
            }

            return _original.Call(node, unit, args, keywordArgNames);
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:7,代码来源:SpecializedNamespace.cs


示例16: CloneSpecializationImpl

        private static IAnalysisSet CloneSpecializationImpl(FunctionValue func, Node node, AnalysisUnit unit, IAnalysisSet @this, IAnalysisSet[] args) {
            if (args.Length > 0) {
                return args[0];
            }

            return AnalysisSet.Empty;            
        }
开发者ID:lioaphy,项目名称:nodejstools,代码行数:7,代码来源:OverviewWalker.Specializations.cs


示例17: GetMember

        public override IAnalysisSet GetMember(Node node, AnalysisUnit unit, string name) {
            // Must unconditionally call the base implementation of GetMember
            var res = base.GetMember(node, unit, name);

            switch (name) {
                case "append":
                    return _appendMethod = _appendMethod ?? new SpecializedCallable(
                        res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
                        ListAppend,
                        false
                    );
                case "pop":
                    return _popMethod = _popMethod ?? new SpecializedCallable(
                        res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
                        ListPop,
                        false
                    );
                case "insert":
                    return _insertMethod = _insertMethod ?? new SpecializedCallable(
                        res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
                        ListInsert,
                        false
                    );
                case "extend":
                    return _extendMethod = _extendMethod ?? new SpecializedCallable(
                        res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
                        ListExtend,
                        false
                    );
            }

            return res;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:33,代码来源:ListInfo.cs


示例18: Call

 public override INamespaceSet Call(Node node, AnalysisUnit unit, INamespaceSet[] args, NameExpression[] keywordArgNames)
 {
     if (args.Length == 0) {
         return unit.Scope.GetOrMakeNodeValue(node, n => new IteratorInfo(_indexTypes, _iterClass, n));
     }
     return NamespaceSet.Empty;
 }
开发者ID:borota,项目名称:JTVS,代码行数:7,代码来源:IterBoundBuiltinMethod.cs


示例19: Call

        public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
            if (args.Length == 1) {
                var res = unit.Scope.GetOrMakeNodeValue(
                    node,
                    (node_) => MakeFromIndexes(node_, unit.ProjectEntry)
                ) as SequenceInfo;

                List<IAnalysisSet> seqTypes = new List<IAnalysisSet>();
                foreach (var type in args[0]) {
                    SequenceInfo seqInfo = type as SequenceInfo;
                    if (seqInfo != null) {
                        for (int i = 0; i < seqInfo.IndexTypes.Length; i++) {
                            if (seqTypes.Count == i) {
                                seqTypes.Add(seqInfo.IndexTypes[i].Types);
                            } else {
                                seqTypes[i] = seqTypes[i].Union(seqInfo.IndexTypes[i].Types);
                            }
                        }
                    } else {
                        var defaultIndexType = type.GetIndex(node, unit, ProjectState.GetConstant(0));
                        if (seqTypes.Count == 0) {
                            seqTypes.Add(defaultIndexType);
                        } else {
                            seqTypes[0] = seqTypes[0].Union(defaultIndexType);
                        }
                    }
                }

                res.AddTypes(unit, seqTypes.ToArray());

                return res;
            }

            return base.Call(node, unit, args, keywordArgNames);
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:35,代码来源:SequenceBuiltinClassInfo.cs


示例20: GetMember

        public override IAnalysisSet GetMember(Node node, AnalysisUnit unit, string name) {
            // Must unconditionally call the base implementation of GetMember
            var res = base.GetMember(node, unit, name);

            switch(name) {
                case "next":
                    if (unit.ProjectState.LanguageVersion.Is2x()) {
                        return _nextMethod = _nextMethod ?? new SpecializedCallable(
                            res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
                            GeneratorNext,
                            false
                        );
                    }
                    break;
                case "__next__":
                    if (unit.ProjectState.LanguageVersion.Is3x()) {
                        return _nextMethod = _nextMethod ?? new SpecializedCallable(
                            res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
                            GeneratorNext,
                            false
                        );
                    }
                    break;
                case "send":
                    return _sendMethod = _sendMethod ?? new SpecializedCallable(
                        res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
                        GeneratorSend,
                        false
                    );
            }

            return res;
        }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:33,代码来源:GeneratorInfo.cs



注:本文中的AnalysisUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AnalysisValue类代码示例发布时间:2022-05-24
下一篇:
C# AnalysisData类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap