Example #1
0
        public async Task SetExecutorAsync(ISymbolInfo function, ISymbolInfo formal, IRVisClient rVisClient)
        {
            RequireDirectory(_pathToContainingDirectory);
            var pathToCode = Combine(_pathToContainingDirectory, _codeFileName);

            var code   = new SimCode(_codeFileName, function.Symbol, formal.Symbol);
            var config = new SimConfig("Managed import", "dummy", default, code, default, default);
Example #2
0
        private void ValidateSymbolInfo(ISymbolInfo symbolInfo)
        {
            switch (symbolInfo)
            {
            case AttributeInfo attributeInfo:
                ValidateAttributeInfo(attributeInfo);
                break;

            case TypeInfo typeInfo:
                ValidateTypeInfo(typeInfo);
                break;

            case FunctionInfo functionInfo:
                ValidateFunctionInfo(functionInfo);
                break;

            case ParameterInfo parameterInfo:
                ValidateParameterInfo(parameterInfo);
                break;


            default:
                break;
            }
        }
Example #3
0
        private void ticksDataCacheEvent_TaskProcessChanged(object sender, TicksManagerProcessEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new TicksManagerTaskProcessEventHandler(ticksDataCacheEvent_TaskProcessChanged), sender, e);
                return;
            }

            ISymbolInfo symbol = sender as ISymbolInfo;
            SymbolTask  cST    = _symbolsTask[new SymbolKey(symbol.Name)];

            cST.Total   = e.Total;
            cST.Current = e.Current;

            if (DateTime.Now.Ticks - _savedTime < 10000000L)
            {
                return;
            }
            _savedTime = DateTime.Now.Ticks;

            int total   = 0;
            int current = 0;

            foreach (SymbolTask st in _symbolsTask.Values)
            {
                total   += st.Total;
                current += st.Current;
            }
            total = Math.Max(total, 1);
            _pgsSymbols.Maximum = total;
            _pgsSymbols.Value   = current;
        }
Example #4
0
        public static Arr <ParameterCandidate> CreateForExec(ISymbolInfo formal, Arr <ISymbolInfo> symbolInfos)
        {
            RequireTrue(formal.Value?.NColumns > 0);
            RequireTrue(formal.Value.NRows == 1);

            var parameterCandidates = formal.Value.NumDataColumns
                                      .Map(ndc => new ParameterCandidate(ndc.Name, ndc[0]))
                                      .OrderBy(pc => pc.Name)
                                      .ToArr();

            foreach (var parameterCandidate in parameterCandidates)
            {
                if (parameterCandidate.Description.IsntAString() || parameterCandidate.Unit.IsntAString())
                {
                    var labelled = symbolInfos.Filter(si => si.Comment.IsAString() || si.Unit.IsAString());

                    var symbolInfo = labelled.Find(si => si.Symbol == parameterCandidate.Name);

                    if (symbolInfo.IsNone)
                    {
                        var re = new Regex($"^{parameterCandidate.Name}\\W*=[^=]");
                        symbolInfo = labelled.Filter(si => si.Code.IsAString()).Find(si => re.IsMatch(si.Code !));
                    }

                    symbolInfo.IfSome(si =>
                    {
                        parameterCandidate.Description ??= si.Comment;
                        parameterCandidate.Unit ??= si.Unit;
                    });
                }
            }

            return(parameterCandidates);
        }
Example #5
0
        private void ticksDataCacheEvent_StopTask(object sender, TicksManagerTaskEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new TicksManagerTaskEventHandler(ticksDataCacheEvent_StopTask), sender, e);
                return;
            }
            ISymbolInfo symbol = sender as ISymbolInfo;

            _symbolsTask.Remove(new SymbolKey(symbol.Name));

            foreach (DataGridViewRow row in _dataGridView.Rows)
            {
                if (row.Cells[0].Value.ToString() == symbol.Name)
                {
                    row.DefaultCellStyle.BackColor = Color.White;
                    break;
                }
            }
            foreach (DataRow row in _table.Rows)
            {
                if ((string)row["name"] != symbol.Name)
                {
                    continue;
                }
                this.UpdateRow(row, sender as ITickCollection, "");
                break;
            }

            this.UpdateSymbolProgress();
        }
Example #6
0
        public void Add(ISymbolInfo symbol, ITrade trade)
        {
            var data = GetOrAddData(symbol);

            data.Add(trade);
            _Trades.Add(trade);
        }
Example #7
0
        private bool IsDeclaredTypeMember(ISymbolInfo symbol)
        {
            var typeMember = symbol.GetDeclaredElement() as ITypeMember;

            return(typeMember != null && !typeMember.GetContainingType().IsObjectClass() &&
                   !typeMember.HasAttributeInstance(PredefinedType.COMPILER_GENERATED_ATTRIBUTE_CLASS, false));
        }
Example #8
0
        private SymbolFeed GetSymbolFeed(ISymbolInfo _symbol)
        {
            var symbol = GetSymbol(_symbol);
            var sub    = GetDataSub(symbol);
            var feed   = new SymbolFeed(symbol, sub);

            return(feed);
        }
Example #9
0
 private SymbolData GetOrAddData(ISymbolInfo symbol)
 {
     if (!SymbolsData.TryGetValue(symbol.Key, out SymbolData data))
     {
         data = new SymbolData(symbol);
         _SymbolsData[symbol.Key] = data;
     }
     return(data);
 }
Example #10
0
        public static string GetFullName(this ISymbolInfo symbolInfo)
        {
            if (symbolInfo.DeclaringSymbol != null)
            {
                return(symbolInfo.DeclaringSymbol.GetFullName() + "." + symbolInfo.Name);
            }

            return(symbolInfo.Name);
        }
        public IEnumerable<ISourceInfo> FindSources(IList<IPackageEntry> fileInfos, IBinaryInfo peFile, ISymbolInfo pdbFile)
        {
            string pdbName = Path.GetFileNameWithoutExtension(pdbFile.File.FullPath);
            IList<string> originalPaths;
            using (var peStream = peFile.File.Stream)
            using (var pdbStream = pdbFile.File.Stream)
                originalPaths = pdbSourceExtractor.ReadSources(peStream, pdbStream);

            if (originalPaths.Any())
            {
                string maxCommonOriginalPath = GetMaxCommonPath(originalPaths.Select(o => o.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)));
                if (originalPaths.Count == 1)
                    maxCommonOriginalPath = Path.GetDirectoryName(maxCommonOriginalPath);

                //Clean fileInfos
                var originalPathsExtensions = originalPaths.Select(Path.GetExtension).Distinct().ToArray();
                fileInfos = fileInfos.Where(f => originalPathsExtensions.Any(o => string.Equals(Path.GetExtension(f.FullPath), o, StringComparison.OrdinalIgnoreCase))).ToArray();


                string maxCommonFileInfosPath = GetMaxCommonPath(fileInfos.Select(o => o.FullPath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)));
                if (fileInfos.Count == 1)
                    maxCommonFileInfosPath = Path.GetDirectoryName(maxCommonFileInfosPath);


                foreach (var originalPath in originalPaths)
                {
                    var actualPath = GetActualPaths(fileInfos, originalPath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar), maxCommonOriginalPath, maxCommonFileInfosPath);

                    string keyPath = Path.Combine(pdbName, originalPath.Substring(maxCommonOriginalPath.Length+1)).Replace('\\', '/');

                    if(log.IsDebugEnabled)
                        log.DebugFormat("Found '{0}' -> '{1}' ('{2}') ", originalPath, actualPath!=null ? actualPath.FullPath : "NOT FOUND", keyPath);

                    if (actualPath != null)
                        using (var stream = actualPath.Stream)
                            yield return new SourceInfo(pdbFile)
                                             {
                                                 OriginalPath = originalPath,
                                                 ActualPath = actualPath,
                                                 KeyPath = keyPath,
                                                 Md5Hash = sourceStoreManager.ReadHash(stream)
                                             };
                    else
                        yield return new SourceInfo(pdbFile)
                                         {
                                             OriginalPath = originalPath,
                                             KeyPath = keyPath,
                                         };

                }
                yield break;
            }

            yield break;
        }
Example #12
0
        public ISymbol CreateInstance(ISymbolInfo entry, ISymbol parent)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }
            ISymbol symbol = this.OnCreateSymbol(entry, parent);

            ((IBindable)symbol).Bind(this.FactoryServices.Binder);
            return(symbol);
        }
Example #13
0
        void IDeclaringSymbolInfo.AddDeclaration(ISymbolInfo declaration)
        {
            switch (declaration)
            {
            case AttributeInfo attributeInfo:
                AddAttribute(attributeInfo);
                break;

            default:
                throw new NotSupportedException();
            }
        }
Example #14
0
        public ParameterCandidate(ISymbolInfo symbolInfo)
        {
            RequireNotNullEmptyWhiteSpace(symbolInfo.Symbol);
            RequireTrue(symbolInfo.Scalar.HasValue);

            SymbolInfo = symbolInfo;

            Name        = symbolInfo.Symbol;
            Value       = symbolInfo.Scalar.Value;
            Description = symbolInfo.Comment;
            Unit        = symbolInfo.Unit;
        }
            public override bool Accepts(ISymbolInfo datum)
            {
                var method = datum.GetDeclaredElement() as IMethod;

                if (method != null)
                {
                    var isSameType = Equals(method.GetContainingType(), _completionTarget);
                    return(isSameType || !method.IsExtensionMethod);
                }

                return(true);
            }
Example #16
0
        private bool FilterToApplicableMembers(ISymbolInfo symbolInfo)
        {
            var declaredElement = symbolInfo.GetDeclaredElement() as ITypeMember;

            if (declaredElement == null)
            {
                return(false);
            }

            var predefinedType = declaredElement.Module.GetPredefinedType();

            // TODO: Allow all members, and have a problem analyser to show wrong signatures
            if (declaredElement.GetAccessRights() != AccessRights.PUBLIC || !declaredElement.IsStatic)
            {
                return(false);
            }

            var property = declaredElement as IProperty;
            var field    = declaredElement as IField;
            var method   = declaredElement as IMethod;

            if (property == null && field == null && method == null)
            {
                return(false);
            }

            if (method is IAccessor)
            {
                return(false);
            }

            var conversionRule = getTypeConversionRule(declaredElement);

            var genericEnumerableTypeElement = predefinedType.GenericIEnumerable.GetTypeElement();

            if (genericEnumerableTypeElement == null)
            {
                return(false);
            }
            var objectArrayType = TypeFactory.CreateArrayType(predefinedType.Object, 1);
            var x = EmptySubstitution.INSTANCE.Extend(genericEnumerableTypeElement.TypeParameters, new IType[] { objectArrayType }).Apply(predefinedType.GenericIEnumerable);

            var type = declaredElement.Type();

            if (type == null)
            {
                return(false);
            }

            return(type.IsImplicitlyConvertibleTo(x, conversionRule));
        }
Example #17
0
        void IDeclaringSymbolInfo.AddDeclaration(ISymbolInfo declaration)
        {
            if (declaration == null)
            {
                throw new ArgumentNullException(nameof(declaration));
            }

            if (declaration.DeclaringSymbol != this)
            {
                throw new InvalidOperationException();
            }

            declarations_.Add(declaration);
        }
Example #18
0
        private void UpdateAutoList()
        {
            blueprintSyntaxBox.AutoListClear();

            foreach (string placeholder in compiler.Placeholders)
            {
                ISymbolInfo symbolInfo = compiler.GetPlaceholderInfo(placeholder);
                string      title      = compiler.GetTitleOfPlaceholder(placeholder);
                string      itemText   = string.Format("{0} ({1})", symbolInfo.Title, symbolInfo.Placeholder);
                string      toolTip    = string.Format("{0}\n{1}", itemText, WrapWords(symbolInfo.Description, 150));

                blueprintSyntaxBox.AutoListAdd(itemText, placeholder, toolTip, 0);
            }
        }
Example #19
0
        public ISymbolInfo[] GetSymbolInfoSet(string[] symbols)
        {
            List <ISymbolInfo> symbolInfoSet = new List <ISymbolInfo>();

            foreach (string symbol in symbols)
            {
                ISymbolInfo symbolInfo = GetSymbolInfo(symbol);
                if (symbolInfo != null)
                {
                    symbolInfoSet.Add(symbolInfo);
                }
            }
            return(symbolInfoSet.ToArray());
        }
Example #20
0
        internal AlgorithmInfo(string name, ISymbolInfo declaringSymbol)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (declaringSymbol == null)
            {
                throw new ArgumentNullException(nameof(declaringSymbol));
            }

            Name            = name;
            DeclaringSymbol = declaringSymbol;
        }
Example #21
0
        protected TypeInfo(string name, ISymbolInfo declaringSymbol)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (declaringSymbol == null)
            {
                throw new ArgumentNullException(nameof(declaringSymbol));
            }

            Name            = name;
            DeclaringSymbol = declaringSymbol;
        }
Example #22
0
        void IDeclaringSymbolInfo.AddDeclaration(ISymbolInfo declaration)
        {
            if (declaration.DeclaringSymbol != this)
            {
                throw new InvalidOperationException();
            }

            if (declaration is ParameterInfo parameterInfo)
            {
                parameters_.Add(parameterInfo);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Example #23
0
        public ValueCandidate(ISymbolInfo symbolInfo, Arr <ISymbolInfo> symbolInfos)
        {
            RequireNotNullEmptyWhiteSpace(symbolInfo.Symbol);
            RequireTrue(symbolInfo.Value?.NColumns > 0);

            SymbolInfo = symbolInfo;

            Name = symbolInfo.Symbol;

            ElementCandidates = symbolInfo.Value.NumDataColumns
                                .Map(ndc => new ElementCandidate(ndc.Name, ndc.Data.ToArr(), symbolInfos))
                                .OrderBy(ec => ec.Name)
                                .ToArr();

            if (ElementCandidates.Count == 1)
            {
                var elementCandidate = ElementCandidates.Head();
                elementCandidate.Description ??= symbolInfo.Comment;
                elementCandidate.Unit ??= symbolInfo.Unit;
            }
        }
Example #24
0
        private void ticksDataCacheEvent_StartTask(object sender, TicksManagerTaskEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new TicksManagerTaskEventHandler(ticksDataCacheEvent_StartTask), sender, e);
                return;
            }

            ISymbolInfo symbol = sender as ISymbolInfo;

            _symbolsTask.Add(new SymbolKey(symbol.Name), new  SymbolTask());

            foreach (DataGridViewRow row in _dataGridView.Rows)
            {
                if (row.Cells[0].Value.ToString() == symbol.Name)
                {
                    row.DefaultCellStyle.BackColor = e.Task == TicksManagerTask.DataCaching ? Color.Red : Color.Green;
                    row.Cells["task"].Value        = e.Task.ToString();
                    break;
                }
            }
            this.UpdateSymbolProgress();
        }
        private static bool FilterToApplicableProperties(ISymbolInfo symbolInfo)
        {
            var declaredElement = symbolInfo.GetDeclaredElement() as ITypeMember;

            if (declaredElement == null)
            {
                return(false);
            }

            var predefinedType = declaredElement.GetPredefinedType();

            var property = declaredElement as IProperty;

            if (property == null)
            {
                return(false);
            }

            if (property.GetAccessRights() != AccessRights.PUBLIC || !property.IsStatic)
            {
                return(false);
            }

            var conversionRule = new CSharpTypeConversionRule(property.Module);

            var genericEnumerableTypeElement = predefinedType.GenericIEnumerable.GetTypeElement();

            if (genericEnumerableTypeElement == null)
            {
                return(false);
            }
            var objectArrayType = TypeFactory.CreateArrayType(predefinedType.Object, 1);
            var x = EmptySubstitution.INSTANCE.Extend(genericEnumerableTypeElement.TypeParameters, new[] { objectArrayType }).Apply(predefinedType.GenericIEnumerable);

            return(property.Type.IsImplicitlyConvertibleTo(x, conversionRule));
        }
Example #26
0
 internal EntityInfo(string fullName, ISymbolInfo declaringSymbol) : base(fullName, declaringSymbol)
 {
 }
Example #27
0
 public virtual ISymbolInfo Visit(ISymbolInfo symbolInfo)
 {
     Visit(symbolInfo.SourceInfos);
     return(symbolInfo);
 }
Example #28
0
 public SymbolTraceRange(ISymbolInfo symbolInfo)
 {
     Start = symbolInfo.Address;
     Size  = symbolInfo.Size;
 }
Example #29
0
 internal AttributeInfo(string name, ISymbolInfo declaringSymbol)
 {
     Name          = name;
     DeclaringType = (TypeInfo)declaringSymbol;
 }
 public SourceInfo(ISymbolInfo symbolInfo)
 {
     SymbolInfo = symbolInfo;
 }
Example #31
0
        public IEnumerable <ISourceInfo> FindSources(IList <IPackageEntry> fileInfos, ISymbolInfo pdbFile)
        {
            IList <string> originalPaths;

            using (var pdbStream = pdbFile.File.GetStream())
                originalPaths = pdbSourceExtractor.ReadSources(pdbStream);

            var files = fileInfos
                        .Select(f =>
                                new
            {
                Split = f.FullPath.ToLowerInvariant().Split(new [] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries),
                Info  = f,
            }
                                )
                        .ToArray();

            foreach (var originalPath in originalPaths)
            {
                var path = originalPath.ToLowerInvariant().Split(new[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries);

                var proposition = files
                                  .Select(f => new
                {
                    Level = ComputeLevel(path, f.Split),
                    f.Info
                })
                                  .Where(f => f.Level > 0)
                                  .OrderByDescending(f => f.Level)
                                  .Select(f => f.Info)
                                  .FirstOrDefault();

                if (proposition != null)
                {
                    using (var stream = proposition.GetStream())
                        yield return new SourceInfo()
                               {
                                   OriginalPath = originalPath,
                                   File         = proposition,
                                   Hash         = sourceStoreManager.ReadHash(stream)
                               };
                }
            }
        }
Example #32
0
        public IEnumerable <ISourceInfo> FindSources(IList <IPackageEntry> fileInfos, IBinaryInfo peFile, ISymbolInfo pdbFile)
        {
            string         pdbName = Path.GetFileNameWithoutExtension(pdbFile.File.FullPath);
            IList <string> originalPaths;

            using (var peStream = peFile.File.Stream)
                using (var pdbStream = pdbFile.File.Stream)
                    originalPaths = pdbSourceExtractor.ReadSources(peStream, pdbStream);

            if (originalPaths.Any())
            {
                string maxCommonOriginalPath = GetMaxCommonPath(originalPaths.Select(o => o.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)));
                if (originalPaths.Count == 1)
                {
                    maxCommonOriginalPath = Path.GetDirectoryName(maxCommonOriginalPath);
                }

                //Clean fileInfos
                var originalPathsExtensions = originalPaths.Select(Path.GetExtension).Distinct().ToArray();
                fileInfos = fileInfos.Where(f => originalPathsExtensions.Any(o => string.Equals(Path.GetExtension(f.FullPath), o, StringComparison.OrdinalIgnoreCase))).ToArray();


                string maxCommonFileInfosPath = GetMaxCommonPath(fileInfos.Select(o => o.FullPath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)));
                if (fileInfos.Count == 1)
                {
                    maxCommonFileInfosPath = Path.GetDirectoryName(maxCommonFileInfosPath);
                }


                foreach (var originalPath in originalPaths)
                {
                    var actualPath = GetActualPaths(fileInfos, originalPath.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar), maxCommonOriginalPath, maxCommonFileInfosPath);

                    string keyPath = Path.Combine(pdbName, originalPath.Substring(maxCommonOriginalPath.Length + 1)).Replace('\\', '/');

                    if (log.IsDebugEnabled)
                    {
                        log.DebugFormat("Found '{0}' -> '{1}' ('{2}') ", originalPath, actualPath != null ? actualPath.FullPath : "NOT FOUND", keyPath);
                    }

                    if (actualPath != null)
                    {
                        using (var stream = actualPath.Stream)
                            yield return new SourceInfo(pdbFile)
                                   {
                                       OriginalPath = originalPath,
                                       ActualPath   = actualPath,
                                       KeyPath      = keyPath,
                                       Md5Hash      = sourceStoreManager.ReadHash(stream)
                                   }
                    }
                    ;
                    else
                    {
                        yield return new SourceInfo(pdbFile)
                               {
                                   OriginalPath = originalPath,
                                   KeyPath      = keyPath,
                               }
                    };
                }
                yield break;
            }

            yield break;
        }
 public virtual ISymbolInfo Visit(ISymbolInfo symbolInfo)
 {
     Visit(symbolInfo.SourceInfos);
     return symbolInfo;
 }