Skip to content

Commit 362202e

Browse files
committed
- Handle arrays of records inside records correctly in DAEDump.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15862 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 42a0f2f commit 362202e

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

Compiler/FrontEnd/DAEDump.mo

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ algorithm
17481748
// protected vars are not input!, see Modelica Spec 3.2, Section 12.6, Record Constructor Functions, page 140
17491749
case(DAE.T_COMPLEX(cistate,DAE.TYPES_VAR(name=name,attributes = DAE.ATTR(visibility=SCode.PROTECTED()),ty=tp,binding=binding)::varLst,ec,lstPath))
17501750
equation
1751-
s1 =" protected "+&Types.unparseType(tp)+&" "+&name+&printRecordConstructorBinding(binding)+&";\n";
1751+
s1 =" protected "+&unparseType(tp)+&" "+&name+&printRecordConstructorBinding(binding)+&";\n";
17521752
s2 = printRecordConstructorInputsStr(DAE.T_COMPLEX(cistate,varLst,ec,lstPath));
17531753
str = s1 +&s2;
17541754
then
@@ -1757,15 +1757,15 @@ algorithm
17571757
// constants are not input! see Modelica Spec 3.2, Section 12.6, Record Constructor Functions, page 140
17581758
case(DAE.T_COMPLEX(cistate,DAE.TYPES_VAR(name=name,attributes=DAE.ATTR(variability=SCode.CONST()),ty=tp,binding=binding)::varLst,ec,lstPath))
17591759
equation
1760-
s1 =" constant "+&Types.unparseType(tp)+&" "+&name+&printRecordConstructorBinding(binding)+&";\n";
1760+
s1 =" constant "+&unparseType(tp)+&" "+&name+&printRecordConstructorBinding(binding)+&";\n";
17611761
s2 = printRecordConstructorInputsStr(DAE.T_COMPLEX(cistate,varLst,ec,lstPath));
17621762
str = s1 +& s2;
17631763
then
17641764
str;
17651765

17661766
case(DAE.T_COMPLEX(cistate,DAE.TYPES_VAR(name=name,ty=tp,binding=binding)::varLst,ec,lstPath))
17671767
equation
1768-
s1 =" input "+&Types.unparseType(tp)+&" "+&name+&printRecordConstructorBinding(binding)+&";\n";
1768+
s1 =" input "+&unparseType(tp)+&" "+&name+&printRecordConstructorBinding(binding)+&";\n";
17691769
s2 = printRecordConstructorInputsStr(DAE.T_COMPLEX(cistate,varLst,ec,lstPath));
17701770
str = s1 +& s2;
17711771
then
@@ -2984,16 +2984,30 @@ protected function unparseType "wrapper function for Types.unparseType, so recor
29842984
algorithm
29852985
str := matchcontinue(tp)
29862986
local
2987-
String name; Absyn.Path path;
2988-
Types.Type bc_tp;
2989-
2990-
case(DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(_),source = {path})) equation
2991-
name = Absyn.pathStringNoQual(path);
2992-
then name;
2987+
String name, dim_str;
2988+
Absyn.Path path;
2989+
Types.Type bc_tp, ty;
2990+
list<DAE.Dimension> dims;
29932991

2994-
case(DAE.T_SUBTYPE_BASIC(complexType = bc_tp)) then Types.unparseType(bc_tp);
2992+
case DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(_), source = {path})
2993+
equation
2994+
name = Absyn.pathStringNoQual(path);
2995+
then
2996+
name;
29952997

2996-
case _ then Types.unparseType(tp);
2998+
case DAE.T_ARRAY(ty = ty)
2999+
equation
3000+
DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(_), source = {path}) =
3001+
Types.arrayElementType(ty);
3002+
(_, dims) = Types.flattenArrayTypeOpt(tp);
3003+
name = Absyn.pathStringNoQual(path);
3004+
dim_str = List.toString(dims, ExpressionDump.dimensionString, "", "[",
3005+
", ", "]", false);
3006+
then
3007+
name +& dim_str;
3008+
3009+
case DAE.T_SUBTYPE_BASIC(complexType = bc_tp) then Types.unparseType(bc_tp);
3010+
else Types.unparseType(tp);
29973011
end matchcontinue;
29983012
end unparseType;
29993013

0 commit comments

Comments
 (0)