diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-01-18 17:15:46 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2017-01-18 17:15:46 (GMT) |
commit | fc78cfdc4d1f5bba8dbd6a412f23651e185cb191 (patch) | |
tree | dd32929c07e6c19250f2e8fde1e73712bab0c6fb /src/uscxml/plugins/datamodel | |
parent | 01ee860a88b5c8cf25fb7dcc145662d2c27f3ebe (diff) | |
download | uscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.zip uscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.tar.gz uscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.tar.bz2 |
Worked on passing even more IRP tests
Diffstat (limited to 'src/uscxml/plugins/datamodel')
10 files changed, 140 insertions, 149 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 22e8ccc..bcde9c9 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -420,7 +420,12 @@ Data JSCDataModel::getAsData(const std::string& content) { (trimmed[0] == '\'' && trimmed[trimmed.length() - 1] == '\''))) { d = Data(trimmed.substr(1, trimmed.length() - 2), Data::VERBATIM); } else { - d = Data(trimmed, Data::INTERPRETED); + // test558, test562 + ERROR_EXECUTION(e, "Given content cannot be interpreted as data"); + e.data.compound["literal"] = Data(trimmed, Data::VERBATIM); + throw e; + +// d = Data(trimmed, Data::INTERPRETED); } } return d; @@ -684,7 +689,7 @@ JSValueRef JSCDataModel::getNodeAsValue(const DOMNode* node) { // } } -void JSCDataModel::assign(const std::string& location, const Data& data) { +void JSCDataModel::assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) { // flags on attribute are ignored? if (location.compare("_sessionid") == 0) // test 322 @@ -714,7 +719,7 @@ void JSCDataModel::assign(const std::string& location, const Data& data) { handleException(exception); } -void JSCDataModel::init(const std::string& location, const Data& data) { +void JSCDataModel::init(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) { try { if (data.empty()) { assign(location, Data("null", Data::INTERPRETED)); @@ -728,26 +733,6 @@ void JSCDataModel::init(const std::string& location, const Data& data) { } } -std::string JSCDataModel::andExpressions(std::list<std::string> expressions) { - if (expressions.size() == 0) - return ""; - - if (expressions.size() == 1) - return *(expressions.begin()); - - std::ostringstream exprSS; - exprSS << "("; - std::string conjunction = ""; - for (std::list<std::string>::const_iterator exprIter = expressions.begin(); - exprIter != expressions.end(); - exprIter++) { - exprSS << conjunction << "(" << *exprIter << ")"; - conjunction = " && "; - } - exprSS << ")"; - return exprSS.str(); -} - void JSCDataModel::handleException(JSValueRef exception) { JSStringRef exceptionStringRef = JSValueToStringCopy(_ctx, exception, NULL); size_t maxSize = JSStringGetMaximumUTF8CStringSize(exceptionStringRef); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h index c5129a4..3a53da2 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.h @@ -80,10 +80,12 @@ public: virtual bool isDeclared(const std::string& expr); - virtual void assign(const std::string& location, const Data& data); - virtual void init(const std::string& location, const Data& data); - - virtual std::string andExpressions(std::list<std::string>); + virtual void assign(const std::string& location, + const Data& data, + const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()); + virtual void init(const std::string& location, + const Data& data, + const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()); protected: diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index 283372d..61eb815 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -408,7 +408,7 @@ void V8DataModel::setEvent(const Event& event) { } } if (!data.empty()) { -// std::cout << Data::toJSON(eventCopy.data); +// std::cout << Data::toJSON(data); eventObj->Set(v8::String::NewSymbol("data"), getDataAsValue(data)); // set data part of _event } else { // test 343 / test 488 @@ -436,7 +436,10 @@ Data V8DataModel::getAsData(const std::string& content) { (trimmed[0] == '\'' && trimmed[trimmed.length() - 1] == '\''))) { d = Data(trimmed.substr(1, trimmed.length() - 2), Data::VERBATIM); } else { - d = Data(trimmed, Data::INTERPRETED); + // test558, test562 + ERROR_EXECUTION(e, "Given content cannot be interpreted as data"); + e.data.compound["literal"] = Data(trimmed, Data::VERBATIM); + throw e; } } return d; @@ -631,12 +634,22 @@ void V8DataModel::jsIn(const v8::FunctionCallbackInfo<v8::Value>& info) { } bool V8DataModel::isValidSyntax(const std::string& expr) { + v8::Locker locker(_isolate); + v8::Isolate::Scope isoScope(_isolate); + v8::HandleScope scope(_isolate); + + v8::Local<v8::Context> ctx = v8::Local<v8::Context>::New(_isolate, _context); + v8::Context::Scope contextScope(ctx); // segfaults at newinstance without! + v8::TryCatch tryCatch; v8::Local<v8::String> source = v8::String::New(expr.c_str()); - v8::Local<v8::Script> script = v8::Script::Compile(source); + if (tryCatch.HasCaught() || source.IsEmpty()) { + return false; + } - if (script.IsEmpty() || tryCatch.HasCaught()) { + v8::Local<v8::Script> script = v8::Script::Compile(source); + if (tryCatch.HasCaught() || script.IsEmpty()) { return false; } @@ -726,7 +739,7 @@ bool V8DataModel::evalAsBool(const std::string& expr) { } -void V8DataModel::assign(const std::string& location, const Data& data) { +void V8DataModel::assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) { v8::Locker locker(_isolate); v8::Isolate::Scope isoScope(_isolate); @@ -754,8 +767,7 @@ void V8DataModel::assign(const std::string& location, const Data& data) { } } -void V8DataModel::init(const std::string& location, - const Data& data) { +void V8DataModel::init(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) { v8::Locker locker(_isolate); v8::Isolate::Scope isoScope(_isolate); v8::HandleScope scope(_isolate); @@ -774,26 +786,6 @@ void V8DataModel::init(const std::string& location, } } -std::string V8DataModel::andExpressions(std::list<std::string> expressions) { - if (expressions.size() == 0) - return ""; - - if (expressions.size() == 1) - return *(expressions.begin()); - - std::ostringstream exprSS; - exprSS << "("; - std::string conjunction = ""; - for (std::list<std::string>::const_iterator exprIter = expressions.begin(); - exprIter != expressions.end(); - exprIter++) { - exprSS << conjunction << "(" << *exprIter << ")"; - conjunction = " && "; - } - exprSS << ")"; - return exprSS.str(); -} - v8::Local<v8::Value> V8DataModel::evalAsValue(const std::string& expr, bool dontThrow) { // v8::Locker locker(_isolate); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h index 3b4d776..a9dbca1 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h @@ -73,10 +73,12 @@ public: virtual bool isDeclared(const std::string& expr); - virtual void assign(const std::string& location, const Data& data); - virtual void init(const std::string& location, const Data& data); - - virtual std::string andExpressions(std::list<std::string>); + virtual void assign(const std::string& location, + const Data& data, + const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()); + virtual void init(const std::string& location, + const Data& data, + const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()); protected: diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp index 2ad89b5..ad35f80 100644 --- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp @@ -349,9 +349,12 @@ Data LuaDataModel::evalAsData(const std::string& content) { throw originalError; // we will assume syntax error and throw } - if (retVals == 0) +#if 1 + // Note: Empty result is not an error test302, but how to do test488? + if (retVals == 0 && !isValidSyntax(trimmedExpr)) { throw originalError; // we will assume syntax error and throw - + } +#endif try { if (retVals == 1) { @@ -446,7 +449,7 @@ bool LuaDataModel::isDeclared(const std::string& expr) { } -void LuaDataModel::assign(const std::string& location, const Data& data) { +void LuaDataModel::assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) { if (location.length() == 0) { ERROR_EXECUTION_THROW("Assign element has neither id nor location"); } @@ -539,7 +542,7 @@ void LuaDataModel::assign(const std::string& location, const Data& data) { } } -void LuaDataModel::init(const std::string& location, const Data& data) { +void LuaDataModel::init(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) { luabridge::setGlobal(_luaState, luabridge::Nil(), location.c_str()); assign(location, data); } @@ -582,17 +585,4 @@ Data LuaDataModel::getAsData(const std::string& content) { return data; } - -std::string LuaDataModel::andExpressions(std::list<std::string> exprs) { - std::stringstream exprSS; - std::list<std::string>::const_iterator listIter; - std::string andExpr; - for (listIter = exprs.begin(); listIter != exprs.end(); listIter++) { - exprSS << andExpr << *listIter; - andExpr = " && "; - } - return exprSS.str(); -} - - } diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h index 7b7121f..85d7b53 100644 --- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.h +++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.h @@ -77,10 +77,12 @@ public: virtual bool isDeclared(const std::string& expr); - virtual void assign(const std::string& location, const Data& data); - virtual void init(const std::string& location, const Data& data); - - virtual std::string andExpressions(std::list<std::string>); + virtual void assign(const std::string& location, + const Data& data, + const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()); + virtual void init(const std::string& location, + const Data& data, + const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()); protected: diff --git a/src/uscxml/plugins/datamodel/null/NULLDataModel.h b/src/uscxml/plugins/datamodel/null/NULLDataModel.h index 4bea664..fba8577 100644 --- a/src/uscxml/plugins/datamodel/null/NULLDataModel.h +++ b/src/uscxml/plugins/datamodel/null/NULLDataModel.h @@ -90,24 +90,14 @@ public: return true; } - virtual void assign(const XERCESC_NS::DOMElement* assignElem, - const XERCESC_NS::DOMNode* node, - const std::string& content) {} - virtual void assign(const std::string& location, const Data& data) {} - - virtual void init(const XERCESC_NS::DOMElement* dataElem, - const XERCESC_NS::DOMNode* node, - const std::string& content) {} - virtual void init(const std::string& location, const Data& data) {} + virtual void assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) {} + virtual void init(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) {} virtual void setCallbacks(DataModelCallbacks* callbacks) { _callbacks = callbacks; } virtual void addExtension(DataModelExtension* ext) {} - virtual std::string andExpressions(std::list<std::string>) { - return ""; - } protected: diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp index a524c7e..14d24c3 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.cpp @@ -146,7 +146,7 @@ void PromelaDataModel::setEvent(const Event& event) { start != end; start = event.params.upper_bound(start->first)) { // only set first param key if (isNumeric(start->second.atom.c_str(), 10)) { - variable.compound["value"].compound["data"].compound[start->first] = strTo<int>(start->second.atom); + variable.compound["value"].compound["data"].compound[start->first] = Data(strTo<int>(start->second.atom)); } else { variable.compound["value"].compound["data"].compound[start->first] = start->second; } @@ -154,7 +154,7 @@ void PromelaDataModel::setEvent(const Event& event) { for (Event::namelist_t::const_iterator iter = event.namelist.begin(); iter != event.namelist.end(); iter++) { if (isNumeric(iter->second.atom.c_str(), 10)) { - variable.compound["value"].compound["data"].compound[iter->first] = strTo<int>(iter->second.atom); + variable.compound["value"].compound["data"].compound[iter->first] = Data(strTo<int>(iter->second.atom)); } else { variable.compound["value"].compound["data"].compound[iter->first] = iter->second; } @@ -225,11 +225,25 @@ void PromelaDataModel::setEvent(const Event& event) { PromelaParser arrayParser(ss.str(), 1, PromelaParser::PROMELA_EXPR); - setVariable(itemParser.ast, getVariable(arrayParser.ast)); + try { + setVariable(itemParser.ast, getVariable(arrayParser.ast)); + } catch (ErrorEvent e) { + // test150 + PromelaParser itemDeclParser("int " + item); // this is likely the wrong type + evaluateDecl(itemDeclParser.ast); + setVariable(itemParser.ast, getVariable(arrayParser.ast)); + } if (index.length() > 0) { PromelaParser indexParser(index, 1, PromelaParser::PROMELA_EXPR); - setVariable(indexParser.ast, iteration); + try { + setVariable(indexParser.ast, Data(iteration)); + } catch (ErrorEvent e) { + // test150 + PromelaParser indexDeclParser("int " + index); + evaluateDecl(indexDeclParser.ast); + setVariable(indexParser.ast, Data(iteration)); + } } } @@ -322,7 +336,7 @@ void PromelaDataModel::setEvent(const Event& event) { PromelaParserNode* name = *opIterAsgn++; int size = dataToInt(evaluateExpr(*opIterAsgn++)); - variable.compound["size"] = size; + variable.compound["size"] = Data(size); for (size_t i = 0; i < size; i++) { variable.compound["value"].array.push_back(Data(0, Data::INTERPRETED)); } @@ -385,7 +399,7 @@ void PromelaDataModel::setEvent(const Event& event) { return Data(false); if (iequals(node->value, "true")) return Data(true); - return strTo<int>(node->value); + return Data(strTo<int>(node->value)); case PML_NAME: case PML_VAR_ARRAY: case PML_CMPND: @@ -396,13 +410,13 @@ void PromelaDataModel::setEvent(const Event& event) { // return Data(node->value, Data::INTERPRETED); } case PML_PLUS: - return dataToInt(evaluateExpr(*opIter++)) + dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) + dataToInt(evaluateExpr(*opIter++))); case PML_MINUS: - return dataToInt(evaluateExpr(*opIter++)) - dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) - dataToInt(evaluateExpr(*opIter++))); case PML_DIVIDE: - return dataToInt(evaluateExpr(*opIter++)) / dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) / dataToInt(evaluateExpr(*opIter++))); case PML_MODULO: - return dataToInt(evaluateExpr(*opIter++)) % dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) % dataToInt(evaluateExpr(*opIter++))); case PML_EQ: { PromelaParserNode* lhs = *opIter++; PromelaParserNode* rhs = *opIter++; @@ -418,24 +432,24 @@ void PromelaDataModel::setEvent(const Event& event) { || (left.type == Data::VERBATIM && right.type == Data::VERBATIM)) { return (left.atom.compare(right.atom) == 0 ? Data(true) : Data(false)); } - return dataToInt(left) == dataToInt(right); + return Data(dataToInt(left) == dataToInt(right)); } case PML_NEG: - return !dataToBool(evaluateExpr(*opIter++)); + return Data(!dataToBool(evaluateExpr(*opIter++))); case PML_LT: - return dataToInt(evaluateExpr(*opIter++)) < dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) < dataToInt(evaluateExpr(*opIter++))); case PML_LE: - return dataToInt(evaluateExpr(*opIter++)) <= dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) <= dataToInt(evaluateExpr(*opIter++))); case PML_GT: - return dataToInt(evaluateExpr(*opIter++)) > dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) > dataToInt(evaluateExpr(*opIter++))); case PML_GE: - return dataToInt(evaluateExpr(*opIter++)) >= dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) >= dataToInt(evaluateExpr(*opIter++))); case PML_TIMES: - return dataToInt(evaluateExpr(*opIter++)) * dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) * dataToInt(evaluateExpr(*opIter++))); case PML_LSHIFT: - return dataToInt(evaluateExpr(*opIter++)) << dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) << dataToInt(evaluateExpr(*opIter++))); case PML_RSHIFT: - return dataToInt(evaluateExpr(*opIter++)) >> dataToInt(evaluateExpr(*opIter++)); + return Data(dataToInt(evaluateExpr(*opIter++)) >> dataToInt(evaluateExpr(*opIter++))); case PML_AND: case PML_OR: { PromelaParserNode* lhs = *opIter++; @@ -452,15 +466,15 @@ void PromelaDataModel::setEvent(const Event& event) { bool truthRight = dataToBool(right); if (node->type == PML_AND) { - return truthLeft && truthRight; + return Data(truthLeft && truthRight); } else { - return truthLeft || truthRight; + return Data(truthLeft || truthRight); } } default: ERROR_EXECUTION_THROW("Support for " + PromelaParserNode::typeToDesc(node->type) + " expressions not implemented"); } - return 0; + return Data(0, Data::INTERPRETED); } void PromelaDataModel::evaluateStmnt(void* ast) { @@ -481,12 +495,12 @@ void PromelaDataModel::setEvent(const Event& event) { } case PML_INCR: { PromelaParserNode* name = *opIter++; - setVariable(name, strTo<long>(getVariable(name)) + 1); + setVariable(name, Data(strTo<long>(getVariable(name)) + 1)); break; } case PML_DECR: { PromelaParserNode* name = *opIter++; - setVariable(name, strTo<long>(getVariable(name)) - 1); + setVariable(name, Data(strTo<long>(getVariable(name)) - 1)); break; } default: @@ -503,11 +517,6 @@ void PromelaDataModel::setEvent(const Event& event) { ERROR_EXECUTION_THROW("Cannot assign to " + node->value); } -// if (_variables.compound.find(name->value) == _variables.compound.end()) { -// // declare implicitly / convenience -// evaluateDecl(ast); -// } - switch (node->type) { case PML_VAR_ARRAY: { std::list<PromelaParserNode*>::iterator opIter = node->operands.begin(); @@ -515,6 +524,10 @@ void PromelaDataModel::setEvent(const Event& event) { PromelaParserNode* name = *opIter++; PromelaParserNode* expr = *opIter++; + if (!_variables.hasKey(name->value)) { + ERROR_EXECUTION_THROW("Variable " + name->value + " is undeclared"); + } + // is the location an array? if (!_variables[name->value].hasKey("size")) { ERROR_EXECUTION_THROW("Variable " + name->value + " is no array"); @@ -532,6 +545,10 @@ void PromelaDataModel::setEvent(const Event& event) { } case PML_NAME: { // location is an array, but no array was passed + if (!_variables.hasKey(node->value)) { + ERROR_EXECUTION_THROW("Variable " + node->value + " is undeclared"); + } + if (_variables[node->value].hasKey("size")) { if (value.compound.size() > 0 || value.atom.size() > 0) ERROR_EXECUTION_THROW("Variable " + node->value + " is an array"); @@ -547,6 +564,10 @@ void PromelaDataModel::setEvent(const Event& event) { std::list<PromelaParserNode*>::iterator opIter = node->operands.begin(); PromelaParserNode* name = *opIter++; + if (!_variables.hasKey(name->value)) { + ERROR_EXECUTION_THROW("Variable " + name->value + " is undeclared"); + } + // location is no array if (_variables[name->value].hasKey("size")) { ERROR_EXECUTION_THROW("Variable " + name->value + " is an array"); @@ -657,38 +678,43 @@ void PromelaDataModel::setEvent(const Event& event) { default: ERROR_EXECUTION_THROW("Retrieving value of " + PromelaParserNode::typeToDesc(node->type) + " variable not implemented"); } - return 0; + return Data(0, Data::INTERPRETED); } - std::string PromelaDataModel::andExpressions(std::list<std::string> expressions) { + void PromelaDataModel::assign(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) { + PromelaParser parser(location); + if (data.atom.size() > 0 && data.type == Data::INTERPRETED) { + setVariable(parser.ast, evalAsData(data.atom)); + } else { + setVariable(parser.ast, data); + } + } - if (expressions.size() == 0) - return ""; + void PromelaDataModel::init(const std::string& location, const Data& data, const std::map<std::string, std::string>& attr) { + { + std::string type = (attr.find("type") != attr.end() ? attr.at("type") : "auto"); + std::string arrSize; - if (expressions.size() == 1) - return *(expressions.begin()); + size_t bracketPos = type.find("["); + if (bracketPos != std::string::npos) { + arrSize = type.substr(bracketPos, type.length() - bracketPos); + type = type.substr(0, bracketPos); + } - std::ostringstream exprSS; - exprSS << "("; - std::string conjunction = ""; - for (std::list<std::string>::const_iterator exprIter = expressions.begin(); - exprIter != expressions.end(); - exprIter++) { - exprSS << conjunction << "(" << *exprIter << ")"; - conjunction = " && "; + std::string expr = type + " " + location + arrSize; + PromelaParser parser(expr, 1, PromelaParser::PROMELA_DECL); + evaluateDecl(parser.ast); } - exprSS << ")"; - return exprSS.str(); - } - void PromelaDataModel::assign(const std::string& location, const Data& data) { - // used for e.g. to assign command line parameters and idlocation PromelaParser parser(location); - setVariable(parser.ast, data); - } - - void PromelaDataModel::init(const std::string& location, const Data& data) { - assign(location, data); + if (data.atom.size() > 0 && data.type == Data::INTERPRETED) { + Data d = Data::fromJSON(data); + if (!d.empty()) + setVariable(parser.ast, Data::fromJSON(data)); + setVariable(parser.ast, data); + } else { + setVariable(parser.ast, data); + } } bool PromelaDataModel::isDeclared(const std::string& expr) { diff --git a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h index 2c1f58d..4a763ac 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h +++ b/src/uscxml/plugins/datamodel/promela/PromelaDataModel.h @@ -60,10 +60,12 @@ public: virtual bool isDeclared(const std::string& expr); - virtual void assign(const std::string& location, const Data& data); - virtual void init(const std::string& location, const Data& data); - - virtual std::string andExpressions(std::list<std::string>); + virtual void assign(const std::string& location, + const Data& data, + const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()); + virtual void init(const std::string& location, + const Data& data, + const std::map<std::string, std::string>& attr = std::map<std::string, std::string>()); protected: diff --git a/src/uscxml/plugins/datamodel/promela/PromelaParser.h b/src/uscxml/plugins/datamodel/promela/PromelaParser.h index 51a2111..236233d 100644 --- a/src/uscxml/plugins/datamodel/promela/PromelaParser.h +++ b/src/uscxml/plugins/datamodel/promela/PromelaParser.h @@ -83,7 +83,7 @@ public: PromelaParserNode* ast; Type type; - Event pendingException; + ErrorEvent pendingException; operator bool() const { return ast != NULL; } |