Commit 67a992a2 authored by Dr. Michael Petter's avatar Dr. Michael Petter

init

parents
Pipeline #1206 failed with stages
in 1 second
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/commons-cli-1.0.jar"/>
<classpathentry kind="lib" path="lib/jgraph.jar"/>
<classpathentry kind="lib" path="lib/jgrapht-0.5.3.jar"/>
<classpathentry kind="lib" path="lib/cfgstructure.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Analysator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<project name="PolyInvar" default ="shared" basedir=".">
<property name="lib" location="lib" />
<property name="src" location="src" />
<property name="classes" location="bin" />
<property name="dist" location="dist"/>
<property name="etc" location="etc" />
<property name="images" location="images" />
<property name="tools" location="tools" />
<property name="plugins" location="/opt/eclipse-2.1.2/plugins" />
<property name="java" location="java"/>
<property name="jflex" location="jflex"/>
<property name="docs" location="docs"/>
<property environment="env" />
<path id="sources">
<fileset dir="${src}">
<include name="**/**.java" />
</fileset>
</path>
<path id="libraries">
<pathelement location="${classes}" />
<pathelement location="${lib}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
<!-- here, we include all necessary libraries -->
<!--fileset dir="${plugins}">
<include name="**/*.jar" />
</fileset-->
<pathelement path="${java.class.path}" />
</path>
<path id="tools">
<fileset dir="${tools}">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
<pathelement path="${java.class.path}" />
</path>
<!-- taskdef JFlex -->
<taskdef name="jflex"
classname="JFlex.anttask.JFlexTask"
classpathref="tools"
/>
<!-- initialize the workspace -->
<target name="init">
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${etc}" />
<mkdir dir="${java}" />
<mkdir dir="${docs}" />
</target>
<!-- deletes all build-related directories -->
<target name="clean">
<delete dir="${classes}" />
<delete dir="${dist}" />
<delete dir="${etc}" />
<delete dir="${java}" />
<delete dir="${docs}" />
</target>
<target name="copygen" depends="init">
<!--jflex file="${jflex}/ReverseSymtab.jflex" destdir="${java}"/>
<jflex file="${jflex}/StraightSymtab.jflex" destdir="${java}" /-->
<!--jflex file="${jflex}/Expression2Text.jflex" destdir="${java}" /-->
<copy todir="${java}"><fileset dir="${src}"/></copy>
</target>
<!-- Compiles the generated .java files to the classes directory -->
<target name="classes" depends="copygen">
<depend srcdir="${java}" destdir="${classes}" cache="${etc}" />
<javac srcdir="${java}" destdir="${classes}" verbose="off" listfiles="off"
source="1.5" target="1.5" debug="on">
<!--compilerarg value="-Xlint:unchecked" /-->
<classpath refid="libraries"/>
</javac>
</target>
<!-- Packs the runnable classes into single .jar files -->
<target name="shared" depends="classes">
<copy todir="${classes}/images"><fileset dir="${images}"/></copy>
<jar jarfile="${dist}/gui.jar" basedir="${classes}" includes="de/tum/in/wwwseidl/polyinvar/gui/**,images/**">
<manifest>
<attribute name="Main-Class" value="de.tum.in.wwwseidl.polyinvar.gui.GUI" />
<attribute name="Class-Path" value="fixpointiteration.jar cfgstructure.jar intrapoly.jar commons-cli-1.0.jar Compiler.jar" />
</manifest>
</jar>
<jar jarfile="${dist}/fixpointiteration.jar" basedir="${classes}" includes="de/tum/in/wwwseidl/polyinvar/messages/**,de/tum/in/wwwseidl/polyinvar/iterator/**" />
<copy todir="${dist}"><fileset dir="${lib}"></fileset></copy>
<!--signjar jar="${dist}/${ant.project.name}-static-${DSTAMP}.jar" alias="petter" keypass="hashen" storepass="hashen"/-->
</target>
<!-- Generates the API Documentation -->
<target name="javadoc">
<javadoc packagenames="de.tum.in.wwwseidl.polyinvar.iterator.*"
sourcepath="${src}" destdir="${docs}" windowtitle="Fixpoint Iteration API"
use="true" classpathref="libraries" linksource="yes">
<!--taglet name="ru.k2s.sam.gdk.taglet.ExampleTaglet"><path refid="tools" /></taglet-->
<doctitle><![CDATA[<h1>Fixpoint Iteration API</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright &#169; 2005 Michael Petter and Andrea
Flexeder, Chair Seidl, TU M&uuml;nchen. All Rights
Reserved.</i>]]></bottom>
<link href="http://java.sun.com/j2se/1.5.0/docs/api" />
<link href="../../cfgstructure/docs" />
</javadoc>
<copy file="${tools}/stylesheet.css" overwrite="true" todir="${docs}" />
</target>
<target name="run" depends="shared">
<java classname="de.tum.in.wwwseidl.polyinvar.gui.GUI" fork="true">
<classpath refid="libraries" />
<jvmarg value="-Dcom.sun.management.jmxremote"/>
<!--jvmarg value="-Dcom.sun.management.jmxremote"/-->
<!--assertions><enable /></assertions-->
</java>
</target>
<target name="debug" depends="shared">
<java classname="de.tum.in.wwwseidl.polyinvar.gui.GUI" fork="true">
<classpath refid="libraries" />
<jvmarg value="-Dcom.sun.management.jmxremote"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=y"/>
<assertions><enable /></assertions>
</java>
</target>
<!-- build the whole project -->
<target name="all" depends="clean,shared" />
</project>
package de.tum.in.wwwseidl.polyinvar.gui;
import de.tum.in.wwwseidl.programanalysis.cfg.SymbolTable;
import java.io.StringReader;
import java.io.IOException;
%%
%class Expression2Text
%public
%unicode
%standalone
%type String
%eofval{
return "";
%eofval}
%{
private SymbolTable symtab;
public Expression2Text(String input, SymbolTable symtab){
this.symtab = symtab;
this.yy_reader = new StringReader(input);
}
public static String convertToText(String input, SymbolTable symtab){
StringBuffer sb = new StringBuffer();
Expression2Text ss = new Expression2Text(input,symtab);
try {
while (!ss.yy_atEOF) {
String s = ss.yylex();
if (s==null) return null;
sb.append(s);
}
}catch (IOException ioe) {};
return sb.toString();
}
%}
%%
"(Variable: #" [0-9]+ ")" {
String text = yytext();
return symtab.getName(Integer.parseInt(text.substring(12,text.length()-1)));
}
.|\n { return yytext(); }
(require 'bs)
(global-set-key [C-tab] 'bs-cycle-next)
(global-set-key [C-M-tab] 'bs-cycle-previous)
package de.tum.in.wwwseidl.polyinvar.gui;
// File I/O
import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.net.URLClassLoader;
import java.net.URL;
import java.io.IOException;
import java.util.Properties;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.FileReader;
// Collection classes
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
import java.util.Map;
// Swing UI
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.Cursor;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.Graphics;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JToggleButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextPane;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.border.EtchedBorder;
import javax.swing.filechooser.FileFilter;
import javax.swing.JTabbedPane;
import javax.swing.text.*;
import javax.swing.plaf.basic.BasicTextPaneUI;
// generic mother of all fixpoint iterations covered here...
import de.tum.in.wwwseidl.polyinvar.iterator.FixpointIteration;
import de.tum.in.wwwseidl.polyinvar.iterator.FixpointIteration.Command;
// the components of a CFG to be displayed graphically
import de.tum.in.wwwseidl.programanalysis.cfg.CFGClass;
import de.tum.in.wwwseidl.programanalysis.cfg.Analyzable;
import de.tum.in.wwwseidl.programanalysis.cfg.SymbolTable;
import de.tum.in.wwwseidl.programanalysis.cfg.CFGMethode;
import de.tum.in.wwwseidl.programanalysis.cfg.CFGState;
import de.tum.in.wwwseidl.programanalysis.cfg.edges.CFGEdge;
// Reading CFGs from simplec Files directly
import de.tum.in.wwwseidl.invar.simplec.Compiler;
// apaches handling of Command Line Interface
import org.apache.commons.cli.*;
// Reflection
import java.lang.reflect.Method;
import java.lang.reflect.Array;
import de.tum.in.wwwseidl.polyinvar.gui.graphlayout.GraphLayout;
import de.tum.in.wwwseidl.polyinvar.gui.graphlayout.DotLayout;
import static de.tum.in.wwwseidl.invar.simplec.sym.*;
import de.tum.in.wwwseidl.invar.simplec.Lexer;
import de.tum.in.wwwseidl.invar.utils.AnnotatingSymbolFactory.ExtendedLocation;
public class GUI extends JApplet{
public static final String VERSION = "v0.1.0alpha";
private static final int width = 1024;
private static final int height= 768;
private CFGMethode methode;
private CFGClass myClass;
private Properties props = new Properties();
private final int nlast = 4;
private JMenuItem last [] = new JMenuItem[nlast];
private FixpointIteration remoteControl;
private RemoteControl rc;
private Map<CFGMethode,GraphPanel> meth2GP = new HashMap<CFGMethode,GraphPanel>();
//display useful infos about calculations
private JPanel worksetinformation= new JPanel(); // display information about worksets
private long stepnumber=0;
private JPanel detailedinfo = new JPanel(); // display information about selected program points
private JTextArea messages = new JTextArea("Welcome to Java Analysator Version "+VERSION+"\n");
private JLabel progpointid;
private JTabbedPane tabpanel;
private JPanel sourcepanel;
private JTextPane sourceEditor;
private JTabbedPane centerpanel; // here we store the graphs
private JPanel infopanel= new JPanel();
private JFrame frame; // frame, to control size and so on
private JProgressBar working;
private AbstractAction nextAction;
private AbstractAction ffAction;
private AbstractAction pauseAction;
private AbstractAction immediateAction;
private long actualSelected;
private boolean fastforward = false;
private boolean rununbounded = false;
private class OpenAction extends AbstractAction{
private String filename;
public OpenAction(String filename){
super((new File(filename)).getName(),new ImageIcon(GUI.class.getResource("/images/cfg.png")));
this.filename = filename;
putValue(Action.SHORT_DESCRIPTION,"opens "+filename);
}
public void actionPerformed(ActionEvent ae){
reset(new File(filename));
}
}
public GUI(JFrame frame) {
super();
this.frame=frame;
}
private File loadFile(final String extension, final String description){
String [] ex = new String[1]; ex[0]=extension;
String [] de = new String[1]; de[0]=description;
return loadFile(ex,de);
}
private File loadFile(final String [] extension,final String [] description){
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new FileFilter(){
public boolean accept(File f) {
if (f.isDirectory()) return true;
for (int i = 0; i < extension.length; i++)
if (f.getName().toLowerCase().endsWith(extension[i])) return true;
return false;
}
public String getDescription(){
String d = "";
for (int i = 0; i < description.length; i++)
d+=description[i]+" ";
return d;
}
});
chooser.showOpenDialog(null);
return chooser.getSelectedFile();
}
private File validFile(File f){
if ((f!=null)&&(f.exists())&&(f.isFile())) return f;
f = loadFile(new String[]{".cfg",".c"},new String[]{"Control Flow Graphs (*.cfg)","Simple C Code (*.c)"});
if (!f.getAbsolutePath().equals(props.getProperty("last1"))){
adjustLast(4,props.getProperty("last3"));
adjustLast(3,props.getProperty("last2"));
adjustLast(2,props.getProperty("last1"));
adjustLast(1,f.getAbsolutePath());
}
return f;
}
private CFGClass loadCFG(File f){
CFGClass c = null;
if (f.getName().endsWith(".c"))
try {
c = Compiler.parse(f);
}catch(Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null,e+"\nFile not opened","Error in C File",JOptionPane.ERROR_MESSAGE);
return null;
}
else {
ObjectInputStream ois;
try {
ois = new ObjectInputStream(new FileInputStream(f));
c = (CFGClass)ois.readObject();
} catch (Exception e) {e.printStackTrace();}
}
return c;
}
private void adjustLast(int i, String s){
if (s == null) return;
props.setProperty("last"+i,s);
if (last[i-1]!=null) last[i-1].setAction(new OpenAction(s));
}
private void renderWorkset(Object[] workset){
worksetinformation.invalidate();
worksetinformation.removeAll();
worksetinformation.setLayout(new BorderLayout());
worksetinformation.add(new JLabel("steps passed: "+stepnumber+" remaining "+workset.length),BorderLayout.NORTH);
//worksetinformation.add(new JLabel("remaining :"+workset.length),BorderLayout.NORTH);
String [] externalview = new String[workset.length];
for (int i = 0;i<workset.length;i++) externalview[i]=workset[i].toString();
//Expression2Text.convertToText(workset[i].toString(),myClass.getSymTab());
final JList list = new JList(externalview);
// Versuch: Warteliste auslesen
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int index = list.locationToIndex(e.getPoint());
Object o = remoteControl.getQueuedItem(index);
JOptionPane.showMessageDialog(null, o.toString(), "Queued Item # "+index, JOptionPane.INFORMATION_MESSAGE);
}
}
};
list.addMouseListener(mouseListener);
// Warteliste auslesen
list.setSelectedIndex(0);
worksetinformation.add(list,BorderLayout.CENTER);
working.setMaximum((int)(workset.length+stepnumber));
working.setValue((int)stepnumber);
worksetinformation.revalidate();
// Button controlling