Commit 3c94f62c authored by Alfons Laarman's avatar Alfons Laarman

Small refactor

parent b543e6c6
......@@ -37,7 +37,7 @@ public abstract class Action implements LTSminModelFeature {
}
public boolean isLocal(final Proctype proc) {
return true;
return false;
}
@Override
......
......@@ -39,7 +39,7 @@ public class AssertAction extends Action {
return false;
}
}
return super.isLocal(proc);
return true;
}
@Override
......
......@@ -49,7 +49,7 @@ public class AssignAction extends Action {
public boolean isLocal(final Proctype proc) {
if (expr != null && !(new ExprAction(expr)).isLocal(proc))
return false;
return proc.hasVariable(id.getVariable().getName()) && super.isLocal(proc);
return proc.hasVariable(id.getVariable().getName());
}
@Override
......
......@@ -74,7 +74,7 @@ public class ChannelReadAction extends Action implements CompoundExpression {
}
}
}
return super.isLocal(proc);
return true;
}
@Override
......
......@@ -74,7 +74,7 @@ public class ChannelSendAction extends Action implements CompoundExpression {
}
}
}
return super.isLocal(proc);
return true;
}
@Override
......
......@@ -48,7 +48,7 @@ public class ExprAction extends Action {
}
if (null != expr.getSideEffect())
return false;
return super.isLocal(proc);
return true;
}
@Override
......
......@@ -76,7 +76,7 @@ public class PrintAction extends Action implements CompoundExpression {
}
}
}
return super.isLocal(proc);
return true;
}
@Override
......
......@@ -100,14 +100,6 @@ public class ActionTransition extends Transition {
return true;
}
/**
* @see spins.promela.compiler.automaton.Transition#isUseless()
*/
@Override
public boolean isUseless() {
return false;
}
/**
* @see spins.promela.compiler.automaton.Transition#getAction(int)
*/
......
......@@ -42,22 +42,6 @@ public class ElseTransition extends Transition {
return t;
}
/**
* @see spins.promela.compiler.automaton.Transition#isLocal()
*/
@Override
public boolean isLocal() {
return false;
}
/**
* @see spins.promela.compiler.automaton.Transition#isUseless()
*/
@Override
public boolean isUseless() {
return false;
}
/**
* @see spins.promela.compiler.automaton.Transition#getText()
*/
......
......@@ -45,22 +45,6 @@ public class EndTransition extends Transition {
return t;
}
/**
* @see spins.promela.compiler.automaton.Transition#isLocal()
*/
@Override
public boolean isLocal() {
return false;
}
/**
* @see spins.promela.compiler.automaton.Transition#isUseless()
*/
@Override
public boolean isUseless() {
return false;
}
/**
* @see spins.promela.compiler.automaton.Transition#getText()
*/
......
......@@ -16,7 +16,6 @@ package spins.promela.compiler.automaton;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import spins.promela.compiler.Proctype;
import spins.promela.compiler.actions.Action;
......@@ -47,8 +46,6 @@ public abstract class Transition implements ActionContainer {
private final int transId;
private List<String> labels;
private int priority = -1;
protected Transition(final State from, final State to) {
......@@ -80,7 +77,6 @@ public abstract class Transition implements ActionContainer {
this(from, to);
if (t != null) {
this.priority = t.priority;
this.labels = t.labels;
}
}
......@@ -288,7 +284,7 @@ public abstract class Transition implements ActionContainer {
getClass().getSimpleName()).append(" from ").append(
from == null ? "nowhere" : from.getStateId()).append(" to ").append(
to == null ? "nowhere" : to.getStateId()).append(" ").append(
labels == null ? "" : " "+labels).append(getText()).toString();
getText()).toString();
}
public boolean isAlwaysEnabled() {
......@@ -318,16 +314,8 @@ public abstract class Transition implements ActionContainer {
return getFrom().getAutomaton().getProctype();
}
public void setLabels(List<String> labels) {
this.labels = labels;
}
public List<String> getLabels() {
return labels;
}
public int getUnlessPriority() {
return priority ;
public int getUnlessPriority() {
return priority;
}
public void setUnlessPriority(int p) {
......
......@@ -49,6 +49,14 @@ public class UselessTransition extends Transition {
return t;
}
/**
* @see spins.promela.compiler.automaton.Transition#isLocal()
*/
@Override
public boolean isLocal() {
return true;
}
/**
* @see spins.promela.compiler.automaton.Transition#isUseless()
*/
......
......@@ -279,7 +279,7 @@ public class LTSminTreeWalker {
/* Statements are exported in SPIN format with line numbers for traces */
model.addType(STATEMENT_TYPE_NAME);
model.addEdgeLabel(STATEMENT_EDGE_LABEL_NAME, STATEMENT_TYPE_NAME);
for(LTSminTransition t : model.getTransitions()) {
for (LTSminTransition t : model.getTransitions()) {
Action act = (t.getTransition().getActionCount() > 0 ? t.getTransition().getAction(0) : null);
String name = t.getName().split("\t")[1];
int line = null == act ? -1 : act.getToken().beginLine;
......
......@@ -266,7 +266,7 @@ public class LTSminTransition implements LTSminGuardContainer,
public boolean isProgress() {
return begin.isProgress() ||
State.hasLabelPrefix(original.getLabels(), State.LABEL_PROGRESS);
State.hasLabelPrefix(original.getFrom().getLabels(), State.LABEL_PROGRESS);
}
public int getIndex() {
......
......@@ -33,9 +33,8 @@ public class RemoveUselessActions implements GraphOptimizer {
final State next = out.getTo();
for (final Transition t : next.output) {
Transition duplicate = t.duplicateFrom(state);
t.duplicateFrom(state);
//duplicate.changeFrom(state, out);
duplicate.setLabels(next.getLabels());
}
uselessCount++;
......
......@@ -44,7 +44,6 @@ public class StateMerging implements GraphOptimizer {
for (final Action action : out) {
in.addAction(action);
}
in.getFrom().addLabels(state.getLabels());
state.delete();
merged++;
......
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