Skip to content

Commit 63643f3

Browse files
committed
Started using elabExpInExpression instead of elabExp in many places (so functions returning multiple outputs work better)
Note: This interferes slightly with the MetaModelica type system (things RML did not handle; so no changes needed). The changes cause MetaModelica models using equations with tuples to fail (but that is okay; we do not use MetaModelica in models) git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21933 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 8fb864a commit 63643f3

File tree

6 files changed

+237
-221
lines changed

6 files changed

+237
-221
lines changed

Compiler/FrontEnd/InstSection.mo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ algorithm
462462
// equality equations e1 = e2
463463
case (cache,env,ih,pre,csets,ci_state,SCode.EQ_EQUALS(expLeft = e1,expRight = e2,info = info,comment=comment),initial_,impl,graph,_)
464464
equation
465-
// Do static analysis and constant evaluation of expressions.
465+
// Do static analysis and constant evaluation of expressions.
466466
// Gives expression and properties
467467
// (Type bool | (Type Const as (bool | Const list))).
468468
// For a function, it checks the funtion name.
@@ -476,6 +476,7 @@ algorithm
476476
// Returns the output parameters from the function.
477477
(cache,e1_1,prop1,_) = Static.elabExp(cache, env, e1, impl, NONE(), true /*do vectorization*/, pre, info);
478478
(cache,e2_1,prop2,_) = Static.elabExp(cache, env, e2, impl, NONE(), true /*do vectorization*/, pre, info);
479+
479480
(cache, e1_1, prop1) = Ceval.cevalIfConstant(cache, env, e1_1, prop1, impl, info);
480481
(cache, e2_1, prop2) = Ceval.cevalIfConstant(cache, env, e2_1, prop2, impl, info);
481482

Compiler/FrontEnd/Patternm.mo

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,7 @@ algorithm
19371937
((_,useTree)) = Expression.traverseExp(DAE.META_OPTION(dPatternGuard), useLocalCref, useTree);
19381938
(elabPatterns,_) = traversePatternList(elabPatterns, checkDefUsePattern, (localsTree,useTree,patternInfo));
19391939
elabCase = DAE.CASE(elabPatterns, dPatternGuard, caseDecls, body, elabResult, resultInfo, 0, info);
1940+
(elabResult,resType) = makeTupleFromMetaTuple(elabResult,resType);
19401941
then (cache,elabCase,elabResult,resType,st);
19411942

19421943
// ELSE is the same as CASE, but without pattern
@@ -2755,4 +2756,24 @@ algorithm
27552756
Error.assertionOrAddSourceMessage(b or not Flags.isSet(Flags.PATTERNM_ALL_INFO),Error.META_DEAD_CODE,{"Statement optimised away"},DAEUtil.getElementSourceFileInfo(Algorithm.getStatementSource(statement)));
27562757
end isNotDummyStatement;
27572758

2759+
protected function makeTupleFromMetaTuple
2760+
input Option<DAE.Exp> inExp;
2761+
input Option<DAE.Type> inType;
2762+
output Option<DAE.Exp> exp;
2763+
output Option<DAE.Type> ty;
2764+
algorithm
2765+
(exp,ty) := match (inExp,inType)
2766+
local
2767+
list<DAE.Exp> exps;
2768+
list<DAE.Type> tys,tys2;
2769+
list<Absyn.Path> source;
2770+
case (SOME(DAE.META_TUPLE(exps)),SOME(DAE.T_METATUPLE(types=tys,source=source)))
2771+
equation
2772+
tys2 = List.map(tys, Types.unboxedType);
2773+
(exps,tys2) = Types.matchTypeTuple(exps, tys, tys2, false);
2774+
then (SOME(DAE.TUPLE(exps)),SOME(DAE.T_TUPLE(tys2,source)));
2775+
else (inExp,inType);
2776+
end match;
2777+
end makeTupleFromMetaTuple;
2778+
27582779
end Patternm;

0 commit comments

Comments
 (0)