Массивы в json
This commit is contained in:
20
src/Common/Utils/IntegerPairJson.java
Normal file
20
src/Common/Utils/IntegerPairJson.java
Normal 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() {
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class MassSelectArrays extends SapforModification {
|
||||
for (ProjectArray array : arrays) {
|
||||
if (
|
||||
Global.mainModule.getProject().declaratedArrays.getUI().isObjectVisible(array) && array.isSelectionEnabled()) {
|
||||
array.State = new_state;
|
||||
array.setState(new_state);
|
||||
array.SaveUserState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,6 @@ public class SPF_GetGCovInfo extends SilentSapforPass {
|
||||
}
|
||||
protected void unpack(String packed) throws Exception {
|
||||
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){
|
||||
fileJson.file = Utils_.toW(fileJson.file);
|
||||
//--
|
||||
@@ -65,10 +63,9 @@ public class SPF_GetGCovInfo extends SilentSapforPass {
|
||||
if (lineJson.line > 0) {
|
||||
int v_line = lineJson.line - 1;
|
||||
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)) {
|
||||
projectFile.gcov_info.add_line(v_line, v_execution);
|
||||
// System.out.println("+");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class DBArray extends DBObject {
|
||||
public DBArray(ProjectArray array) {
|
||||
UniqKey = array.UniqKey;
|
||||
shortName = array.shortName;
|
||||
State = array.State;
|
||||
State = array.getState();
|
||||
}
|
||||
@Override
|
||||
public Object getPK() {
|
||||
|
||||
@@ -168,7 +168,7 @@ public class SPFEditor extends BaseEditor implements SPFEditorInterface {
|
||||
Pair<Long, Integer> p = file.gcov_info.line_info.get(lineNum);
|
||||
Color color = never;
|
||||
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;
|
||||
}
|
||||
if (color != null) {
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DataDirective extends Directive {
|
||||
maxLen = Math.max(maxLen, a.GetLenString());
|
||||
LinkedHashMap<String, Vector<String>> toPrint = new LinkedHashMap<>();
|
||||
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);
|
||||
if (!toPrint.containsKey(result.getKey()))
|
||||
toPrint.put(result.getKey(), new Vector<>());
|
||||
@@ -35,7 +35,7 @@ public class DataDirective extends Directive {
|
||||
maxLen = Math.max(maxLen, a.GetLenString());
|
||||
LinkedHashMap<String, Vector<String>> toPrint = new LinkedHashMap<>();
|
||||
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);
|
||||
if (!toPrint.containsKey(result.getKey()))
|
||||
toPrint.put(result.getKey(), new Vector<>());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package _VisualDVM.ProjectData.SapforData.Arrays;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Utils.Index;
|
||||
import Common.Utils.Pair;
|
||||
import Common.Utils.IntegerPairJson;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Global;
|
||||
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.Regions.ParallelRegion;
|
||||
import _VisualDVM.ProjectData.SapforData.Regions.UI.ArrayAlignmentBar;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.math.BigInteger;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import java.util.stream.Collectors;
|
||||
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 String UniqKey;
|
||||
public ArrayState State;
|
||||
//-----------------------------
|
||||
//json-------------------
|
||||
@Expose
|
||||
public long id;
|
||||
@Expose
|
||||
public String name;
|
||||
@Expose
|
||||
public String shortName;
|
||||
@Expose
|
||||
public int dimSize;
|
||||
@Expose
|
||||
public int typeSize;
|
||||
public ArrayLocation location;
|
||||
@Expose
|
||||
int state;
|
||||
@Expose
|
||||
int location;
|
||||
@Expose
|
||||
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 int isTemplFlag;
|
||||
public int isLoopArrayFlag;
|
||||
//----------------------------
|
||||
public BigInteger address;
|
||||
//----------------------------
|
||||
public ParallelRegion parent_region = null; //родительяская область распараллеливания.
|
||||
//связи->
|
||||
@@ -56,43 +93,41 @@ public class ProjectArray extends DBObject {
|
||||
//------------------------------------------------------------------------------------------------------>
|
||||
//<editor-fold desc="Функционал шаблона">
|
||||
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) {
|
||||
id = Integer.parseInt(infoF[idx.Inc()]);
|
||||
name = infoF[idx.Inc()];
|
||||
shortName = infoF[idx.Inc()];
|
||||
dimSize = Integer.parseInt(infoF[idx.Inc()]);
|
||||
typeSize = Integer.parseInt(infoF[idx.Inc()]);
|
||||
address = address_in;
|
||||
State = ArrayState.fromInt(Integer.parseInt(infoF[idx.Inc()]));
|
||||
location = ArrayLocation.fromInt(Integer.parseInt(infoF[idx.Inc()]));
|
||||
locName = infoF[idx.Inc()];
|
||||
id = Integer.parseInt(infoF[idx.Inc()]); //+
|
||||
name = infoF[idx.Inc()]; //+
|
||||
shortName = infoF[idx.Inc()]; //+
|
||||
dimSize = Integer.parseInt(infoF[idx.Inc()]); //+
|
||||
typeSize = Integer.parseInt(infoF[idx.Inc()]); //+
|
||||
// address = address_in;
|
||||
state = Integer.parseInt(infoF[idx.Inc()]); //+
|
||||
location = Integer.parseInt(infoF[idx.Inc()]); //+
|
||||
locName = infoF[idx.Inc()]; //+
|
||||
int sizes_size = Integer.parseInt(infoF[idx.Inc()]);
|
||||
for (int i = 0; i < sizes_size; ++i) {
|
||||
int first = 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()]);
|
||||
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()]);
|
||||
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()]);
|
||||
for (int i = 0; i < templateInfo_size; ++i) {
|
||||
BigInteger key = new BigInteger(infoF[idx.Inc()]);
|
||||
TemplateLink templateLink = new TemplateLink(infoF, idx);
|
||||
templateInfo.put(key, templateLink);
|
||||
// templateInfo.put(key, templateLink);
|
||||
}
|
||||
String[] localSplited = infoF[idx.Inc()].split("\\|");
|
||||
isTemplFlag = Integer.parseInt(localSplited[0]);
|
||||
isLoopArrayFlag = Integer.parseInt(localSplited[1]);
|
||||
isTemplFlag = Integer.parseInt(localSplited[0]); //+
|
||||
isLoopArrayFlag = Integer.parseInt(localSplited[1]); //+
|
||||
int numDeclPlaces = Integer.parseInt(localSplited[2]);
|
||||
int idxPl = 3;
|
||||
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);
|
||||
int declLine = Integer.parseInt(localSplited[idxPl + 1]);
|
||||
//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);
|
||||
file.array_decls.add(decl); //--
|
||||
file.array_decls.add(decl); //++
|
||||
}
|
||||
int numRegs = Integer.parseInt(localSplited[idxPl++]);
|
||||
for (int i = 0; i < numRegs; ++i)
|
||||
regions.add(localSplited[idxPl++]);
|
||||
UniqKey = shortName + locName + dimSize;
|
||||
regions.add(localSplited[idxPl++]); //++
|
||||
Init();
|
||||
}
|
||||
public void Init(){
|
||||
//короткое имя+ функция/модуль/комон+ размерность
|
||||
UniqKey = shortName + locName + dimSize;
|
||||
}
|
||||
public static String fill_binary(int d, String binary) {
|
||||
int delta = Math.abs(binary.length() - d);
|
||||
@@ -150,12 +188,12 @@ public class ProjectArray extends DBObject {
|
||||
return (isLoopArrayFlag == 0) ? ((isTemplFlag == 0) ? "МАССИВ" : "ШАБЛОН") : "ЦИКЛ";
|
||||
}
|
||||
public String state_symbol() {
|
||||
return State == ArrayState.Selected ? "☑" : "☐";
|
||||
return getState() == ArrayState.Selected ? "☑" : "☐";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return id + " " + state_symbol() + " " +
|
||||
State + " " +
|
||||
getState() + " " +
|
||||
shortName + " " +
|
||||
locName + " : " + location + " " + dimSize + " " + typeSize;
|
||||
}
|
||||
@@ -339,7 +377,7 @@ public class ProjectArray extends DBObject {
|
||||
public void SaveUserState() throws Exception {
|
||||
if (Global.mainModule.getProject().db.savedArrays.Data.containsKey(UniqKey)) {
|
||||
DBArray sa = Global.mainModule.getProject().db.savedArrays.Data.get(UniqKey);
|
||||
sa.State = State;
|
||||
sa.State = getState();
|
||||
Global.mainModule.getProject().db.Update(sa);
|
||||
} else
|
||||
Global.mainModule.getProject().db.Insert(new DBArray(this));
|
||||
@@ -347,11 +385,11 @@ public class ProjectArray extends DBObject {
|
||||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean isSelectionEnabled() {
|
||||
return (State == ArrayState.Selected) || (State == ArrayState.None);
|
||||
return (getState() == ArrayState.Selected) || (getState() == ArrayState.None);
|
||||
}
|
||||
@Override
|
||||
public ImageIcon GetDisabledIcon() {
|
||||
return Utils_.getIcon("/icons/Arrays/" + State.toString() + ".png");
|
||||
return Utils_.getIcon("/icons/Arrays/" +getState().toString() + ".png");
|
||||
}
|
||||
@Override
|
||||
public void select(boolean flag) {
|
||||
@@ -359,7 +397,7 @@ public class ProjectArray extends DBObject {
|
||||
}
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return (State == ArrayState.Selected);
|
||||
return (getState() == ArrayState.Selected);
|
||||
}
|
||||
//-
|
||||
public void init_new_ac() {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ProjectArraysForm extends DataSetControlForm<ProjectArray> {
|
||||
new ColumnInfo<ProjectArray>("Область описания") {
|
||||
@Override
|
||||
public Object getFieldAt(ProjectArray object) {
|
||||
return object.locName + " : " + object.location;
|
||||
return object.locName + " : " + object.getLocation();
|
||||
}
|
||||
},
|
||||
new ColumnInfo<ProjectArray>("Файлы объявления") {
|
||||
@@ -88,7 +88,7 @@ public class ProjectArraysForm extends DataSetControlForm<ProjectArray> {
|
||||
return new ColumnInfo<ProjectArray>("") {
|
||||
@Override
|
||||
public Object getFieldAt(ProjectArray object) {
|
||||
return object.State;
|
||||
return object.getState();
|
||||
}
|
||||
@Override
|
||||
public int getMinWidth() {
|
||||
@@ -113,7 +113,7 @@ public class ProjectArraysForm extends DataSetControlForm<ProjectArray> {
|
||||
if (super.isObjectVisible(object)) {
|
||||
if (object.isTemplFlag > 0) return true;
|
||||
return object.shortName.startsWith(filterName) &&
|
||||
object.location.toString().startsWith(filterLocation) &&
|
||||
object.getLocation().toString().startsWith(filterLocation) &&
|
||||
object.locName.startsWith(filterLocationName) &&
|
||||
object.has_decl_place(filterFile) &&
|
||||
object.has_region(filterRegion);
|
||||
|
||||
Reference in New Issue
Block a user