версия под джсон. в графе циклов временно закоммичена старая распаковка

This commit is contained in:
2025-03-28 19:57:24 +03:00
parent 41b98607cd
commit ef5bd5b1a8
7 changed files with 89 additions and 19 deletions

11
.idea/workspace.xml generated
View File

@@ -7,17 +7,12 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment=""> <list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Loops/Json/LoopsJson.java" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Loops/Json/LoopJson.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Database/Objects/DBObject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Database/Objects/DBObject.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SPF_GetGraphLoops.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SPF_GetGraphLoops.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/DBProjectFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/DBProjectFile.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/DBProjectFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/DBProjectFile.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Messages/Message.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Messages/Message.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Arrays/ArrayDecl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Arrays/ArrayDecl.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/FileObject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/FileObject.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/FileObject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/FileObject.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/FuncCall.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/FuncCall.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Loops/Json/LoopsJson.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Loops/Json/LoopsJson.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/FuncInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/FuncInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/FuncParam.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/FuncParam.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Includes/FileInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Includes/FileInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Loops/Loop.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Loops/Loop.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Loops/Loop.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Loops/Loop.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />

View File

@@ -4,6 +4,7 @@ import Common.Utils.Utils_;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.Passes.Sapfor.SapforAnalysis; import _VisualDVM.Passes.Sapfor.SapforAnalysis;
import _VisualDVM.ProjectData.Files.DBProjectFile; import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.SapforData.Loops.Json.LoopsJson;
import _VisualDVM.ProjectData.SapforData.Loops.Loop; import _VisualDVM.ProjectData.SapforData.Loops.Loop;
import java.util.Vector; import java.util.Vector;
@@ -38,6 +39,7 @@ public class SPF_GetGraphLoops extends SapforAnalysis {
@Override @Override
protected void unpack(String packed) throws Exception { protected void unpack(String packed) throws Exception {
//System.out.println(Utils_.Brackets(packed)); //System.out.println(Utils_.Brackets(packed));
/*old
Vector<String> done_programs = new Vector<>(); Vector<String> done_programs = new Vector<>();
String[] splitedPackedGraph = packed.split("\\|"); String[] splitedPackedGraph = packed.split("\\|");
for (int i = 0; i < splitedPackedGraph.length; i += 2) { for (int i = 0; i < splitedPackedGraph.length; i += 2) {
@@ -57,6 +59,26 @@ public class SPF_GetGraphLoops extends SapforAnalysis {
} }
} }
target.UpdateLoopsCount(); target.UpdateLoopsCount();
//--
*/
int allLoops=0;
Vector<String> loops_programs = new Vector<>();
System.out.println("packed_loops = "+Utils_.Brackets(packed));
LoopsJson loopsJson = Utils_.gson.fromJson(packed, LoopsJson.class);
for (Loop loop: loopsJson.values){
target.db.files.get(loop.file).LoopNests.add(loop);
//-
if (!loops_programs.contains(loop.file)){
loops_programs.add(loop.file);
}
}
//-
for (String program_name: loops_programs){
DBProjectFile program = target.db.files.get(program_name);
program.saveAllLoops();
program.LoopGraphTitle = "Всего циклов: " + program.AllLoops.size();
target.numLoops += program.AllLoops.size();
}
} }
@Override @Override
protected void FocusResult() { protected void FocusResult() {

View File

@@ -474,4 +474,9 @@ public class DBProjectFile extends ProjectFile {
return res; return res;
} }
//--- //---
public void saveAllLoops(){
for (Loop loop: LoopNests){
loop.toMap_r(AllLoops);
}
}
} }

View File

@@ -9,10 +9,8 @@ import com.sun.org.glassfish.gmbal.Description;
//объект принадлежащий файлу и относящийся к его строке. //объект принадлежащий файлу и относящийся к его строке.
public class FileObject implements Selectable { public class FileObject implements Selectable {
@Expose @Expose
@Description("DEFAULT ''")
public String file = ""; public String file = "";
@Expose @Expose
@Description("DEFAULT 1")
public int line = 1; public int line = 1;
public FileObject() { public FileObject() {
} }

View File

@@ -0,0 +1,41 @@
package _VisualDVM.ProjectData.SapforData.Loops.Json;
import _VisualDVM.ProjectData.SapforData.Functions.FuncCall;
import _VisualDVM.ProjectData.SapforData.Loops.*;
import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Vector;
public class LoopJson {
@Expose
String file;
@Expose
int line;
@Expose
int lineNumAfterLoop;
@Expose
int perfectLoop;
@Expose
int hasOutGoto;
@Expose
int hasPrints;
@Expose
int hasNonRectIters;
@Expose
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<>();
}

View File

@@ -6,5 +6,5 @@ import java.util.List;
import java.util.Vector; import java.util.Vector;
public class LoopsJson { public class LoopsJson {
@Expose @Expose
public List<Loop> values= new Vector<>(); public List<Loop> values = new Vector<>();
} }

View File

@@ -6,21 +6,24 @@ import _VisualDVM.ProjectData.Messages.Message;
import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages; import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages;
import _VisualDVM.ProjectData.SapforData.Functions.FuncCall; import _VisualDVM.ProjectData.SapforData.Functions.FuncCall;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.sun.org.glassfish.gmbal.Description;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
public class Loop extends FileObjectWithMessages { public class Loop extends FileObjectWithMessages {
//public String file = "";
//public int line = 1;
@Expose @Expose
private final int lineNumAfterLoop; private final int lineNumAfterLoop;
@Expose @Expose
private final int perfectLoop; private final int perfectLoop;
@Expose @Expose
private final boolean hasOutGoto; private final int hasOutGoto;
@Expose @Expose
private final boolean hasPrints; private final int hasPrints;
@Expose @Expose
private final boolean hasNonRectIters; private final int hasNonRectIters;
//
@Expose @Expose
private final int childCount; private final int childCount;
@Expose @Expose
@@ -52,6 +55,7 @@ public class Loop extends FileObjectWithMessages {
children.addAll(loops); children.addAll(loops);
return children; return children;
} }
public Loop(String[] packedLoopInfo, Index idx, DBProjectFile father_in) { public Loop(String[] packedLoopInfo, Index idx, DBProjectFile father_in) {
file = father_in.name; file = father_in.name;
int calls = Integer.parseInt(packedLoopInfo[idx.Inc()]);//+ int calls = Integer.parseInt(packedLoopInfo[idx.Inc()]);//+
@@ -63,8 +67,8 @@ public class Loop extends FileObjectWithMessages {
line = Integer.parseInt(packedLoopInfo[idx.Inc()]); line = Integer.parseInt(packedLoopInfo[idx.Inc()]);
lineNumAfterLoop = Integer.parseInt(packedLoopInfo[idx.Inc()]); lineNumAfterLoop = Integer.parseInt(packedLoopInfo[idx.Inc()]);
perfectLoop = Integer.parseInt(packedLoopInfo[idx.Inc()]); perfectLoop = Integer.parseInt(packedLoopInfo[idx.Inc()]);
hasOutGoto = (Integer.parseInt(packedLoopInfo[idx.Inc()]) == 1); hasOutGoto = Integer.parseInt(packedLoopInfo[idx.Inc()]);
hasPrints = (Integer.parseInt(packedLoopInfo[idx.Inc()]) == 1); hasPrints = Integer.parseInt(packedLoopInfo[idx.Inc()]);
childCount = Integer.parseInt(packedLoopInfo[idx.Inc()]); childCount = Integer.parseInt(packedLoopInfo[idx.Inc()]);
int state = Integer.parseInt(packedLoopInfo[idx.Inc()]); int state = Integer.parseInt(packedLoopInfo[idx.Inc()]);
switch (state) { switch (state) {
@@ -78,8 +82,8 @@ public class Loop extends FileObjectWithMessages {
loopState = LoopState.Loop; loopState = LoopState.Loop;
break; break;
} }
hasNonRectIters = (Integer.parseInt(packedLoopInfo[idx.Inc()]) == 1); //+ hasNonRectIters = Integer.parseInt(packedLoopInfo[idx.Inc()]); //+
if (hasNonRectIters) if (hasNonRectIters==1)
non_rect_iters.add(new NonRectIter(father_in, line)); non_rect_iters.add(new NonRectIter(father_in, line));
////------------------------------------------------------------------------------- ////-------------------------------------------------------------------------------
// число внешних переходов // число внешних переходов
@@ -135,4 +139,9 @@ public class Loop extends FileObjectWithMessages {
public VisualiserFonts getFont() { public VisualiserFonts getFont() {
return loopState.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);
}
} }