Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit fe6fd31

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Do not BackendDump empty sections
Belonging to [master]: - #2971 - OpenModelica/OpenModelica-testsuite#1136
1 parent 61571e8 commit fe6fd31

File tree

1 file changed

+54
-34
lines changed

1 file changed

+54
-34
lines changed

Compiler/BackEnd/BackendDump.mo

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -674,28 +674,34 @@ public function dumpBasePartitions
674674
input array<BackendDAE.BasePartition> basePartitions;
675675
input String heading;
676676
algorithm
677-
print("\n" + heading + " (" + intString(arrayLength(basePartitions)) + ")\n" + UNDERLINE + "\n");
678-
printBasePartitions(basePartitions);
679-
print("\n");
677+
if arrayLength(basePartitions) > 0 then
678+
print("\n" + heading + " (" + intString(arrayLength(basePartitions)) + ")\n" + UNDERLINE + "\n");
679+
printBasePartitions(basePartitions);
680+
print("\n");
681+
end if;
680682
end dumpBasePartitions;
681683

682684
public function dumpSubPartitions
683685
input array<BackendDAE.SubPartition> subPartitions;
684686
input String heading;
685687
algorithm
686-
print("\n" + heading + " (" + intString(arrayLength(subPartitions)) + ")\n" + UNDERLINE + "\n");
687-
printSubPartitions(subPartitions);
688-
print("\n");
688+
if arrayLength(subPartitions) > 0 then
689+
print("\n" + heading + " (" + intString(arrayLength(subPartitions)) + ")\n" + UNDERLINE + "\n");
690+
printSubPartitions(subPartitions);
691+
print("\n");
692+
end if;
689693
end dumpSubPartitions;
690694

691695

692696
public function dumpVariables "function dumpVariables"
693697
input BackendDAE.Variables inVars;
694698
input String heading;
695699
algorithm
696-
print("\n" + heading + " (" + intString(BackendVariable.varsSize(inVars)) + ")\n" + UNDERLINE + "\n");
697-
printVariables(inVars);
698-
print("\n");
700+
if BackendVariable.varsSize(inVars) > 0 then
701+
print("\n" + heading + " (" + intString(BackendVariable.varsSize(inVars)) + ")\n" + UNDERLINE + "\n");
702+
printVariables(inVars);
703+
print("\n");
704+
end if;
699705
end dumpVariables;
700706

701707
public function dumpVarList "function dumpVarList"
@@ -711,36 +717,44 @@ public function dumpEquationArray "function dumpEquationArray"
711717
input BackendDAE.EquationArray inEqns;
712718
input String heading;
713719
algorithm
714-
print("\n" + heading + " (" + intString(listLength(BackendEquation.equationList(inEqns))) + ", " + intString(BackendEquation.equationArraySize(inEqns)) + ")\n" + UNDERLINE + "\n");
715-
printEquationArray(inEqns);
716-
print("\n");
720+
if BackendEquation.getNumberOfEquations(inEqns) + BackendEquation.equationArraySize(inEqns) > 0 then
721+
print("\n" + heading + " (" + intString(BackendEquation.getNumberOfEquations(inEqns)) + ", " + intString(BackendEquation.equationArraySize(inEqns)) + ")\n" + UNDERLINE + "\n");
722+
printEquationArray(inEqns);
723+
print("\n");
724+
end if;
717725
end dumpEquationArray;
718726

719727
public function dumpEquationList "function dumpEquationList"
720728
input list<BackendDAE.Equation> inEqns;
721729
input String heading;
722730
algorithm
723-
print("\n" + heading + " (" + intString(listLength(inEqns)) + ")\n" + UNDERLINE + "\n");
724-
printEquationList(inEqns);
725-
print("\n");
731+
if not listEmpty(inEqns) then
732+
print("\n" + heading + " (" + intString(listLength(inEqns)) + ")\n" + UNDERLINE + "\n");
733+
printEquationList(inEqns);
734+
print("\n");
735+
end if;
726736
end dumpEquationList;
727737

728738
protected function dumpExternalObjectClasses "dump classes of external objects"
729739
input BackendDAE.ExternalObjectClasses inEOC;
730740
input String heading;
731741
algorithm
732-
print("\n" + heading + " (" + intString(listLength(inEOC)) + ")\n" + UNDERLINE + "\n");
733-
printExternalObjectClasses(inEOC);
734-
print("\n");
742+
if not listEmpty(inEOC) then
743+
print("\n" + heading + " (" + intString(listLength(inEOC)) + ")\n" + UNDERLINE + "\n");
744+
printExternalObjectClasses(inEOC);
745+
print("\n");
746+
end if;
735747
end dumpExternalObjectClasses;
736748

737749
protected function dumpStateSets
738750
input BackendDAE.StateSets stateSets;
739751
input String heading;
740752
algorithm
741-
print("\n" + heading + "\n" + UNDERLINE + "\n");
742-
printStateSets(stateSets);
743-
print("\n");
753+
if not listEmpty(stateSets) then
754+
print("\n" + heading + "\n" + UNDERLINE + "\n");
755+
printStateSets(stateSets);
756+
print("\n");
757+
end if;
744758
end dumpStateSets;
745759

746760
public function dumpZeroCrossingList
@@ -749,11 +763,13 @@ public function dumpZeroCrossingList
749763
protected
750764
BackendDAE.ZeroCrossing zeroCrossing;
751765
algorithm
752-
print("\n" + heading + " (" + intString(listLength(inZeroCrossingList)) + ")\n" + UNDERLINE + "\n");
753-
for zeroCrossing in inZeroCrossingList loop
754-
print(zeroCrossingString(zeroCrossing) + "\n");
755-
end for;
756-
print("\n");
766+
if not listEmpty(inZeroCrossingList) then
767+
print("\n" + heading + " (" + intString(listLength(inZeroCrossingList)) + ")\n" + UNDERLINE + "\n");
768+
for zeroCrossing in inZeroCrossingList loop
769+
print(zeroCrossingString(zeroCrossing) + "\n");
770+
end for;
771+
print("\n");
772+
end if;
757773
end dumpZeroCrossingList;
758774

759775
public function dumpTimeEvents
@@ -762,20 +778,24 @@ public function dumpTimeEvents
762778
protected
763779
BackendDAE.TimeEvent timeEvent;
764780
algorithm
765-
print("\n" + heading + " (" + intString(listLength(inTimeEvents)) + ")\n" + UNDERLINE + "\n");
766-
for timeEvent in inTimeEvents loop
767-
print(timeEventString(timeEvent) + "\n");
768-
end for;
769-
print("\n");
781+
if not listEmpty(inTimeEvents) then
782+
print("\n" + heading + " (" + intString(listLength(inTimeEvents)) + ")\n" + UNDERLINE + "\n");
783+
for timeEvent in inTimeEvents loop
784+
print(timeEventString(timeEvent) + "\n");
785+
end for;
786+
print("\n");
787+
end if;
770788
end dumpTimeEvents;
771789

772790
protected function dumpConstraintList
773791
input list<DAE.Constraint> inConstraintArray;
774792
input String heading;
775793
algorithm
776-
print("\n" + heading + " (" + intString(listLength(inConstraintArray)) + ")\n" + UNDERLINE + "\n");
777-
dumpConstraints(inConstraintArray, 0);
778-
print("\n");
794+
if not listEmpty(inConstraintArray) then
795+
print("\n" + heading + " (" + intString(listLength(inConstraintArray)) + ")\n" + UNDERLINE + "\n");
796+
dumpConstraints(inConstraintArray, 0);
797+
print("\n");
798+
end if;
779799
end dumpConstraintList;
780800

781801
public function dumpHashSet "author lochel"

0 commit comments

Comments
 (0)