Skip to content

Commit eaa9d77

Browse files
committed
#2862 - testing performance of not replacing size(exp, 1) with a non-constant expressions
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22610 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent b6301f4 commit eaa9d77

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Compiler/FrontEnd/Expression.mo

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,24 @@ algorithm
556556
end match;
557557
end liftArrayR;
558558

559+
public function dimensionSizeConstantExp
560+
"Converts (extracts) a dimension to an expression.
561+
This function will fail if dimension is unknown or an expression (in case the dimension is from a different scope).
562+
If you want to(kind of) handle unknown dims use dimensionSizeExpHandleUnkown."
563+
input DAE.Dimension dim;
564+
output DAE.Exp exp;
565+
algorithm
566+
exp := match(dim)
567+
local
568+
Integer i;
569+
DAE.Exp e;
570+
571+
case DAE.DIM_INTEGER(integer = i) then DAE.ICONST(i);
572+
case DAE.DIM_ENUM(size = i) then DAE.ICONST(i);
573+
case DAE.DIM_BOOLEAN() then DAE.ICONST(2);
574+
end match;
575+
end dimensionSizeConstantExp;
576+
559577
public function dimensionSizeExp
560578
"Converts (extracts) a dimension to an expression.
561579
This function will fail if dimension is unknown. i.e. DIM_UNKNOWN.

Compiler/FrontEnd/Static.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3352,7 +3352,7 @@ algorithm
33523352
dim_count = listLength(inDimensions);
33533353
true = (dim_int > 0 and dim_int <= dim_count);
33543354
dim = listNth(inDimensions, dim_int - 1);
3355-
exp = Expression.dimensionSizeExp(dim);
3355+
exp = Expression.dimensionSizeConstantExp(dim);
33563356
prop = DAE.PROP(DAE.T_INTEGER_DEFAULT, DAE.C_CONST());
33573357
then
33583358
(SOME(exp), SOME(prop));

0 commit comments

Comments
 (0)