summaryrefslogtreecommitdiffstats
path: root/src/uscxml
diff options
context:
space:
mode:
authorStefan Radomski <sradomski@mintwerk.de>2016-01-19 13:13:41 (GMT)
committerStefan Radomski <sradomski@mintwerk.de>2016-01-19 13:13:41 (GMT)
commit024d82815dc6f2e2298fc8661424c25dd4c79d85 (patch)
treeeb68a5d9932a45902c7058589a339468cf7daefd /src/uscxml
parent6e96eafb9bf087c35cfe8e60196d0a2a1698d22b (diff)
downloaduscxml-024d82815dc6f2e2298fc8661424c25dd4c79d85.zip
uscxml-024d82815dc6f2e2298fc8661424c25dd4c79d85.tar.gz
uscxml-024d82815dc6f2e2298fc8661424c25dd4c79d85.tar.bz2
Fixed a bug with deep initial states in compounds for C transformation
Diffstat (limited to 'src/uscxml')
-rw-r--r--src/uscxml/transform/ChartToC.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index f261ffd..94473f9 100644
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -517,9 +517,6 @@ void ChartToC::writeExecContent(std::ostream& stream) {
for (size_t j = 0; j < onentry.size(); j++) {
stream << " " << DOMUtils::idForNode(state) << "_on_entry_" << toStr(j) << "(ctx, state, event);" << std::endl;
}
-// if (hasInitialState) {
-// stream << " " << DOMUtils::idForNode(state) << "_initial" << "(ctx, state, event);" << std::endl;
-// }
stream << " return SCXML_ERR_OK;" << std::endl;
stream << "}" << std::endl;
@@ -541,8 +538,6 @@ void ChartToC::writeExecContent(std::ostream& stream) {
for (size_t i = 0; i < _transitions.size(); i++) {
Element<std::string> transition(_transitions[i]);
-// if (iequals(TAGNAME_CAST(transition.getParentNode()), "initial"))
-// continue;
NodeSet<std::string> execContent = filterChildType(Node_base::ELEMENT_NODE, transition);
@@ -1491,18 +1486,30 @@ void ChartToC::writeFSM(std::ostream& stream) {
stream << " SET_BIT(j, trans_set);" << std::endl;
stream << " CLEARBIT(i, entry_set);" << std::endl;
stream << " bit_or(entry_set, scxml_transitions[j].target, " << _stateCharArraySize << ");" << std::endl;
- stream << " // one target may have been above, reestablish completion" << std::endl;
- stream << " // goto ADD_DESCENDANTS; // initial will have to be first!" << std::endl;
- stream << " }" << std::endl;
+ stream << " for (size_t k = 0; k < SCXML_NUMBER_STATES; k++) {" << std::endl;
+ stream << " if (IS_SET(k, scxml_transitions[j].target)) {" << std::endl;
+ stream << " bit_or(entry_set, scxml_states[k].ancestors, " << _stateCharArraySize << ");" << std::endl;
+ stream << " }" << std::endl;
+ stream << " }" << std::endl;
+ stream << " }" << std::endl;
stream << " }" << std::endl;
stream << " break;" << std::endl;
stream << " }" << std::endl;
stream << " case SCXML_STATE_COMPOUND: { // we need to check whether one child is already in entry_set" << std::endl;
- stream << " if (!bit_has_and(entry_set, scxml_states[i].children, " << _stateCharArraySize << ") &&" << std::endl;
- stream << " (!bit_has_and(ctx->config, scxml_states[i].children, " << _stateCharArraySize << ") ||" << std::endl;
- stream << " bit_has_and(exit_set, scxml_states[i].children, " << _stateCharArraySize << ")))" << std::endl;
+ stream << " if (!bit_has_and(entry_set, scxml_states[i].children, 1) &&" << std::endl;
+ stream << " (!bit_has_and(ctx->config, scxml_states[i].children, 1) ||" << std::endl;
+ stream << " bit_has_and(exit_set, scxml_states[i].children, 1)))" << std::endl;
stream << " {" << std::endl;
- stream << " bit_or(entry_set, scxml_states[i].completion, " << _stateCharArraySize << ");" << std::endl;
+ stream << " bit_or(entry_set, scxml_states[i].completion, 1);" << std::endl;
+ stream << " if (!bit_has_and(scxml_states[i].completion, scxml_states[i].children, 1)) {" << std::endl;
+ stream << " // deep completion" << std::endl;
+ stream << " for (size_t j = 0; j < SCXML_NUMBER_STATES; j++) {" << std::endl;
+ stream << " if (IS_SET(j, scxml_states[i].completion)) {" << std::endl;
+ stream << " bit_or(entry_set, scxml_states[j].ancestors, 1);" << std::endl;
+ stream << " break; // completion of compound is single state" << std::endl;
+ stream << " }" << std::endl;
+ stream << " }" << std::endl;
+ stream << " }" << std::endl;
stream << " }" << std::endl;
stream << " break;" << std::endl;
stream << " }" << std::endl;