public static IPythonPropertyType Property(string name, IPythonModule declaringModule, IPythonType declaringType, IMember returnValue)
        {
            var prop = new PythonPropertyType(name, declaringModule, declaringType, false, LocationInfo.Empty);
            var o    = new PythonFunctionOverload(prop.Name, declaringModule, _ => LocationInfo.Empty);

            o.AddReturnValue(returnValue);
            prop.AddOverload(o);
            return(prop);
        }
Пример #2
0
        public static IPythonPropertyType Property(string name, IPythonModule declaringModule, IPythonType declaringType, IMember returnValue)
        {
            var location = new Location(declaringModule);
            var prop     = new PythonPropertyType(name, location, string.Empty, declaringType, false);
            var o        = new PythonFunctionOverload(prop, location);

            o.AddReturnValue(returnValue);
            prop.AddOverload(o);
            return(prop);
        }
Пример #3
0
 private PythonPropertyType AddProperty(FunctionDefinition node, IPythonModule declaringModule, IPythonType declaringType, bool isAbstract, LocationInfo loc)
 {
     if (!(_eval.LookupNameInScopes(node.Name, LookupOptions.Local) is PythonPropertyType existing))
     {
         existing = new PythonPropertyType(node, declaringModule, declaringType, isAbstract, loc);
         _eval.DeclareVariable(node.Name, existing, VariableSource.Declaration, loc);
     }
     AddOverload(node, existing, o => existing.AddOverload(o));
     return(existing);
 }
 private void AddProperty(FunctionDefinition node, IPythonType declaringType, bool isAbstract)
 {
     if (!(_eval.LookupNameInScopes(node.Name, LookupOptions.Local) is PythonPropertyType existing))
     {
         existing = new PythonPropertyType(node, _eval.GetLocationOfName(node), declaringType, isAbstract);
         // The variable is transient (non-user declared) hence it does not have location.
         // Property type is tracking locations for references and renaming.
         _eval.DeclareVariable(node.Name, existing, VariableSource.Declaration);
     }
     AddOverload(node, existing, o => existing.AddOverload(o));
 }
 private void AddProperty(FunctionDefinition fd, PythonType declaringType, bool isAbstract)
 {
     if (!(_eval.LookupNameInScopes(fd.Name, LookupOptions.Local) is PythonPropertyType p))
     {
         p = new PythonPropertyType(fd, _eval.GetLocationOfName(fd), declaringType, isAbstract);
         // The variable is transient (non-user declared) hence it does not have location.
         // Property type is tracking locations for references and renaming.
         _eval.DeclareVariable(fd.Name, p, VariableSource.Declaration);
         _typeMap[fd] = p;
         declaringType?.AddMember(p.Name, p, overwrite: true);
     }
     AddOverload(fd, p, o => p.AddOverload(o));
 }
Пример #6
0
        public PythonLazyPropertyType(PropertyModel model, ModuleFactory mf, IGlobalScope gs, IPythonType declaringType)
            : base(model, mf, gs, declaringType)
        {
            var location = new Location(mf.Module, model.IndexSpan.ToSpan());

            _property = new PythonPropertyType(model.Name, location, model.Documentation, declaringType,
                                               model.Attributes.HasFlag(FunctionAttributes.Abstract));

            // parameters and return type just to look at them.
            var o = new PythonFunctionOverload(_property, location);

            o.SetDocumentation(model.Documentation);
            _property.AddOverload(o);

            IsReadOnly = model.IsReadOnly;
            SetInnerType(_property);
        }
Пример #7
0
 public override IMember Create(ModuleFactory mf, IPythonType declaringType, IGlobalScope gs)
 => _property ?? (_property = new PythonPropertyType(Name, new Location(mf.Module, IndexSpan.ToSpan()), Documentation, declaringType, (Attributes & FunctionAttributes.Abstract) != 0));