Commit c6ac338e authored by Ludovic Apvrille's avatar Ludovic Apvrille

Update on tonetwork: resolving bugs on choices

parent 93628118
......@@ -77,6 +77,8 @@ public class TMLSyntaxChecking {
private final String WRONG_PARAMS = "The number of params is not compatible";
private final String DUPLICATE_NAMES = "Two elements have the same name";
private final String INVALID_NB_OF_GUARD = "The number of guards is not equal to the number of next elements";
private final String TOO_MANY_MEMORIES = "Channel is mapped on more than one memory";
private final String INVALID_CHANNEL_PATH = "Channel path is invalid";
private final String INVALID_BUS_PATH = "Bus path is invalid for channel"; // Should be a warning only
......@@ -124,6 +126,8 @@ public class TMLSyntaxChecking {
checkNextActions();
checkChoices();
checkPortName();
//added by minh hiep
......@@ -207,6 +211,21 @@ public class TMLSyntaxChecking {
}
}
public void checkChoices() {
for (TMLTask t : tmlm.getTasks()) {
TMLActivity tactivity = t.getActivityDiagram();
int n = tactivity.nElements();
for (int i = 0; i < n; i++) {
TMLActivityElement elt = tactivity.get(i);
if (elt instanceof TMLChoice) {
if (elt.getNbNext() != ((TMLChoice) elt).getNbGuard()) {
addError(t, elt, elt.getName() + ": " + INVALID_NB_OF_GUARD, TMLError.ERROR_BEHAVIOR);
}
}
}
}
}
public void checkDuplicateNames() {
List<TMLElement> elts;
......
......@@ -186,6 +186,7 @@ public class TaskNetworkInterfaceOUT extends TMLTask {
if (packetsAvailable.size() == 0) {
TMLStopState stopOfLeftBranchOfChoice = new TMLStopState("stopNoDestinationTask", referenceObject);
addElement(packetChoice, stopOfLeftBranchOfChoice);
packetChoice.addGuard("");
return;
}
......
......@@ -137,7 +137,7 @@ public class TaskOUTForDispatch extends TMLTask {
mainChoice = new TMLChoice("ChoiceOf" + i, referenceObject);
activity.addLinkElement(notified, mainChoice);
activity.addLinkElement(notified, new TMLStopState("StopAfterMainChoice", referenceObject));
activity.addLinkElement(mainChoice, new TMLStopState("StopAfterMainChoice", referenceObject));
mainChoice.addGuard("nEvt == 0");
TMLForLoop loopInside = new TMLForLoop("LoopInside" + i, referenceObject);
......
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