Skip to content

Commit

Permalink
Fix bug: #2374
Browse files Browse the repository at this point in the history
- Modelica.Electrical.QuasiStationary.Machines.Examples.TransformerTestbench.mos now works and gives correct results
- handle // ASUB(CAST(e)) -> CAST(liftArray(t), ASUB(e)) in ExpressionSimplify
- handle CAST(cref) in SimCodeUtil.createSingleComplexEqnCode2


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17447 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Sep 30, 2013
1 parent 0b323a3 commit 71b3476
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Compiler/BackEnd/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5477,7 +5477,7 @@ algorithm
vars = List.map(varlst, typesVarNoBinding);
rt_1 = sname :: rt;
(accRecDecls, rt_2) = elaborateNestedRecordDeclarations(varlst, accRecDecls, rt_1);
recDecl = SimCode.RECORD_DECL_FULL(sname, path, vars);
recDecl = SimCode.RECORD_DECL_FULL(sname, name, vars);
accRecDecls = List.appendElt(recDecl, accRecDecls);
then (accRecDecls, rt_2);

Expand Down Expand Up @@ -6097,6 +6097,21 @@ algorithm
Integer uniqueEqIndex;
list<DAE.Var> varLst;
HashSet.HashSet ht;

case (_, DAE.CAST(exp = e1), _, _, _, _)
equation
(equations_, ouniqueEqIndex, otempvars) =
createSingleComplexEqnCode2(crefs, e1, inExp4, iuniqueEqIndex, itempvars, source);
then
(equations_, ouniqueEqIndex, otempvars);

case (_, _, DAE.CAST(exp = e1), _, _, _)
equation
(equations_, ouniqueEqIndex, otempvars) =
createSingleComplexEqnCode2(crefs, inExp3, e1, iuniqueEqIndex, itempvars, source);
then
(equations_, ouniqueEqIndex, otempvars);

case (_, e1 as DAE.CREF(componentRef = cr2), e2, _, _, _)
equation
List.map1rAllValue(crefs, ComponentReference.crefPrefixOf, true, cr2);
Expand Down
8 changes: 8 additions & 0 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ algorithm
true = Config.acceptMetaModelicaGrammar();
then ((simplifyMetaModelica(e),(true,options)));

// ASUB(CAST(e)) -> CAST(liftArray(t), ASUB(e))
case ((DAE.ASUB(exp = DAE.CAST(tp,e), sub = subs),(_,options)))
equation
tp = Expression.unliftArray(tp);
e = DAE.CAST(tp, DAE.ASUB(e, subs));
then
((e, (true, options)));

// Simplify asubs where some of the subscripts are slices.
case ((DAE.ASUB(exp = e, sub = subs), (_, options)))
equation
Expand Down

0 comments on commit 71b3476

Please sign in to comment.