Skip to content
Snippets Groups Projects
Commit 6e54350f authored by Bastien Sultan's avatar Bastien Sultan
Browse files

Patching JURASSIC compiler, adding new features and adding a new command for...

Patching JURASSIC compiler, adding new features and adding a new command for performing a batch of mutations
parent a8ce8f7d
No related branches found
No related tags found
1 merge request!478Adding a compiler for JURASSIC AMULET
......@@ -67,6 +67,7 @@ import proverifspec.ProVerifQueryResult;
import tmltranslator.*;
import tmltranslator.mutations.ApplyDiplodocusMutationException;
import tmltranslator.mutations.DiplodocusMutation;
import tmltranslator.mutations.DiplodocusMutationParser;
import tmltranslator.mutations.ParseDiplodocusMutationException;
import ui.MainGUI;
import ui.avatarinteractivesimulation.AvatarInteractiveSimulationActions;
......@@ -646,7 +647,7 @@ public class Action extends Command implements ProVerifOutputListener {
}
public String getDescription() {
return "Performs a mutation on an DIPLODOCUS (TML, TMAP or TARCHI) model";
return "Performs a mutation on a DIPLODOCUS (TML, TMAP or TARCHI) model";
}
public String getUsage() {
......@@ -697,6 +698,77 @@ public class Action extends Command implements ProVerifOutputListener {
};
Command makeMutationBatchFromDiplodocus = new Command() {
public String getCommand() {
return DIPLO_MUTATION_BATCH;
}
public String getShortCommand() {
return "dmb";
}
public String getDescription() {
return "Perform a series of mutations on a DIPLODOCUS (TML, TMAP or TARCHI) model";
}
public String getUsage() {
return "[MUTATION]\n";
}
public String getExample() {
return "dmb path_to_command_file";
}
public String executeCommand(String command, Interpreter interpreter) {
if (!interpreter.isTToolStarted()) {
return Interpreter.TTOOL_NOT_STARTED;
}
String[] commands = command.split(" ");
if (commands.length < 1) {
return Interpreter.BAD;
}
TMLModeling<?> tmlModel = interpreter.mgui.gtm.getTMLModeling();
TMLMapping tmlMapping = interpreter.mgui.gtm.getTMLMapping();
List<String> mutationList = null;
try {
mutationList = Files.readAllLines(new File(command).toPath());
} catch (IOException e) {
throw new RuntimeException(e);
}
for (String mutationCommand:mutationList){
try {
DiplodocusMutation dm = DiplodocusMutation.createFromString(mutationCommand);
if (dm != null) {
switch (dm.getMutationType()){
case "TMLmutation":
if(tmlModel == null){
return "No TML model";
} else{
dm.apply(tmlModel);
}
//case "TARCHImutation":
//case "TMAPmutation":
}
}
} catch (ParseDiplodocusMutationException e) {
TraceManager.addDev("Exception in parsing mutation: " + e.getMessage());
return e.getMessage();
} catch (ApplyDiplodocusMutationException e) {
TraceManager.addDev("Exception in applying mutation: " + e.getMessage());
return e.getMessage();
}
}
return null;
}
};
// Diplodocus interactive simulation
Command diplodocusInteractiveSimulation = new Command() {
public String getCommand() {
......@@ -2265,6 +2337,7 @@ public class Action extends Command implements ProVerifOutputListener {
addAndSortSubcommand(checkSyntax);
addAndSortSubcommand(removeTimeOperators);
addAndSortSubcommand(makeMutationFromDiplodocus);
addAndSortSubcommand(makeMutationBatchFromDiplodocus);
addAndSortSubcommand(drawDiplodocusModel);
addAndSortSubcommand(generateRGFromAvatar);
addAndSortSubcommand(diplodocusInteractiveSimulation);
......
......@@ -417,14 +417,26 @@ public class TMLTask extends TMLElement {
channelsList.add(_ch);
}
public void removeTMLChannel(TMLChannel _ch) {
channelsList.remove(_ch);
}
public void addReadTMLChannel(TMLChannel _ch) {
readTMLChannelsList.add(_ch);
}
public void removeReadTMLChannel(TMLChannel _ch) {
readTMLChannelsList.remove(_ch);
}
public void addWriteTMLChannel(TMLChannel _ch) {
writeTMLChannelsList.add(_ch);
}
public void removeWriteTMLChannel(TMLChannel _ch) {
writeTMLChannelsList.remove(_ch);
}
/*public List<TMLChannel> getTMLChannels() {
return new ArrayList<TMLChannel>(channelsList);
}*/
......@@ -441,6 +453,10 @@ public class TMLTask extends TMLElement {
eventsList.add(_evt);
}
public void removeTMLEvent(TMLEvent _evt) {
eventsList.remove(_evt);
}
public List<TMLEvent> getTMLEvents() {
return new ArrayList<TMLEvent>(eventsList);
}
......
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.fr
*
* This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package tmltranslator.mutations;
import tmltranslator.TMLModeling;
public class AddRequestConnectionMutation extends RequestConnectionMutation {
protected AddRequestConnectionMutation(String _originTaskName, String _destinationTaskName, String _connectionName) {
super(_originTaskName, _destinationTaskName, _connectionName);
}
@Override
public void apply(TMLModeling<?> _tmlModel) throws ApplyDiplodocusMutationException {
}
}
......@@ -83,15 +83,13 @@ public abstract class EventConnectionMutation extends ConnectionMutation{
if (_tmlModel.getTasks().size() != 0){
appName = _tmlModel.getTasks().get(0).getName().split("__")[0];
}
for (TMLEvent e : events){
System.out.println(e.getName());
if (e.getName().equals(getConnectionName())) {
return e;
} else if (e.getName().equals(appName + "__" + getConnectionName() + "__" + appName + "__" + getConnectionName())) {
return e;
}
TMLEvent event = _tmlModel.getEventByName(getConnectionName());
if (event != null){
return event;
} else {
return _tmlModel.getEventByName(appName + "__" + getConnectionName() + "__" + appName + "__" + getConnectionName());
}
return null;
}
public static EventConnectionMutation createFromString(String toParse) throws ParseDiplodocusMutationException{
......
......@@ -40,6 +40,7 @@ package tmltranslator.mutations;
import tmltranslator.TMLChannel;
import tmltranslator.TMLModeling;
import tmltranslator.TMLTask;
public class RemoveDataConnectionMutation extends DataConnectionMutation{
protected RemoveDataConnectionMutation(String _connectionName) {
......@@ -53,6 +54,14 @@ public class RemoveDataConnectionMutation extends DataConnectionMutation{
throw new ApplyDiplodocusMutationException("There is no channel named " + getConnectionName() + " in this model.");
} else {
_tmlModel.removeChannel(channel);
TMLTask originTask = channel.getOriginTask();
TMLTask destinationTask = channel.getDestinationTask();
originTask.removeTMLChannel(channel);
originTask.removeReadTMLChannel(channel);
originTask.removeWriteTMLChannel(channel);
destinationTask.removeTMLChannel(channel);
destinationTask.removeReadTMLChannel(channel);
destinationTask.removeWriteTMLChannel(channel);
}
}
......
......@@ -53,6 +53,8 @@ public class RemoveEventConnectionMutation extends EventConnectionMutation{
throw new ApplyDiplodocusMutationException("There is no event named " + getConnectionName() + " in this model.");
} else {
_tmlModel.removeEvent(event);
event.getOriginTask().removeTMLEvent(event);
event.getDestinationTask().removeTMLEvent(event);
}
}
......
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.fr
*
* This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package tmltranslator.mutations;
import tmltranslator.TMLModeling;
import tmltranslator.TMLRequest;
import java.util.List;
public abstract class RequestConnectionMutation extends ConnectionMutation {
protected RequestConnectionMutation(String _originTaskName, String _destinationTaskName, String _connectionName) {
super(_originTaskName, _destinationTaskName, _connectionName);
}
protected RequestConnectionMutation(String _connectionName) {
super(_connectionName);
}
public TMLRequest getRequest(TMLModeling<?> _tmlModel){
String appName = "";
if (_tmlModel.getTasks().size() != 0){
appName = _tmlModel.getTasks().get(0).getName().split("__")[0];
}
TMLRequest request = _tmlModel.getRequestByName(getConnectionName());
if (request != null){
return request;
} else {
return _tmlModel.getRequestByName(appName + "__" + getConnectionName() + "__" + appName + "__" + getConnectionName());
}
}
public static RequestConnectionMutation createFromString(String toParse) throws ParseDiplodocusMutationException{
switch (DiplodocusMutationParser.findMutationToken(toParse)) {
case "ADD":
case "RM":
case "REMOVE":
default:
break;
}
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment