рефакторинг объектов сапфора для подготовки к джсону

This commit is contained in:
2025-03-28 18:55:54 +03:00
parent 7178ecbc9c
commit 41b98607cd
12 changed files with 145 additions and 48 deletions

View File

@@ -5,25 +5,60 @@ import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.Messages.Message;
import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages;
import _VisualDVM.ProjectData.SapforData.Functions.FuncCall;
import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Vector;
public class Loop extends FileObjectWithMessages {
@Expose
private final int lineNumAfterLoop;
@Expose
private final int perfectLoop;
@Expose
private final boolean hasOutGoto;
@Expose
private final boolean hasPrints;
@Expose
private final boolean hasNonRectIters;
//
@Expose
private final int childCount;
@Expose
public LoopState loopState;
public Vector<FileObjectWithMessages> children = new Vector<>();
//---
@Expose
public List<FuncCall> func_calls = new Vector<>();
@Expose
public List<NonRectIter> non_rect_iters = new Vector<>();
@Expose
public List<EGoto> e_gotos = new Vector<>();
@Expose
public List<IGoto> i_gotos = new Vector<>();
@Expose
public List<IO> ios = new Vector<>();
@Expose
public List<Stop> stops = new Vector<>();
@Expose
public List<Loop> loops = new Vector<>();
//--
public List<FileObjectWithMessages> getChildren(){
List<FileObjectWithMessages> children = new Vector<>();
children.addAll(func_calls);
children.addAll(non_rect_iters);
children.addAll(e_gotos);
children.addAll(i_gotos);
children.addAll(ios);
children.addAll(stops);
children.addAll(loops);
return children;
}
public Loop(String[] packedLoopInfo, Index idx, DBProjectFile father_in) {
file = father_in.name;
int calls = Integer.parseInt(packedLoopInfo[idx.Inc()]);
int calls = Integer.parseInt(packedLoopInfo[idx.Inc()]);//+
for (int k = 0; k < calls; ++k) {
String c_name = packedLoopInfo[idx.Inc()];
int c_line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
children.add(new FuncCall(father_in, c_name, c_line));
func_calls.add(new FuncCall(father_in, c_name, c_line));
}
line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
lineNumAfterLoop = Integer.parseInt(packedLoopInfo[idx.Inc()]);
@@ -43,38 +78,38 @@ public class Loop extends FileObjectWithMessages {
loopState = LoopState.Loop;
break;
}
hasNonRectIters = (Integer.parseInt(packedLoopInfo[idx.Inc()]) == 1);
hasNonRectIters = (Integer.parseInt(packedLoopInfo[idx.Inc()]) == 1); //+
if (hasNonRectIters)
children.add(new NonRectIter(father_in, line));
non_rect_iters.add(new NonRectIter(father_in, line));
////-------------------------------------------------------------------------------
// число внешних переходов
int e_gotos = Integer.parseInt(packedLoopInfo[idx.Inc()]);
for (int k = 0; k < e_gotos; ++k) {
int e_gotos_size = Integer.parseInt(packedLoopInfo[idx.Inc()]); //+
for (int k = 0; k < e_gotos_size; ++k) {
int c_line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
children.add(new EGoto(father_in, c_line));
e_gotos.add(new EGoto(father_in, c_line));
}
//число внутренних переходов
int i_gotos = Integer.parseInt(packedLoopInfo[idx.Inc()]);
for (int k = 0; k < i_gotos; ++k) {
int i_gotos_size = Integer.parseInt(packedLoopInfo[idx.Inc()]); //+
for (int k = 0; k < i_gotos_size; ++k) {
int c_line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
children.add(new IGoto(father_in, c_line));
i_gotos.add(new IGoto(father_in, c_line));
}
//число операторов печати
int IO = Integer.parseInt(packedLoopInfo[idx.Inc()]);
for (int k = 0; k < IO; ++k) {
int IOs_size = Integer.parseInt(packedLoopInfo[idx.Inc()]); //+
for (int k = 0; k < IOs_size; ++k) {
int c_line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
children.add(new IO(father_in, c_line));
ios.add(new IO(father_in, c_line));
}
//число операторов останова (STOPб PAUSE)
int stop = Integer.parseInt(packedLoopInfo[idx.Inc()]);
for (int k = 0; k < stop; ++k) {
int stops_size = Integer.parseInt(packedLoopInfo[idx.Inc()]); //++
for (int k = 0; k < stops_size; ++k) {
int c_line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
children.add(new Stop(father_in, c_line));
stops.add(new Stop(father_in, c_line));
}
//--------------------------------------------------------------------------------
for (int i = 0; i < childCount; ++i) {
Loop nextChild = new Loop(packedLoopInfo, idx, father_in);
children.add(nextChild);
loops.add(nextChild);
}
father_in.AllLoops.put(line, this);
//нельзя использовать конструктор с параметрами из за особеностей распаковки.