STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Unsupported type "<<typeStructure.dump()<<" for variable '"<<name<<"' (scope: "<<scopeDescription<<")");
STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Unsupported type "<<typeStructure.dump()<<" for variable '"<<variableName<<"' (scope: "<<scopeDescription<<")");
}
}elseif(typeStructure.is_object()){
STORM_LOG_THROW(typeStructure.count("kind")==1,storm::exceptions::InvalidJaniException,"For complex type as in variable "<<variableName<<"(scope: "<<scopeDescription<<") kind must be given");
@ -671,10 +671,10 @@ namespace storm {
}
}elseif(kind=="array"){
STORM_LOG_THROW(typeStructure.count("base")==1,storm::exceptions::InvalidJaniException,"For array type as in variable "<<variableName<<"(scope: "<<scopeDescription<<") base must be given");
STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Unsupported kind "<<kind<<" for complex type of variable "<<name<<"(scope: "<<scopeDescription<<") ");
STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Unsupported kind "<<kind<<" for complex type of variable "<<variableName<<"(scope: "<<scopeDescription<<") ");
}
}
}
@ -763,29 +763,31 @@ namespace storm {
}elseif(type.arrayBase){
STORM_LOG_THROW(type.arrayBase->basicType,storm::exceptions::InvalidJaniException,"Array base type for variable "+name+"(scope "+scopeDescription+") should be a BasicType or a BoundedType.");
STORM_LOG_THROW(initVal.get().hasArrayType(),storm::exceptions::InvalidJaniException,"Initial value for array variable "+name+"(scope "+scopeDescription+") should be an Array");
STORM_LOG_THROW(initVal->getType().isArrayType(),storm::exceptions::InvalidJaniException,"Initial value for array variable "+name+"(scope "+scopeDescription+") should be an Array");
STORM_LOG_THROW(expected==actual,storm::exceptions::InvalidJaniException,"Operator "<<opstring<<" expects "<<expected<<" arguments, but got "<<actual<<" in "<<errorInfo<<".");
storm::expressions::Expressionleft=parseExpression(expressionDecl.at("exp"),"Argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator);
storm::expressions::Expressionleft=parseExpression(expressionDecl.at("exp"),"Argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables);
storm::expressions::Expressionleft=parseExpression(expressionDecl.at("left"),"Left argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator);
storm::expressions::Expressionright=parseExpression(expressionDecl.at("right"),"Right argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator);
storm::expressions::Expressionleft=parseExpression(expressionDecl.at("left"),"Left argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables);
storm::expressions::Expressionright=parseExpression(expressionDecl.at("right"),"Right argument of operator "+opstring+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables);
return{left,right};
}
/**
@ -823,29 +825,79 @@ namespace storm {
STORM_LOG_THROW(expr.hasNumericalType(),storm::exceptions::InvalidJaniException,"Operator "<<opstring<<" expects argument "+std::to_string(argNr)+" to be numerical in "<<errorInfo<<".");
STORM_LOG_THROW(expr.hasIntegerType(),storm::exceptions::InvalidJaniException,"Operator "<<opstring<<" expects argument "+std::to_string(argNr)+" to be numerical in "<<errorInfo<<".");
STORM_LOG_THROW(expr.getType().isArrayType(),storm::exceptions::InvalidJaniException,"Operator "<<opstring<<" expects argument "+std::to_string(argNr)+" to be of type 'array' in "<<errorInfo<<".");
STORM_LOG_THROW(opstring=="aa",storm::exceptions::InvalidJaniException,"Unknown operation '"<<opstring<<"' occurs in "<<scopeDescription);
STORM_LOG_THROW(lValueStructure.count("exp"),storm::exceptions::InvalidJaniException,"Missing 'exp' in array access at "<<scopeDescription);
storm::jani::LValueexp=parseLValue(lValueStructure.at("exp"),"LValue description of array expression in "+scopeDescription,globalVars,constants,localVars);
STORM_LOG_THROW(lValueStructure.count("index"),storm::exceptions::InvalidJaniException,"Missing 'index' in array access at "<<scopeDescription);
storm::expressions::Expressionindex=parseExpression(lValueStructure.at("index"),"Index expression of array access at "+scopeDescription,globalVars,constants,localVars);
returnstorm::jani::LValue(exp,index);
}else{
STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Unknown identifier '"<<ident<<"' occurs in "<<scopeDescription);
STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Unknown LValue '"<<lValueStructure.dump()<<"' occurs in "<<scopeDescription);
arguments.push_back(parseExpression(expressionStructure.at("if"),"if-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator));
arguments.push_back(parseExpression(expressionStructure.at("then"),"then-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator));
arguments.push_back(parseExpression(expressionStructure.at("else"),"else-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator));
arguments.push_back(parseExpression(expressionStructure.at("if"),"if-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables));
arguments.push_back(parseExpression(expressionStructure.at("then"),"then-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables));
arguments.push_back(parseExpression(expressionStructure.at("else"),"else-formula in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables));
STORM_LOG_THROW(false,storm::exceptions::NotImplementedException,"log operation is not yet implemented");
}elseif(opstring=="aa"){
STORM_LOG_THROW(expressionStructure.count("exp")==1,storm::exceptions::InvalidJaniException,"Array access operator requires exactly one exp (at "+scopeDescription+").");
storm::expressions::Expressionexp=parseExpression(expressionStructure.at("exp"),"exp in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables);
STORM_LOG_THROW(expressionStructure.count("index")==1,storm::exceptions::InvalidJaniException,"Array access operator requires exactly one index (at "+scopeDescription+").");
storm::expressions::Expressionindex=parseExpression(expressionStructure.at("index"),"index in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables);
STORM_LOG_THROW(expressionStructure.count("elements")==1,storm::exceptions::InvalidJaniException,"Array value operator requires exactly one 'elements' (at "+scopeDescription+").");
elements.push_back(parseExpression(element,"element "+std::to_string(elements.size())+" in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables).getBaseExpressionPointer());
STORM_LOG_THROW(false,storm::exceptions::InvalidJaniException,"Incompatible element types "<<commonType<<" and "<<elements.back()->getType()<<" of array value expression at "<<scopeDescription);
STORM_LOG_THROW(expressionStructure.count("length")==1,storm::exceptions::InvalidJaniException,"Array access operator requires exactly one length (at "+scopeDescription+").");
storm::expressions::Expressionlength=parseExpression(expressionStructure.at("length"),"index in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,auxiliaryVariables);
STORM_LOG_THROW(expressionStructure.count("var")==1,storm::exceptions::InvalidJaniException,"Array access operator requires exactly one var (at "+scopeDescription+").");
std::stringindexVarName=getString(expressionStructure.at("var"),"Field 'var' of Array access operator (at "+scopeDescription+").");
STORM_LOG_THROW(auxiliaryVariables.find(indexVarName)==auxiliaryVariables.end(),storm::exceptions::InvalidJaniException,"Index variable "<<indexVarName<<" is already defined as an auxiliary variable (at "+scopeDescription+").");
STORM_LOG_THROW(expressionStructure.count("exp")==1,storm::exceptions::InvalidJaniException,"Array access operator requires exactly one exp (at "+scopeDescription+").");
storm::expressions::Expressionexp=parseExpression(expressionStructure.at("exp"),"exp in "+scopeDescription,globalVars,constants,localVars,returnNoneInitializedOnUnknownOperator,newAuxVars);
STORM_LOG_THROW(transientValueEntry.count("ref")==1,storm::exceptions::InvalidJaniException,"Transient values in location "<<locName<<" need exactly one ref that is assigned to");
STORM_LOG_THROW(transientValueEntry.count("value")==1,storm::exceptions::InvalidJaniException,"Transient values in location "<<locName<<" need exactly one assigned value");
storm::jani::Variableconst&lhs=getLValue(transientValueEntry.at("ref"),parentModel.getGlobalVariables(),automaton.getVariables(),"LHS of assignment in location "+locName+" (automaton '"+name+"')");
STORM_LOG_THROW(lhs.isTransient(),storm::exceptions::InvalidJaniException,"Assigned non-transient variable "+lhs.getName()+" in location "+locName+" (automaton: '"+name+"')");
storm::expressions::Expressionrhs=parseExpression(transientValueEntry.at("value"),"Assignment of variable "+lhs.getName()+" in location "+locName+" (automaton: '"+name+"')",globalVars,constants,localVars);
transientAssignments.emplace_back(lhs,rhs);
storm::jani::LValuelValue=parseLValue(transientValueEntry.at("ref"),"LHS of assignment in location "+locName+" (automaton '"+name+"')",globalVars,constants,localVars);
STORM_LOG_THROW(lValue.isTransient(),storm::exceptions::InvalidJaniException,"Assigned non-transient variable "<<lValue<<" in location "+locName+" (automaton: '"+name+"')");
storm::expressions::Expressionrhs=parseExpression(transientValueEntry.at("value"),"Assignment of lValue in location "+locName+" (automaton: '"+name+"')",globalVars,constants,localVars);
STORM_LOG_THROW(assignmentEntry.count("ref")==1,storm::exceptions::InvalidJaniException,"Assignment in edge from '"<<sourceLoc<<"' to '"<<targetLoc<<"' in automaton '"<<name<<"' must have one ref field");
std::stringrefstring=getString(assignmentEntry.at("ref"),"assignment in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'");
storm::jani::Variableconst&lhs=getLValue(refstring,parentModel.getGlobalVariables(),automaton.getVariables(),"Assignment variable in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'");
storm::jani::LValuelValue=parseLValue(refstring,"Assignment variable in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'",globalVars,constants,localVars);
// value
STORM_LOG_THROW(assignmentEntry.count("value")==1,storm::exceptions::InvalidJaniException,"Assignment in edge from '"<<sourceLoc<<"' to '"<<targetLoc<<"' in automaton '"<<name<<"' must have one value field");
storm::expressions::ExpressionassignmentExpr=parseExpression(assignmentEntry.at("value"),"assignment in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'",globalVars,constants,localVars);
@ -1220,7 +1310,7 @@ namespace storm {
if(assignmentEntry.count("index")>0){
assignmentIndex=getUnsignedInt(assignmentEntry.at("index"),"assignment index in edge from '"+sourceLoc+"' to '"+targetLoc+"' in automaton '"+name+"'");
STORM_LOG_THROW(i<elements.size(),storm::exceptions::InvalidArgumentException,"Tried to access the element with index "<<i<<" of an array of size "<<elements.size()<<".");
STORM_LOG_THROW(this->variableToExpressionMapping.find(expression.getIndexVar())==this->variableToExpressionMapping.end(),storm::exceptions::InvalidArgumentException,"substitution of the index variable of a constructorArrayExpression is not possible.");
// If the arguments did not change, we simply push the expression itself.