summaryrefslogtreecommitdiffstats
path: root/src/uscxml/transform
diff options
context:
space:
mode:
authorStefan Radomski <sradomski@mintwerk.de>2015-05-08 10:58:28 (GMT)
committerStefan Radomski <sradomski@mintwerk.de>2015-05-08 10:58:28 (GMT)
commit1bc525a7992f560735bb7e0de6981e8e6f616246 (patch)
treea2ac035bb763b80c2c566194e78c92f1915c32dc /src/uscxml/transform
parent81aa1c79dd158aa7bc76876552e4b1d05ecea656 (diff)
downloaduscxml-1bc525a7992f560735bb7e0de6981e8e6f616246.zip
uscxml-1bc525a7992f560735bb7e0de6981e8e6f616246.tar.gz
uscxml-1bc525a7992f560735bb7e0de6981e8e6f616246.tar.bz2
Some fixes for transition preemption with flattening
Diffstat (limited to 'src/uscxml/transform')
-rw-r--r--src/uscxml/transform/ChartToFSM.cpp5
-rw-r--r--src/uscxml/transform/ChartToPromela.cpp111
2 files changed, 65 insertions, 51 deletions
diff --git a/src/uscxml/transform/ChartToFSM.cpp b/src/uscxml/transform/ChartToFSM.cpp
index 38262db..971ee10 100644
--- a/src/uscxml/transform/ChartToFSM.cpp
+++ b/src/uscxml/transform/ChartToFSM.cpp
@@ -820,8 +820,11 @@ template <typename T> bool PtrComp(const T * const & a, const T * const & b) {
bool hasUnconditionalSuperset(GlobalTransition* first, GlobalTransition* second) {
NodeSet<std::string> firstTransitions = first->getTransitions();
- NodeSet<std::string> secondTransitions = first->getTransitions();
+ NodeSet<std::string> secondTransitions = second->getTransitions();
+// if (first->condition.size() > 0)
+// return false;
+
if (isSuperset(second, first)) {
for (int i = 0; i < firstTransitions.size(); i++) {
if (!InterpreterImpl::isMember(firstTransitions[i], secondTransitions)) {
diff --git a/src/uscxml/transform/ChartToPromela.cpp b/src/uscxml/transform/ChartToPromela.cpp
index 59f1d75..806c1f4 100644
--- a/src/uscxml/transform/ChartToPromela.cpp
+++ b/src/uscxml/transform/ChartToPromela.cpp
@@ -181,7 +181,8 @@ void PromelaCodeAnalyzer::addCode(const std::string& code, ChartToPromela* inter
std::list<PromelaParserNode*>::iterator opIter = node->operands.begin();
if ((*opIter)->type != PML_NAME) {
node->dump();
- assert(false);
+ return;
+ assert(false);
}
PromelaTypedef* td = &_typeDefs;
@@ -803,34 +804,38 @@ void ChartToPromela::writeTransition(std::ostream& stream, GlobalTransition* tra
}
std::list<GlobalTransition*>::const_iterator histIter;
- stream << std::endl << _prefix << "t" << transition->index << ": /* ######################## " << std::endl;
- FlatStateIdentifier flatActiveSource(transition->source);
- stream << " from state: ";
- PRETTY_PRINT_LIST(stream, flatActiveSource.getActive());
- stream << std::endl;
-// stream << " with history: " << flatActiveSource.getFlatHistory() << std::endl;
- stream << " ----- on event: " << (transition->eventDesc.size() > 0 ? transition->eventDesc : "SPONTANEOUS") << " --" << std::endl;
- stream << " to state: ";
- std::set<FlatStateIdentifier> destinations;
- destinations.insert(FlatStateIdentifier(transition->destination));
- histIter = transition->historyTrans.begin();
- while(histIter != transition->historyTrans.end()) {
- destinations.insert(FlatStateIdentifier((*histIter)->destination));
- histIter++;
- }
-
- std::string seperator = "";
- for (std::set<FlatStateIdentifier>::iterator destIter = destinations.begin(); destIter != destinations.end(); destIter++) {
- stream << seperator;
- PRETTY_PRINT_LIST(stream, destIter->getActive());
- stream << " with " << (destIter->getFlatHistory().size() > 0 ? destIter->getFlatHistory() : "no history");
- seperator = "\n ";
- }
- stream << std::endl;
-
- stream << "############################### */" << std::endl;
- stream << std::endl;
-
+ if (envVarIsTrue("USCXML_ANNOTATE_NOCOMMENT")) {
+ stream << std::endl << _prefix << "t" << transition->index << ": /* ######################## */ " << std::endl;
+
+ } else {
+
+ stream << std::endl << _prefix << "t" << transition->index << ": /* ######################## " << std::endl;
+ FlatStateIdentifier flatActiveSource(transition->source);
+ stream << " from state: ";
+ PRETTY_PRINT_LIST(stream, flatActiveSource.getActive());
+ stream << std::endl;
+ // stream << " with history: " << flatActiveSource.getFlatHistory() << std::endl;
+ stream << " ----- on event: " << (transition->eventDesc.size() > 0 ? transition->eventDesc : "SPONTANEOUS") << " --" << std::endl;
+ stream << " to state: ";
+ std::set<FlatStateIdentifier> destinations;
+ destinations.insert(FlatStateIdentifier(transition->destination));
+ histIter = transition->historyTrans.begin();
+ while(histIter != transition->historyTrans.end()) {
+ destinations.insert(FlatStateIdentifier((*histIter)->destination));
+ histIter++;
+ }
+ std::string seperator = "";
+ for (std::set<FlatStateIdentifier>::iterator destIter = destinations.begin(); destIter != destinations.end(); destIter++) {
+ stream << seperator;
+ PRETTY_PRINT_LIST(stream, destIter->getActive());
+ stream << " with " << (destIter->getFlatHistory().size() > 0 ? destIter->getFlatHistory() : "no history");
+ seperator = "\n ";
+ }
+ stream << std::endl;
+
+ stream << "############################### */" << std::endl;
+ }
+ stream << std::endl;
stream << padding << "skip;" << std::endl;
stream << padding << "d_step {" << std::endl;
if (_writeTransitionPrintfs)
@@ -1104,12 +1109,14 @@ void ChartToPromela::writeTransition(std::ostream& stream, GlobalTransition* tra
continue;
stream << padding << "if" << std::endl;
- stream << "/* to state ";
- FlatStateIdentifier flatActiveDest(histNewState->activeId);
- PRETTY_PRINT_LIST(stream, flatActiveDest.getActive());
- stream << " via history */" << std::endl;
+ if (!envVarIsTrue("USCXML_ANNOTATE_NOCOMMENT")) {
+ stream << "/* to state ";
+ FlatStateIdentifier flatActiveDest(histNewState->activeId);
+ PRETTY_PRINT_LIST(stream, flatActiveDest.getActive());
+ stream << " via history */" << std::endl;
+ }
- stream << padding << ":: " << conditionalizeForHist(histTargetIter->second) << " -> " << _prefix << "s = s" << histNewState->activeIndex << ";" << std::endl;
+ stream << padding << ":: " << conditionalizeForHist(histTargetIter->second) << " -> " << _prefix << "s = s" << histNewState->activeIndex << ";" << std::endl;
// writeTransitionClosure(stream, *histTargetIter->second.begin(), histNewState, indent + 1); // is this correct for everyone in set?
@@ -1120,10 +1127,11 @@ void ChartToPromela::writeTransition(std::ostream& stream, GlobalTransition* tra
FlatStateIdentifier flatActiveDest(transition->activeDestination);
assert(origNewState != NULL);
- stream << "/* to state ";
- PRETTY_PRINT_LIST(stream, flatActiveDest.getActive());
- stream << " */" << std::endl;
-
+ if (!envVarIsTrue("USCXML_ANNOTATE_NOCOMMENT")) {
+ stream << "/* to state ";
+ PRETTY_PRINT_LIST(stream, flatActiveDest.getActive());
+ stream << " */" << std::endl;
+ }
if (hasHistoryTarget) {
stream << padding << ":: else -> ";
padding += " ";
@@ -1948,7 +1956,7 @@ void ChartToPromela::writeDeclarations(std::ostream& stream) {
if (_prefix.size() == 0 || _prefix == "MAIN_") {
if (_analyzer->usesEventField("sendid")) {
- stream << "chan sendIdQ = [" << MAX(_externalQueueLength + 1, 1) << "] of {_event_t} /* temporary queue to cancel events per sendidexpr */" << std::endl;
+// stream << "chan sendIdQ = [" << MAX(_externalQueueLength + 1, 1) << "] of {_event_t} /* temporary queue to cancel events per sendidexpr */" << std::endl;
stream << "hidden int _lastSendId = 0; /* sequential counter for send ids */" << std::endl;
}
@@ -2243,7 +2251,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
if (eventNames.size() > 0) {
stream << " if " << std::endl;
for (std::set<std::string>::iterator evIter = eventNames.begin(); evIter != eventNames.end(); evIter++) {
- stream << " :: true -> { " << _prefix << "_event.name = " << _analyzer->macroForLiteral(*evIter) << " }" << std::endl;
+ stream << " :: true -> { " << _prefix << "_event" << (_analyzer->usesComplexEventStruct() ? ".name" : "")<< " = " << _analyzer->macroForLiteral(*evIter) << " }" << std::endl;
}
stream << " fi " << std::endl;
}
@@ -2671,11 +2679,13 @@ void ChartToPromela::writeDispatchingBlock(std::ostream& stream, std::list<Globa
}
if (currTrans->hasExecutableContent || currTrans->historyTrans.size() > 0) {
stream << " -> { " << std::endl;
- stream << "/* transition to ";
- FlatStateIdentifier flatActiveSource(currTrans->activeDestination);
- PRETTY_PRINT_LIST(stream, flatActiveSource.getActive());
- stream << " */" << std::endl;
-
+ if (!envVarIsTrue("USCXML_ANNOTATE_NOCOMMENT")) {
+ stream << "/* transition to ";
+ FlatStateIdentifier flatActiveSource(currTrans->activeDestination);
+ PRETTY_PRINT_LIST(stream, flatActiveSource.getActive());
+ stream << " */" << std::endl;
+ }
+
if (_traceTransitions) {
for (std::set<int>::iterator transRefIter = currTrans->transitionRefs.begin(); transRefIter != currTrans->transitionRefs.end(); transRefIter++) {
stream << padding << " " << _prefix << "transitions[" << *transRefIter << "] = true; " << std::endl;
@@ -2691,11 +2701,12 @@ void ChartToPromela::writeDispatchingBlock(std::ostream& stream, std::list<Globa
GlobalState* newState = _activeConf[currTrans->activeDestination];
assert(newState != NULL);
- stream << "/* new state ";
- FlatStateIdentifier flatActiveDest(currTrans->activeDestination);
- PRETTY_PRINT_LIST(stream, flatActiveDest.getActive());
- stream << " */" << std::endl;
-
+ if (!envVarIsTrue("USCXML_ANNOTATE_NOCOMMENT")) {
+ stream << "/* new state ";
+ FlatStateIdentifier flatActiveDest(currTrans->activeDestination);
+ PRETTY_PRINT_LIST(stream, flatActiveDest.getActive());
+ stream << " */" << std::endl;
+ }
stream << padding << " " << _prefix << "s = s" << newState->activeIndex << ";" << std::endl;
writeTransitionClosure(stream, currTrans, newState, indent + 1);