Commit cb32ce27 authored by Edoardo Putti's avatar Edoardo Putti Committed by Mart Lubbers

clean some trash formatting in runnner

parent 1377da8a
......@@ -19,22 +19,19 @@ import javax.swing.UIManager;
import nl.uu.cs.ssm.Config;
public class Runner extends Thread
{
public class Runner extends Thread {
protected int delay = 50 ;
SSMRunner ssmRunner ;
public Runner(int delay)
{
SSMRunner ssmRunner;
public Runner(int delay) {
this.delay = delay;
try {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
System.out.println("Could not set GUI appearance from system");
}
ssmRunner = new SSMRunner( this );
ssmRunner = new SSMRunner(this);
ssmRunner.initComponents();
ssmRunner.setVisible(true);
ssmRunner.requestFocus() ;
......@@ -66,13 +63,11 @@ public class Runner extends Thread
System.exit(1);
}
public void run()
{
while( true )
{
public void run() {
while (true) {
int steppingState = ssmRunner.steppingState() ;
if ( steppingState != SSMRunner.STEP_BY_STEP )
{
// handle emulation direction
if (steppingState != SSMRunner.STEP_BY_STEP) {
if ( ssmRunner.hasBreakpointAtPC() )
ssmRunner.stopContinuouslyDoingSteps() ;
else if ( steppingState == SSMRunner.STEP_CONT_FORWARD )
......@@ -80,17 +75,22 @@ public class Runner extends Thread
else if ( steppingState == SSMRunner.STEP_CONT_BACKWARD )
ssmRunner.doAStepBack() ;
}
try { sleep( delay ) ; } catch ( InterruptedException e ) {}
// try to wait for the delay
try {
sleep(delay);
} catch ( InterruptedException e ) {
System.err.println("-- woke up too early");
}
}
}
// Main entry point
static public void main(String[] args) throws IOException {
File initialFile = null;
long steps = -1;
boolean stdin = false;
boolean cli = false;
int guiDelay =50;
int guiDelay = 50;
for (int i = 0; i< args.length; i++) {
String key = args[i];
switch(key) {
......@@ -106,15 +106,15 @@ public class Runner extends Thread
steps = Long.parseLong(args[i]);
break;
case "--stdin":
if(initialFile != null) {
System.out.println("--stdin cannot be used with --file");
stdin = true;
if (initialFile != null) {
System.err.println("--stdin cannot be used with --file");
usage();
}
stdin=true;
break;
case "--file":
if(stdin) {
System.out.println("--file cannot be used with --stdin");
if (stdin) {
System.err.println("--file cannot be used with --stdin");
usage();
} else {
i++;
......@@ -133,20 +133,20 @@ public class Runner extends Thread
}
}
if(initialFile != null && !initialFile.exists()) {
System.out.println("Input file does not exist");
if (initialFile != null && !initialFile.exists()) {
System.err.println("No input file" + initialFile);
usage();
}
if(cli) {
CliRunner cliRunner = new CliRunner( steps);
if(stdin) {
if (cli) {
CliRunner cliRunner = new CliRunner(steps);
if (stdin) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
cliRunner.load(reader);
reader.close();
} else {
if(!stdin && initialFile == null) {
System.out.println("Need some input in CLI mode");
if (!stdin && initialFile == null) {
System.err.println("Need some input in CLI mode");
}
FileReader fr = new FileReader( initialFile ) ;
cliRunner.load(fr);
......@@ -159,10 +159,9 @@ public class Runner extends Thread
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
r.loadReader(reader);
reader.close();
} else if(initialFile != null) {
} else if (initialFile != null) {
r.loadFile(initialFile);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment