summaryrefslogtreecommitdiffstats
path: root/src/uscxml/transform/ChartToPromela.cpp
diff options
context:
space:
mode:
authorStefan Radomski <sradomski@mintwerk.de>2016-02-24 10:50:32 (GMT)
committerStefan Radomski <sradomski@mintwerk.de>2016-02-24 10:50:32 (GMT)
commitcf19f11b8d2bd6d9566c7528fbed40af06928abf (patch)
treea373b8e934fa78a1bf9db8afca2e9854437e45da /src/uscxml/transform/ChartToPromela.cpp
parent7212d5a3dbbd2845d09df96b2c345132c8a24931 (diff)
downloaduscxml-cf19f11b8d2bd6d9566c7528fbed40af06928abf.zip
uscxml-cf19f11b8d2bd6d9566c7528fbed40af06928abf.tar.gz
uscxml-cf19f11b8d2bd6d9566c7528fbed40af06928abf.tar.bz2
Some more refactoring and VHDL transformation
Diffstat (limited to 'src/uscxml/transform/ChartToPromela.cpp')
-rw-r--r--src/uscxml/transform/ChartToPromela.cpp92
1 files changed, 46 insertions, 46 deletions
diff --git a/src/uscxml/transform/ChartToPromela.cpp b/src/uscxml/transform/ChartToPromela.cpp
index 747fb34..b0c3c79 100644
--- a/src/uscxml/transform/ChartToPromela.cpp
+++ b/src/uscxml/transform/ChartToPromela.cpp
@@ -52,7 +52,7 @@
}
#define INDENT_MIN(stream, start, cols) \
-for (int indentIndex = start; indentIndex < cols; indentIndex++) \
+for (size_t indentIndex = start; indentIndex < cols; indentIndex++) \
stream << " ";
#define DIFF_MAPS(base, compare, result) \
@@ -392,7 +392,7 @@ std::string PromelaCodeAnalyzer::getTypeReset(const std::string& var, const Prom
while(typeIter != type.types.end()) {
const PromelaTypedef& innerType = typeIter->second;
if (innerType.arraySize > 0) {
- for (int i = 0; i < innerType.arraySize; i++) {
+ for (size_t i = 0; i < innerType.arraySize; i++) {
assignment << padding << var << "." << typeIter->first << "[" << i << "] = 0;" << std::endl;
}
} else if (innerType.types.size() > 0) {
@@ -413,7 +413,7 @@ std::string PromelaCodeAnalyzer::getTypeAssignment(const std::string& varTo, con
while(typeIter != type.types.end()) {
const PromelaTypedef& innerType = typeIter->second;
if (innerType.arraySize > 0) {
- for (int i = 0; i < innerType.arraySize; i++) {
+ for (size_t i = 0; i < innerType.arraySize; i++) {
assignment << padding << varTo << "." << typeIter->first << "[" << i << "] = " << varFrom << "." << typeIter->first << "[" << i << "];" << std::endl;
}
} else if (innerType.types.size() > 0) {
@@ -597,7 +597,7 @@ void ChartToPromela::writeStates(std::ostream& stream) {
stateIter++;
}
-// for (int i = 0; i < _globalConf.size(); i++) {
+// for (size_t i = 0; i < _globalConf.size(); i++) {
// stream << "#define " << "s" << i << " " << i;
// stream << " /* from \"" << ATTR_CAST(_globalStates[i], "id") << "\" */" << std::endl;
// }
@@ -856,7 +856,7 @@ std::string ChartToPromela::conditionalizeForHist(const std::set<GlobalTransitio
void ChartToPromela::writeTransition(std::ostream& stream, GlobalTransition* transition, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
std::list<GlobalTransition*>::const_iterator histIter;
@@ -1222,7 +1222,7 @@ void ChartToPromela::writeTransition(std::ostream& stream, GlobalTransition* tra
void ChartToPromela::writeHistoryAssignments(std::ostream& stream, GlobalTransition* transition, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -1464,7 +1464,7 @@ void HistoryTransitionClass::merge(const HistoryTransitionClass& other) {
void ChartToPromela::writeTransitionClosure(std::ostream& stream, GlobalTransition* transition, GlobalState* state, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -1489,7 +1489,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica:
return;
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -1513,7 +1513,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica:
}
} else if(TAGNAME(nodeElem) == "script") {
NodeSet<std::string> scriptText = DOMUtils::filterChildType(Node_base::TEXT_NODE, node, true);
- for (int i = 0; i < scriptText.size(); i++) {
+ for (size_t i = 0; i < scriptText.size(); i++) {
stream << ADAPT_SRC(beautifyIndentation(scriptText[i].getNodeValue(), indent)) << std::endl;
}
@@ -1657,7 +1657,7 @@ void ChartToPromela::writeExecutableContent(std::ostream& stream, const Arabica:
NodeSet<std::string> sendContents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", nodeElem);
std::string sendNameList = ATTR(nodeElem, "namelist");
if (sendParams.size() > 0) {
- for (int i = 0; i < sendParams.size(); i++) {
+ for (size_t i = 0; i < sendParams.size(); i++) {
Element<std::string> paramElem = Element<std::string>(sendParams[i]);
typeAssignSS << padding << " tmpE.data." << ATTR(paramElem, "name") << " = " << ADAPT_SRC(ATTR(paramElem, "expr")) << ";" << std::endl;
}
@@ -1842,11 +1842,11 @@ PromelaInlines::PromelaInlines(const Arabica::DOM::Node<std::string>& node) {
PromelaInline* predecessor = NULL;
// iterate all nodes at given level
- for (int i = 0; i < levelNodes.size(); i++) {
+ for (size_t i = 0; i < levelNodes.size(); i++) {
// get all comments
NodeSet<std::string> comments = DOMUtils::filterChildType(Node_base::COMMENT_NODE, levelNodes[i]);
- for (int j = 0; j < comments.size(); j++) {
+ for (size_t j = 0; j < comments.size(); j++) {
PromelaInline* tmp = new PromelaInline(comments[j]);
if (tmp->type == PromelaInline::PROMELA_NIL) {
delete tmp;
@@ -1904,7 +1904,7 @@ void ChartToPromela::writeIfBlock(std::ostream& stream, const Arabica::XPath::No
return;
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -1957,7 +1957,7 @@ void ChartToPromela::writeIfBlock(std::ostream& stream, const Arabica::XPath::No
stream << "{" << std::endl;
Arabica::XPath::NodeSet<std::string> cdrCondChain;
- for (int i = 1; i < condChain.size(); i++) {
+ for (size_t i = 1; i < condChain.size(); i++) {
cdrCondChain.push_back(condChain[i]);
}
writeIfBlock(stream, cdrCondChain, indent + 1);
@@ -1972,7 +1972,7 @@ void ChartToPromela::writeIfBlock(std::ostream& stream, const Arabica::XPath::No
std::string ChartToPromela::beautifyIndentation(const std::string& code, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -2096,7 +2096,7 @@ void ChartToPromela::writeDeclarations(std::ostream& stream) {
// automatic types
PromelaCodeAnalyzer::PromelaTypedef allTypes = _analyzer->getTypes();
- for (int i = 0; i < datas.size(); i++) {
+ for (size_t i = 0; i < datas.size(); i++) {
Node<std::string> data = datas[i];
if (isInEmbeddedDocument(data))
@@ -2177,7 +2177,7 @@ void ChartToPromela::writeEventSources(std::ostream& stream) {
void ChartToPromela::writeStartInvoker(std::ostream& stream, const Arabica::DOM::Node<std::string>& node, ChartToPromela* invoker, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -2193,7 +2193,7 @@ void ChartToPromela::writeStartInvoker(std::ostream& stream, const Arabica::DOM:
// set from params
NodeSet<std::string> invokeParams = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", node);
- for (int i = 0; i < invokeParams.size(); i++) {
+ for (size_t i = 0; i < invokeParams.size(); i++) {
std::string identifier = ATTR_CAST(invokeParams[i], "name");
std::string expression = ATTR_CAST(invokeParams[i], "expr");
if (invoker->_dataModelVars.find(identifier) != invoker->_dataModelVars.end()) {
@@ -2225,7 +2225,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
NodeSet<std::string> scripts = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml, false);
if (scripts.size() > 0) {
stream << std::endl << "/* global scripts */" << std::endl;
- for (int i = 0; i < scripts.size(); i++) {
+ for (size_t i = 0; i < scripts.size(); i++) {
writeExecutableContent(stream, scripts[i], 1);
}
stream << std::endl;
@@ -2339,7 +2339,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
NodeSet<std::string> transitions = DOMUtils::filterChildElements("transition", es.container, true);
std::set<std::string> eventNames;
- for (int i = 0; i < transitions.size(); i++) {
+ for (size_t i = 0; i < transitions.size(); i++) {
if (!HAS_ATTR_CAST(transitions[i], "event"))
continue;
if (HAS_ATTR_CAST(transitions[i], "cond") && ATTR_CAST(transitions[i], "cond").find("_event.") != std::string::npos)
@@ -2492,7 +2492,7 @@ void ChartToPromela::writeFSM(std::ostream& stream) {
void ChartToPromela::writeRescheduleProcess(std::ostream& stream, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -2536,7 +2536,7 @@ void ChartToPromela::writeRescheduleProcess(std::ostream& stream, int indent) {
void ChartToPromela::writeDetermineShortestDelay(std::ostream& stream, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -2557,7 +2557,7 @@ void ChartToPromela::writeDetermineShortestDelay(std::ostream& stream, int inden
void ChartToPromela::writeInsertWithDelay(std::ostream& stream, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -2651,7 +2651,7 @@ void ChartToPromela::writeInsertWithDelay(std::ostream& stream, int indent) {
void ChartToPromela::writeAdvanceTime(std::ostream& stream, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -2739,7 +2739,7 @@ void ChartToPromela::writeCancelEvents(std::ostream& stream, int indent) {
void ChartToPromela::writeScheduleMachines(std::ostream& stream, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -2814,7 +2814,7 @@ void ChartToPromela::writeEventDispatching(std::ostream& stream) {
void ChartToPromela::writeDispatchingBlock(std::ostream& stream, std::list<GlobalTransition*> transitions, int indent) {
std::string padding;
- for (int i = 0; i < indent; i++) {
+ for (size_t i = 0; i < indent; i++) {
padding += " ";
}
@@ -2976,7 +2976,7 @@ void ChartToPromela::initNodes() {
// get all states
NodeSet<std::string> states = getAllStates();
- for (int i = 0; i < states.size(); i++) {
+ for (size_t i = 0; i < states.size(); i++) {
if (InterpreterImpl::isInEmbeddedDocument(states[i]))
continue;
Element<std::string> stateElem(states[i]);
@@ -2992,7 +2992,7 @@ void ChartToPromela::initNodes() {
invokes.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "uninvoke", _scxml, true));
// make sure all invokers have an id!
- for (int i = 0; i < invokes.size(); i++) {
+ for (size_t i = 0; i < invokes.size(); i++) {
if (!HAS_ATTR_CAST(invokes[i], "id")) {
Element<std::string> invokeElem(invokes[i]);
invokeElem.setAttribute("id", "INV_" + UUID::getUUID().substr(0,5));
@@ -3008,7 +3008,7 @@ void ChartToPromela::initNodes() {
// are there nestes SCXML invokers?
{
NodeSet<std::string> invokes = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true);
- for (int i = 0; i < invokes.size(); i++) {
+ for (size_t i = 0; i < invokes.size(); i++) {
if (!HAS_ATTR_CAST(invokes[i], "type") ||
ATTR_CAST(invokes[i], "type") == "scxml" ||
ATTR_CAST(invokes[i], "type") == "http://www.w3.org/TR/scxml/#SCXMLEventProcessor" ||
@@ -3075,7 +3075,7 @@ void ChartToPromela::initNodes() {
histStatesMembers.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "parallel", histIter->second.getParentNode(), isDeep));
histStatesMembers.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "final", histIter->second.getParentNode(), isDeep));
- for (int i = 0; i < histStatesMembers.size(); i++) {
+ for (size_t i = 0; i < histStatesMembers.size(); i++) {
_historyMembers[histIter->first].insert(std::make_pair(ATTR_CAST(histStatesMembers[i], "id"), i));
}
histIter++;
@@ -3087,7 +3087,7 @@ void ChartToPromela::initNodes() {
internalEventNames.push_back(_xpath.evaluate("//" + _nsInfo.xpathPrefix + "raise", _scxml).asNodeSet());
internalEventNames.push_back(_xpath.evaluate("//" + _nsInfo.xpathPrefix + "send", _scxml).asNodeSet());
- for (int i = 0; i < internalEventNames.size(); i++) {
+ for (size_t i = 0; i < internalEventNames.size(); i++) {
if (HAS_ATTR_CAST(internalEventNames[i], "event")) {
std::string eventNames = ATTR_CAST(internalEventNames[i], "event");
std::list<std::string> events = tokenize(eventNames);
@@ -3113,7 +3113,7 @@ void ChartToPromela::initNodes() {
asgn.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true));
asgn.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
- for (int i = 0; i < asgn.size(); i++) {
+ for (size_t i = 0; i < asgn.size(); i++) {
if (isInEmbeddedDocument(asgn[i]))
continue;
@@ -3139,7 +3139,7 @@ void ChartToPromela::initNodes() {
} else {
NodeSet<std::string> textChilds = DOMUtils::filterChildType(Node_base::TEXT_NODE, asgnElem);
if (textChilds.size() > 0) {
- for (int j = 0; j < textChilds.size(); j++) {
+ for (size_t j = 0; j < textChilds.size(); j++) {
value += textChilds[j].getNodeValue();
}
}
@@ -3180,7 +3180,7 @@ void ChartToPromela::initNodes() {
_analyzer->addCode("_event.invokeid", this);
}
- for (int i = 0; i < sends.size(); i++) {
+ for (size_t i = 0; i < sends.size(); i++) {
if (HAS_ATTR_CAST(sends[i], "idlocation")) {
_analyzer->addCode("_event.sendid", this);
}
@@ -3191,7 +3191,7 @@ void ChartToPromela::initNodes() {
}
// do we need delays?
- for (int i = 0; i < sends.size(); i++) {
+ for (size_t i = 0; i < sends.size(); i++) {
if (HAS_ATTR_CAST(sends[i], "delay") || HAS_ATTR_CAST(sends[i], "delayexpr")) {
_analyzer->addCode("_event.delay", this);
#if NEW_DELAY_RESHUFFLE
@@ -3208,9 +3208,9 @@ void ChartToPromela::initNodes() {
withContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true));
withContent.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "raise", _scxml, true));
- for (int i = 0; i < withContent.size(); i++) {
+ for (size_t i = 0; i < withContent.size(); i++) {
NodeSet<std::string> content = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", withContent[i], true);
- for (int j = 0; j < content.size(); j++) {
+ for (size_t j = 0; j < content.size(); j++) {
Element<std::string> contentElem(content[j]);
std::string content = spaceNormalize(contentElem.getFirstChild().getNodeValue());
if (!isNumeric(content.c_str(), 10))
@@ -3243,7 +3243,7 @@ void ChartToPromela::initNodes() {
}
if (json.array.size() > 0) {
- for (int i = 0; i < json.array.size(); i++) {
+ for (size_t i = 0; i < json.array.size(); i++) {
std::string expr = dataToAssignments("_event", json.item(i));
_analyzer->addCode(expr, this);
}
@@ -3266,7 +3266,7 @@ void ChartToPromela::initNodes() {
}
NodeSet<std::string> contents = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", _scxml, true);
- for (int i = 0; i < contents.size(); i++) {
+ for (size_t i = 0; i < contents.size(); i++) {
Element<std::string> contentElem = Element<std::string>(contents[i]);
if (contentElem.hasChildNodes() && contentElem.getFirstChild().getNodeType() == Node_base::TEXT_NODE && contentElem.getChildNodes().getLength() == 1) {
std::string content = contentElem.getFirstChild().getNodeValue();
@@ -3283,7 +3283,7 @@ void ChartToPromela::initNodes() {
withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "transition", _scxml, true));
withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "if", _scxml, true));
withCond.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "elseif", _scxml, true));
- for (int i = 0; i < withCond.size(); i++) {
+ for (size_t i = 0; i < withCond.size(); i++) {
Element<std::string> elem = Element<std::string>(withCond[i]);
if (HAS_ATTR(elem, "cond")) {
std::string code = ATTR(elem, "cond");
@@ -3300,7 +3300,7 @@ void ChartToPromela::initNodes() {
withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "content", _scxml, true));
withExpr.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "param", _scxml, true));
- for (int i = 0; i < withExpr.size(); i++) {
+ for (size_t i = 0; i < withExpr.size(); i++) {
Element<std::string> elem = Element<std::string>(withExpr[i]);
if (HAS_ATTR(elem, "expr")) {
std::string code = ATTR(elem, "expr");
@@ -3313,7 +3313,7 @@ void ChartToPromela::initNodes() {
{
NodeSet<std::string> withLocation;
withLocation.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "assign", _scxml, true));
- for (int i = 0; i < withLocation.size(); i++) {
+ for (size_t i = 0; i < withLocation.size(); i++) {
Element<std::string> elem = Element<std::string>(withLocation[i]);
if (HAS_ATTR(elem, "location")) {
std::string code = ATTR(elem, "location");
@@ -3327,9 +3327,9 @@ void ChartToPromela::initNodes() {
NodeSet<std::string> withText;
withText.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "script", _scxml, true));
// withText.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "data", _scxml, true));
- for (int i = 0; i < withText.size(); i++) {
+ for (size_t i = 0; i < withText.size(); i++) {
NodeSet<std::string> texts = DOMUtils::filterChildType(Node_base::TEXT_NODE, withText[i], true);
- for (int j = 0; j < texts.size(); j++) {
+ for (size_t j = 0; j < texts.size(); j++) {
if (texts[j].getNodeValue().size() > 0) {
Text<std::string> elem = Text<std::string>(texts[j]);
std::string code = elem.getNodeValue();
@@ -3342,7 +3342,7 @@ void ChartToPromela::initNodes() {
}
{
NodeSet<std::string> foreachs = DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "foreach", _scxml, true);
- for (int i = 0; i < foreachs.size(); i++) {
+ for (size_t i = 0; i < foreachs.size(); i++) {
if (HAS_ATTR_CAST(foreachs[i], "index")) {
allCode.insert(ATTR_CAST(foreachs[i], "index"));
} else {
@@ -3362,7 +3362,7 @@ void ChartToPromela::initNodes() {
NodeSet<std::string> withNamelist;
withNamelist.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "send", _scxml, true));
withNamelist.push_back(DOMUtils::filterChildElements(_nsInfo.xmlNSPrefix + "invoke", _scxml, true));
- for (int i = 0; i < withNamelist.size(); i++) {
+ for (size_t i = 0; i < withNamelist.size(); i++) {
if (HAS_ATTR_CAST(withNamelist[i], "namelist")) {
std::string namelist = ATTR_CAST(withNamelist[i], "namelist");
std::list<std::string> names = tokenize(namelist);