Skip to content

Commit 51201a0

Browse files
committed
Added missing DAE.DIM_BOOLEAN (analogous to DIM_ENUM)
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15954 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 705fc3f commit 51201a0

File tree

12 files changed

+81
-57
lines changed

12 files changed

+81
-57
lines changed

Compiler/FrontEnd/Ceval.mo

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5381,6 +5381,12 @@ algorithm
53815381
then
53825382
(cache,DAE.INDEX(e1_1));
53835383

5384+
case (cache,env,DAE.INDEX(exp = e1),dim,impl,msg,_)
5385+
equation
5386+
(cache,v1 as Values.BOOL(_),_) = ceval(cache,env, e1, impl,NONE(),msg,numIter+1);
5387+
e1_1 = ValuesUtil.valueExp(v1);
5388+
then (cache,DAE.INDEX(e1_1));
5389+
53845390
// an expression slice that can be constant evaluated
53855391
case (cache,env,DAE.SLICE(exp = e1),dim,impl,msg,_)
53865392
equation
@@ -6855,6 +6861,9 @@ algorithm
68556861
case (_, _, DAE.DIM_ENUM(size = dim_int), _, _, _, _)
68566862
then (inCache, Values.INTEGER(dim_int), inST);
68576863

6864+
case (_, _, DAE.DIM_BOOLEAN(), _, _, _, _)
6865+
then (inCache, Values.INTEGER(2), inST);
6866+
68586867
// Dimension given by expression, evaluate the expression.
68596868
case (_, _, DAE.DIM_EXP(exp = exp), _, _, _, _)
68606869
equation

Compiler/FrontEnd/ComponentReference.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,6 +2829,8 @@ algorithm
28292829
then
28302830
List.map(enum_expl, Expression.makeIndexSubscript);
28312831

2832+
case DAE.DIM_BOOLEAN() then DAE.INDEX(DAE.BCONST(false))::DAE.INDEX(DAE.BCONST(true))::{};
2833+
28322834
end match;
28332835
end expandDimension;
28342836

Compiler/FrontEnd/DAE.mo

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,9 @@ uniontype Dimension
10211021
Integer integer;
10221022
end DIM_INTEGER;
10231023

1024+
record DIM_BOOLEAN "Dimension given by Boolean"
1025+
end DIM_BOOLEAN;
1026+
10241027
record DIM_ENUM "Dimension given by an enumeration."
10251028
Absyn.Path enumTypeName "The enumeration type name.";
10261029
list<String> literals "A list of the literals in the enumeration.";

Compiler/FrontEnd/Expression.mo

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ algorithm
485485

486486
case DAE.DIM_INTEGER(integer = i) then DAE.ICONST(i);
487487
case DAE.DIM_ENUM(size = i) then DAE.ICONST(i);
488+
case DAE.DIM_BOOLEAN() then DAE.ICONST(2);
488489
case DAE.DIM_EXP(exp = e) then e;
489490
end match;
490491
end dimensionSizeExp;
@@ -509,6 +510,7 @@ algorithm
509510

510511
case DAE.DIM_INTEGER(integer = i) then DAE.INDEX(DAE.ICONST(i));
511512
case DAE.DIM_ENUM(size = i) then DAE.INDEX(DAE.ICONST(i));
513+
case DAE.DIM_BOOLEAN() then DAE.INDEX(DAE.ICONST(2));
512514
case DAE.DIM_UNKNOWN() then DAE.WHOLEDIM();
513515
end match;
514516
end dimensionSubscript;
@@ -1816,6 +1818,7 @@ algorithm
18161818
Integer i;
18171819
case DAE.DIM_INTEGER(integer = i) then i;
18181820
case DAE.DIM_ENUM(size = i) then i;
1821+
case DAE.DIM_BOOLEAN() then 2;
18191822
case DAE.DIM_EXP(exp = DAE.ICONST(integer = i)) then i;
18201823
case DAE.DIM_EXP(exp = DAE.ENUM_LITERAL(index = i)) then i;
18211824
end match;
@@ -1826,27 +1829,15 @@ public function addDimensions
18261829
input DAE.Dimension dim2;
18271830
output DAE.Dimension dim;
18281831
algorithm
1829-
dim := match(dim1,dim2)
1832+
dim := matchcontinue (dim1,dim2)
18301833
local
18311834
Integer i1,i2,i;
1832-
case (DAE.DIM_INTEGER(integer = i1),DAE.DIM_INTEGER(integer = i2))
1833-
equation
1834-
i = i1+i2;
1835-
then DAE.DIM_INTEGER(i);
1836-
case (DAE.DIM_ENUM(size = i1),DAE.DIM_INTEGER(integer = i2))
1837-
equation
1838-
i = i1+i2;
1839-
then DAE.DIM_INTEGER(i);
1840-
case (DAE.DIM_INTEGER(integer = i1),DAE.DIM_ENUM(size = i2))
1841-
equation
1842-
i = i1+i2;
1843-
then DAE.DIM_INTEGER(i);
1844-
case (DAE.DIM_ENUM(size = i1),DAE.DIM_ENUM(size = i2))
1835+
case (_,_)
18451836
equation
1846-
i = i1+i2;
1837+
i = dimensionSize(dim1)+dimensionSize(dim2);
18471838
then DAE.DIM_INTEGER(i);
18481839
else DAE.DIM_UNKNOWN();
1849-
end match;
1840+
end matchcontinue;
18501841
end addDimensions;
18511842

18521843
public function dimensionSizeAll
@@ -1861,6 +1852,7 @@ algorithm
18611852
DAE.Exp e;
18621853
case DAE.DIM_INTEGER(integer = i) then i;
18631854
case DAE.DIM_ENUM(size = i) then i;
1855+
case DAE.DIM_BOOLEAN() then 2;
18641856
case DAE.DIM_EXP(exp = e) then expInt(e);
18651857
case DAE.DIM_EXP(exp = _)
18661858
equation
@@ -8298,6 +8290,7 @@ algorithm
82988290
known := matchcontinue(dim)
82998291
case DAE.DIM_UNKNOWN() then false;
83008292
case DAE.DIM_EXP(exp = DAE.ICONST(integer = _)) then true;
8293+
case DAE.DIM_EXP(exp = DAE.BCONST(bool = _)) then true;
83018294
case DAE.DIM_EXP(exp = DAE.ENUM_LITERAL(index = _)) then true;
83028295
case DAE.DIM_EXP(exp = _) then false;
83038296
case _ then true;
@@ -8875,6 +8868,7 @@ algorithm
88758868
i := match dim
88768869
case DAE.DIM_INTEGER(integer=i) then i;
88778870
case DAE.DIM_ENUM(size=i) then i;
8871+
case DAE.DIM_BOOLEAN() then 2;
88788872
else complexityDimLarge;
88798873
end match;
88808874
end dimComplexity;

Compiler/FrontEnd/ExpressionDump.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,8 @@ algorithm
16361636
then
16371637
s;
16381638

1639+
case DAE.DIM_BOOLEAN() then "Boolean";
1640+
16391641
case DAE.DIM_INTEGER(integer = x)
16401642
equation
16411643
s = intString(x);

Compiler/FrontEnd/Inst.mo

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9380,35 +9380,8 @@ algorithm
93809380
DAE.Dimension dim;
93819381

93829382
case ({},ty) then ty;
9383-
case ((DAE.DIM_INTEGER(integer = i) :: xs),tty)
9384-
equation
9385-
ty_1 = makeArrayType(xs, tty);
9386-
ts = Types.getTypeSource(tty);
9387-
then
9388-
DAE.T_ARRAY(ty_1,{DAE.DIM_INTEGER(i)},ts);
9389-
9390-
case ((DAE.DIM_ENUM(size = i) :: xs), tty)
9391-
equation
9392-
ty_1 = makeArrayType(xs, tty);
9393-
ts = Types.getTypeSource(tty);
9394-
then
9395-
DAE.T_ARRAY(ty_1,{DAE.DIM_INTEGER(i)},ts);
9396-
9397-
/*case ((DAE.DIM_SUBSCRIPT(subscript = _) :: xs),tty)
9398-
equation
9399-
ty_1 = makeArrayType(xs, tty);
9400-
ts = Types.getTypeSource(tty);
9401-
then
9402-
DAE.T_ARRAY(ty_1,{DAE.DIM_UNKNOWN()},ts);*/
94039383

9404-
case (DAE.DIM_UNKNOWN() :: xs, tty)
9405-
equation
9406-
ty_1 = makeArrayType(xs, tty);
9407-
ts = Types.getTypeSource(tty);
9408-
then
9409-
DAE.T_ARRAY(ty_1, {DAE.DIM_UNKNOWN()}, ts);
9410-
9411-
case ((dim as DAE.DIM_EXP(exp = _)) :: xs, tty)
9384+
case (dim :: xs, tty)
94129385
equation
94139386
ty_1 = makeArrayType(xs, tty);
94149387
ts = Types.getTypeSource(tty);
@@ -10301,6 +10274,7 @@ algorithm
1030110274
case (DAE.DIM_UNKNOWN(),_) then DAE.WHOLEDIM();
1030210275
case (DAE.DIM_INTEGER(integer = i),_) then DAE.INDEX(DAE.ICONST(i));
1030310276
case (DAE.DIM_ENUM(size = i), _) then DAE.INDEX(DAE.ICONST(i));
10277+
case (DAE.DIM_BOOLEAN(), _) then DAE.INDEX(DAE.ICONST(2));
1030410278
case (DAE.DIM_EXP(exp = e), _) then DAE.INDEX(e);
1030510279
end match;
1030610280
end instDimExp;
@@ -10320,6 +10294,7 @@ algorithm
1032010294
case (DAE.DIM_UNKNOWN(),_) then DAE.WHOLEDIM();
1032110295
case (DAE.DIM_INTEGER(integer = i),_) then DAE.WHOLE_NONEXP(DAE.ICONST(i));
1032210296
case (DAE.DIM_ENUM(size = i), _) then DAE.WHOLE_NONEXP(DAE.ICONST(i));
10297+
case (DAE.DIM_BOOLEAN(), _) then DAE.WHOLE_NONEXP(DAE.ICONST(2));
1032310298
//case (DAE.DIM_EXP(exp = e as DAE.RANGE(exp = _)), _) then DAE.INDEX(e);
1032410299
case (DAE.DIM_EXP(exp = e), _) then DAE.WHOLE_NONEXP(e);
1032510300
end match;
@@ -10703,13 +10678,13 @@ algorithm
1070310678
DAE.Exp e,lhs,rhs;
1070410679
DAE.Properties p;
1070510680
Env.Cache cache;
10706-
Env.Env env_1,env,compenv;
10681+
Env.Env env_1,env_2,env,compenv;
1070710682
Connect.Sets csets;
1070810683
DAE.Type ty;
1070910684
ClassInf.State st,ci_state;
1071010685
DAE.ComponentRef cr;
1071110686
DAE.Type ty_1;
10712-
DAE.Mod mod,mod_1;
10687+
DAE.Mod mod,mod_1,mod_2;
1071310688
Prefix.Prefix pre;
1071410689
String n, str1, str2, str3, str4;
1071510690
SCode.Element cl;
@@ -10865,6 +10840,18 @@ algorithm
1086510840
then
1086610841
(cache,env,ih,store,DAEUtil.emptyDae,csets,DAE.T_UNKNOWN_DEFAULT,graph);
1086710842

10843+
case (cache, env, ih, store, ci_state, mod, pre, n, (cl, attr), pf, i, DAE.DIM_BOOLEAN(), dims, idxs, inst_dims, impl, comment, _, graph, csets)
10844+
equation
10845+
mod_1 = Mod.lookupIdxModification(mod, i);
10846+
mod_2 = Mod.lookupIdxModification(mod, i+1);
10847+
(cache, env_1, ih, store, dae1, csets, ty, graph) =
10848+
instVar2(cache, env, ih, store, ci_state, mod_1, pre, n, cl, attr, pf, dims, (DAE.INDEX(DAE.BCONST(false)) :: idxs), inst_dims, impl, comment, info, graph, csets);
10849+
(cache, _, ih, store, dae2, csets, ty, graph) =
10850+
instVar2(cache, env, ih, store, ci_state, mod_2, pre, n, cl, attr, pf, dims, (DAE.INDEX(DAE.BCONST(true)) :: idxs), inst_dims, impl, comment, info, graph, csets);
10851+
daeLst = DAEUtil.joinDaes(dae1, dae2);
10852+
then
10853+
(cache, env_1, ih, store, daeLst, csets, ty, graph);
10854+
1086810855
case (cache,env,ih,store,ci_state,mod,pre,n,(cl,attr),pf,i,_,dims,idxs,inst_dims,impl,comment,_,graph,_)
1086910856
equation
1087010857
failure(_ = Mod.lookupIdxModification(mod, i));

Compiler/FrontEnd/InstSection.mo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4532,6 +4532,11 @@ algorithm
45324532
expl = List.map1(ints, makeAsubIndex, inArray);
45334533
then
45344534
expl;
4535+
case (DAE.DIM_BOOLEAN(), _)
4536+
equation
4537+
expl = DAE.BCONST(false)::DAE.BCONST(true)::{};
4538+
then
4539+
expl;
45354540
case (DAE.DIM_ENUM(enumTypeName = name, literals = ls), _)
45364541
equation
45374542
expl = makeEnumLiteralIndices(name, ls, 1, inArray);

Compiler/FrontEnd/Lookup.mo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,6 +2890,11 @@ algorithm
28902890
expl = List.map(List.intRange(sz), Expression.makeIntegerExp);
28912891
then
28922892
DAE.SLICE(DAE.ARRAY(DAE.T_INTEGER_DEFAULT, true, expl));
2893+
case DAE.DIM_BOOLEAN()
2894+
equation
2895+
expl = DAE.BCONST(false)::DAE.BCONST(true)::{};
2896+
then
2897+
DAE.SLICE(DAE.ARRAY(DAE.T_BOOL_DEFAULT, true, expl));
28932898
// Array with enumeration dimension.
28942899
case DAE.DIM_ENUM(enumTypeName = enum_name, literals = l, size = sz)
28952900
equation

Compiler/FrontEnd/Static.mo

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11666,8 +11666,7 @@ algorithm
1166611666
case (_,_,_,_,_,pre,_)
1166711667
equation
1166811668
ErrorExt.setCheckpoint("elabSubscriptsDims");
11669-
(outCache, outSubs, outConst) = elabSubscriptsDims2(cache, env, subs,
11670-
dims, impl, pre, info, DAE.C_CONST(), {});
11669+
(outCache, outSubs, outConst) = elabSubscriptsDims2(cache, env, subs, dims, impl, pre, info, DAE.C_CONST(), {});
1167111670
ErrorExt.rollBack("elabSubscriptsDims");
1167211671
then (outCache,outSubs,outConst);
1167311672

@@ -11718,14 +11717,11 @@ algorithm
1171811717

1171911718
case (_, _, asub :: rest_asub, dim :: rest_dims, _, _, _, _, _)
1172011719
equation
11721-
(cache, dsub, const, prop) = elabSubscript(inCache, inEnv, asub, inImpl,
11722-
inPrefix, inInfo);
11720+
(cache, dsub, const, prop) = elabSubscript(inCache, inEnv, asub, inImpl, inPrefix, inInfo);
1172311721
const = Types.constAnd(const, inConst);
11724-
(cache, dsub) = elabSubscriptsDims3(cache, inEnv, dsub, dim,
11725-
const, prop, inImpl, inInfo);
11722+
(cache, dsub) = elabSubscriptsDims3(cache, inEnv, dsub, dim, const, prop, inImpl, inInfo);
1172611723
elabed_subs = dsub :: inElabSubscripts;
11727-
(cache, elabed_subs, const) = elabSubscriptsDims2(cache, inEnv,
11728-
rest_asub, rest_dims, inImpl, inPrefix, inInfo, const, elabed_subs);
11724+
(cache, elabed_subs, const) = elabSubscriptsDims2(cache, inEnv, rest_asub, rest_dims, inImpl, inPrefix, inInfo, const, elabed_subs);
1172911725
then
1173011726
(cache, elabed_subs, const);
1173111727

@@ -11906,6 +11902,7 @@ algorithm
1190611902

1190711903
case (DAE.T_INTEGER(varLst = _),_,sub,_,_) then DAE.INDEX(sub);
1190811904
case (DAE.T_ENUMERATION(path = _),_,sub,_,_) then DAE.INDEX(sub);
11905+
case (DAE.T_BOOL(varLst = _),_,sub,_,_) then DAE.INDEX(sub);
1190911906
case (DAE.T_ARRAY(ty = DAE.T_INTEGER(varLst = _)),_,sub,_,_) then DAE.SLICE(sub);
1191011907

1191111908
// Modelica.Electrical.Analog.Lines.M_OLine.segment in MSL 3.1 uses a real
@@ -14328,10 +14325,9 @@ algorithm
1432814325
then
1432914326
(inCache, dim);
1433014327

14331-
case (_, _, _, Absyn.SUBSCRIPT(subscript = Absyn.CREF(componentRef =
14332-
Absyn.CREF_IDENT(name = "Boolean"))), _, _, _, _, _)
14328+
case (_, _, _, Absyn.SUBSCRIPT(subscript = Absyn.CREF(componentRef = Absyn.CREF_IDENT(name = "Boolean"))), _, _, _, _, _)
1433314329
then
14334-
(inCache, DAE.DIM_INTEGER(2));
14330+
(inCache, DAE.DIM_BOOLEAN());
1433514331

1433614332
// Array dimension from an enumeration.
1433714333
case (_, _, _, Absyn.SUBSCRIPT(subscript = Absyn.CREF(cr)), _, _, _, _, _)

Compiler/FrontEnd/Types.mo

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4978,6 +4978,15 @@ algorithm
49784978
DAE.PROP(t,c) = matchWithPromote(DAE.PROP(t1,c1), DAE.PROP(t2,c2), havereal);
49794979
then
49804980
DAE.PROP(DAE.T_ARRAY(t,{dim},ts2),c);
4981+
// match boolean, second
4982+
case (DAE.PROP(type_ = t1,constFlag = c1),
4983+
DAE.PROP(type_ = DAE.T_ARRAY(dims = {dim as DAE.DIM_BOOLEAN()},ty = t2, source = ts2),constFlag = c2),
4984+
havereal)
4985+
equation
4986+
false = isArray(t1,{});
4987+
DAE.PROP(t,c) = matchWithPromote(DAE.PROP(t1,c1), DAE.PROP(t2,c2), havereal);
4988+
then
4989+
DAE.PROP(DAE.T_ARRAY(t,{dim},ts2),c);
49814990
// match integer, first
49824991
case (DAE.PROP(type_ = DAE.T_ARRAY(dims = {DAE.DIM_INTEGER(1)},ty = t1, source = ts),constFlag = c1),
49834992
DAE.PROP(type_ = t2,constFlag = c2),havereal)
@@ -4994,6 +5003,14 @@ algorithm
49945003
DAE.PROP(t,c) = matchWithPromote(DAE.PROP(t1,c1), DAE.PROP(t2,c2), havereal);
49955004
then
49965005
DAE.PROP(DAE.T_ARRAY(t,{dim},ts),c);
5006+
// match boolean, first
5007+
case (DAE.PROP(type_ = DAE.T_ARRAY(dims = {dim as DAE.DIM_BOOLEAN()},ty = t1, source = ts),constFlag = c1),
5008+
DAE.PROP(type_ = t2,constFlag = c2),havereal)
5009+
equation
5010+
false = isArray(t2,{});
5011+
DAE.PROP(t,c) = matchWithPromote(DAE.PROP(t1,c1), DAE.PROP(t2,c2), havereal);
5012+
then
5013+
DAE.PROP(DAE.T_ARRAY(t,{dim},ts),c);
49975014
// equal types
49985015
case (DAE.PROP(type_ = t1,constFlag = c1),
49995016
DAE.PROP(type_ = t2,constFlag = c2),false)

0 commit comments

Comments
 (0)