Skip to content

Commit

Permalink
[Backend] do not hide $-variables in result file
Browse files Browse the repository at this point in the history
 - instead mark $TMP and $CSE variables with hide result
 - fixing ticket:5021

Belonging to [master]:
  - OpenModelica/OMCompiler#2597
  - OpenModelica/OpenModelica-testsuite#1010
  • Loading branch information
kabdelhak authored and OpenModelica-Hudson committed Aug 9, 2018
1 parent fabb954 commit 8423437
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 36 deletions.
1 change: 1 addition & 0 deletions Compiler/BackEnd/BackendVariable.mo
Expand Up @@ -1600,6 +1600,7 @@ algorithm
outVar = BackendDAE.VAR(inCref, varKind, DAE.BIDIR(), DAE.NON_PARALLEL(), inType, NONE(), NONE(), {}, DAE.emptyElementSource, DAEUtil.setProtectedAttr(NONE(), true), NONE(), DAE.BCONST(false), NONE(), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
then outVar;
end match;
outVar := setHideResult(outVar, DAE.BCONST(true));
end createCSEVar;

public function generateVar
Expand Down
1 change: 1 addition & 0 deletions Compiler/BackEnd/DynamicOptimization.mo
Expand Up @@ -510,6 +510,7 @@ algorithm
equation
(var,_) = BackendVariable.getVarSingle(cr, vars);
true = BackendVariable.isVarOnTopLevelAndInput(var);
var = BackendVariable.setHideResult(var, DAE.BCONST(true));
cr1 = ComponentReference.prependStringCref("$TMP$DER$P", cr);
//cr1 = ComponentReference.crefPrefixDer(cr);
e = Expression.crefExp(cr1);
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/FindZeroCrossings.mo
Expand Up @@ -329,7 +329,7 @@ algorithm
ht := BaseHashTable.add((inCondition, inIndex), inHT);
crStr := "$whenCondition" + intString(inIndex);

var := BackendDAE.VAR(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), BackendDAE.DISCRETE(), DAE.BIDIR(), DAE.NON_PARALLEL(), DAE.T_BOOL_DEFAULT, NONE(), NONE(), {}, inSource, DAEUtil.setProtectedAttr(SOME(DAE.emptyVarAttrBool), true), NONE(), DAE.BCONST(false), SOME(SCode.COMMENT(NONE(), SOME(ExpressionDump.printExpStr(inCondition)))), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
var := BackendDAE.VAR(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), BackendDAE.DISCRETE(), DAE.BIDIR(), DAE.NON_PARALLEL(), DAE.T_BOOL_DEFAULT, NONE(), NONE(), {}, inSource, DAEUtil.setProtectedAttr(SOME(DAE.emptyVarAttrBool), true), NONE(), DAE.BCONST(true), SOME(SCode.COMMENT(NONE(), SOME(ExpressionDump.printExpStr(inCondition)))), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
var := BackendVariable.setVarFixed(var, true);
eqn := BackendDAE.EQUATION(DAE.CREF(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), DAE.T_BOOL_DEFAULT), inCondition, inSource, BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC);

Expand Down Expand Up @@ -484,7 +484,7 @@ algorithm
case (DAE.ARRAY(array={condition})) equation
crStr = "$whenCondition" + intString(inIndex);

var = BackendDAE.VAR(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), BackendDAE.DISCRETE(), DAE.BIDIR(), DAE.NON_PARALLEL(), DAE.T_BOOL_DEFAULT, NONE(), NONE(), {}, inSource, DAEUtil.setProtectedAttr(SOME(DAE.emptyVarAttrBool), true), NONE(), DAE.BCONST(false), SOME(SCode.COMMENT(NONE(), SOME(ExpressionDump.printExpStr(inCondition)))), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
var = BackendDAE.VAR(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), BackendDAE.DISCRETE(), DAE.BIDIR(), DAE.NON_PARALLEL(), DAE.T_BOOL_DEFAULT, NONE(), NONE(), {}, inSource, DAEUtil.setProtectedAttr(SOME(DAE.emptyVarAttrBool), true), NONE(), DAE.BCONST(true), SOME(SCode.COMMENT(NONE(), SOME(ExpressionDump.printExpStr(inCondition)))), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
var = BackendVariable.setVarFixed(var, true);
stmt = DAE.STMT_ASSIGN(DAE.T_BOOL_DEFAULT, DAE.CREF(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), DAE.T_BOOL_DEFAULT), condition, inSource);

Expand All @@ -500,7 +500,7 @@ algorithm
case _ equation
crStr = "$whenCondition" + intString(inIndex);

var = BackendDAE.VAR(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), BackendDAE.DISCRETE(), DAE.BIDIR(), DAE.NON_PARALLEL(), DAE.T_BOOL_DEFAULT, NONE(), NONE(), {}, inSource, DAEUtil.setProtectedAttr(SOME(DAE.emptyVarAttrBool), true), NONE(), DAE.BCONST(false), SOME(SCode.COMMENT(NONE(), SOME(ExpressionDump.printExpStr(inCondition)))), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
var = BackendDAE.VAR(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), BackendDAE.DISCRETE(), DAE.BIDIR(), DAE.NON_PARALLEL(), DAE.T_BOOL_DEFAULT, NONE(), NONE(), {}, inSource, DAEUtil.setProtectedAttr(SOME(DAE.emptyVarAttrBool), true), NONE(), DAE.BCONST(true), SOME(SCode.COMMENT(NONE(), SOME(ExpressionDump.printExpStr(inCondition)))), DAE.NON_CONNECTOR(), DAE.NOT_INNER_OUTER(), true);
var = BackendVariable.setVarFixed(var, true);
stmt = DAE.STMT_ASSIGN(DAE.T_BOOL_DEFAULT, DAE.CREF(DAE.CREF_IDENT(crStr, DAE.T_BOOL_DEFAULT, {}), DAE.T_BOOL_DEFAULT), inCondition, inSource);

Expand Down
8 changes: 4 additions & 4 deletions Compiler/SimCode/SimCodeUtil.mo
Expand Up @@ -2690,7 +2690,7 @@ algorithm

case(DAE.CREF(cr, ty)::rest) equation
slst = List.map(dims, intString);
var = SimCodeVar.SIMVAR(cr, BackendDAE.VARIABLE(), "", "", "", 0, NONE(), NONE(), NONE(), NONE(), false, ty, false, SOME(name), SimCodeVar.NOALIAS(), DAE.emptyElementSource, SimCodeVar.NONECAUS(), NONE(), slst, false, true, false, NONE(), NONE());
var = SimCodeVar.SIMVAR(cr, BackendDAE.VARIABLE(), "", "", "", 0, NONE(), NONE(), NONE(), NONE(), false, ty, false, SOME(name), SimCodeVar.NOALIAS(), DAE.emptyElementSource, SimCodeVar.NONECAUS(), NONE(), slst, false, true, true, NONE(), NONE());
tempvars = createTempVarsforCrefs(rest, {var});
then List.append_reverse(tempvars, itempvars);
end match;
Expand Down Expand Up @@ -2726,7 +2726,7 @@ algorithm
arrayCref = ComponentReference.getArrayCref(cr);
inst_dims = ComponentReference.crefDims(cr);
numArrayElement = List.map(inst_dims, ExpressionDump.dimensionString);
var = SimCodeVar.SIMVAR(cr, BackendDAE.VARIABLE(), "", "", "", 0, NONE(), NONE(), NONE(), NONE(), false, ty, false, arrayCref, SimCodeVar.NOALIAS(), DAE.emptyElementSource, SimCodeVar.NONECAUS(), NONE(), numArrayElement, false, true, false, NONE(), NONE());
var = SimCodeVar.SIMVAR(cr, BackendDAE.VARIABLE(), "", "", "", 0, NONE(), NONE(), NONE(), NONE(), false, ty, false, arrayCref, SimCodeVar.NOALIAS(), DAE.emptyElementSource, SimCodeVar.NONECAUS(), NONE(), numArrayElement, false, true, true, NONE(), NONE());
then createTempVarsforCrefs(rest, var::itempvars);
end match;
end createTempVarsforCrefs;
Expand Down Expand Up @@ -2769,13 +2769,13 @@ algorithm
arraycref := ComponentReference.crefStripSubs(cr);
ty := ComponentReference.crefTypeFull(cr);
var := SimCodeVar.SIMVAR(cr, BackendDAE.VARIABLE(), "", "", "", 0, NONE(), NONE(), NONE(), NONE(), false,
ty, false, SOME(arraycref), SimCodeVar.NOALIAS(), DAE.emptyElementSource, SimCodeVar.NONECAUS(), NONE(), {}, false, true, false, NONE(), NONE());
ty, false, SOME(arraycref), SimCodeVar.NOALIAS(), DAE.emptyElementSource, SimCodeVar.NONECAUS(), NONE(), {}, false, true, true, NONE(), NONE());

/* The rest don't need to be marked i.e. we have 'NONE()'. Just create simvars. */
ttmpvars := {var};
for cr in crlst loop
ty := ComponentReference.crefTypeFull(cr);
var := SimCodeVar.SIMVAR(cr, BackendDAE.VARIABLE(), "", "", "", 0, NONE(), NONE(), NONE(), NONE(), false, ty, false, NONE(), SimCodeVar.NOALIAS(), DAE.emptyElementSource, SimCodeVar.NONECAUS(), NONE(), {}, false, true, false, NONE(), NONE());
var := SimCodeVar.SIMVAR(cr, BackendDAE.VARIABLE(), "", "", "", 0, NONE(), NONE(), NONE(), NONE(), false, ty, false, NONE(), SimCodeVar.NOALIAS(), DAE.emptyElementSource, SimCodeVar.NONECAUS(), NONE(), {}, false, true, true, NONE(), NONE());
ttmpvars := var::ttmpvars;
end for;
ttmpvars := Dangerous.listReverseInPlace(ttmpvars);
Expand Down
34 changes: 5 additions & 29 deletions SimulationRuntime/c/simulation/simulation_input_xml.c
Expand Up @@ -607,11 +607,7 @@ void read_input_xml(MODEL_DATA* modelData,
omc_ScalarVariable *v = *findHashLongVar(in, i); \
read_var_info(v, info); \
read_var_attribute(v, attribute); \
if (info->name[0] == '$') \
{ \
out[j].filterOutput = 1; \
} \
else if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(v, "isProtected"), "true") && 0 == strcmp(findHashStringString(v, "hideResult"), "true")) \
if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(v, "isProtected"), "true") && 0 == strcmp(findHashStringString(v, "hideResult"), "true")) \
{ \
infoStreamPrint(LOG_DEBUG, 0, "filtering protected variable %s", info->name); \
out[j].filterOutput = 1; \
Expand Down Expand Up @@ -671,12 +667,7 @@ void read_input_xml(MODEL_DATA* modelData,
}
infoStreamPrint(LOG_DEBUG, 0, "read for %s negated %d from setup file", modelData->realAlias[i].info.name, modelData->realAlias[i].negate);

if(modelData->realAlias[i].info.name[0] == '$')
{
/* filter internal variables */
modelData->realAlias[i].filterOutput = 1;
}
else if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(*findHashLongVar(mi.rAli,i), "isProtected"), "true") && 0 == strcmp(findHashStringString(*findHashLongVar(mi.rAli,i), "hideResult"), "true"))
if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(*findHashLongVar(mi.rAli,i), "isProtected"), "true") && 0 == strcmp(findHashStringString(*findHashLongVar(mi.rAli,i), "hideResult"), "true"))
{
infoStreamPrint(LOG_DEBUG, 0, "filtering protected variable %s", modelData->realAlias[i].info.name);
modelData->realAlias[i].filterOutput = 1;
Expand Down Expand Up @@ -728,12 +719,7 @@ void read_input_xml(MODEL_DATA* modelData,

infoStreamPrint(LOG_DEBUG, 0, "read for %s negated %d from setup file",modelData->integerAlias[i].info.name,modelData->integerAlias[i].negate);

/* filter internal variables */
if(modelData->integerAlias[i].info.name[0] == '$')
{
modelData->integerAlias[i].filterOutput = 1;
}
else if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(*findHashLongVar(mi.iAli,i), "isProtected"), "true") && 0 == strcmp(findHashStringString(*findHashLongVar(mi.iAli,i), "hideResult"), "true"))
if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(*findHashLongVar(mi.iAli,i), "isProtected"), "true") && 0 == strcmp(findHashStringString(*findHashLongVar(mi.iAli,i), "hideResult"), "true"))
{
infoStreamPrint(LOG_DEBUG, 0, "filtering protected variable %s", modelData->integerAlias[i].info.name);
modelData->integerAlias[i].filterOutput = 1;
Expand Down Expand Up @@ -782,12 +768,7 @@ void read_input_xml(MODEL_DATA* modelData,

infoStreamPrint(LOG_DEBUG, 0, "read for %s negated %d from setup file", modelData->booleanAlias[i].info.name, modelData->booleanAlias[i].negate);

if(modelData->booleanAlias[i].info.name[0] == '$')
{
/* filter internal variables */
modelData->booleanAlias[i].filterOutput = 1;
}
else if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(*findHashLongVar(mi.bAli,i), "isProtected"), "true") && 0 == strcmp(findHashStringString(*findHashLongVar(mi.bAli,i), "hideResult"), "true"))
if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(*findHashLongVar(mi.bAli,i), "isProtected"), "true") && 0 == strcmp(findHashStringString(*findHashLongVar(mi.bAli,i), "hideResult"), "true"))
{
infoStreamPrint(LOG_DEBUG, 0, "filtering protected variable %s", modelData->booleanAlias[i].info.name);
modelData->booleanAlias[i].filterOutput = 1;
Expand Down Expand Up @@ -835,12 +816,7 @@ void read_input_xml(MODEL_DATA* modelData,
}
infoStreamPrint(LOG_DEBUG, 0, "read for %s negated %d from setup file", modelData->stringAlias[i].info.name, modelData->stringAlias[i].negate);

if(modelData->stringAlias[i].info.name[0] == '$')
{
/* filter internal variables */
modelData->stringAlias[i].filterOutput = 1;
}
else if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(*findHashLongVar(mi.sAli,i), "isProtected"), "true") && 0 == strcmp(findHashStringString(*findHashLongVar(mi.sAli,i), "hideResult"), "true"))
if (!omc_flag[FLAG_EMIT_PROTECTED] && 0 == strcmp(findHashStringString(*findHashLongVar(mi.sAli,i), "isProtected"), "true") && 0 == strcmp(findHashStringString(*findHashLongVar(mi.sAli,i), "hideResult"), "true"))
{
infoStreamPrint(LOG_DEBUG, 0, "filtering protected variable %s", modelData->stringAlias[i].info.name);
modelData->stringAlias[i].filterOutput = 1;
Expand Down

0 comments on commit 8423437

Please sign in to comment.