Массивы в json

This commit is contained in:
2025-05-06 16:26:47 +03:00
parent b46f86bebb
commit 6e0956e3e5
9 changed files with 114 additions and 53 deletions

8
.idea/workspace.xml generated
View File

@@ -7,10 +7,16 @@
</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/Common/Utils/IntegerPairJson.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$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" /> <change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/MassSelectArrays.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/MassSelectArrays.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SPF_GetGCovInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SPF_GetGCovInfo.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SPF_GetGCovInfo.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/SPF_GetGCovInfo.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/GCOV/GCOVJson.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/GCOV/GCOVJson.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/DBArray/DBArray.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/DBArray/DBArray.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/UI/Editor/SPFEditor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/UI/Editor/SPFEditor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Arrays/Distribution/DataDirective.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Arrays/Distribution/DataDirective.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Arrays/ProjectArray.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Arrays/ProjectArray.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Arrays/UI/ProjectArraysForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/SapforData/Arrays/UI/ProjectArraysForm.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -0,0 +1,20 @@
package Common.Utils;
import com.google.gson.annotations.Expose;
public class IntegerPairJson {
@Expose
public int key;
@Expose
public int value;
public int getKey() {
return key;
}
public int getValue() {
return value;
}
public IntegerPairJson(int key_in, int value_in) {
key = key_in;
value = value_in;
}
public IntegerPairJson() {
}
}

View File

@@ -62,7 +62,7 @@ public class MassSelectArrays extends SapforModification {
for (ProjectArray array : arrays) { for (ProjectArray array : arrays) {
if ( if (
Global.mainModule.getProject().declaratedArrays.getUI().isObjectVisible(array) && array.isSelectionEnabled()) { Global.mainModule.getProject().declaratedArrays.getUI().isObjectVisible(array) && array.isSelectionEnabled()) {
array.State = new_state; array.setState(new_state);
array.SaveUserState(); array.SaveUserState();
} }
} }

View File

@@ -55,8 +55,6 @@ public class SPF_GetGCovInfo extends SilentSapforPass {
} }
protected void unpack(String packed) throws Exception { protected void unpack(String packed) throws Exception {
GCOVJson allJson = Utils_.gson.fromJson(packed, GCOVJson.class); GCOVJson allJson = Utils_.gson.fromJson(packed, GCOVJson.class);
// System.out.println("packed="+ Utils_.Brackets(packed));
// System.out.println(allJson.allGCov.size());
for (FileGCOVJson fileJson: allJson.allGCov){ for (FileGCOVJson fileJson: allJson.allGCov){
fileJson.file = Utils_.toW(fileJson.file); fileJson.file = Utils_.toW(fileJson.file);
//-- //--
@@ -65,10 +63,9 @@ public class SPF_GetGCovInfo extends SilentSapforPass {
if (lineJson.line > 0) { if (lineJson.line > 0) {
int v_line = lineJson.line - 1; int v_line = lineJson.line - 1;
long v_execution = (lineJson.execution >= 0) ? lineJson.execution : 0; long v_execution = (lineJson.execution >= 0) ? lineJson.execution : 0;
// System.out.println("line="+v_line+"/"+v_execution);
if (!projectFile.gcov_info.line_info.containsKey(v_line)) { if (!projectFile.gcov_info.line_info.containsKey(v_line)) {
projectFile.gcov_info.add_line(v_line, v_execution); projectFile.gcov_info.add_line(v_line, v_execution);
// System.out.println("+");
} }
} }
} }

View File

@@ -15,7 +15,7 @@ public class DBArray extends DBObject {
public DBArray(ProjectArray array) { public DBArray(ProjectArray array) {
UniqKey = array.UniqKey; UniqKey = array.UniqKey;
shortName = array.shortName; shortName = array.shortName;
State = array.State; State = array.getState();
} }
@Override @Override
public Object getPK() { public Object getPK() {

View File

@@ -168,7 +168,7 @@ public class SPFEditor extends BaseEditor implements SPFEditorInterface {
Pair<Long, Integer> p = file.gcov_info.line_info.get(lineNum); Pair<Long, Integer> p = file.gcov_info.line_info.get(lineNum);
Color color = never; Color color = never;
if (p.getKey() > 0) { if (p.getKey() > 0) {
color = (p.getValue() >= Global.mainModule.getProject().sapforProperties.GCOVLimit) ? color = (p.getValue() >= 0) ?
new Color(255, 255, (100 - p.getValue()), 90) : null; new Color(255, 255, (100 - p.getValue()), 90) : null;
} }
if (color != null) { if (color != null) {

View File

@@ -17,7 +17,7 @@ public class DataDirective extends Directive {
maxLen = Math.max(maxLen, a.GetLenString()); maxLen = Math.max(maxLen, a.GetLenString());
LinkedHashMap<String, Vector<String>> toPrint = new LinkedHashMap<>(); LinkedHashMap<String, Vector<String>> toPrint = new LinkedHashMap<>();
for (AlignRule a : alignRules) { for (AlignRule a : alignRules) {
if (Arrays.get(a.alignArray_address).location != ArrayLocation.parameter) { if (Arrays.get(a.alignArray_address).getLocation() != ArrayLocation.parameter) {
Pair<String, String> result = a.GenRule(maxLen); Pair<String, String> result = a.GenRule(maxLen);
if (!toPrint.containsKey(result.getKey())) if (!toPrint.containsKey(result.getKey()))
toPrint.put(result.getKey(), new Vector<>()); toPrint.put(result.getKey(), new Vector<>());
@@ -35,7 +35,7 @@ public class DataDirective extends Directive {
maxLen = Math.max(maxLen, a.GetLenString()); maxLen = Math.max(maxLen, a.GetLenString());
LinkedHashMap<String, Vector<String>> toPrint = new LinkedHashMap<>(); LinkedHashMap<String, Vector<String>> toPrint = new LinkedHashMap<>();
for (AlignRule a : alignRules) { for (AlignRule a : alignRules) {
if (Arrays.get(a.alignArray_address).location != ArrayLocation.parameter) { if (Arrays.get(a.alignArray_address).getLocation() != ArrayLocation.parameter) {
Pair<String, String> result = a.GenRule(maxLen); Pair<String, String> result = a.GenRule(maxLen);
if (!toPrint.containsKey(result.getKey())) if (!toPrint.containsKey(result.getKey()))
toPrint.put(result.getKey(), new Vector<>()); toPrint.put(result.getKey(), new Vector<>());

View File

@@ -1,7 +1,7 @@
package _VisualDVM.ProjectData.SapforData.Arrays; package _VisualDVM.ProjectData.SapforData.Arrays;
import Common.Database.Objects.DBObject; import Common.Database.Objects.DBObject;
import Common.Utils.Index; import Common.Utils.Index;
import Common.Utils.Pair; import Common.Utils.IntegerPairJson;
import Common.Utils.Utils_; import Common.Utils.Utils_;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode; import _VisualDVM.Passes.PassCode;
@@ -13,31 +13,68 @@ import _VisualDVM.ProjectData.SapforData.Arrays.Templates.TemplateDimensionState
import _VisualDVM.ProjectData.SapforData.Arrays.Templates.TemplateLink; import _VisualDVM.ProjectData.SapforData.Arrays.Templates.TemplateLink;
import _VisualDVM.ProjectData.SapforData.Regions.ParallelRegion; import _VisualDVM.ProjectData.SapforData.Regions.ParallelRegion;
import _VisualDVM.ProjectData.SapforData.Regions.UI.ArrayAlignmentBar; import _VisualDVM.ProjectData.SapforData.Regions.UI.ArrayAlignmentBar;
import com.google.gson.annotations.Expose;
import javax.swing.*; import javax.swing.*;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Vector; import java.util.Vector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ProjectArray extends DBObject { public class ProjectArray extends DBObject {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
public static final String[] alignNames = {"i", "j", "k", "l", "m", "n", "q", "r", "s", "t", "u", "w", "x", "y", "z"}; public static final String[] alignNames = {"i", "j", "k", "l", "m", "n", "q", "r", "s", "t", "u", "w", "x", "y", "z"};
public String UniqKey; //json-------------------
public ArrayState State; @Expose
//-----------------------------
public long id; public long id;
@Expose
public String name; public String name;
@Expose
public String shortName; public String shortName;
@Expose
public int dimSize; public int dimSize;
@Expose
public int typeSize; public int typeSize;
public ArrayLocation location; @Expose
int state;
@Expose
int location;
@Expose
public String locName; public String locName;
@Expose
public int isTemplFlag;
@Expose
public int isLoopArrayFlag;
@Expose
Vector<ArrayDecl> declPlaces = new Vector<>();
//--шаблон---
@Expose
List<Integer> deprecateToDist = new Vector<>();
@Expose
List<Integer> mappedDims = new Vector<>();
@Expose
Vector<IntegerPairJson> sizes = new Vector<>();
@Expose
Vector<String> regions = new Vector<>();
// LinkedHashMap<BigInteger, TemplateLink> templateInfo = new LinkedHashMap<>();
//---
public String UniqKey;
public BigInteger address;
//--
public ArrayState getState() {
return ArrayState.fromInt(state);
}
public void setState(ArrayState state_in){
state = state_in.ordinal();
}
public ArrayLocation getLocation() {
return ArrayLocation.fromInt(location);
}
//только для шаблонов. для ФИЛЬТРА управления распределением измерений. //только для шаблонов. для ФИЛЬТРА управления распределением измерений.
public Vector<TemplateDimension> dimensions = new Vector<>(); public Vector<TemplateDimension> dimensions = new Vector<>();
public int isTemplFlag;
public int isLoopArrayFlag;
//----------------------------
public BigInteger address;
//---------------------------- //----------------------------
public ParallelRegion parent_region = null; //родительяская область распараллеливания. public ParallelRegion parent_region = null; //родительяская область распараллеливания.
//связи-> //связи->
@@ -56,43 +93,41 @@ public class ProjectArray extends DBObject {
//------------------------------------------------------------------------------------------------------> //------------------------------------------------------------------------------------------------------>
//<editor-fold desc="Функционал шаблона"> //<editor-fold desc="Функционал шаблона">
public Vector<BigInteger> regIDs = new Vector<>(); public Vector<BigInteger> regIDs = new Vector<>();
Vector<Pair<Integer, Integer>> sizes = new Vector<>();
Vector<Integer> deprecateToDist = new Vector<>();
Vector<Integer> mappedDims = new Vector<>(); //--
LinkedHashMap<BigInteger, TemplateLink> templateInfo = new LinkedHashMap<>();
Vector<ArrayDecl> declPlaces = new Vector<>();
Vector<String> regions = new Vector<>();
public ProjectArray(String[] infoF, Index idx, BigInteger address_in) { public ProjectArray(String[] infoF, Index idx, BigInteger address_in) {
id = Integer.parseInt(infoF[idx.Inc()]); id = Integer.parseInt(infoF[idx.Inc()]); //+
name = infoF[idx.Inc()]; name = infoF[idx.Inc()]; //+
shortName = infoF[idx.Inc()]; shortName = infoF[idx.Inc()]; //+
dimSize = Integer.parseInt(infoF[idx.Inc()]); dimSize = Integer.parseInt(infoF[idx.Inc()]); //+
typeSize = Integer.parseInt(infoF[idx.Inc()]); typeSize = Integer.parseInt(infoF[idx.Inc()]); //+
address = address_in; // address = address_in;
State = ArrayState.fromInt(Integer.parseInt(infoF[idx.Inc()])); state = Integer.parseInt(infoF[idx.Inc()]); //+
location = ArrayLocation.fromInt(Integer.parseInt(infoF[idx.Inc()])); location = Integer.parseInt(infoF[idx.Inc()]); //+
locName = infoF[idx.Inc()]; locName = infoF[idx.Inc()]; //+
int sizes_size = Integer.parseInt(infoF[idx.Inc()]); int sizes_size = Integer.parseInt(infoF[idx.Inc()]);
for (int i = 0; i < sizes_size; ++i) { for (int i = 0; i < sizes_size; ++i) {
int first = Integer.parseInt(infoF[idx.Inc()]); int first = Integer.parseInt(infoF[idx.Inc()]);
int second = Integer.parseInt(infoF[idx.Inc()]); int second = Integer.parseInt(infoF[idx.Inc()]);
sizes.add(new Pair<>(first, second)); sizes.add(new IntegerPairJson(first, second)); //+
} }
sizes_size = Integer.parseInt(infoF[idx.Inc()]); sizes_size = Integer.parseInt(infoF[idx.Inc()]);
for (int i = 0; i < sizes_size; ++i) for (int i = 0; i < sizes_size; ++i)
deprecateToDist.add(Integer.parseInt(infoF[idx.Inc()])); deprecateToDist.add(Integer.parseInt(infoF[idx.Inc()])); //+
sizes_size = Integer.parseInt(infoF[idx.Inc()]); sizes_size = Integer.parseInt(infoF[idx.Inc()]);
for (int i = 0; i < sizes_size; ++i) for (int i = 0; i < sizes_size; ++i)
mappedDims.add(Integer.parseInt(infoF[idx.Inc()])); mappedDims.add(Integer.parseInt(infoF[idx.Inc()])); //+
int templateInfo_size = Integer.parseInt(infoF[idx.Inc()]); int templateInfo_size = Integer.parseInt(infoF[idx.Inc()]);
for (int i = 0; i < templateInfo_size; ++i) { for (int i = 0; i < templateInfo_size; ++i) {
BigInteger key = new BigInteger(infoF[idx.Inc()]); BigInteger key = new BigInteger(infoF[idx.Inc()]);
TemplateLink templateLink = new TemplateLink(infoF, idx); TemplateLink templateLink = new TemplateLink(infoF, idx);
templateInfo.put(key, templateLink); // templateInfo.put(key, templateLink);
} }
String[] localSplited = infoF[idx.Inc()].split("\\|"); String[] localSplited = infoF[idx.Inc()].split("\\|");
isTemplFlag = Integer.parseInt(localSplited[0]); isTemplFlag = Integer.parseInt(localSplited[0]); //+
isLoopArrayFlag = Integer.parseInt(localSplited[1]); isLoopArrayFlag = Integer.parseInt(localSplited[1]); //+
int numDeclPlaces = Integer.parseInt(localSplited[2]); int numDeclPlaces = Integer.parseInt(localSplited[2]);
int idxPl = 3; int idxPl = 3;
for (int i = 0; i < numDeclPlaces; ++i, idxPl += 2) { for (int i = 0; i < numDeclPlaces; ++i, idxPl += 2) {
@@ -100,15 +135,18 @@ public class ProjectArray extends DBObject {
DBProjectFile file = Global.mainModule.getProject().db.files.Data.get(declFile); DBProjectFile file = Global.mainModule.getProject().db.files.Data.get(declFile);
int declLine = Integer.parseInt(localSplited[idxPl + 1]); int declLine = Integer.parseInt(localSplited[idxPl + 1]);
//declPlaces.add(new Pair<>(declFile, declLine)); //declPlaces.add(new Pair<>(declFile, declLine));
ArrayDecl decl = new ArrayDecl(shortName, location, file, declLine); ArrayDecl decl = new ArrayDecl(shortName, getLocation(), file, declLine);
declPlaces.add(decl); declPlaces.add(decl);
file.array_decls.add(decl); //-- file.array_decls.add(decl); //++
} }
int numRegs = Integer.parseInt(localSplited[idxPl++]); int numRegs = Integer.parseInt(localSplited[idxPl++]);
for (int i = 0; i < numRegs; ++i) for (int i = 0; i < numRegs; ++i)
regions.add(localSplited[idxPl++]); regions.add(localSplited[idxPl++]); //++
UniqKey = shortName + locName + dimSize; Init();
}
public void Init(){
//короткое имя+ функция/модуль/комон+ размерность //короткое имя+ функция/модуль/комон+ размерность
UniqKey = shortName + locName + dimSize;
} }
public static String fill_binary(int d, String binary) { public static String fill_binary(int d, String binary) {
int delta = Math.abs(binary.length() - d); int delta = Math.abs(binary.length() - d);
@@ -150,12 +188,12 @@ public class ProjectArray extends DBObject {
return (isLoopArrayFlag == 0) ? ((isTemplFlag == 0) ? "МАССИВ" : "ШАБЛОН") : "ЦИКЛ"; return (isLoopArrayFlag == 0) ? ((isTemplFlag == 0) ? "МАССИВ" : "ШАБЛОН") : "ЦИКЛ";
} }
public String state_symbol() { public String state_symbol() {
return State == ArrayState.Selected ? "" : ""; return getState() == ArrayState.Selected ? "" : "";
} }
@Override @Override
public String toString() { public String toString() {
return id + " " + state_symbol() + " " + return id + " " + state_symbol() + " " +
State + " " + getState() + " " +
shortName + " " + shortName + " " +
locName + " : " + location + " " + dimSize + " " + typeSize; locName + " : " + location + " " + dimSize + " " + typeSize;
} }
@@ -339,7 +377,7 @@ public class ProjectArray extends DBObject {
public void SaveUserState() throws Exception { public void SaveUserState() throws Exception {
if (Global.mainModule.getProject().db.savedArrays.Data.containsKey(UniqKey)) { if (Global.mainModule.getProject().db.savedArrays.Data.containsKey(UniqKey)) {
DBArray sa = Global.mainModule.getProject().db.savedArrays.Data.get(UniqKey); DBArray sa = Global.mainModule.getProject().db.savedArrays.Data.get(UniqKey);
sa.State = State; sa.State = getState();
Global.mainModule.getProject().db.Update(sa); Global.mainModule.getProject().db.Update(sa);
} else } else
Global.mainModule.getProject().db.Insert(new DBArray(this)); Global.mainModule.getProject().db.Insert(new DBArray(this));
@@ -347,11 +385,11 @@ public class ProjectArray extends DBObject {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override @Override
public boolean isSelectionEnabled() { public boolean isSelectionEnabled() {
return (State == ArrayState.Selected) || (State == ArrayState.None); return (getState() == ArrayState.Selected) || (getState() == ArrayState.None);
} }
@Override @Override
public ImageIcon GetDisabledIcon() { public ImageIcon GetDisabledIcon() {
return Utils_.getIcon("/icons/Arrays/" + State.toString() + ".png"); return Utils_.getIcon("/icons/Arrays/" +getState().toString() + ".png");
} }
@Override @Override
public void select(boolean flag) { public void select(boolean flag) {
@@ -359,7 +397,7 @@ public class ProjectArray extends DBObject {
} }
@Override @Override
public boolean isSelected() { public boolean isSelected() {
return (State == ArrayState.Selected); return (getState() == ArrayState.Selected);
} }
//- //-
public void init_new_ac() { public void init_new_ac() {

View File

@@ -41,7 +41,7 @@ public class ProjectArraysForm extends DataSetControlForm<ProjectArray> {
new ColumnInfo<ProjectArray>("Область описания") { new ColumnInfo<ProjectArray>("Область описания") {
@Override @Override
public Object getFieldAt(ProjectArray object) { public Object getFieldAt(ProjectArray object) {
return object.locName + " : " + object.location; return object.locName + " : " + object.getLocation();
} }
}, },
new ColumnInfo<ProjectArray>("Файлы объявления") { new ColumnInfo<ProjectArray>("Файлы объявления") {
@@ -88,7 +88,7 @@ public class ProjectArraysForm extends DataSetControlForm<ProjectArray> {
return new ColumnInfo<ProjectArray>("") { return new ColumnInfo<ProjectArray>("") {
@Override @Override
public Object getFieldAt(ProjectArray object) { public Object getFieldAt(ProjectArray object) {
return object.State; return object.getState();
} }
@Override @Override
public int getMinWidth() { public int getMinWidth() {
@@ -113,7 +113,7 @@ public class ProjectArraysForm extends DataSetControlForm<ProjectArray> {
if (super.isObjectVisible(object)) { if (super.isObjectVisible(object)) {
if (object.isTemplFlag > 0) return true; if (object.isTemplFlag > 0) return true;
return object.shortName.startsWith(filterName) && return object.shortName.startsWith(filterName) &&
object.location.toString().startsWith(filterLocation) && object.getLocation().toString().startsWith(filterLocation) &&
object.locName.startsWith(filterLocationName) && object.locName.startsWith(filterLocationName) &&
object.has_decl_place(filterFile) && object.has_decl_place(filterFile) &&
object.has_region(filterRegion); object.has_region(filterRegion);