Skip to content

Commit 168bb22

Browse files
committed
Import latest sources and convert to maven
1 parent 18a07dd commit 168bb22

File tree

470 files changed

+42029
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

470 files changed

+42029
-1
lines changed

visualizer/C1Visualizer.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Readme for C1Visualizer
2+
3+
4+
# Developing the C1Visualizer
5+
6+
C1Visualizer is based on Netbeans 26 but can be often be worked on with later releases or with any
7+
IDE that supports Maven. Care must be taken not to commmit anything that would keep it from working
8+
with 26 so any automatic changes to property file updates by later NetBeans versions shouldn't be
9+
pushed. The packaged product is built by:
10+
```
11+
cd C1Visualizer
12+
mvn package
13+
```
14+
15+
# Regenerating the cfg file parser
16+
17+
The cfg file parser is based on CoCo/R which hasn't been updated since 2018 and doesn't support
18+
large files. For simplicity, it has been checked in and some bugs with handling of large files were
19+
fixed. It can be regenerated by getting Coco.jar from https://ssw.jku.at/Research/Projects/Coco and
20+
running the following command line. Note that still will overwrite any locals fixes but this should
21+
never be necessary.
22+
23+
```
24+
java -jar Coco.jar -o CompilationModel/src/main/java/at/ssw/visualizer/parser \
25+
-package at.ssw.visualizer.parser CompilationModel/src/main/java/at/ssw/visualizer/parser/CompilerOutput.atg
26+
```
27+
28+
# Releasing a new version
29+
30+
As this is now maven based, `mvn -B release:prepare` is used to update to new versions which will automatically bump the module versions.
31+
32+
The resulting zip file will be in `C1Visualizer/application/target`.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<artifactId>C1Visualizer-parent</artifactId>
5+
<groupId>at.ssw.visualizer</groupId>
6+
<version>1.13-SNAPSHOT</version>
7+
</parent>
8+
<groupId>at.ssw.visualizer</groupId>
9+
<artifactId>BlockView</artifactId>
10+
<version>1.13-SNAPSHOT</version>
11+
<packaging>nbm</packaging>
12+
<name>BlockView</name>
13+
<properties>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
<dependencies>
17+
<dependency>
18+
<groupId>at.ssw.visualizer</groupId>
19+
<artifactId>VisualizerUI</artifactId>
20+
<version>${project.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>at.ssw.visualizer</groupId>
24+
<artifactId>CompilationModel</artifactId>
25+
<version>${project.version}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.netbeans.api</groupId>
29+
<artifactId>org-openide-explorer</artifactId>
30+
<version>${netbeans.version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.netbeans.api</groupId>
34+
<artifactId>org-openide-loaders</artifactId>
35+
<version>${netbeans.version}</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.netbeans.api</groupId>
39+
<artifactId>org-openide-nodes</artifactId>
40+
<version>${netbeans.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.netbeans.api</groupId>
44+
<artifactId>org-openide-util</artifactId>
45+
<version>${netbeans.version}</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.netbeans.api</groupId>
49+
<artifactId>org-openide-util-lookup</artifactId>
50+
<version>${netbeans.version}</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.netbeans.api</groupId>
54+
<artifactId>org-openide-windows</artifactId>
55+
<version>${netbeans.version}</version>
56+
</dependency>
57+
</dependencies>
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.apache.netbeans.utilities</groupId>
62+
<artifactId>nbm-maven-plugin</artifactId>
63+
<version>${nbmmvnplugin.version}</version>
64+
<extensions>true</extensions>
65+
<configuration>
66+
<publicPackages>
67+
<publicPackage>at.ssw.visualizer.BlockView</publicPackage>
68+
</publicPackages>
69+
</configuration>
70+
</plugin>
71+
<plugin>
72+
<groupId>org.apache.maven.plugins</groupId>
73+
<artifactId>maven-compiler-plugin</artifactId>
74+
<version>${mvncompilerplugin.version}</version>
75+
<configuration>
76+
<source>1.8</source>
77+
<target>1.8</target>
78+
</configuration>
79+
</plugin>
80+
<plugin>
81+
<groupId>org.apache.maven.plugins</groupId>
82+
<artifactId>maven-jar-plugin</artifactId>
83+
<version>${mvnjarplugin.version}</version>
84+
<configuration>
85+
<!-- to have the jar plugin pickup the nbm generated manifest -->
86+
<archive>
87+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
88+
</archive>
89+
</configuration>
90+
</plugin>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-enforcer-plugin</artifactId>
94+
</plugin>
95+
</plugins>
96+
</build>
97+
</project>
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package at.ssw.visualizer.block.view;
24+
25+
import at.ssw.visualizer.model.cfg.BasicBlock;
26+
import at.ssw.visualizer.model.cfg.ControlFlowGraph;
27+
import java.util.Collections;
28+
import java.util.List;
29+
import javax.swing.table.AbstractTableModel;
30+
31+
/**
32+
* TableModel containing the blocks of the currently selected view
33+
*
34+
* @author Bernhard Stiftner
35+
* @author Christian Wimmer
36+
*/
37+
public class BlockTableModel extends AbstractTableModel {
38+
39+
public static final int BLOCK_TABLE_NAME_COL_IDX = 0;
40+
public static final int BLOCK_TABLE_BCI_COL_IDX = 1;
41+
public static final int BLOCK_TABLE_FLAGS_COL_IDX = 2;
42+
public static final int BLOCK_TABLE_LOOP_DEPTH_COL_IDX = 3;
43+
public static final int BLOCK_TABLE_LOOP_INDEX_COL_IDX = 4;
44+
public static final int BLOCK_TABLE_DOMINATOR_COL_IDX = 5;
45+
public static final int BLOCK_TABLE_PREDECESSORS_COL_IDX = 6;
46+
public static final int BLOCK_TABLE_SUCCESSORS_COL_IDX = 7;
47+
public static final int BLOCK_TABLE_XHANDLERS_COL_IDX = 8;
48+
public static final int BLOCK_TABLE_PROBABILITY_COL_IDX = 9;
49+
50+
public static final String[] COLUMN_NAMES = new String[]{"Name", "BCI", "Flags", "Loop Depth", "Loop Index", "Dominator", "Predecessors", "Successors", "XHandlers", "Probability"};
51+
public static final int[] COLUMN_WIDTHS = new int[]{60, 60, 60, 80, 80, 60, 120, 120, 120};
52+
53+
private List<BasicBlock> blocks = Collections.emptyList();
54+
55+
public void setControlFlowGraph(ControlFlowGraph cfg) {
56+
if (cfg == null) {
57+
blocks = Collections.emptyList();
58+
} else {
59+
blocks = cfg.getBasicBlocks();
60+
}
61+
fireTableDataChanged();
62+
}
63+
64+
public int getRowCount() {
65+
return blocks.size();
66+
}
67+
68+
public int getColumnCount() {
69+
return COLUMN_NAMES.length;
70+
}
71+
72+
@Override
73+
public String getColumnName(int column) {
74+
return COLUMN_NAMES[column];
75+
}
76+
77+
public Object getValueAt(int row, int column) {
78+
BasicBlock block = blocks.get(row);
79+
switch (column) {
80+
case BLOCK_TABLE_NAME_COL_IDX:
81+
return block.getName();
82+
case BLOCK_TABLE_BCI_COL_IDX:
83+
return "[" + block.getFromBci() + ", " + block.getToBci() + "]";
84+
case BLOCK_TABLE_FLAGS_COL_IDX:
85+
return formatFlags(block.getFlags());
86+
case BLOCK_TABLE_LOOP_DEPTH_COL_IDX:
87+
return Integer.toString(block.getLoopDepth());
88+
case BLOCK_TABLE_LOOP_INDEX_COL_IDX:
89+
return block.getLoopDepth() > 0 ? Integer.toString(block.getLoopIndex()) : "";
90+
case BLOCK_TABLE_DOMINATOR_COL_IDX:
91+
return block.getDominator() != null ? block.getDominator().getName() : "";
92+
case BLOCK_TABLE_PREDECESSORS_COL_IDX:
93+
return formatBlocks(block.getPredecessors());
94+
case BLOCK_TABLE_SUCCESSORS_COL_IDX:
95+
return formatBlocks(block.getSuccessors());
96+
case BLOCK_TABLE_XHANDLERS_COL_IDX:
97+
return formatBlocks(block.getXhandlers());
98+
case BLOCK_TABLE_PROBABILITY_COL_IDX:
99+
return Double.isNaN(block.getProbability()) ? "" : (Double)block.getProbability();
100+
default:
101+
throw new Error("invalid column");
102+
}
103+
}
104+
105+
@Override
106+
public Class<?> getColumnClass(int columnIndex) {
107+
if (blocks.isEmpty()) {
108+
return Object.class;
109+
}
110+
return getValueAt(0, columnIndex).getClass();
111+
}
112+
113+
private String formatFlags(List<String> flags) {
114+
StringBuilder sb = new StringBuilder();
115+
String prefix = "";
116+
for (String flag : flags) {
117+
sb.append(prefix).append(flag);
118+
prefix = ", ";
119+
}
120+
return sb.toString();
121+
}
122+
123+
private String formatBlocks(List<BasicBlock> blocks) {
124+
StringBuilder sb = new StringBuilder();
125+
String prefix = "";
126+
for (BasicBlock block : blocks) {
127+
sb.append(prefix).append(block.getName());
128+
prefix = ", ";
129+
}
130+
return sb.toString();
131+
}
132+
}

0 commit comments

Comments
 (0)