private int GetWaitCount(SequentialStatement SeqStatement) { int WaitCount = 0; if (SeqStatement is WaitStatement) { return(1); } foreach (VhdlElement el in SeqStatement.GetAllStatements()) { if (el is SequentialStatement) { WaitCount += GetWaitCount(el as SequentialStatement); } } return(WaitCount); }
/// <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); }