148 lines
5.6 KiB
Java
148 lines
5.6 KiB
Java
package _VisualDVM.ProjectData.SapforData.Loops;
|
||
import Common.Utils.Index;
|
||
import Common.Visual.Fonts.VisualiserFonts;
|
||
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 com.sun.org.glassfish.gmbal.Description;
|
||
|
||
import java.util.LinkedHashMap;
|
||
import java.util.List;
|
||
import java.util.Vector;
|
||
public class Loop extends FileObjectWithMessages {
|
||
//public String file = "";
|
||
//public int line = 1;
|
||
@Expose
|
||
private final int lineNumAfterLoop;
|
||
@Expose
|
||
private final int perfectLoop;
|
||
@Expose
|
||
private final int hasOutGoto;
|
||
@Expose
|
||
private final int hasPrints;
|
||
@Expose
|
||
private final int hasNonRectIters;
|
||
@Expose
|
||
private final int childCount;
|
||
@Expose
|
||
public LoopState loopState;
|
||
//---
|
||
@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()]);//+
|
||
for (int k = 0; k < calls; ++k) {
|
||
String c_name = packedLoopInfo[idx.Inc()];
|
||
int c_line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
func_calls.add(new FuncCall(father_in, c_name, c_line));
|
||
}
|
||
line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
lineNumAfterLoop = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
perfectLoop = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
hasOutGoto = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
hasPrints = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
childCount = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
int state = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
switch (state) {
|
||
case 1:
|
||
loopState = LoopState.GoodLoop;
|
||
break;
|
||
case 2:
|
||
loopState = LoopState.BadLoop;
|
||
break;
|
||
default:
|
||
loopState = LoopState.Loop;
|
||
break;
|
||
}
|
||
hasNonRectIters = Integer.parseInt(packedLoopInfo[idx.Inc()]); //+
|
||
if (hasNonRectIters==1)
|
||
non_rect_iters.add(new NonRectIter(father_in, line));
|
||
////-------------------------------------------------------------------------------
|
||
// число внешних переходов
|
||
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()]);
|
||
e_gotos.add(new EGoto(father_in, c_line));
|
||
}
|
||
//число внутренних переходов
|
||
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()]);
|
||
i_gotos.add(new IGoto(father_in, c_line));
|
||
}
|
||
//число операторов печати
|
||
int IOs_size = Integer.parseInt(packedLoopInfo[idx.Inc()]); //+
|
||
for (int k = 0; k < IOs_size; ++k) {
|
||
int c_line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
ios.add(new IO(father_in, c_line));
|
||
}
|
||
//число операторов останова (STOPб PAUSE)
|
||
int stops_size = Integer.parseInt(packedLoopInfo[idx.Inc()]); //++
|
||
for (int k = 0; k < stops_size; ++k) {
|
||
int c_line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
|
||
stops.add(new Stop(father_in, c_line));
|
||
}
|
||
//--------------------------------------------------------------------------------
|
||
for (int i = 0; i < childCount; ++i) {
|
||
Loop nextChild = new Loop(packedLoopInfo, idx, father_in);
|
||
loops.add(nextChild);
|
||
}
|
||
father_in.AllLoops.put(line, this);
|
||
//нельзя использовать конструктор с параметрами из за особеностей распаковки.
|
||
CheckMessagesPresence();
|
||
}
|
||
@Override
|
||
public String TypeKey() {
|
||
return loopState.toString();
|
||
}
|
||
@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 loopState.getFont();
|
||
}
|
||
public void toMap_r(LinkedHashMap<Integer, Loop> loops_map){
|
||
loops_map.put(line, this);
|
||
for (Loop loop: loops)
|
||
loop.toMap_r(loops_map);
|
||
}
|
||
}
|