Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Handle ASUB for change()


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15502 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 7, 2013
1 parent 5a9b755 commit c56bcd7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
11 changes: 11 additions & 0 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -9468,5 +9468,16 @@ algorithm
end match;
end transposeArray;

public function getCrefFromCrefOrAsub
"Get the cref from an expression that might be ASUB. If so, return the base CREF (this function does *not* always return a CREF with the same type as the full expression)."
input DAE.Exp exp;
output DAE.ComponentRef cr;
algorithm
cr := match exp
case DAE.CREF(componentRef=cr) then cr;
case DAE.ASUB(exp=DAE.CREF(componentRef=cr)) then cr;
end match;
end getCrefFromCrefOrAsub;

end Expression;

25 changes: 13 additions & 12 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -5200,36 +5200,37 @@ algorithm
Prefix.Prefix pre;
String sp;

case (cache,env,{(exp as Absyn.CREF(componentRef = cr))},_,impl,pre,_) /* simple type, constant variability */
equation
(cache,exp_1,DAE.PROP(tp1,c),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
_ = Expression.getCrefFromCrefOrAsub(exp_1);
true = Types.isParameterOrConstant(c);
then (cache, DAE.BCONST(false), DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_CONST()));

case (cache,env,{(exp as Absyn.CREF(componentRef = cr))},_,impl,pre,_) /* simple type, \'discrete\' variable */
equation
(cache,(exp_1 as DAE.CREF(cr_1,_)),DAE.PROP(tp1,_),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
(cache,exp_1,DAE.PROP(tp1,_),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
Types.simpleType(tp1);
cr_1 = Expression.getCrefFromCrefOrAsub(exp_1);
(cache,DAE.ATTR(variability = SCode.DISCRETE()),_,_,_,_,_,_,_) = Lookup.lookupVar(cache,env, cr_1);
exp_1 = Expression.makeBuiltinCall("change", {exp_1}, DAE.T_BOOL_DEFAULT);
then
(cache, exp_1, DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_VAR()));

case (cache,env,{(exp as Absyn.CREF(componentRef = cr))},_,impl,pre,_) /* simple type, boolean or integer => discrete variable */
equation
(cache,(exp_1 as DAE.CREF(cr_1,_)),DAE.PROP(tp1,_),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
(cache,exp_1,DAE.PROP(tp1,_),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
_ = Expression.getCrefFromCrefOrAsub(exp_1);
Types.simpleType(tp1);
Types.discreteType(tp1);
exp_1 = Expression.makeBuiltinCall("change", {exp_1}, DAE.T_BOOL_DEFAULT);
then
(cache, exp_1, DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_VAR()));

case (cache,env,{(exp as Absyn.CREF(componentRef = cr))},_,impl,pre,_) /* simple type, constant variability */
equation
(cache,(exp_1 as DAE.CREF(cr_1,_)),DAE.PROP(tp1,c),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
true = Types.isParameterOrConstant(c);
Types.simpleType(tp1);
exp_1 = Expression.makeBuiltinCall("change", {exp_1}, DAE.T_BOOL_DEFAULT);
then
(cache, exp_1, DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_VAR()));

case (cache,env,{(exp as Absyn.CREF(componentRef = cr))},_,impl,pre,_)
equation
(cache,(exp_1 as DAE.CREF(cr_1,_)),DAE.PROP(tp1,_),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
(cache,exp_1,DAE.PROP(tp1,_),_) = elabExp(cache,env, exp, impl,NONE(),true,pre,info);
cr_1 = Expression.getCrefFromCrefOrAsub(exp_1);
Types.simpleType(tp1);
(cache,_,_,_,_,_,_,_,_) = Lookup.lookupVar(cache,env, cr_1);
sp = PrefixUtil.printPrefixStr3(pre);
Expand Down

0 comments on commit c56bcd7

Please sign in to comment.