Esempio n. 1
0
        /// <summary>
        /// Получение элемента семантического дерева по его смещению
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        public VhdlElement GetElementByOffset(VhdlElement parent, int offset)
        {
            if ((parent == null) || (file == null))
            {
                return(null);
            }

            if (((parent is IDeclarativeRegion) == false) && ((parent is SequentialStatement) == false))
            {
                return(parent);
            }

            if (parent is IDeclarativeRegion)
            {
                IDeclarativeRegion decl    = parent as IDeclarativeRegion;
                List <object>      objects = decl.Scope.GetLocalListOfObjects();
                if (objects.Count >= 1)
                {
                    foreach (object obj in objects)
                    {
                        if (parent == obj)
                        {
                            continue;
                        }
                        if (obj is VhdlElement)
                        {
                            PositionInformation pos = GetPositionInformation(obj as VhdlElement);
                            if ((pos != null) && (pos.Begin.Index <= offset) && (pos.End.Index >= offset))
                            {
                                (obj as VhdlElement).Parent = (parent as IDeclarativeRegion);
                                return(GetElementByOffset(obj as VhdlElement, offset));
                            }
                            if (pos == null)
                            {
                                (obj as VhdlElement).Parent = (parent as IDeclarativeRegion);
                                return(obj as VhdlElement);
                            }
                        }
                    }
                }
            }
            if (parent is SequentialStatement)
            {
                SequentialStatement stat    = parent as SequentialStatement;
                List <VhdlElement>  objects = stat.GetAllStatements();
                if (objects.Count >= 1)
                {
                    foreach (VhdlElement obj in objects)
                    {
                        if (parent == obj)
                        {
                            continue;
                        }
                        if (obj == null)
                        {
                            continue;
                        }

                        PositionInformation pos = GetPositionInformation(obj as VhdlElement);
                        if ((pos != null) && (pos.Begin.Index <= offset) && (pos.End.Index >= offset))
                        {
                            (obj as VhdlElement).Parent = ((parent as SequentialStatement).Parent);
                            return(GetElementByOffset(obj as VhdlElement, offset));
                        }
                        if (pos == null)
                        {
                            (obj as VhdlElement).Parent = (parent as IDeclarativeRegion);
                            return(obj as VhdlElement);
                        }
                    }
                }
            }
            return(parent);
        }
 public ExpressionInference(IDeclarativeRegion scope, TypeInference baseInfer)
 {
     this.baseInfer = baseInfer;
     this.scope     = scope;
 }
Esempio n. 3
0
 private List <T> resolveAll <T>(IDeclarativeRegion scope) where T : class
 {
     return(ObjectSearcher.SearchAll <T>(scope, parts).Distinct().ToList());
 }
Esempio n. 4
0
 private T resolve <T>(IDeclarativeRegion scope) where T : class
 {
     return(ObjectSearcher.Search <T>(scope, parts));
 }
Esempio n. 5
0
 public NameInference(IDeclarativeRegion scope, TypeInference baseInfer)
 {
     this.inferer = baseInfer;
     this.scope   = scope;
 }
Esempio n. 6
0
 public static Out Search <Out>([NotNull] IDeclarativeRegion scope, List <Part> parts) where Out : class
 {
     return(Search <Out>(scope, parts, o => true));
 }