2024-10-09 22:21:57 +03:00
|
|
|
package _VisualDVM.ProjectData.SapforData.Loops;
|
2024-10-14 15:19:13 +03:00
|
|
|
import Common.Visual.Fonts.VisualiserFonts;
|
2025-03-31 22:01:40 +03:00
|
|
|
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.ProjectData.Messages.Message;
|
|
|
|
|
import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages;
|
|
|
|
|
import _VisualDVM.ProjectData.SapforData.Functions.FuncCall;
|
2025-03-28 18:55:54 +03:00
|
|
|
import com.google.gson.annotations.Expose;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
2025-03-28 19:57:24 +03:00
|
|
|
import java.util.LinkedHashMap;
|
2025-03-28 18:55:54 +03:00
|
|
|
import java.util.List;
|
2023-09-17 22:13:42 +03:00
|
|
|
import java.util.Vector;
|
|
|
|
|
public class Loop extends FileObjectWithMessages {
|
2025-03-28 18:55:54 +03:00
|
|
|
@Expose
|
2025-03-30 15:30:38 +03:00
|
|
|
private int lineNumAfterLoop;
|
2025-03-28 18:55:54 +03:00
|
|
|
@Expose
|
2025-03-30 15:30:38 +03:00
|
|
|
private int perfectLoop;
|
2025-03-28 18:55:54 +03:00
|
|
|
@Expose
|
2025-03-30 15:35:00 +03:00
|
|
|
private int hasNonRectangularBounds;
|
|
|
|
|
@Expose
|
2025-03-31 14:18:43 +03:00
|
|
|
private int loopState;
|
|
|
|
|
public LoopState getLoopState(){
|
|
|
|
|
switch (loopState){
|
|
|
|
|
case 1:
|
|
|
|
|
return LoopState.GoodLoop;
|
|
|
|
|
case 2:
|
|
|
|
|
return LoopState.BadLoop;
|
|
|
|
|
default:
|
|
|
|
|
return LoopState.Loop;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-28 18:55:54 +03:00
|
|
|
//---
|
|
|
|
|
@Expose
|
2025-03-30 16:38:39 +03:00
|
|
|
public List<FuncCall> funcCalls = new Vector<>();
|
|
|
|
|
// @Expose
|
|
|
|
|
// public List<NonRectIter> non_rect_iters = new Vector<>();
|
2025-03-28 18:55:54 +03:00
|
|
|
@Expose
|
2025-03-31 22:01:40 +03:00
|
|
|
public List<Integer> extGotos = new Vector<>();
|
2025-03-28 18:55:54 +03:00
|
|
|
@Expose
|
2025-03-31 22:01:40 +03:00
|
|
|
public List<Integer> intGotos = new Vector<>();
|
2025-03-28 18:55:54 +03:00
|
|
|
@Expose
|
2025-03-31 22:01:40 +03:00
|
|
|
public List<Integer> ios = new Vector<>();
|
2025-03-28 18:55:54 +03:00
|
|
|
@Expose
|
2025-03-31 22:01:40 +03:00
|
|
|
public List<Integer> stops = new Vector<>();
|
2025-03-28 18:55:54 +03:00
|
|
|
@Expose
|
2025-03-30 15:30:38 +03:00
|
|
|
public List<Loop> children = new Vector<>();
|
2025-03-28 18:55:54 +03:00
|
|
|
//--
|
2025-03-31 22:01:40 +03:00
|
|
|
public List<FileObjectWithMessages> getGraphNodes(DBProjectFile dbProjectFile){
|
2025-03-30 15:30:38 +03:00
|
|
|
List<FileObjectWithMessages> all_children = new Vector<>();
|
2025-03-31 22:01:40 +03:00
|
|
|
//-
|
|
|
|
|
if (hasNonRectangularBounds!=0)
|
|
|
|
|
all_children.add(new NonRectIter(dbProjectFile, line));
|
|
|
|
|
//-
|
2025-03-30 16:38:39 +03:00
|
|
|
all_children.addAll(funcCalls);
|
2025-03-31 22:01:40 +03:00
|
|
|
//-
|
|
|
|
|
for (int line_: extGotos)
|
|
|
|
|
all_children.add(new EGoto(dbProjectFile, line_));
|
|
|
|
|
for (int line_: intGotos)
|
|
|
|
|
all_children.add(new IGoto(dbProjectFile, line_));
|
|
|
|
|
for (int line_: ios)
|
|
|
|
|
all_children.add(new IO(dbProjectFile, line_));
|
|
|
|
|
for (int line_: stops)
|
|
|
|
|
all_children.add(new Stop(dbProjectFile, line_));
|
|
|
|
|
//-
|
2025-03-30 15:30:38 +03:00
|
|
|
all_children.addAll(children);
|
|
|
|
|
return all_children;
|
2025-03-28 18:55:54 +03:00
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
@Override
|
|
|
|
|
public String TypeKey() {
|
2025-03-31 14:18:43 +03:00
|
|
|
return getLoopState().toString();
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String Description() {
|
|
|
|
|
return "цикл";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public boolean HasMessage(Message message) {
|
|
|
|
|
return (message.line >= line) && (message.line < lineNumAfterLoop);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return super.toString() + ((perfectLoop > 1) ? (" тесная вложенность " + perfectLoop) : "");
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public VisualiserFonts getFont() {
|
2025-03-31 14:18:43 +03:00
|
|
|
return getLoopState().getFont();
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
2025-03-28 19:57:24 +03:00
|
|
|
public void toMap_r(LinkedHashMap<Integer, Loop> loops_map){
|
|
|
|
|
loops_map.put(line, this);
|
2025-03-30 15:30:38 +03:00
|
|
|
for (Loop loop: children)
|
2025-03-28 19:57:24 +03:00
|
|
|
loop.toMap_r(loops_map);
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|