Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 5 / 0 / 5
Functions: -% 0 / 1 / 1
Branches: 66.7% 4 / 0 / 6

OMCompiler/Compiler/FrontEnd/InstBasics.mo
Line Branch Exec Source
1 /*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC),
5 * c/o Linköpings universitet, Department of Computer and Information Science,
6 * SE-58183 Linköping, Sweden.
7 *
8 * All rights reserved.
9 *
10 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
14 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
17 * Public License (OSMC-PL) are obtained from OSMC, either from the above
18 * address, from the URLs:
19 * http://www.openmodelica.org or
20 * https://github.com/OpenModelica/ or
21 * http://www.ida.liu.se/projects/OpenModelica,
22 * and in the OpenModelica distribution.
23 *
24 * GNU AGPL version 3 is obtained from:
25 * https://www.gnu.org/licenses/licenses.html#GPL
26 *
27 * This program is distributed WITHOUT ANY WARRANTY; without
28 * even the implied warranty of MERCHANTABILITY or FITNESS
29 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
30 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
31 *
32 * See the full OSMC Public License conditions for more details.
33 *
34 */
35
36 encapsulated package InstBasics
37 " file: InstBasics.mo
38 package: InstBasics
39 description: Instantiation utilities
40
41
42 This package supports Inst*.mo and NFFrontend
43 "
44 import Absyn;
45 import DAE;
46 import SCode;
47 protected
48 import SCodeUtil;
49
50 public function commentIsInlineFunc
51 input SCode.Comment cmt;
52 output DAE.InlineType outInlineType;
53 algorithm
54 outInlineType := match cmt
55 local
56 list<SCode.SubMod> smlst;
57
58 case SCode.COMMENT(annotation_=SOME(SCode.ANNOTATION(SCode.MOD(subModLst = smlst))))
59 86956 then isInlineFunc2(smlst);
60
61 else DAE.DEFAULT_INLINE();
62 end match;
63 end commentIsInlineFunc;
64
65 protected function isInlineFunc2
66 input list<SCode.SubMod> inSubModList;
67 output DAE.InlineType res;
68 protected
69 Boolean stop = false;
70 algorithm
71
72 res := DAE.DEFAULT_INLINE();
73
74
2/2
✓ Branch 0 taken 164848 times.
✓ Branch 1 taken 81062 times.
245910 for tp in inSubModList loop
75 stop := match tp
76
77 case SCode.NAMEMOD("Inline",SCode.MOD(binding = SOME(Absyn.BOOL(true))))
78 algorithm
79 res := DAE.NORM_INLINE();
80 then false;
81
82 case SCode.NAMEMOD("Inline",SCode.MOD(binding = SOME(Absyn.BOOL(false))))
83 algorithm
84 res := DAE.NO_INLINE();
85 then false;
86
87 case SCode.NAMEMOD("LateInline",SCode.MOD(binding = SOME(Absyn.BOOL(true))))
88 algorithm
89 res := DAE.AFTER_INDEX_RED_INLINE();
90 then true;
91
92 case SCode.NAMEMOD("__MathCore_InlineAfterIndexReduction",SCode.MOD(binding = SOME(Absyn.BOOL(true))))
93 algorithm
94 res := DAE.AFTER_INDEX_RED_INLINE();
95 then true;
96
97 case SCode.NAMEMOD("__Dymola_InlineAfterIndexReduction",SCode.MOD(binding = SOME(Absyn.BOOL(true))))
98 algorithm
99 res := DAE.AFTER_INDEX_RED_INLINE();
100 then true;
101
102 case SCode.NAMEMOD("InlineAfterIndexReduction",SCode.MOD(binding = SOME(Absyn.BOOL(true))))
103 algorithm
104 res := DAE.AFTER_INDEX_RED_INLINE();
105 then true;
106
107 case SCode.NAMEMOD("__OpenModelica_EarlyInline",SCode.MOD(binding = SOME(Absyn.BOOL(true))))
108 algorithm
109 res := DAE.EARLY_INLINE();
110 then true;
111 else false;
112 end match;
113
114 if stop then
115 break;
116 end if;
117
118 end for;
119
120 end isInlineFunc2;
121
122 public function commentGenerateEvents
123 input SCode.Comment cmt;
124 output Boolean generateEvents;
125 protected
126 function commentGenerateEvents2
127 input list<SCode.SubMod> inSubModList;
128 output Boolean res;
129 protected
130 Boolean stop;
131 algorithm
132 res := false;
133
134
1/2
✓ Branch 0 taken 22755 times.
✗ Branch 1 not taken.
22755 for tp in inSubModList loop
135 stop := match tp
136 case SCode.NAMEMOD("GenerateEvents",SCode.MOD(binding = SOME(Absyn.BOOL(res)))) then false;
137 else true;
138 end match;
139
140 if stop then break; end if;
141 end for;
142 end commentGenerateEvents2;
143 algorithm
144 generateEvents := match cmt
145 local
146 list<SCode.SubMod> smlst;
147
148 case SCode.COMMENT(annotation_=SOME(SCode.ANNOTATION(SCode.MOD(subModLst = smlst))))
149 22755 then commentGenerateEvents2(smlst);
150
151 else false;
152 end match;
153 end commentGenerateEvents;
154
155 public function getFunctionRestrictionPurity
156 input Absyn.FunctionPurity purity;
157 input SCode.Comment cmt;
158 input Boolean newFrontend;
159 output DAE.Purity outPurity;
160 algorithm
161 outPurity := match purity
162 case Absyn.FunctionPurity.PURE() then DAE.Purity.PURE;
163 case Absyn.FunctionPurity.IMPURE() then DAE.Purity.IMPURE;
164 else DAE.Purity.UNDEFINED;
165 end match;
166
167 if outPurity == DAE.Purity.UNDEFINED then
168
1/2
✓ Branch 1 taken 82297 times.
✗ Branch 2 not taken.
82297 if SCodeUtil.commentHasBooleanNamedAnnotation(cmt, "__ModelicaAssociation_Impure") then
169 outPurity := DAE.Purity.IMPURE;
170 elseif not newFrontend and SCodeUtil.commentHasBooleanNamedAnnotation(cmt, "__OpenModelica_Impure") then
171 // __OpenModelica_Impure is only used for MetaModelica, which the NF doesn't care about.
172 outPurity := DAE.Purity.OM_IMPURE;
173 end if;
174 end if;
175 end getFunctionRestrictionPurity;
176
177 annotation(__OpenModelica_Interface="frontend_dump");
178 end InstBasics;
179