Exemplo n.º 1
0
        internal FunctionValue(ProjectEntry projectEntry, ExpandoValue prototype = null, string name = null)
            : base(projectEntry, projectEntry.Analyzer._functionPrototype)
        {
            if (prototype == null)
            {
                string description = null;
#if DEBUG
                if (String.IsNullOrWhiteSpace(Name ?? name))
                {
                    if (AnalysisUnit != null)
                    {
                        var loc = Locations.First();
                        description = "prototype object of " + AnalysisUnit.FullName + " " + loc.FilePath + "(" + loc.Column + ")";
                    }
                    else
                    {
                        description = "prototype object of <unknown objects>";
                    }
                }
                else
                {
                    description = "prototype object of " + (Name ?? name);
                }
#endif
                prototype = new PrototypeValue(ProjectEntry, this, description: description);
            }
            Add("prototype", prototype.Proxy);
            prototype.Add("constructor", this.Proxy);
            _instance = new InstanceValue(ProjectEntry, prototype, name);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Makes this analysis value include all of the source analysis
 /// values and automatically pick up new values if the source
 /// changes.
 /// </summary>
 /// <param name="source"></param>
 public void AddLinkedValue(AnalysisUnit unit, ExpandoValue source)
 {
     if (_linkedValues == null)
     {
         _linkedValues = new TypedDef();
     }
     _linkedValues.AddTypes(unit, source.SelfSet);
 }
Exemplo n.º 3
0
 public BuiltinFunctionValue(ProjectEntry projectEntry,
                             string name,
                             string documentation   = null,
                             ExpandoValue prototype = null,
                             params ParameterResult[] signature)
     : this(projectEntry, name, new[] { new SimpleOverloadResult(name, documentation, signature) }, documentation, prototype)
 {
 }
Exemplo n.º 4
0
        public BuiltinFunctionValue(ProjectEntry projectEntry,
                                    string name,
                                    OverloadResult[] overloads,
                                    string documentation   = null,
                                    ExpandoValue prototype = null)
            : base(projectEntry, prototype, name)
        {
            _name          = name;
            _documentation = documentation;
            _overloads     = overloads;

            Add("length", projectEntry.Analyzer.GetConstant(1.0).Proxy);
            Add("name", projectEntry.Analyzer.GetConstant(name).Proxy);
            Add("arguments", projectEntry.Analyzer._nullInst.Proxy);
            Add("caller", projectEntry.Analyzer._nullInst.Proxy);

            projectEntry.Analyzer.AnalysisValueCreated(typeof(BuiltinFunctionValue));
        }
Exemplo n.º 5
0
        internal override IPropertyDescriptor GetProperty(Node node, AnalysisUnit unit, string name)
        {
            EnsureDescriptors();

            PropertyDescriptorValue desc;

            if (!_descriptors.TryGetValue(name, out desc))
            {
                _descriptors[name] = desc = new PropertyDescriptorValue(ProjectEntry);
                _descriptorDependencies.EnqueueDependents();
            }

            if (IsMutable(name))
            {
                if (desc.Values == null)
                {
                    desc.Values = new EphemeralVariableDef();
                }
                desc.Values.AddDependency(unit);
            }

            if (_linkedValues != null)
            {
                foreach (var link in _linkedValues.GetTypes(unit, DeclaringModule))
                {
                    ExpandoValue expando = link.Value as ExpandoValue;
                    if (expando._descriptors != null && expando._descriptors.ContainsKey(name))
                    {
                        return(new MergedPropertyDescriptor(
                                   this,
                                   desc,
                                   name
                                   ));
                    }
                }
            }

            return(desc);
        }
Exemplo n.º 6
0
 public MergedPropertyDescriptor(ExpandoValue instance, PropertyDescriptorValue propDesc, string name)
 {
     _instance = instance;
     _propDesc = propDesc;
     _name     = name;
 }
Exemplo n.º 7
0
 public SpecializedFunctionValue(ProjectEntry projectEntry, string name, CallDelegate func, string documentation = null, ExpandoValue prototype = null, params ParameterResult[] signature)
     : base(projectEntry, name, documentation, prototype, signature)
 {
     _func = func;
 }
Exemplo n.º 8
0
 public SpecializedFunctionValue(ProjectEntry projectEntry, string name, CallDelegate func, OverloadResult[] overloads, string documentation = null, ExpandoValue prototype = null)
     : base(projectEntry, name, overloads, documentation, prototype)
 {
     _func = func;
 }