Files
VisualSapfor/src/_VisualDVM/ProjectData/SapforData/Loops/Loop.java

93 lines
2.9 KiB
Java
Raw Normal View History

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;
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;
import com.google.gson.annotations.Expose;
2023-09-17 22:13:42 +03:00
import java.util.LinkedHashMap;
import java.util.List;
2023-09-17 22:13:42 +03:00
import java.util.Vector;
public class Loop extends FileObjectWithMessages {
@Expose
private int lineNumAfterLoop;
@Expose
private int perfectLoop;
@Expose
2025-03-30 15:35:00 +03:00
private int hasNonRectangularBounds;
@Expose
private int loopState;
public LoopState getLoopState(){
switch (loopState){
case 1:
return LoopState.GoodLoop;
case 2:
return LoopState.BadLoop;
default:
return LoopState.Loop;
}
}
//---
@Expose
2025-03-30 16:38:39 +03:00
public List<FuncCall> funcCalls = new Vector<>();
// @Expose
// public List<NonRectIter> non_rect_iters = new Vector<>();
@Expose
public List<Integer> extGotos = new Vector<>();
@Expose
public List<Integer> intGotos = new Vector<>();
@Expose
public List<Integer> ios = new Vector<>();
@Expose
public List<Integer> stops = new Vector<>();
@Expose
public List<Loop> children = new Vector<>();
//--
public List<FileObjectWithMessages> getGraphNodes(DBProjectFile dbProjectFile){
List<FileObjectWithMessages> all_children = new Vector<>();
//-
if (hasNonRectangularBounds!=0)
all_children.add(new NonRectIter(dbProjectFile, line));
//-
2025-03-30 16:38:39 +03:00
all_children.addAll(funcCalls);
//-
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_));
//-
all_children.addAll(children);
return all_children;
}
2023-09-17 22:13:42 +03:00
@Override
public String TypeKey() {
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() {
return getLoopState().getFont();
2023-09-17 22:13:42 +03:00
}
public void toMap_r(LinkedHashMap<Integer, Loop> loops_map){
loops_map.put(line, this);
for (Loop loop: children)
loop.toMap_r(loops_map);
}
2023-09-17 22:13:42 +03:00
}