граф процедур в json
This commit is contained in:
14
.idea/workspace.xml
generated
14
.idea/workspace.xml
generated
@@ -6,7 +6,19 @@
|
||||
</artifacts-to-build>
|
||||
</component>
|
||||
<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/Functions/Json/FileFunctionsJson.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/Json/FunctionParameterJson.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/Json/FunctionsJson.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SPF_GetGraphFunctions.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SPF_GetGraphFunctions.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/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/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/FunctionsJson/FileFunctionsJson.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Functions/FunctionsJson/FunctionsJson.java" beforeDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"ServerUserPassword": "mprit_2011",
|
||||
"OfferRegistrationOnStart": true,
|
||||
"Workspace": "E:\\Tests",
|
||||
"ProjectsSearchDirectory": "E:\\Tests\\Downloads\\bugreport_1677002580",
|
||||
"ProjectsSearchDirectory": "E:\\BUG",
|
||||
"DocumentsDirectory": "C:\\Users\\misha\\Documents\\_testing_system",
|
||||
"VisualiserPath": "C:\\Users\\misha\\Downloads",
|
||||
"Sapfor_FPath": "E:\\_sapfor_x64\\Components\\Sapfor_F",
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package _VisualDVM.Passes.All;
|
||||
import Common.Utils.Index;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.UI;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
@@ -10,9 +8,10 @@ import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FuncCall;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FuncInfo;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FunctionType;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.Json.FileFunctionsJson;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.Json.FunctionsJson;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class SPF_GetGraphFunctions extends SapforAnalysis {
|
||||
@Override
|
||||
protected void showPreparation() {
|
||||
@@ -49,43 +48,16 @@ public class SPF_GetGraphFunctions extends SapforAnalysis {
|
||||
@Override
|
||||
protected void unpack(String packed) throws Exception {
|
||||
LinkedHashMap<String, FuncInfo> declarated_functions = new LinkedHashMap<>();
|
||||
String[] splited = packed.split("\\|");
|
||||
Index idx = new Index();
|
||||
// new version of function graph reading, availible from Sapfor version 156
|
||||
int numOfFiles = Integer.parseInt(splited[idx.Inc()]);
|
||||
Vector<String> done_programs = new Vector<>();
|
||||
for (int i = 0; i < numOfFiles; ++i) {
|
||||
String fileName = Utils_.toW(splited[idx.Inc()]);
|
||||
int functions_count = Integer.parseInt(splited[idx.Inc()]);
|
||||
DBProjectFile file = target.db.files.Data.get(fileName);
|
||||
if (!done_programs.contains(fileName)) {
|
||||
int call_count = 0;
|
||||
done_programs.add(fileName);
|
||||
for (int k = 0; k < functions_count; ++k) {
|
||||
String f_name = splited[idx.Inc()];
|
||||
Index calls_number = new Index();
|
||||
//тело функции
|
||||
FuncInfo nf = new FuncInfo(f_name, file, splited[idx.Inc()].split("#"), calls_number);
|
||||
if (nf.isMain()) {
|
||||
file.isMain = 1;
|
||||
target.main_function = nf;
|
||||
target.db.Update(file);
|
||||
}
|
||||
declarated_functions.put(nf.funcName, nf);
|
||||
//--------------------------------
|
||||
file.function_decls.put(nf.funcName, nf);
|
||||
//--------------------------------
|
||||
call_count += calls_number.getValue();
|
||||
for (int j = 0; j < calls_number.getValue(); ++j) {
|
||||
String call_name = splited[idx.Inc()];
|
||||
int c_line = Integer.parseInt(splited[idx.Inc()]);
|
||||
//-
|
||||
FuncCall fc = new FuncCall(file, call_name, c_line);
|
||||
fc.parentLineOffset = nf.line - fc.line;
|
||||
nf.calls.add(fc);
|
||||
}
|
||||
}
|
||||
file.CallGraphTitle = "Объявлений : " + file.function_decls.size() + "; Вызовов : " + call_count;
|
||||
//--
|
||||
FunctionsJson functionsJson = Utils_.gson.fromJson(packed, FunctionsJson.class);
|
||||
for (FileFunctionsJson fileFunctionsJson : functionsJson.allFunctions) {
|
||||
fileFunctionsJson.file = Utils_.toW(fileFunctionsJson.file);
|
||||
DBProjectFile projectFile = target.db.files.get(fileFunctionsJson.file);
|
||||
projectFile.saveFunctions(fileFunctionsJson.functions);
|
||||
//--
|
||||
for (FuncInfo funcInfo: projectFile.function_decls.values()){
|
||||
if (!declarated_functions.containsKey(funcInfo.funcName))
|
||||
declarated_functions.put(funcInfo.funcName, funcInfo);
|
||||
}
|
||||
}
|
||||
//---
|
||||
|
||||
@@ -13,6 +13,7 @@ import _VisualDVM.ProjectData.SapforData.Arrays.ArrayDecl;
|
||||
import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FuncCall;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FuncInfo;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FunctionType;
|
||||
import _VisualDVM.ProjectData.SapforData.Loops.Loop;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.Visual.Windows.FileForm;
|
||||
@@ -486,4 +487,25 @@ public class DBProjectFile extends ProjectFile {
|
||||
}
|
||||
LoopGraphTitle = "Всего циклов: " +AllLoops.size();
|
||||
}
|
||||
public void saveFunctions(List<FuncInfo> funcInfos_in) throws Exception{
|
||||
function_decls.clear();
|
||||
int call_count = 0;
|
||||
//--
|
||||
for (FuncInfo funcInfo: funcInfos_in){
|
||||
//--
|
||||
if (funcInfo.isMain!=0){
|
||||
isMain = 1;
|
||||
funcInfo.type = FunctionType.Main;
|
||||
father.main_function = funcInfo;
|
||||
father.db.Update(this);
|
||||
}else {
|
||||
funcInfo.type = FunctionType.Default;
|
||||
}
|
||||
//--
|
||||
function_decls.put(funcInfo.funcName, funcInfo);
|
||||
call_count+=funcInfo.calls.size();
|
||||
}
|
||||
//--
|
||||
CallGraphTitle = "Объявлений : " + function_decls.size() + "; Вызовов : " + call_count;
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,16 @@ import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
public class FuncCall extends FileObjectWithMessages{
|
||||
@Description("IGNORE")
|
||||
private boolean selected = false;
|
||||
//JSON------------------------------------------
|
||||
@Expose
|
||||
public String funcName = ""; //не нужны дополнительные поля.имя функции это уже ключ.
|
||||
public String funcName = "";
|
||||
@Expose
|
||||
public int canBeInlined = 0;
|
||||
@Expose
|
||||
public int parentLineOffset = 0;
|
||||
public int parentLineOffset = 0;// line объявления - line
|
||||
//END OF JSON------------------------------------
|
||||
@Description("IGNORE")
|
||||
private boolean selected = false;
|
||||
//---
|
||||
public FuncCall(DBProjectFile father_in, String funcName_in, int line_in) {
|
||||
super(father_in, line_in);
|
||||
|
||||
@@ -1,30 +1,33 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Functions;
|
||||
import Common.Utils.Index;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||||
import _VisualDVM.ProjectData.SapforData.FileObjectWithMessages;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.Json.FunctionParameterJson;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.mxgraph.model.mxCell;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class FuncInfo extends FileObjectWithMessages {
|
||||
//----------------------------------------------------------
|
||||
@Expose
|
||||
public int lineEnd;
|
||||
//JSON--------------------------------------------
|
||||
@Expose
|
||||
public String funcName;
|
||||
@Expose
|
||||
public FunctionType type;
|
||||
public int lineEnd; //строка где кончается тело объявления
|
||||
@Expose
|
||||
public int isMain; //является ли гпе
|
||||
@Expose
|
||||
public int needToInline;
|
||||
@Expose
|
||||
public int doNotInline;
|
||||
@Expose
|
||||
public int doNotAnalyze;
|
||||
@Expose
|
||||
public int needToInline;
|
||||
@Expose
|
||||
public FuncParam parameters;
|
||||
public List<FunctionParameterJson> params = new Vector<>();
|
||||
//END OF JSON-----------------------------------------
|
||||
|
||||
public FunctionType type = FunctionType.Default;
|
||||
//вызовы функций в теле этой функции
|
||||
public Vector<FuncCall> calls = new Vector<>();
|
||||
//вызовы этой самой функции, рассортированные по файлам.
|
||||
@@ -32,25 +35,6 @@ public class FuncInfo extends FileObjectWithMessages {
|
||||
//Узел фуннкции при отрисовке графа процедур.
|
||||
//Нужен для сохранения всех позиций графа.
|
||||
public mxCell functionsGraphCell = null;
|
||||
//это конструктор при пофайловой распаковке. в него попадают только объявленные в проекте функции.
|
||||
public FuncInfo(String f_name, DBProjectFile father_in, String[] splited, Index calls_number) {
|
||||
super(father_in, Integer.parseInt(splited[0]));
|
||||
funcName = f_name;
|
||||
lineEnd = Integer.parseInt(splited[1]);
|
||||
calls_number.Set(Integer.parseInt(splited[2]));
|
||||
needToInline = Integer.parseInt(splited[3]);
|
||||
doNotInline = Integer.parseInt(splited[4]);
|
||||
doNotAnalyze = Integer.parseInt(splited[5]);
|
||||
//в си это поле isMain
|
||||
type = ((Integer.parseInt(splited[6])) != 0) ? FunctionType.Main : FunctionType.Default;
|
||||
parameters = new FuncParam();
|
||||
if (splited.length > 6) {
|
||||
int countP = Integer.parseInt(splited[7]);
|
||||
parameters.Init(countP);
|
||||
for (int z = 0; z < countP * 3; z += 3)
|
||||
parameters.FillParam(z / 3, splited[8 + z + 2], splited[8 + z], Integer.parseInt(splited[8 + z + 1]));
|
||||
}
|
||||
}
|
||||
//функция без объявления. у нее есть только имя и тип.
|
||||
public FuncInfo(String f_name, FunctionType type_in) {
|
||||
funcName = f_name;
|
||||
@@ -62,9 +46,6 @@ public class FuncInfo extends FileObjectWithMessages {
|
||||
public String getSelectionText() {
|
||||
return type.getDescription() + " " + Utils_.Brackets(funcName);
|
||||
}
|
||||
public boolean isMain() {
|
||||
return type.equals(FunctionType.Main);
|
||||
}
|
||||
//------------------------------------------------
|
||||
@Override
|
||||
public boolean isSelectionEnabled() {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Functions.FunctionsJson;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class FunctionsJson {
|
||||
@Expose
|
||||
public List<FileFunctionsJson> functions = new Vector<>();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Functions.FunctionsJson;
|
||||
package _VisualDVM.ProjectData.SapforData.Functions.Json;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FuncInfo;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Functions.Json;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
public class FunctionParameterJson {
|
||||
@Expose
|
||||
public Integer inoutType;
|
||||
@Expose
|
||||
public String identificator;
|
||||
@Expose
|
||||
public String parameterT;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Functions.Json;
|
||||
import _VisualDVM.ProjectData.SapforData.Loops.Json.FileLoopsJson;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class FunctionsJson {
|
||||
@Expose
|
||||
public List<FileFunctionsJson> allFunctions = new Vector<>();
|
||||
}
|
||||
Reference in New Issue
Block a user