Пример #1
0
        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);

            IAnalysisSet specializedRes;

            if (_specializedValues != null && _specializedValues.TryGetValue(name, out specializedRes))
            {
                return(specializedRes);
            }

            if (_type == null)
            {
                return(unit.ProjectState.ClassInfos[BuiltinTypeId.NoneType].Instance);
            }

            var member = _type.GetMember(unit.DeclaringModule.InterpreterContext, name);

            if (member != null)
            {
                res = ProjectState.GetAnalysisValueFromObjects(member);
            }
            return(res);
        }
Пример #2
0
 public IEnumerable <KeyValuePair <string, AnalysisValue> > GetChildrenPackages(IModuleContext context)
 {
     foreach (var name in _type.GetChildrenModules())
     {
         yield return(new KeyValuePair <string, AnalysisValue>(name, ProjectState.GetAnalysisValueFromObjects(_type.GetMember(context, name))));
     }
 }
Пример #3
0
        public override IAnalysisSet GetStaticDescriptor(AnalysisUnit unit)
        {
            if (_value.IsStatic)
            {
                return(ProjectState.GetAnalysisValueFromObjects(_value.Type).GetInstanceType());
            }

            return(base.GetStaticDescriptor(unit));
        }
Пример #4
0
        public override IAnalysisSet GetDescriptor(Node node, AnalysisValue instance, AnalysisValue context, AnalysisUnit unit)
        {
            if (instance == ProjectState._noneInst)
            {
                return(base.GetDescriptor(node, instance, context, unit));
            }

            return(ProjectState.GetAnalysisValueFromObjects(_value.Type).GetInstanceType());
        }
Пример #5
0
        public IModule GetChildPackage(IModuleContext context, string name)
        {
            var mem = _type.GetMember(context, name);

            if (mem != null)
            {
                return(ProjectState.GetAnalysisValueFromObjects(mem) as IModule);
            }
            return(null);
        }
        public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames)
        {
            var returnTypes = GetFunctionOverloads().Where(o => o.ReturnType != null).SelectMany(o => o.ReturnType);
            var types       = returnTypes.Select(t => {
                var av = ProjectState.GetAnalysisValueFromObjects(t);
                return(t.IsTypeFactory
                    ? AnalysisSet.Create(av)
                    : ProjectState.GetAnalysisValueFromObjects(t).GetInstanceType());
            });

            return(AnalysisSet.UnionAll(types));
        }
Пример #7
0
        public IModule GetChildPackage(IModuleContext context, string name)
        {
            var mem = _type.GetMember(context, name);

            if (mem != null)
            {
                return(ProjectState.GetAnalysisValueFromObjects(mem) as IModule);
            }
            if (_childModules != null && _childModules.TryGetValue(name, out var child))
            {
                return(child as IModule ?? MultipleMemberInfo.Create(child.Where(m => m is IModule)) as IModule);
            }
            return(null);
        }
        public bool TryGetMember(string name, out IAnalysisSet value)
        {
            IAnalysisSet res;

            if (_specializedValues != null && _specializedValues.TryGetValue(name, out res))
            {
                value = res;
                return(true);
            }
            var member = _type.GetMember(ProjectState._defaultContext, name);

            if (member != null)
            {
                value = ProjectState.GetAnalysisValueFromObjects(member);
                return(true);
            }
            value = null;
            return(false);
        }
Пример #9
0
        public override IAnalysisSet GetTypeMember(Node node, AnalysisUnit unit, string name)
        {
            var res = AnalysisSet.Empty;

            if (_specializedValues != null && _specializedValues.TryGetValue(name, out var specializedRes))
            {
                return(specializedRes);
            }

            if (Type == null)
            {
                return(unit.State.ClassInfos[BuiltinTypeId.NoneType].Instance);
            }

            var member = Type.GetMember(unit.DeclaringModule.InterpreterContext, name);

            if (member != null)
            {
                res = ProjectState.GetAnalysisValueFromObjects(member);
            }
            return(res);
        }
Пример #10
0
 public IEnumerable <KeyValuePair <string, AnalysisValue> > GetChildrenPackages(IModuleContext context)
 {
     return(_type.GetChildrenModules().Union(_childModules.MaybeEnumerate().Keys())
            .Select(name => new KeyValuePair <string, AnalysisValue>(name, ProjectState.GetAnalysisValueFromObjects(_type.GetMember(context, name)))));
 }