Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 81.2% 289 / 0 / 356
Functions: -% 0 / 1 / 1
Branches: 65.3% 124 / 0 / 190

OMCompiler/Compiler/FrontEnd/InstVar.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 InstVar
37 " file: InstVar.mo
38 package: InstVar
39 description: Model instantiation
40
41
42 This module is responsible for instantiation of Modelica components.
43
44 "
45
46 public import Absyn;
47 public import ClassInf;
48 public import DAE.Connect;
49 public import ConnectionGraph;
50 public import DAE;
51 public import FCore;
52 public import FGraph;
53 public import InnerOuter;
54 public import InstTypes;
55 public import Mod;
56 public import SCode;
57 public import UnitAbsyn;
58
59 protected import Config;
60 protected import ConnectUtil;
61 protected import Debug;
62 protected import Dump;
63 protected import DAEUtil;
64 protected import ElementSource;
65 protected import Inst;
66 protected import InstBinding;
67 protected import InstDAE;
68 protected import InstFunction;
69 protected import InstSection;
70 protected import InstUtil;
71 protected import Util;
72 import SCodeUtil;
73 protected import Types;
74 protected import PrefixUtil;
75 protected import List;
76 protected import ComponentReference;
77 protected import ComponentReferenceBasics;
78 protected import UnitAbsynBuilder;
79 protected import Flags;
80 protected import Expression;
81 protected import Error;
82 protected import ErrorExt;
83 protected import Lookup;
84 protected import SCodeDump;
85 protected import BaseHashSet;
86 protected import HashSet;
87 protected import ExpressionBasics;
88 protected import ClassInfUtil;
89
90 protected type Ident = DAE.Ident "an identifier";
91 protected type InstanceHierarchy = InnerOuter.InstHierarchy "an instance hierarchy";
92 protected type InstDims = list<list<DAE.Dimension>>;
93
94 public function instVar
95 "this function will look if a variable is inner/outer and depending on that will:
96 - lookup for inner in the instanance hieararchy if we have ONLY outer
97 - instantiate normally via instVar_dispatch otherwise
98 - report an error if we have modifications on outer
99
100 BTH: Added cases that handles 'outer' and 'inner outer' variables differently if they
101 are declared wihin an instance of a synchronous State Machine state: basically, instead of
102 substituting 'outer' variables through their 'inner' counterparts the 'outer' variable is
103 declared with a modification equation that sets the 'outer' variable equal to the 'inner'
104 variable. Hence, the information in which instance an 'outer' variable was declared is
105 preserved in the flattened code. This information is necessary to handle state machines in
106 the backend. The current implementation doesn't handle cases in which the
107 'inner' is not (yet) set.
108 "
109 input FCore.Cache inCache;
110 input FCore.Graph inEnv;
111 input InnerOuter.InstHierarchy inIH;
112 input UnitAbsyn.InstStore inStore;
113 input ClassInf.State inState;
114 input DAE.Mod inMod;
115 input DAE.Prefix inPrefix;
116 input String inIdent;
117 input SCode.Element inClass;
118 input SCode.Attributes inAttributes;
119 input SCode.Prefixes inPrefixes;
120 input DAE.Dimensions inDimensionLst;
121 input list<DAE.Subscript> inIntegerLst;
122 input list<list<DAE.Dimension>> inInstDims;
123 input Boolean inImpl;
124 input SCode.Comment inComment;
125 input SourceInfo info;
126 input ConnectionGraph.ConnectionGraph inGraph;
127 input Connect.Sets inSets;
128 input FCore.Graph componentDefinitionParentEnv;
129 output FCore.Cache outCache;
130 output FCore.Graph outEnv;
131 output InnerOuter.InstHierarchy outIH;
132 output UnitAbsyn.InstStore outStore;
133 output DAE.DAElist outDae;
134 output Connect.Sets outSets;
135 output DAE.Type outType;
136 output ConnectionGraph.ConnectionGraph outGraph;
137 protected
138 Absyn.InnerOuter io;
139 algorithm
140 if match inIdent
141 case "Integer" then true;
142 case "Real" then true;
143 case "Boolean" then true;
144 case "String" then true;
145 case "time" then true;
146 else false; end match then
147 61 Error.addSourceMessage(Error.RESERVED_IDENTIFIER, {inIdent}, info);
148 61 fail();
149 end if;
150
151 587051 io := SCodeUtil.prefixesInnerOuter(inPrefixes);
152
153 (outCache,outEnv,outIH,outStore,outDae,outSets,outType,outGraph) :=
154 matchcontinue (inCache, inEnv, inIH, inStore, inState, inMod, inPrefix, inIdent, inClass, inAttributes, inPrefixes, inDimensionLst, inIntegerLst, inInstDims, inImpl, inComment, inGraph, inSets)
155 local
156 DAE.Dimensions dims;
157 FCore.Graph compenv,env,innerCompEnv,outerCompEnv;
158 DAE.DAElist dae, outerDAE, innerDAE;
159 Connect.Sets csets,csetsInner;
160 DAE.Type ty;
161 ClassInf.State ci_state;
162 DAE.Mod mod;
163 DAE.Prefix pre, innerPrefix;
164 String n,s1,s2,s3,s;
165 SCode.Element cl;
166 SCode.Attributes attr;
167 list<DAE.Subscript> idxs;
168 InstDims inst_dims;
169 Boolean impl;
170 SCode.Comment comment;
171 FCore.Cache cache;
172 ConnectionGraph.ConnectionGraph graph;
173 InstanceHierarchy ih;
174 DAE.ComponentRef cref, crefOuter, crefInner;
175 list<DAE.ComponentRef> outers;
176 String nInner, typeName, fullName;
177 Absyn.Path typePath;
178 String innerScope;
179 Absyn.InnerOuter ioInner;
180 Option<InnerOuter.InstResult> instResult;
181 SCode.Prefixes pf;
182 UnitAbsyn.InstStore store;
183 InnerOuter.TopInstance topInstance;
184 HashSet.HashSet sm;
185
186
187 // is ONLY inner
188 case (cache, env, ih, store, ci_state, mod, pre, n, cl as SCode.CLASS(name=typeName), attr, pf, dims, idxs, inst_dims, impl, comment, graph, csets)
189 algorithm
190 // only inner!
191
2/2
✓ Branch 1 taken 587011 times.
✓ Branch 2 taken 40 times.
587051 true := AbsynUtil.isOnlyInner(io);
192
193 // fprintln(Flags.INNER_OUTER, "- InstVar.instVar inner: " + PrefixUtil.printPrefixStr(pre) + "/" + n + " in env: " + FGraph.printGraphPathStr(env));
194
195 // instantiate as inner
196 40 (cache,innerCompEnv,ih,store,dae,csets,ty,graph) :=
197 instVar_dispatch(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph,csets);
198
199 40 (cache,cref) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
200 40 fullName := ComponentReferenceBasics.printComponentRefStr(cref);
201 40 (cache, typePath) := Inst.makeFullyQualifiedIdent(cache, env, typeName);
202
203 // also all the components in the environment should be updated to be outer!
204 // switch components from inner to outer in the component env.
205 40 outerCompEnv := InnerOuter.switchInnerToOuterInGraph(innerCompEnv, cref);
206
207 // outer doesn't generate a visible DAE
208 outerDAE := DAE.emptyDae;
209
210 40 innerScope := FGraph.printGraphPathStr(componentDefinitionParentEnv);
211
212 // add to instance hierarchy
213 80 ih := InnerOuter.updateInstHierarchy(ih, pre, io,
214 InnerOuter.INST_INNER(
215 pre, // prefix
216 n, // component name,
217 io, // inner outer atttributes
218 fullName, // full component name
219 typePath, // fully qual type path
220 innerScope, // the scope,
221 SOME(InnerOuter.INST_RESULT(cache,outerCompEnv,store,outerDAE,csets,ty,graph)), // instantiation result
222 {}, // outers connected to this inner
223 NONE()
224 ));
225 40 then
226 (cache,innerCompEnv,ih,store,dae,csets,ty,graph);
227
228 // is ONLY outer and it has modifications on it!
229 case (cache, env, ih, store, ci_state, mod, pre, n, cl, attr, pf, dims, idxs, inst_dims, impl, comment, graph, csets)
230 algorithm
231 // only outer!
232
2/2
✓ Branch 1 taken 586309 times.
✓ Branch 2 taken 702 times.
587011 true := AbsynUtil.isOnlyOuter(io);
233
234 // we should have here any kind of modification!
235
2/2
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 1 time.
702 false := Mod.modEqual(mod, DAE.NOMOD());
236 1 (cache,cref) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
237 1 s1 := ComponentReferenceBasics.printComponentRefStr(cref);
238 1 s2 := Mod.prettyPrintMod(mod, 0);
239 1 s := s1 + " " + s2;
240 // add a warning!
241 1 Error.addSourceMessage(Error.OUTER_MODIFICATION, {s}, info);
242
243 // call myself without any modification!
244 1 (cache,compenv,ih,store,dae,csets,ty,graph) :=
245 instVar(cache,env,ih,store,ci_state,DAE.NOMOD(),pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph,csets,componentDefinitionParentEnv);
246 then
247 (cache,compenv,ih,store,dae,csets,ty,graph);
248
249 // is ONLY outer output and is inside an instance of a State Machine state
250 case (cache, env, ih, store, ci_state, mod, pre, n, cl, attr as SCode.ATTR(direction=Absyn.OUTPUT()), pf, dims, idxs, inst_dims, impl, comment, graph, csets)
251 algorithm
252 // only outer!
253
2/2
✓ Branch 1 taken 75654 times.
✓ Branch 2 taken 6 times.
75660 true := AbsynUtil.isOnlyOuter(io);
254
255 // we should have NO modifications on only outer!
256
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 true := Mod.modEqual(mod, DAE.NOMOD());
257
258 // lookup in IH
259
2/4
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
6 InnerOuter.INST_INNER(
260 _,
261 _,
262 _,
263 _,
264 _,
265 _,
266 SOME(InnerOuter.INST_RESULT(cache,compenv,store,_,_,ty,graph)),
267 _,_) :=
268 InnerOuter.lookupInnerVar(cache, env, ih, pre, n, io);
269
270
271 // the outer must be in an instance that is part of a State Machine
272 6 topInstance := listHead(ih);
273 6 InnerOuter.TOP_INSTANCE(sm=sm) := topInstance;
274
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 true := BaseHashSet.currentSize(sm) > 0;
275 6 cref := PrefixUtil.prefixToCref(inPrefix);
276
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 true := BaseHashSet.has(cref, sm);
277
278 6 (cache,compenv,ih,store,dae,csets,ty,graph) :=
279 instVar_dispatch(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph,csets);
280 6 then
281 (inCache,compenv,ih,store,dae,csets,ty,graph);
282
283
284 // is ONLY outer
285 case (cache, env, ih, store, _, mod, pre, n, _, _, _, _, _, _, _, _, graph, csets)
286 algorithm
287 // only outer!
288
2/2
✓ Branch 1 taken 586309 times.
✓ Branch 2 taken 695 times.
587004 true := AbsynUtil.isOnlyOuter(io);
289
290 // we should have NO modifications on only outer!
291
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
695 true := Mod.modEqual(mod, DAE.NOMOD());
292
293 // lookup in IH
294
2/4
✗ Branch 1 not taken.
✓ Branch 2 taken 693 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
695 InnerOuter.INST_INNER(
295 innerPrefix,
296 nInner,
297 ioInner,
298 fullName,
299 typePath,
300 innerScope,
301 instResult as SOME(InnerOuter.INST_RESULT(cache,compenv,store,outerDAE,_,ty,graph)),
302 outers,_) :=
303 InnerOuter.lookupInnerVar(cache, env, ih, pre, n, io);
304
305 // add outer prefix + component name and its corresponding inner prefix to the IH
306 693 (cache,crefOuter) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
307 693 (cache,crefInner) := PrefixUtil.prefixCref(cache,env,ih,innerPrefix, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
308 693 ih := InnerOuter.addOuterPrefixToIH(ih, crefOuter, crefInner);
309 693 outers := List.unionElt(crefOuter, outers);
310 // update the inner with the outer for easy reference
311 693 ih := InnerOuter.updateInstHierarchy(ih, innerPrefix, ioInner,
312 InnerOuter.INST_INNER(
313 innerPrefix, // prefix
314 nInner, // component name,
315 ioInner, // inner outer atttributes
316 fullName, // full component name
317 typePath, // fully qual type path
318 innerScope, // the scope,
319 instResult,
320 outers, // outers connected to this inner
321 NONE()
322 ));
323
324 // outer dae has no meaning!
325 outerDAE := DAE.emptyDae;
326 693 then
327 (inCache /* we don't want to return the old, crappy cache as ours was newer */,compenv,ih,store,outerDAE,csets,ty,graph);
328
329 // is ONLY outer and the inner was not yet set in the IH or we have no inner declaration!
330 case (cache, env, ih, store, ci_state, mod, pre, n, cl, attr, pf, dims, idxs, inst_dims, impl, comment, graph, csets)
331 algorithm
332 // only outer!
333
2/2
✓ Branch 1 taken 586309 times.
✓ Branch 2 taken 2 times.
586311 true := AbsynUtil.isOnlyOuter(io);
334
335 // no modifications!
336
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 true := Mod.modEqual(mod, DAE.NOMOD());
337
338 // lookup in IH, crap, we couldn't find it!
339 // lookup in IH
340
0/4
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 InnerOuter.INST_INNER(
341 _,
342 _,
343 _,
344 _,
345 typePath,
346 _,
347 NONE(),
348 _,_) :=
349 InnerOuter.lookupInnerVar(cache, env, ih, pre, n, io);
350
351 // fprintln(Flags.INNER_OUTER, "- InstVar.instVar failed to lookup inner: " + PrefixUtil.printPrefixStr(pre) + "/" + n + " in env: " + FGraph.printGraphPathStr(env));
352
353 // display an error message!
354 ✗ (cache,crefOuter) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
355 ✗ typeName := SCodeUtil.className(cl);
356 ✗ (cache, typePath) := Inst.makeFullyQualifiedIdent(cache, env, typeName);
357 // adrpo: do NOT! display an error message if impl = true and prefix is DAE.NOPRE()
358 // print(if_(impl, "impl crap\n", "no impl\n"));
359 ✗ if not (impl and listMember(pre, {DAE.NOPRE()})) and not Config.getGraphicsExpMode() then
360 ✗ s1 := ComponentReferenceBasics.printComponentRefStr(crefOuter);
361 ✗ s2 := AbsynUtil.innerOuterStr(io);
362 ✗ s3 := InnerOuter.getExistingInnerDeclarations(ih, componentDefinitionParentEnv);
363 ✗ s1 := AbsynUtil.pathString(typePath) + " " + s1;
364 ✗ Error.addSourceMessage(Error.MISSING_INNER_PREFIX,{s1, s2, s3}, info);
365 end if;
366
367 // call it normaly
368 ✗ (cache,compenv,ih,store,dae,_,ty,graph) :=
369 instVar_dispatch(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph, csets);
370 ✗ then
371 (cache,compenv,ih,store,dae,csets,ty,graph);
372
373 // is ONLY outer and the inner was not yet set in the IH or we have no inner declaration!
374 case (cache, env, ih, store, ci_state, mod, pre, n, cl, attr, pf, dims, idxs, inst_dims, impl, comment, graph, csets)
375 algorithm
376 // only outer!
377
2/2
✓ Branch 1 taken 586309 times.
✓ Branch 2 taken 2 times.
586311 true := AbsynUtil.isOnlyOuter(io);
378
379 // no modifications!
380
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 true := Mod.modEqual(mod, DAE.NOMOD());
381
382 // lookup in IH, crap, we couldn't find it!
383
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 failure(InnerOuter.lookupInnerVar(cache, env, ih, pre, n, io));
384
385 // fprintln(Flags.INNER_OUTER, "- InstVar.instVar failed to lookup inner: " + PrefixUtil.printPrefixStr(pre) + "/" + n + " in env: " + FGraph.printGraphPathStr(env));
386
387 // display an error message!
388 2 (cache,crefOuter) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
389 2 typeName := SCodeUtil.className(cl);
390 2 (cache, typePath) := Inst.makeFullyQualifiedIdent(cache, env, typeName);
391 // print(if_(impl, "impl crap\n", "no impl\n"));
392 // adrpo: do NOT! display an error message if impl = true and prefix is DAE.NOPRE()
393
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 if not (impl and listMember(pre, {DAE.NOPRE()})) and not Config.getGraphicsExpMode() then
394 2 s1 := ComponentReferenceBasics.printComponentRefStr(crefOuter);
395 2 s2 := AbsynUtil.innerOuterStr(io);
396 2 s3 := InnerOuter.getExistingInnerDeclarations(ih,componentDefinitionParentEnv);
397 2 s1 := AbsynUtil.pathString(typePath) + " " + s1;
398 2 Error.addSourceMessage(Error.MISSING_INNER_PREFIX,{s1, s2, s3}, info);
399 end if;
400
401 // call it normally
402 2 (cache,compenv,ih,store,dae,_,ty,graph) :=
403 instVar_dispatch(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph, csets);
404 2 then
405 (cache,compenv,ih,store,dae,csets,ty,graph);
406
407 // is inner outer output and is inside an instance of a State Machine state!
408 case (cache, env, ih, store, ci_state, mod, pre, n, cl as SCode.CLASS(name=typeName), attr as SCode.ATTR(direction=Absyn.OUTPUT()), pf, dims, idxs, inst_dims, impl, comment, graph, csets)
409 algorithm
410 // both inner and outer
411
2/2
✓ Branch 1 taken 75653 times.
✓ Branch 2 taken 1 time.
75654 true := AbsynUtil.isInnerOuter(io);
412
413 // the inner outer must be in an instance that is part of a State Machine
414 1 topInstance := listHead(ih);
415 1 InnerOuter.TOP_INSTANCE(sm=sm) := topInstance;
416
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 true := BaseHashSet.currentSize(sm) > 0;
417 1 cref := PrefixUtil.prefixToCref(inPrefix);
418
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 true := BaseHashSet.has(cref, sm);
419
420 1 (cache,innerCompEnv,ih,store,dae,csetsInner,ty,graph) :=
421 instVar_dispatch(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph, csets);
422
423 // add it to the instance hierarchy
424 1 (cache,cref) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
425 1 fullName := ComponentReferenceBasics.printComponentRefStr(cref);
426 1 (cache, typePath) := Inst.makeFullyQualifiedIdent(cache, env, typeName);
427
428 // also all the components in the environment should be updated to be outer!
429 // switch components from inner to outer in the component env.
430 1 outerCompEnv := InnerOuter.switchInnerToOuterInGraph(innerCompEnv, cref);
431
432 // keep the dae we get from the instantiation of the inner
433 1 innerDAE := dae;
434
435 1 innerScope := FGraph.printGraphPathStr(componentDefinitionParentEnv);
436
437 // add inner to the instance hierarchy
438 2 ih := InnerOuter.updateInstHierarchy(ih, pre, io,
439 InnerOuter.INST_INNER(
440 pre,
441 n,
442 io,
443 fullName,
444 typePath,
445 innerScope,
446 SOME(InnerOuter.INST_RESULT(cache,outerCompEnv,store,innerDAE,csetsInner,ty,graph)),
447 {},
448 NONE()));
449
450 // now call it normally
451 1 (cache,compenv,ih,store,dae,_,ty,graph) :=
452 instVar_dispatch(cache,env,ih,store,ci_state,DAE.NOMOD(),pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph, csets);
453 1 then
454 (cache,compenv,ih,store,dae,csetsInner,ty,graph);
455
456 // is inner outer!
457 case (cache, env, ih, store, ci_state, mod, pre, n, cl as SCode.CLASS(name=typeName), attr, pf, dims, idxs, inst_dims, impl, comment, graph, csets)
458 algorithm
459 // both inner and outer
460
2/2
✓ Branch 1 taken 586304 times.
✓ Branch 2 taken 4 times.
586308 true := AbsynUtil.isInnerOuter(io);
461
462 // fprintln(Flags.INNER_OUTER, "- InstVar.instVar inner outer: " + PrefixUtil.printPrefixStr(pre) + "/" + n + " in env: " + FGraph.printGraphPathStr(env));
463
464 4 (cache,innerCompEnv,ih,store,dae,csetsInner,ty,graph) :=
465 instVar_dispatch(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph, csets);
466
467 // add it to the instance hierarchy
468 4 (cache,cref) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
469 4 fullName := ComponentReferenceBasics.printComponentRefStr(cref);
470 4 (cache, typePath) := Inst.makeFullyQualifiedIdent(cache, env, typeName);
471
472 // also all the components in the environment should be updated to be outer!
473 // switch components from inner to outer in the component env.
474 4 outerCompEnv := InnerOuter.switchInnerToOuterInGraph(innerCompEnv, cref);
475
476 // keep the dae we get from the instantiation of the inner
477 4 innerDAE := dae;
478
479 4 innerScope := FGraph.printGraphPathStr(componentDefinitionParentEnv);
480
481 // add inner to the instance hierarchy
482 8 ih := InnerOuter.updateInstHierarchy(ih, pre, io,
483 InnerOuter.INST_INNER(
484 pre,
485 n,
486 io,
487 fullName,
488 typePath,
489 innerScope,
490 SOME(InnerOuter.INST_RESULT(cache,outerCompEnv,store,innerDAE,csetsInner,ty,graph)),
491 {},
492 NONE()));
493
494 // now instantiate it as an outer with no modifications
495 4 pf := SCodeUtil.prefixesSetInnerOuter(pf, Absyn.OUTER());
496 4 (cache,compenv,ih,store,dae,_,ty,graph) :=
497 instVar(cache,env,ih,store,ci_state,DAE.NOMOD(),pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph,csets,componentDefinitionParentEnv);
498
499 // keep the dae we get from the instantiation of the outer
500 4 outerDAE := dae;
501
502 // join the dae's (even thou' the outer is empty)
503 4 dae := DAEUtil.joinDaes(outerDAE, innerDAE);
504 4 then
505 (cache,compenv,ih,store,dae,csetsInner,ty,graph);
506
507 // is NO INNER NOR OUTER or it failed before!
508 case (cache, env, ih, store, ci_state, mod, pre, n, cl, attr, pf, dims, idxs, inst_dims, impl, comment, graph, csets)
509 algorithm
510 // no inner no outer
511
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 586304 times.
586304 true := AbsynUtil.isNotInnerOuter(io);
512
513 // fprintln(Flags.INNER_OUTER, "- InstVar.instVar NO inner NO outer: " + PrefixUtil.printPrefixStr(pre) + "/" + n + " in env: " + FGraph.printGraphPathStr(env));
514
515 586304 (cache,compenv,ih,store,dae,csets,ty,graph) :=
516 instVar_dispatch(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,idxs,inst_dims,impl,comment,info,graph,csets);
517 then
518 (cache,compenv,ih,store,dae,csets,ty,graph);
519
520 // failtrace
521 case (cache, env, ih, _, _, mod, pre, n, cl, _, _, _, _, _, _, _, _, _)
522 algorithm
523
1/2
✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
95 true := Flags.isSet(Flags.FAILTRACE);
524 ✗ (cache,cref) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
525 ✗ Debug.traceln("- InstVar.instVar failed while instatiating variable: " +
526 ComponentReferenceBasics.printComponentRefStr(cref) + " " + Mod.prettyPrintMod(mod, 0) +
527 "\nin scope: " + FGraph.printGraphPathStr(env) + " class:\n" + SCodeDump.unparseElementStr(cl));
528 ✗ then
529 fail();
530 end matchcontinue;
531 end instVar;
532
533 protected function instVar_dispatch "A component element in a class may consist of several subcomponents
534 or array elements. This function is used to instantiate a
535 component, instantiating all subcomponents and array elements
536 separately.
537 P.A: Most of the implementation is moved to instVar2. instVar collects
538 dimensions for userdefined types, such that these can be correctly
539 handled by instVar2 (using instArray)"
540 input FCore.Cache inCache;
541 input FCore.Graph inEnv;
542 input InnerOuter.InstHierarchy inIH;
543 input UnitAbsyn.InstStore inStore;
544 input ClassInf.State inState;
545 input DAE.Mod inMod;
546 input DAE.Prefix inPrefix;
547 input String inName;
548 input SCode.Element inClass;
549 input SCode.Attributes inAttributes;
550 input SCode.Prefixes inPrefixes;
551 input list<DAE.Dimension> inDimensions;
552 input list<DAE.Subscript> inIndices;
553 input list<list<DAE.Dimension>> inInstDims;
554 input Boolean inImpl;
555 input SCode.Comment inComment;
556 input SourceInfo inInfo;
557 input ConnectionGraph.ConnectionGraph inGraph;
558 input Connect.Sets inSets;
559 output FCore.Cache outCache;
560 output FCore.Graph outEnv;
561 output InnerOuter.InstHierarchy outIH;
562 output UnitAbsyn.InstStore outStore;
563 output DAE.DAElist outDae;
564 output Connect.Sets outSets;
565 output DAE.Type outType;
566 output ConnectionGraph.ConnectionGraph outGraph;
567 protected
568 list<DAE.Dimension> dims;
569 SCode.Element cls;
570 DAE.Mod type_mods, mod;
571 SCode.Attributes attr;
572 DAE.ElementSource source;
573 algorithm
574 try
575 586358 Error.updateCurrentComponent(inName, inInfo, function PrefixUtil.identAndPrefixToPath(inPrefix=inPrefix));
576
577 586358 (outCache, dims, cls, type_mods) :=
578 InstUtil.getUsertypeDimensions(inCache, inEnv, inIH, inPrefix, inClass, inInstDims, inImpl);
579
580
2/2
✓ Branch 0 taken 582837 times.
✓ Branch 1 taken 3521 times.
586358 if listEmpty(dims) then
581 // No dimensions from userdefined type.
582 582837 dims := inDimensions;
583 582837 cls := inClass;
584 mod := inMod;
585 attr := inAttributes;
586 else
587 // Userdefined array type, e.g. type Point = Real[3].
588 3521 type_mods := liftUserTypeMod(type_mods, inDimensions);
589 3521 dims := listAppend(inDimensions, dims);
590 3521 mod := Mod.merge(inMod, type_mods);
591 3521 attr := InstUtil.propagateClassPrefix(inAttributes, inPrefix);
592 end if;
593
594 586358 (outCache, outEnv, outIH, outStore, outDae, outSets, outType, outGraph) :=
595 instVar2(outCache, inEnv, inIH, inStore, inState, mod, inPrefix, inName,
596 cls, attr, inPrefixes, dims, inIndices, inInstDims, inImpl, inComment,
597 inInfo, inGraph, inSets);
598
599 586263 source := ElementSource.createElementSource(inInfo, FGraph.getScopePath(inEnv), inPrefix);
600 586263 (outCache, outDae) := addArrayVarEquation(outCache, inEnv, outIH, inState,
601 outDae, outType, mod, Types.variabilityToConst(SCodeUtil.attrVariability(attr)),
602 inPrefix, inName, source);
603 586263 outCache := InstFunction.addRecordConstructorFunction(outCache, inEnv,
604 Types.arrayElementType(outType), SCodeUtil.elementInfo(inClass));
605
606 586263 Error.clearCurrentComponent();
607 else
608 95 Error.clearCurrentComponent();
609 95 fail();
610 end try;
611 end instVar_dispatch;
612
613 protected function liftUserTypeMod
614 "This function adds dimensions to a modifier. This is a bit of a hack to make
615 modifiers on user-defined types behave as expected, e.g.:
616
617 type T = Real[3](start = {1, 2, 3});
618 T x[2]; // Modifier from T must be lifted to become [2, 3].
619 "
620 input DAE.Mod inMod;
621 input list<DAE.Dimension> inDims;
622 output DAE.Mod outMod = inMod;
623 algorithm
624
2/2
✓ Branch 0 taken 3517 times.
✓ Branch 1 taken 10 times.
3527 if listEmpty(inDims) then
625 3517 return;
626 end if;
627
628 outMod := matchcontinue outMod
629 case DAE.MOD()
630 algorithm
631 // Only lift modifiers without 'each'.
632
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
10 if not SCodeUtil.eachBool(outMod.eachPrefix) then
633 5 outMod.binding := liftUserTypeEqMod(outMod.binding, inDims);
634
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 5 times.
16 outMod.subModLst := list(liftUserTypeSubMod(s, inDims) for s in outMod.subModLst);
635 end if;
636 then
637 outMod;
638
639 ✗ else outMod;
640 end matchcontinue;
641 end liftUserTypeMod;
642
643 protected function liftUserTypeSubMod
644 input DAE.SubMod inSubMod;
645 input list<DAE.Dimension> inDims;
646 output DAE.SubMod outSubMod = inSubMod;
647 algorithm
648 outSubMod := match outSubMod
649 case DAE.NAMEMOD()
650 algorithm
651 6 outSubMod.mod := liftUserTypeMod(outSubMod.mod, inDims);
652 then
653 outSubMod;
654 end match;
655 end liftUserTypeSubMod;
656
657 protected function liftUserTypeEqMod
658 input Option<DAE.EqMod> inEqMod;
659 input list<DAE.Dimension> inDims;
660 output Option<DAE.EqMod> outEqMod;
661 protected
662 DAE.EqMod eq;
663 DAE.Type ty;
664 algorithm
665
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 time.
5 if isNone(inEqMod) then
666 outEqMod := inEqMod;
667 4 return;
668 end if;
669
670 1 SOME(eq) := inEqMod;
671
672 eq := match eq
673 case DAE.TYPED()
674 algorithm
675 1 eq.modifierAsExp := Expression.liftExpList(eq.modifierAsExp, inDims);
676 1 eq.modifierAsValue := Util.applyOption1(eq.modifierAsValue,
677 ValuesUtil.liftValueList, inDims);
678 1 ty := Types.getPropType(eq.properties);
679 1 eq.properties := Types.setPropType(eq.properties,
680 Types.liftArrayListDims(ty, inDims));
681 then
682 eq;
683
684 else eq;
685 end match;
686
687 outEqMod := SOME(eq);
688 end liftUserTypeEqMod;
689
690 protected function addArrayVarEquation
691 input FCore.Cache inCache;
692 input FCore.Graph inEnv;
693 input InnerOuter.InstHierarchy inIH;
694 input ClassInf.State inState;
695 input DAE.DAElist inDae;
696 input DAE.Type inType;
697 input DAE.Mod mod;
698 input DAE.Const const;
699 input DAE.Prefix pre;
700 input String n;
701 input DAE.ElementSource source;
702 output FCore.Cache outCache;
703 output DAE.DAElist outDae;
704 algorithm
705 (outCache,outDae) := matchcontinue (inDae, const)
706 local
707 FCore.Cache cache;
708 list<DAE.Element> dae;
709 DAE.Exp exp;
710 DAE.Element eq;
711 DAE.Dimensions dims;
712 DAE.ComponentRef cr;
713 DAE.Type ty;
714
715 // Don't add array equations if +scalarizeBindings is set.
716 case (_, _)
717 algorithm
718
2/2
✓ Branch 1 taken 586262 times.
✓ Branch 2 taken 1 time.
586263 true := Config.scalarizeBindings();
719 then
720 (inCache, inDae);
721
722 case (DAE.DAE(dae), DAE.C_VAR())
723 algorithm
724
2/2
✓ Branch 1 taken 361495 times.
✓ Branch 2 taken 144144 times.
505639 false := ClassInfUtil.isFunctionOrRecord(inState);
725 144144 ty := Types.simplifyType(inType);
726
2/2
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 144127 times.
144144 false := Types.isExternalObject(Types.arrayElementType(ty));
727
2/2
✓ Branch 2 taken 10784 times.
✓ Branch 3 taken 133343 times.
144127 false := Types.isComplexType(Types.arrayElementType(ty));
728
2/2
✓ Branch 1 taken 116951 times.
✓ Branch 2 taken 16392 times.
133343 dims as _::_ := TypesDump.getDimensions(ty);
729
3/4
✗ Branch 1 not taken.
✓ Branch 2 taken 16392 times.
✓ Branch 3 taken 7211 times.
✓ Branch 4 taken 9181 times.
16392 SOME(exp) := InstBinding.makeVariableBinding(ty, mod, const, pre, n);
730 9181 cr := ComponentReferenceBasics.makeCrefIdent(n,ty,{});
731 9181 (cache,cr) := PrefixUtil.prefixCref(inCache,inEnv,inIH,pre,cr);
732 9181 eq := DAE.ARRAY_EQUATION(dims, DAE.CREF(cr,ty), exp, source);
733 // print("Creating array equation for " + PrefixUtil.printPrefixStr(pre) + "." + n + " of const " + DAEUtil.constStr(const) + " in classinf " + ClassInfUtil.printStateStr(inState) + "\n");
734 9181 then (cache,DAE.DAE(eq::dae));
735
736 else (inCache,inDae);
737 end matchcontinue;
738 end addArrayVarEquation;
739
740 protected function instVar2
741 "Helper function to instVar, does the main work."
742 input FCore.Cache inCache;
743 input FCore.Graph inEnv;
744 input InnerOuter.InstHierarchy inIH;
745 input UnitAbsyn.InstStore inStore;
746 input ClassInf.State inState;
747 input DAE.Mod inMod;
748 input DAE.Prefix inPrefix;
749 input String inName;
750 input SCode.Element inClass;
751 input SCode.Attributes inAttributes;
752 input SCode.Prefixes inPrefixes;
753 input DAE.Dimensions inDimensions;
754 input list<DAE.Subscript> inSubscripts;
755 input list<list<DAE.Dimension>> inInstDims;
756 input Boolean inImpl;
757 input SCode.Comment inComment;
758 input SourceInfo inInfo;
759 input ConnectionGraph.ConnectionGraph inGraph;
760 input Connect.Sets inSets;
761 output FCore.Cache outCache;
762 output FCore.Graph outEnv;
763 output InnerOuter.InstHierarchy outIH;
764 output UnitAbsyn.InstStore outStore;
765 output DAE.DAElist outDae;
766 output Connect.Sets outSets;
767 output DAE.Type outType;
768 output ConnectionGraph.ConnectionGraph outGraph;
769 algorithm
770 (outCache,outEnv,outIH,outStore,outDae,outSets,outType,outGraph):=
771 matchcontinue (inCache,inEnv,inIH,inStore,inState,inMod,inPrefix,inName,inClass,inAttributes,inPrefixes,inDimensions,inSubscripts,inInstDims,inImpl,inComment,inInfo,inGraph,inSets)
772 local
773 InstDims inst_dims,inst_dims_1;
774 DAE.Exp e,e_1;
775 DAE.Properties p;
776 FCore.Graph env_1,env,compenv;
777 Connect.Sets csets;
778 DAE.Type ty,ty_1,arrty;
779 ClassInf.State ci_state;
780 DAE.ComponentRef cr;
781 DAE.Type ty_2;
782 DAE.DAElist dae;
783 DAE.Mod mod;
784 DAE.Prefix pre;
785 String n;
786 SCode.Element cl;
787 SCode.Attributes attr;
788 DAE.Dimensions dims;
789 list<DAE.Subscript> idxs;
790 Boolean impl;
791 SCode.Comment comment;
792 Option<DAE.VariableAttributes> dae_var_attr;
793 DAE.Subscript dime;
794 DAE.Dimension dim,dim2;
795 FCore.Cache cache;
796 SCode.Visibility vis;
797 ConnectionGraph.ConnectionGraph graph;
798 InstanceHierarchy ih;
799 DAE.ElementSource source "the origin of the element";
800 DAE.Subscript dime2;
801 SCode.Prefixes pf;
802 SCode.Final fin;
803 SourceInfo info;
804 Absyn.InnerOuter io;
805 UnitAbsyn.InstStore store;
806
807 // Rules for instantation of function variables (e.g. input and output
808
809 // Function variables with modifiers (outputs or local/protected variables)
810 // For Functions we cannot always find dimensional sizes. e.g.
811 // input Real x[:]; component environement The class is instantiated
812 // with the calculated modification, and an extended prefix.
813 //
814
815 // mahge: Function variables with subMod modifications. This can happen for records with inline constructions (and maybe other stuff too???)
816 // now only for records.
817 // e.g.
818 // function out
819 // output R1 r(v1=3,v2=3); // <= Here
820 // protected
821 // R1 r2(v1=1, v1=2); // <= Here
822 // end out;
823 // see testsuit/mofiles/RecordBindings.mo.
824 case (cache,env,ih,store,ci_state,mod as DAE.MOD(binding = NONE()),pre,n,cl as SCode.CLASS(restriction = SCode.R_RECORD(_)),attr,pf,dims,_,inst_dims,impl,comment,info,graph,csets)
825 algorithm
826
2/2
✓ Branch 1 taken 5056 times.
✓ Branch 2 taken 8 times.
5064 true := ClassInfUtil.isFunction(ci_state);
827 8 InstUtil.checkFunctionVar(n, attr, pf, info);
828
829
830 //Instantiate type of the component, skip dae/not flattening (but extract functions)
831 // adrpo: do not send in the modifications as it will fail if the modification is an ARRAY.
832 // anyhow the modifications are handled below.
833 // input Integer sequence[3](min = {1,1,1}, max = {3,3,3}) = {1,2,3}; // this will fail if we send in the mod.
834 // see testsuite/mofiles/Sequence.mo
835 8 (cache,env_1,ih,store,_,csets,ty,_,_,graph) :=
836 Inst.instClass(cache, env, ih, store, DAE.NOMOD(), pre, cl, inst_dims, impl, InstTypes.INNER_CALL(), graph, csets);
837 //Make it an array type since we are not flattening
838 8 ty_1 := InstUtil.makeArrayType(dims, ty);
839 8 InstUtil.checkFunctionVarType(ty_1, ci_state, n, info);
840
841 8 (cache,dae_var_attr) := InstBinding.instDaeVariableAttributes(cache,env, mod, ty, {});
842
843 //Generate variable with default binding
844 8 ty_2 := Types.simplifyType(ty_1);
845 8 (cache,cr) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n,ty_2,{}));
846
847 //We should get a call exp from here
848
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 (cache, DAE.EQBOUND(e,_,_,_)) := InstBinding.makeBinding(cache,env,attr,mod,ty_2,pre,n,info);
849
850 // set the source of this element
851 8 source := ElementSource.createElementSource(info, FGraph.getScopePath(env), pre);
852
853
854 8 SCode.PREFIXES(visibility = vis, finalPrefix = fin, innerOuter = io) := pf;
855 8 dae := InstDAE.daeDeclare(cache, env, env_1, cr, ci_state, ty, attr, vis, SOME(e), {dims}, NONE(), dae_var_attr, SOME(comment), io, fin, source, true);
856 8 store := UnitAbsynBuilder.instAddStore(store,ty,cr);
857 8 then
858 (cache,env_1,ih,store,dae,csets,ty_1,graph);
859
860 // mahge: function variables with eqMod modifications.
861 // FIXHERE: They might have subMods too (variable attributes). see testsuite/mofiles/Sequence.mo
862 case (cache,env,ih,store,ci_state,mod as DAE.MOD(binding = SOME(_)),pre,n,cl,attr,pf,dims,_,inst_dims,impl,comment,info,graph,csets)
863 algorithm
864
2/2
✓ Branch 1 taken 364741 times.
✓ Branch 2 taken 71893 times.
436634 true := ClassInfUtil.isFunction(ci_state);
865 71893 InstUtil.checkFunctionVar(n, attr, pf, info);
866
867 //get the equation modification
868
3/6
✗ Branch 1 not taken.
✓ Branch 2 taken 71893 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71893 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 71893 times.
71893 SOME(DAE.TYPED(e,_,p,_)) := Mod.modEquation(mod);
869 //Instantiate type of the component, skip dae/not flattening (but extract functions)
870 // adrpo: do not send in the modifications as it will fail if the modification is an ARRAY.
871 // anyhow the modifications are handled below.
872 // input Integer sequence[3](min = {1,1,1}, max = {3,3,3}) = {1,2,3}; // this will fail if we send in the mod.
873 // see testsuite/mofiles/Sequence.mo
874 71893 (cache,env_1,ih,store,_,csets,ty,_,_,graph) :=
875 Inst.instClass(cache, env, ih, store, /* mod */ DAE.NOMOD(), pre, cl, inst_dims, impl, InstTypes.INNER_CALL(), graph, csets);
876
877 //Make it an array type since we are not flattening
878 71893 ty_1 := InstUtil.makeArrayType(dims, ty);
879 71893 InstUtil.checkFunctionVarType(ty_1, ci_state, n, info);
880
881 71893 (cache,dae_var_attr) := InstBinding.instDaeVariableAttributes(cache, env, mod, ty, {});
882 // Check binding type matches variable type
883 71893 (e_1,_) := Types.matchProp(e,p,DAE.PROP(ty_1,DAE.C_VAR()),true);
884
885 //Generate variable with default binding
886 53697 ty_2 := Types.simplifyType(ty_1);
887 53697 (cache,cr) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n,ty_2,{}));
888
889 // set the source of this element
890 53697 source := ElementSource.createElementSource(info, FGraph.getScopePath(env), pre);
891
892
893 53697 SCode.PREFIXES(visibility = vis, finalPrefix = fin, innerOuter = io) := pf;
894 53697 dae := InstDAE.daeDeclare(cache, env, env_1, cr, ci_state, ty, attr, vis, SOME(e_1), {dims}, NONE(), dae_var_attr, SOME(comment), io, fin, source, true);
895 53697 store := UnitAbsynBuilder.instAddStore(store,ty,cr);
896 53697 then
897 (cache,env_1,ih,store,dae,csets,ty_1,graph);
898
899
900 // Function variables without binding
901 case (cache,env,ih,store,ci_state,mod,pre,n,(cl as SCode.CLASS()),attr,pf,dims,_,inst_dims,impl,comment,info,graph,csets)
902 algorithm
903
2/2
✓ Branch 1 taken 598925 times.
✓ Branch 2 taken 205641 times.
804566 true := ClassInfUtil.isFunction(ci_state);
904 205641 InstUtil.checkFunctionVar(n, attr, pf, info);
905
906 //Instantiate type of the component, skip dae/not flattening
907 205641 (cache,env_1,ih,store,_,csets,ty,_,_,_) :=
908 Inst.instClass(cache, env, ih, store, mod, pre, cl, inst_dims, impl, InstTypes.INNER_CALL(), ConnectionGraph.EMPTY, csets);
909
910 205641 arrty := InstUtil.makeArrayType(dims, ty);
911 205641 InstUtil.checkFunctionVarType(arrty, ci_state, n, info);
912 205631 (cache,cr) := PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReferenceBasics.makeCrefIdent(n,arrty,{}));
913 205631 (cache,dae_var_attr) := InstBinding.instDaeVariableAttributes(cache,env, mod, ty, {});
914
915 // set the source of this element
916 205631 source := ElementSource.createElementSource(info, FGraph.getScopePath(env), pre);
917
918 205631 SCode.PREFIXES(visibility = vis, finalPrefix = fin, innerOuter = io) := pf;
919 205631 dae := InstDAE.daeDeclare(cache, env, env_1, cr, ci_state, ty, attr,vis,NONE(), {dims},NONE(), dae_var_attr, SOME(comment),io,fin,source,true);
920 205631 store := UnitAbsynBuilder.instAddStore(store,ty,cr);
921 205631 then
922 (cache,env_1,ih,store,dae,csets,arrty,graph);
923
924 // Scalar variables.
925 case (_, _, _, _, _, _, _, _, _, _, _, {}, _, _, _, _, _, _, _)
926 algorithm
927
2/2
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 526658 times.
526668 false := ClassInfUtil.isFunction(inState);
928 // print("InstVar.instVar2: Scalar variables case: inClass: " + SCodeDump.unparseElementStr(inClass) + "\n");
929 526658 (cache, env, ih, store, dae, csets, ty, graph) := instScalar(
930 inCache, inEnv, inIH, inStore, inState, inMod, inPrefix,
931 inName, inClass, inAttributes, inPrefixes, inSubscripts,
932 inInstDims, inImpl, SOME(inComment), inInfo, inGraph, inSets);
933 then
934 (cache, env, ih, store, dae, csets, ty, graph);
935
936 // Array variables with unknown dimensions, e.g. Real x[:] = [some expression that can be used to determine dimension].
937 case (cache,env,ih,store,ci_state,(mod as DAE.MOD(binding = SOME(DAE.TYPED()))),pre,n,cl,attr,pf,
938 ((dim as DAE.DIM_UNKNOWN()) :: dims),idxs,inst_dims,impl,comment,info,graph, csets)
939 algorithm
940
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
9 true := Config.splitArrays();
941
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
9 false := ClassInfUtil.isFunction(ci_state);
942
943 // Try to deduce the dimension from the modifier.
944 9 dim2 := InstUtil.instWholeDimFromMod(dim, mod, n, info);
945 9 inst_dims_1 := List.appendLastList(inst_dims, {dim2});
946
947 9 (cache,compenv,ih,store,dae,csets,ty,graph) :=
948 instArray(cache,env,ih,store, ci_state, mod, pre, n, (cl,attr), pf, 1, dim2, dims, idxs, inst_dims_1, impl, comment,info,graph, csets);
949 1 ty_1 := InstUtil.liftNonBasicTypes(ty,dim2); // Do not lift types extending basic type, they are already array types.
950 1 then
951 (cache,compenv,ih,store,dae,csets,ty_1,graph);
952
953 // Array variables with unknown dimensions, non-expanding case
954 case (cache,env,ih,store,ci_state,(mod as DAE.MOD(binding = SOME(DAE.TYPED()))),pre,n,cl,attr,pf,
955 ((dim as DAE.DIM_UNKNOWN()) :: dims),idxs,inst_dims,impl,comment,info,graph, csets)
956 algorithm
957
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 false := Config.splitArrays();
958 ✗ false := ClassInfUtil.isFunction(ci_state);
959 // Try to deduce the dimension from the modifier.
960 /*TODO : mahge: remove this*/
961 /*
962 dime = InstUtil.instWholeDimFromMod(dim, mod, n, info);
963 dime2 = InstUtil.makeNonExpSubscript(dime);
964 dim2 = Expression.subscriptDimension(dime);
965 inst_dims_1 = List.appendLastList(inst_dims, {dime2});
966 */
967 ✗ dim2 := InstUtil.instWholeDimFromMod(dim, mod, n, info);
968 ✗ inst_dims_1 := List.appendLastList(inst_dims, {dim2});
969 ✗ dime2 := Expression.dimensionSubscript(dim2);
970
971 ✗ (cache,compenv,ih,store,dae,csets,ty,graph) :=
972 instVar2(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,dime2::idxs,inst_dims_1,impl,comment,info,graph,csets);
973 ✗ ty_1 := InstUtil.liftNonBasicTypes(ty,dim2); // Do not lift types extending basic type, they are already array types.
974 ✗ then
975 (cache,compenv,ih,store,dae,csets,ty_1,graph);
976
977 // Array variables , e.g. Real x[3]
978 case (cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,(dim :: dims),idxs,inst_dims,impl,comment,info,graph,csets)
979 algorithm
980
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 72266 times.
72266 true := Config.splitArrays();
981
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 72266 times.
72266 false := ClassInfUtil.isFunction(ci_state);
982
983 // dim = InstUtil.evalEnumAndBoolDim(dim);
984 72266 inst_dims_1 := List.appendLastList(inst_dims, {dim});
985
986 72266 (cache,compenv,ih,store,dae,csets,ty,graph) :=
987 instArray(cache,env,ih,store, ci_state, mod, pre, n, (cl,attr), pf, 1, dim, dims, idxs, inst_dims_1, impl, comment,info,graph,csets);
988 72251 ty_1 := InstUtil.liftNonBasicTypes(ty,dim); // Do not lift types extending basic type, they are already array types.
989 72251 then
990 (cache,compenv,ih,store,dae,csets,ty_1,graph);
991
992 // Array variables , non-expanding case
993 case (cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,(dim :: dims),idxs,inst_dims,impl,comment,info,graph,csets)
994 algorithm
995
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 false := Config.splitArrays();
996 ✗ false := ClassInfUtil.isFunction(ci_state);
997 /*TODO : mahge: remove this*/
998 /*
999 dime = InstUtil.instDimExpNonSplit(dim, impl);
1000 inst_dims_1 = List.appendLastList(inst_dims, {dime});
1001 */
1002 ✗ inst_dims_1 := List.appendLastList(inst_dims, {dim});
1003 ✗ dime := Expression.dimensionSubscript(dim);
1004
1005 ✗ (cache,compenv,ih,store,dae,csets,ty,graph) :=
1006 instVar2(cache,env,ih,store,ci_state,mod,pre,n,cl,attr,pf,dims,dime::idxs,inst_dims_1,impl,comment,info,graph,csets);
1007 // Type lifting is done in the "scalar" case
1008 //ty_1 = InstUtil.liftNonBasicTypes(ty,dim); // Do not lift types extending basic type, they are already array types.
1009 then
1010 (cache,compenv,ih,store,dae,csets,ty,graph);
1011
1012 // Array variable with unknown dimensions, but no binding
1013 case (_,_,_,_,_,DAE.NOMOD(),_,n,_,_,_,
1014 ((DAE.DIM_UNKNOWN()) :: _),_,_,_,_,info,_,_)
1015 algorithm
1016 ✗ Error.addSourceMessage(Error.FAILURE_TO_DEDUCE_DIMS_NO_MOD,
1017 {String(listLength(inSubscripts) + 1), n},info);
1018 ✗ then
1019 fail();
1020
1021 // failtrace
1022 case (_,env,_,_,_,mod,pre,n,_,_,_,_,_,_,_,_,_,_,_)
1023 algorithm
1024
1/2
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
117 true := Flags.isSet(Flags.FAILTRACE);
1025 ✗ Debug.traceln("- InstVar.instVar2 failed: " +
1026 PrefixUtil.printPrefixStr(pre) + "." +
1027 n + "(" + Mod.prettyPrintMod(mod, 0) + ")\n Scope: " +
1028 FGraph.printGraphPathStr(env));
1029 ✗ then
1030 fail();
1031 end matchcontinue;
1032 end instVar2;
1033
1034 public function instScalar
1035 "Instantiates a scalar variable."
1036 input FCore.Cache inCache;
1037 input FCore.Graph inEnv;
1038 input InnerOuter.InstHierarchy inIH;
1039 input UnitAbsyn.InstStore inStore;
1040 input ClassInf.State inState;
1041 input DAE.Mod inMod;
1042 input DAE.Prefix inPrefix;
1043 input String inName;
1044 input SCode.Element inClass;
1045 input SCode.Attributes inAttributes;
1046 input SCode.Prefixes inPrefixes;
1047 input list<DAE.Subscript> inSubscripts;
1048 input list<list<DAE.Dimension>> inInstDims;
1049 input Boolean inImpl;
1050 input Option<SCode.Comment> inComment;
1051 input SourceInfo inInfo;
1052 input ConnectionGraph.ConnectionGraph inGraph;
1053 input Connect.Sets inSets;
1054 output FCore.Cache outCache;
1055 output FCore.Graph outEnv;
1056 output InnerOuter.InstHierarchy outIH;
1057 output UnitAbsyn.InstStore outStore;
1058 output DAE.DAElist outDae;
1059 output Connect.Sets outSets;
1060 output DAE.Type outType;
1061 output ConnectionGraph.ConnectionGraph outGraph;
1062 algorithm
1063 (outCache, outEnv, outIH, outStore, outDae, outSets, outType, outGraph) :=
1064 matchcontinue(inCache, inEnv, inIH, inStore, inMod, inClass, inAttributes, inPrefixes, inSubscripts)
1065
1066 local
1067 Absyn.InnerOuter io;
1068 Boolean implicitInstantiation = false;
1069 Boolean inStateAndClassNameIsEqual = false;
1070 ClassInf.State ci_state;
1071 Connect.Sets csets;
1072 ConnectionGraph.ConnectionGraph graph;
1073 DAE.ComponentRef cr;
1074 DAE.DAElist dae, dae1, dae2;
1075 DAE.ElementSource source;
1076 DAE.Mod mod;
1077 DAE.Prefix pre;
1078 DAE.StartValue start;
1079 DAE.Type ident_ty;
1080 DAE.Type ty;
1081 FCore.Cache cache;
1082 FCore.Graph env, env_1;
1083 InstanceHierarchy ih;
1084 Option<DAE.Exp> opt_binding;
1085 Option<DAE.VariableAttributes> dae_var_attr;
1086 Option<SCode.Attributes> opt_attr;
1087 SCode.Attributes attr;
1088 SCode.Element classWithElementsRemoved;
1089 SCode.Final fin;
1090 SCode.Restriction res;
1091 SCode.Variability vt;
1092 SCode.Visibility vis;
1093 String cls_name;
1094 String stateName;
1095 UnitAbsyn.InstStore store;
1096 list<DAE.Dimension> predims;
1097 list<DAE.Subscript> idxs;
1098 case (cache, env, ih, store, mod, SCode.CLASS(name = cls_name, restriction = res), SCode.ATTR(variability = vt), SCode.PREFIXES(visibility = vis, finalPrefix = fin, innerOuter = io), idxs)
1099 algorithm
1100 // Instantiate the components class.
1101 526658 idxs := listReverse(idxs);
1102 526658 ci_state := ClassInfUtil.start(res, Absyn.IDENT(cls_name));
1103 526658 predims := List.lastListOrEmpty(inInstDims);
1104 526658 pre := PrefixUtil.prefixAdd(inName, predims, idxs, inPrefix, vt, ci_state, inInfo);
1105
2/2
✓ Branch 1 taken 100405 times.
✓ Branch 2 taken 426253 times.
526658 if Config.acceptMetaModelicaGrammar() then
1106 100405 stateName := AbsynUtil.pathString(ClassInfUtil.getStateName(inState), delimiter = "");
1107
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 100322 times.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
100405 inStateAndClassNameIsEqual := stringEqual(stateName, cls_name);
1108
5/6
✓ Branch 1 taken 48213 times.
✓ Branch 2 taken 52192 times.
✓ Branch 4 taken 6397 times.
✓ Branch 5 taken 41816 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6397 times.
100405 implicitInstantiation := SCodeUtil.isUniontype(inClass)
1109 and SCodeUtil.isConstant(inAttributes.variability)
1110 and inStateAndClassNameIsEqual;
1111 /*
1112 In the case we have a cycle.
1113 Remove all cruft before instantiating and continue.
1114 In this case we DO NOT cache the result.
1115 Basically create an interface for the type so that it does not cycle.
1116 TODO: Keep records?
1117 */
1118 if implicitInstantiation then
1119 ✗ classWithElementsRemoved := SCodeUtil.setClassDef(SCode.PARTS({}, {}, {}, {}, {}, {}, {}, NONE()), inClass);
1120 ✗ (_, env_1, ih, store, dae1, csets, ty,_, opt_attr, graph) :=
1121 Inst.instClass(cache, env, ih, store, inMod, pre, classWithElementsRemoved, inInstDims,
1122 inImpl, InstTypes.INNER_CALL(), inGraph, inSets);
1123 else /* Continue as usual */
1124 100405 (cache, env_1, ih, store, dae1, csets, ty,_, opt_attr, graph) :=
1125 Inst.instClass(cache, env, ih, store, inMod, pre, inClass, inInstDims,
1126 inImpl, InstTypes.INNER_CALL(), inGraph, inSets);
1127 end if;
1128 else
1129 426253 (cache, env_1, ih, store, dae1, csets, ty,_, opt_attr, graph) :=
1130 Inst.instClass(cache, env, ih, store, inMod, pre, inClass, inInstDims,
1131 inImpl, InstTypes.INNER_CALL(), inGraph, inSets);
1132 end if;
1133 // Propagate and instantiate attributes.
1134 526574 (cache, dae_var_attr) := InstBinding.instDaeVariableAttributes(cache, env_1, inMod, ty, {});
1135 526574 attr := InstUtil.propagateAbSCDirection(vt, inAttributes, opt_attr, inInfo);
1136 526574 attr := SCodeUtil.removeAttributeDimensions(attr);
1137 // Make a component reference for the component.
1138 526574 ident_ty := InstUtil.makeCrefBaseType(ty, inInstDims);
1139 526574 cr := ComponentReferenceBasics.makeCrefIdent(inName, ident_ty, idxs);
1140 526574 (cache, cr) := PrefixUtil.prefixCref(cache, env, ih, inPrefix, cr);
1141 // adrpo: we cannot check this here as:
1142 // we might have modifications on inner that we copy here
1143 // Dymola doesn't report modifications on outer as error!
1144 // instead we check here if the modification is not the same
1145 // as the one on inner
1146 526574 InstUtil.checkModificationOnOuter(cache, env_1, ih, inPrefix, inName, cr, inMod,
1147 vt, io, inImpl, inInfo);
1148 // Set the source of this element.
1149 526574 source := ElementSource.createElementSource(inInfo, FGraph.getScopePath(env_1), inPrefix);
1150 // Instantiate the components binding.
1151
11/12
✓ Branch 0 taken 250645 times.
✓ Branch 1 taken 275929 times.
✓ Branch 3 taken 181715 times.
✓ Branch 4 taken 68930 times.
✓ Branch 6 taken 53029 times.
✓ Branch 7 taken 128686 times.
✓ Branch 10 taken 52320 times.
✓ Branch 11 taken 709 times.
✓ Branch 14 taken 52320 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 3 times.
✓ Branch 18 taken 52317 times.
526574 mod := if not listEmpty(inSubscripts) and not SCodeUtil.isParameterOrConst(vt) and not ClassInfUtil.isFunctionOrRecord(inState) and not Types.isComplexType(Types.arrayElementType(ty)) and not Types.isExternalObject(Types.arrayElementType(ty)) and not Config.scalarizeBindings()
1152 then DAE.NOMOD()
1153 else inMod;
1154 526574 opt_binding := InstBinding.makeVariableBinding(ty, mod, Types.variabilityToConst(vt), inPrefix, inName);
1155 526566 start := InstBinding.instStartBindingExp(inMod /* Yup, let's keep the start-binding. It seems sane. */, ty, vt);
1156 // Propagate the final prefix from the modifier.
1157 //fin = InstUtil.propagateModFinal(mod, fin);
1158
1/2
✓ Branch 1 taken 526566 times.
✗ Branch 2 not taken.
526566 if not Flags.getConfigBool(Flags.USE_LOCAL_DIRECTION) then
1159 526566 attr := stripVarAttrDirection(cr, ih, inState, inPrefix, attr);
1160 end if;
1161 // Propagate prefixes to any elements inside this components if it's a
1162 // structured component.
1163 526566 dae1 := InstUtil.propagateAttributes(dae1, attr, inPrefixes, inInfo);
1164 // Add the component to the DAE.
1165 526566 dae2 := InstDAE.daeDeclare(cache, env, env_1, cr, inState, ty, attr, vis, opt_binding, inInstDims,
1166 start, dae_var_attr, inComment, io, fin, source, false);
1167 526566 store := UnitAbsynBuilder.instAddStore(store, ty, cr);
1168 // The remaining work is done in instScalar2.
1169 526566 dae := instScalar2(cr, ty, vt, inMod, dae2, dae1, source, inImpl);
1170
1/2
✓ Branch 0 taken 526566 times.
✗ Branch 1 not taken.
526566 then
1171 (cache, env_1, ih, store, dae, csets, ty, graph);
1172 else
1173 algorithm
1174
1/2
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
92 true := Flags.isSet(Flags.FAILTRACE);
1175 ✗ Debug.traceln("- Inst.instScalar failed on " + inName + " in scope " + PrefixUtil.printPrefixStr(inPrefix) + " env: " + FGraph.printGraphPathStr(inEnv) + "\n");
1176 ✗ then
1177 fail();
1178 end matchcontinue;
1179 end instScalar;
1180
1181 protected function stripVarAttrDirection
1182 "This function strips the input/output prefixes from components which are not
1183 top-level or inside a top-level connector or part of a state machine component."
1184 input DAE.ComponentRef inCref;
1185 input InstanceHierarchy ih;
1186 input ClassInf.State inState;
1187 input DAE.Prefix inPrefix;
1188 input SCode.Attributes inAttributes;
1189 output SCode.Attributes outAttributes;
1190 algorithm
1191 outAttributes := matchcontinue (inCref, inState, inAttributes)
1192 local
1193 DAE.ComponentRef cref;
1194 InnerOuter.TopInstance topInstance;
1195 HashSet.HashSet sm;
1196 // Component without input/output.
1197 case (_, _, SCode.ATTR(direction = Absyn.BIDIR())) then inAttributes;
1198 // Non-qualified identifier = top-level component.
1199 case (DAE.CREF_IDENT(), _, _) then inAttributes;
1200 // Outside connector
1201 case (_, ClassInf.CONNECTOR(), _)
1202 guard(ConnectUtil.faceEqual(ConnectUtil.componentFaceType(inCref), Connect.OUTSIDE()))
1203 then inAttributes;
1204 // Component with input/output that is part of a state machine
1205 case (_, _, _)
1206 algorithm
1207 39843 topInstance := listHead(ih);
1208 21453 InnerOuter.TOP_INSTANCE(sm=sm) := topInstance;
1209
2/2
✓ Branch 1 taken 21445 times.
✓ Branch 2 taken 8 times.
21453 true := BaseHashSet.currentSize(sm) > 0;
1210 8 cref := PrefixUtil.prefixToCref(inPrefix);
1211
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 true := BaseHashSet.has(cref, sm);
1212 then inAttributes;
1213 // Everything else, strip the input/output prefix.
1214 39835 else SCodeUtil.setAttributesDirection(inAttributes, Absyn.BIDIR());
1215 end matchcontinue;
1216 end stripVarAttrDirection;
1217
1218 protected function instScalar2
1219 "Helper function to instScalar. Some operations needed when instantiating a
1220 scalar depends on what kind of variable it is, i.e. constant, parameter or
1221 variable. This function does these operations to keep instScalar simple."
1222 input DAE.ComponentRef inCref;
1223 input DAE.Type inType;
1224 input SCode.Variability inVariability;
1225 input DAE.Mod inMod;
1226 input DAE.DAElist inDae;
1227 input DAE.DAElist inClassDae;
1228 input DAE.ElementSource inSource;
1229 input Boolean inImpl;
1230 output DAE.DAElist outDae;
1231 algorithm
1232 outDae := match(inType, inVariability, inMod)
1233 local
1234 DAE.DAElist dae, cls_dae;
1235
1236 // Constant with binding.
1237 case (_, SCode.CONST(), DAE.MOD(binding = SOME(DAE.TYPED())))
1238 algorithm
1239 73388 dae := DAEUtil.joinDaes(inClassDae, inDae);
1240 then
1241 dae;
1242
1243 // mahge
1244 // Records with Bindings to other records like =>
1245 // model M
1246 // R r1 = R(1);
1247 // R r1 = r2; <= here
1248 // end M;
1249 // The dae that will be recived from instClass in instScalar will give the default record bindings for the record r1
1250 // which is wrong. Fixing it there would need a LOT of changes.
1251 // So instead we fix it here by moving the equation generated from eqMod modification for each element back to the
1252 // declaration of the element. Then removing the equation. This is done in the function moveBindings.
1253 // SEE testsuit/records/RecordBindingsOrdered.mo and RecordBindingsOrderedSimple.mo
1254 case (DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(_)), _, DAE.MOD(binding = SOME(DAE.TYPED(modifierAsExp = DAE.CREF(_, _)))))
1255 algorithm
1256 1257 dae := InstBinding.instModEquation(inCref, inType, inMod, inSource, inImpl);
1257 //move bindings from dae to inClassDae and use the resulting dae
1258 1257 dae := InstUtil.moveBindings(dae,inClassDae);
1259 1257 dae := DAEUtil.joinDaes(dae, inDae);
1260 then
1261 dae;
1262
1263 case (DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(_)), _, DAE.MOD(binding = SOME(DAE.TYPED(modifierAsExp = DAE.CAST(exp=DAE.CREF(_, _))))))
1264 algorithm
1265 ✗ dae := InstBinding.instModEquation(inCref, inType, inMod, inSource, inImpl);
1266 //move bindings from dae to inClassDae and use the resulting dae
1267 ✗ dae := InstUtil.moveBindings(dae,inClassDae);
1268 ✗ dae := DAEUtil.joinDaes(dae, inDae);
1269 then dae;
1270
1271 // Parameter with binding.
1272 case (_, SCode.PARAM(), DAE.MOD(binding = SOME(DAE.TYPED())))
1273 algorithm
1274 37130 dae := InstBinding.instModEquation(inCref, inType, inMod, inSource, inImpl);
1275 // The equations generated by InstBinding.instModEquation are used only to modify
1276 // the bindings of parameters. No extra equations are added. -- alleb
1277 37130 dae := InstUtil.propagateBinding(inClassDae, dae);
1278 37130 dae := DAEUtil.joinDaes(dae, inDae);
1279 then
1280 dae;
1281
1282 // All other scalars.
1283 else
1284 algorithm
1285
2/2
✓ Branch 1 taken 15139 times.
✓ Branch 2 taken 399652 times.
414791 dae := if Types.isComplexType(inType) then InstBinding.instModEquation(inCref, inType, inMod, inSource, inImpl) else DAE.emptyDae;
1286 414791 cls_dae := stripRecordDefaultBindingsFromDAE(inClassDae, inType, dae);
1287 414791 dae := DAEUtil.joinDaes(dae, inDae);
1288 414791 dae := DAEUtil.joinDaes(cls_dae, dae);
1289 then
1290 dae;
1291 end match;
1292 end instScalar2;
1293
1294 protected function stripRecordDefaultBindingsFromDAE
1295 "This function removes bindings from record members for which a binding
1296 equation has already been generated. This is done because the record members
1297 otherwise get a binding from the default argument of the record too."
1298 input DAE.DAElist inClassDAE;
1299 input DAE.Type inType;
1300 input DAE.DAElist inEqDAE;
1301 output DAE.DAElist outClassDAE;
1302 algorithm
1303 outClassDAE := match(inClassDAE, inType, inEqDAE)
1304 local
1305 list<DAE.Element> els, eqs;
1306
1307 // Check if the component is of record type, and if any equations have been
1308 // generated for the component's binding.
1309 case (DAE.DAE(elementLst = els),
1310 DAE.T_COMPLEX(complexClassType = ClassInf.RECORD()),
1311 DAE.DAE(elementLst = eqs as _ :: _))
1312 algorithm
1313 // This assumes that the equations are ordered the same as the variables.
1314 29 (els, _) := List.mapFold(els, stripRecordDefaultBindingsFromElement, eqs);
1315 29 then
1316 DAE.DAE(els);
1317
1318 else inClassDAE;
1319 end match;
1320 end stripRecordDefaultBindingsFromDAE;
1321
1322 protected function stripRecordDefaultBindingsFromElement
1323 input DAE.Element inVar;
1324 input list<DAE.Element> inEqs;
1325 output DAE.Element outVar;
1326 output list<DAE.Element> outEqs;
1327 algorithm
1328 (outVar, outEqs) := match (inVar, inEqs)
1329 local
1330 DAE.ComponentRef var_cr, eq_cr;
1331 list<DAE.Element> rest_eqs;
1332
1333 case (DAE.VAR(componentRef = var_cr),
1334 DAE.EQUATION(exp = DAE.CREF(componentRef = eq_cr)) :: rest_eqs)
1335 guard
1336 ComponentReferenceBasics.crefEqual(var_cr, eq_cr)
1337 // The first equation assigns the variable. Remove the variable's
1338 // binding and discard the equation.
1339 4 then
1340 (DAEUtil.setElementVarBinding(inVar, NONE()), rest_eqs);
1341
1342 case (DAE.VAR(componentRef = var_cr),
1343 DAE.COMPLEX_EQUATION(lhs = DAE.CREF(componentRef = eq_cr)) :: _)
1344 guard
1345 ComponentReferenceBasics.crefPrefixOf(eq_cr, var_cr)
1346 90 then
1347 (DAEUtil.setElementVarBinding(inVar, NONE()), inEqs);
1348
1349 else (inVar, inEqs);
1350 end match;
1351 end stripRecordDefaultBindingsFromElement;
1352
1353 protected function checkDimensionGreaterThanZero
1354 input DAE.Dimension inDim;
1355 input DAE.Prefix inPrefix;
1356 input String inIdent;
1357 input SourceInfo info;
1358 algorithm
1359 () := match inDim
1360 local
1361 String dim_str, cr_str;
1362 DAE.ComponentRef cr;
1363
1364 case DAE.DIM_INTEGER()
1365 algorithm
1366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71732 times.
71732 if inDim.integer < 0 then
1367 ✗ dim_str := ExpressionBasics.dimensionString(inDim);
1368 ✗ cr := DAE.CREF_IDENT(inIdent, DAE.T_REAL_DEFAULT, {});
1369 ✗ cr_str := ComponentReferenceBasics.printComponentRefStr(
1370 PrefixUtil.prefixCrefNoContext(inPrefix, cr));
1371 ✗ Error.addSourceMessageAndFail(Error.NEGATIVE_DIMENSION_INDEX,
1372 {dim_str, cr_str}, info);
1373 end if;
1374 then
1375 ();
1376
1377 else ();
1378 end match;
1379 end checkDimensionGreaterThanZero;
1380
1381 protected function checkArrayModDimSize
1382 "This function checks that the dimension of a modifier is the same as the
1383 modified components dimension. Only the first dimension is checked, since
1384 this function is meant to be called in instArray which is called recursively
1385 for a component's dimensions."
1386 input DAE.Mod mod;
1387 input DAE.Dimension inDimension;
1388 input DAE.Prefix inPrefix;
1389 input String inIdent;
1390 input SourceInfo inInfo;
1391 algorithm
1392 () := match mod
1393 // Only check modifiers which are not marked with 'each'.
1394 case DAE.MOD(eachPrefix = SCode.NOT_EACH())
1395 algorithm
1396 54309 List.map4_0(mod.subModLst, checkArraySubModDimSize, inDimension, inPrefix, inIdent, inInfo);
1397 then ();
1398 else ();
1399 end match;
1400 end checkArrayModDimSize;
1401
1402 protected function checkArraySubModDimSize
1403 input DAE.SubMod inSubMod;
1404 input DAE.Dimension inDimension;
1405 input DAE.Prefix inPrefix;
1406 input String inIdent;
1407 input SourceInfo inInfo;
1408 algorithm
1409 () := match inSubMod
1410 local
1411 String name;
1412 Option<DAE.EqMod> eqmod;
1413
1414 // Don't check quantity, because Dymola doesn't and as a result the MSL
1415 // contains some type errors.
1416 case DAE.NAMEMOD(ident = "quantity") then ();
1417
1418 case DAE.NAMEMOD(ident = name, mod = DAE.MOD(eachPrefix = SCode.NOT_EACH(),
1419 binding = eqmod))
1420 algorithm
1421 4428 name := inIdent + "." + name;
1422
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 4427 times.
4428 true := checkArrayModBindingDimSize(eqmod, inDimension, inPrefix, name, inInfo);
1423 then
1424 ();
1425
1426 else ();
1427 end match;
1428 end checkArraySubModDimSize;
1429
1430 protected function checkArrayModBindingDimSize
1431 input Option<DAE.EqMod> inBinding;
1432 input DAE.Dimension inDimension;
1433 input DAE.Prefix inPrefix;
1434 input String inIdent;
1435 input SourceInfo inInfo;
1436 output Boolean outIsCorrect;
1437 algorithm
1438 outIsCorrect := matchcontinue inBinding
1439 local
1440 DAE.Exp exp;
1441 DAE.Type ty;
1442 DAE.Dimension ty_dim;
1443 Integer dim_size1, dim_size2;
1444 String exp_str, exp_ty_str, dims_str;
1445 DAE.Dimensions ty_dims;
1446 SourceInfo info;
1447
1448 case SOME(DAE.TYPED(modifierAsExp = exp, properties = DAE.PROP(type_ = ty), info=info))
1449 algorithm
1450 4388 ty_dim := Types.getDimensionNth(ty, 1);
1451 4373 dim_size1 := Expression.dimensionSize(inDimension);
1452 4373 dim_size2 := Expression.dimensionSize(ty_dim);
1453
2/2
✓ Branch 0 taken 4372 times.
✓ Branch 1 taken 1 time.
4373 true := dim_size1 <> dim_size2;
1454 // If the dimensions are not equal, print an error message.
1455 1 exp_str := ExpressionBasics.printExpStr(exp);
1456 1 exp_ty_str := TypesDump.unparseType(ty);
1457 // We don't know the complete expected type, so lets assume that the
1458 // rest of the expression's type is correct (will be caught later anyway).
1459
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 _ :: ty_dims := TypesDump.getDimensions(ty);
1460 1 dims_str := ExpressionBasics.dimensionsString(inDimension :: ty_dims);
1461 1 Error.addMultiSourceMessage(Error.ARRAY_DIMENSION_MISMATCH,
1462 {exp_str, exp_ty_str, dims_str}, info::inInfo::{});
1463 then
1464 false;
1465
1466 else true;
1467 end matchcontinue;
1468 end checkArrayModBindingDimSize;
1469
1470 protected function instArray
1471 "When an array is instantiated by instVar, this function is used
1472 to go through all the array elements and instantiate each array
1473 element separately."
1474 input FCore.Cache inCache;
1475 input FCore.Graph inEnv;
1476 input InnerOuter.InstHierarchy inIH;
1477 input UnitAbsyn.InstStore inStore;
1478 input ClassInf.State inState;
1479 input DAE.Mod inMod;
1480 input DAE.Prefix inPrefix;
1481 input String inIdent;
1482 input tuple<SCode.Element, SCode.Attributes> inElement;
1483 input SCode.Prefixes inPrefixes;
1484 input Integer inInteger;
1485 input DAE.Dimension inDimension;
1486 input DAE.Dimensions inDimensionLst;
1487 input list<DAE.Subscript> inIntegerLst;
1488 input list<list<DAE.Dimension>> inInstDims;
1489 input Boolean inBoolean;
1490 input SCode.Comment inComment;
1491 input SourceInfo info;
1492 input ConnectionGraph.ConnectionGraph inGraph;
1493 input Connect.Sets inSets;
1494 output FCore.Cache outCache;
1495 output FCore.Graph outEnv;
1496 output InnerOuter.InstHierarchy outIH;
1497 output UnitAbsyn.InstStore outStore;
1498 output DAE.DAElist outDae;
1499 output Connect.Sets outSets;
1500 output DAE.Type outType;
1501 output ConnectionGraph.ConnectionGraph outGraph;
1502 algorithm
1503 72275 checkDimensionGreaterThanZero(inDimension, inPrefix, inIdent, info);
1504 72275 checkArrayModDimSize(inMod, inDimension, inPrefix, inIdent, info);
1505
1506 (outCache,outEnv,outIH,outStore,outDae,outSets,outType,outGraph) :=
1507 matchcontinue (inCache, inEnv, inIH, inStore, inState, inMod, inPrefix, inIdent, inElement, inPrefixes, inInteger, inDimension, inDimensionLst, inIntegerLst, inInstDims, inBoolean, inComment, inGraph, inSets)
1508 local
1509 DAE.Exp e,lhs,rhs;
1510 DAE.Properties p;
1511 FCore.Cache cache;
1512 FCore.Graph env_1,env,compenv;
1513 Connect.Sets csets;
1514 DAE.Type ty;
1515 ClassInf.State ci_state;
1516 DAE.ComponentRef cr;
1517 DAE.Type ty_1;
1518 DAE.Mod mod,mod_1,mod_2;
1519 DAE.Prefix pre;
1520 String n, str1, str2, str3, str4;
1521 SCode.Element cl;
1522 SCode.Attributes attr;
1523 Integer i,stop;
1524 DAE.Dimension dim;
1525 DAE.Dimensions dims;
1526 list<DAE.Subscript> idxs;
1527 InstDims inst_dims;
1528 Boolean impl;
1529 SCode.Comment comment;
1530 DAE.DAElist dae,dae1,dae2,daeLst;
1531 ConnectionGraph.ConnectionGraph graph;
1532 InstanceHierarchy ih;
1533 DAE.ElementSource source "the origin of the element";
1534 DAE.Subscript s;
1535 SCode.Prefixes pf;
1536 UnitAbsyn.InstStore store;
1537
1538 // component environment If is a function var.
1539 case (cache, env, ih, store, (ClassInf.FUNCTION()), mod, pre, n, (cl,_), _, _, dim, _, _, inst_dims, _, _, graph, csets)
1540 algorithm
1541 ✗ true := Expression.dimensionUnknownOrExp(dim);
1542 ✗ SOME(DAE.TYPED(modifierAsExp = e, properties = p)) := Mod.modEquation(mod);
1543 ✗ (cache,env_1,ih,store,_,_,ty,_,_,graph) :=
1544 Inst.instClass(cache,env,ih,store, mod, pre, cl, inst_dims, true, InstTypes.INNER_CALL(), graph, csets) "Which has an expression binding";
1545 ✗ ty_1 := Types.simplifyType(ty);
1546 ✗ (cache,cr) := PrefixUtil.prefixCref(cache,env,ih,pre,ComponentReferenceBasics.makeCrefIdent(n,ty_1,{})) "check their types";
1547 ✗ (rhs,_) := Types.matchProp(e,p,DAE.PROP(ty,DAE.C_VAR()),true);
1548
1549 // set the source of this element
1550 ✗ source := ElementSource.createElementSource(info, FGraph.getScopePath(env), pre);
1551
1552 ✗ lhs := Expression.makeCrefExp(cr,ty_1);
1553
1554 ✗ dae := InstSection.makeDaeEquation(lhs, rhs, source, SCode.NON_INITIAL());
1555 // dae = DAEUtil.joinDaes(dae,DAEUtil.extractFunctions(dae1));
1556 ✗ then
1557 (cache,env_1,ih,store,dae,inSets,ty,graph);
1558
1559 case (cache, env, ih, store, ci_state, mod, pre, n, (cl,attr), pf, i, _, dims, idxs, inst_dims, impl, comment, graph, csets)
1560 algorithm
1561
2/2
✓ Branch 1 taken 72247 times.
✓ Branch 2 taken 27 times.
72274 false := Expression.dimensionKnown(inDimension);
1562 27 e := DAE.ICONST(i);
1563 27 s := DAE.INDEX(e);
1564 27 mod := Mod.lookupIdxModification(mod, e);
1565 27 (cache,compenv,ih,store,daeLst,csets,ty,graph) :=
1566 instVar2(cache, env, ih, store, ci_state, mod, pre, n, cl, attr, pf, dims, (s :: idxs), inst_dims, impl, comment,info,graph, csets);
1567 then
1568 (cache,compenv,ih,store,daeLst,csets,ty,graph);
1569
1570 // Special case when instantiating Real[0]. We need to know the type
1571 case (cache, env, ih, store, ci_state, _, pre, n, (cl,attr), pf, _, DAE.DIM_INTEGER(0), dims, idxs, inst_dims, impl, comment, graph, csets)
1572 algorithm
1573 1158 ErrorExt.setCheckpoint("instArray Real[0]");
1574 e := DAE.ICONST(0);
1575 1158 s := DAE.INDEX(e);
1576 // Normal modifiers doesn't really matter since the empty array will be
1577 // removed anyway, and causes issues since you can't look up an element
1578 // in an empty array. But redeclares are still needed to get the correct
1579 // types, so we filter out only the redeclares.
1580 1158 mod := Mod.filterRedeclares(inMod);
1581 1158 mod := Mod.lookupIdxModification(mod, e);
1582 1158 (cache,compenv,ih,store,_,csets,ty,graph) :=
1583 instVar2(cache,env,ih,store, ci_state, mod, pre, n, cl, attr,pf, dims, (s :: idxs), inst_dims, impl, comment,info,graph, csets);
1584 1158 ErrorExt.rollBack("instArray Real[0]");
1585 1158 then
1586 (cache,compenv,ih,store,DAE.emptyDae,csets,ty,graph);
1587
1588 // Keep the errors if we somehow fail
1589 case (_, _, _, _, _, _, _, _, _, _, _, DAE.DIM_INTEGER(0), _, _, _, _, _, _, _)
1590 algorithm
1591 ✗ ErrorExt.delCheckpoint("instArray Real[0]");
1592 ✗ then
1593 fail();
1594
1595 // Handle DIM_INTEGER, where the dimension is >0
1596 case (cache, env, ih, store, ci_state, _, _, _, _, _, _, DAE.DIM_INTEGER(integer = stop), _, _, _, _, _, graph, csets)
1597 algorithm
1598 70573 (cache,env,ih,store,dae,csets,ty,graph) := instArrayDimInteger(cache,env,ih,store,ci_state,inMod,inPrefix,inIdent,inElement,inPrefixes,stop,inDimensionLst,inIntegerLst,inInstDims,inBoolean,inComment,info,graph,csets);
1599 then
1600 (cache,env,ih,store,dae,csets,ty,graph);
1601
1602 // Instantiate an array whose dimension is determined by an enumeration.
1603 case (cache, env, ih, store, ci_state, mod, pre, n, (cl, attr), pf, _, DAE.DIM_ENUM(), dims, idxs, inst_dims, impl, comment, graph, csets)
1604 511 then instArrayDimEnum(cache, env, ih, store, ci_state, mod, pre, n, cl,
1605 attr, pf, inDimension, dims, idxs, inst_dims, impl, comment, info,
1606 graph, csets);
1607
1608 case (cache, env, ih, store, ci_state, mod, pre, n, (cl, attr), pf, _, DAE.DIM_BOOLEAN(), dims, idxs, inst_dims, impl, comment, graph, csets)
1609 algorithm
1610 5 mod_1 := Mod.lookupIdxModification(mod, DAE.BCONST(false));
1611 5 mod_2 := Mod.lookupIdxModification(mod, DAE.BCONST(true));
1612 5 (cache, env_1, ih, store, dae1, csets, ty, graph) :=
1613 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);
1614 5 (cache, _, ih, store, dae2, csets, ty, graph) :=
1615 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);
1616 5 daeLst := DAEUtil.joinDaes(dae1, dae2);
1617 5 then
1618 (cache, env_1, ih, store, daeLst, csets, ty, graph);
1619
1620 case (_, _, _, _, ci_state, mod, pre, n, _, _, i, _, _, idxs, _, _, _, _, _)
1621 algorithm
1622
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 failure(Mod.lookupIdxModification(mod, DAE.ICONST(i)));
1623 ✗ str1 := PrefixUtil.printPrefixStrIgnoreNoPre(PrefixUtil.prefixAdd(n, {}, {}, pre, SCode.VAR(), ci_state, info));
1624 ✗ str2 := "[" + stringDelimitList(List.map(idxs, ExpressionBasics.printSubscriptStr), ", ") + "]";
1625 ✗ str3 := Mod.prettyPrintMod(mod, 1);
1626 ✗ str4 := PrefixUtil.printPrefixStrIgnoreNoPre(pre) + "(" + n + str2 + "=" + str3 + ")";
1627 ✗ str2 := str1 + str2;
1628 ✗ Error.addSourceMessage(Error.MODIFICATION_INDEX_NOT_FOUND, {str1,str4,str2,str3}, info);
1629 ✗ then
1630 fail();
1631
1632 else
1633 algorithm
1634
1/2
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
22 true := Flags.isSet(Flags.FAILTRACE);
1635 ✗ Debug.traceln("- Inst.instArray failed: " + inIdent);
1636 ✗ then
1637 fail();
1638 end matchcontinue;
1639 end instArray;
1640
1641 protected function instArrayDimInteger
1642 "When an array is instantiated by instVar, this function is used to go through all the array elements and instantiate each array element separately.
1643 Special case for DIM_INTEGER: tail-recursive implementation since the number of dimensions may grow arbitrarily large."
1644 input FCore.Cache inCache;
1645 input FCore.Graph inEnv;
1646 input InnerOuter.InstHierarchy inIH;
1647 input UnitAbsyn.InstStore inStore;
1648 input ClassInf.State inState;
1649 input DAE.Mod inMod;
1650 input DAE.Prefix inPrefix;
1651 input String inName;
1652 input tuple<SCode.Element, SCode.Attributes> inElement;
1653 input SCode.Prefixes inPrefixes;
1654 input Integer inDimensionSize;
1655 input DAE.Dimensions inRestDimensions;
1656 input list<DAE.Subscript> inSubscripts;
1657 input list<list<DAE.Dimension>> inInstDims;
1658 input Boolean inImpl;
1659 input SCode.Comment inComment;
1660 input SourceInfo inInfo;
1661 input ConnectionGraph.ConnectionGraph inGraph;
1662 input Connect.Sets inSets;
1663 output FCore.Cache outCache = inCache;
1664 output FCore.Graph outEnv = inEnv;
1665 output InnerOuter.InstHierarchy outIH = inIH;
1666 output UnitAbsyn.InstStore outStore = inStore;
1667 output DAE.DAElist outDae = DAE.emptyDae;
1668 output Connect.Sets outSets = inSets;
1669 output DAE.Type outType = DAE.T_UNKNOWN_DEFAULT;
1670 output ConnectionGraph.ConnectionGraph outGraph = inGraph;
1671 protected
1672 SCode.Element c, cls;
1673 DAE.Mod mod, imod;
1674 Absyn.Path cls_path;
1675 SCode.Mod smod;
1676 SCode.Attributes attr;
1677 DAE.Exp e;
1678 DAE.Subscript s;
1679 list<list<DAE.Dimension>> inst_dims;
1680 DAE.DAElist dae;
1681 algorithm
1682 (cls, mod, attr, inst_dims) := match inElement
1683 // adrpo: if a class is derived WITH AN ARRAY DIMENSION we should instVar2
1684 // the derived from type not the actual type!!!
1685 case (c as SCode.CLASS(classDef = SCode.DERIVED(
1686 typeSpec = Absyn.TPATH(cls_path, SOME(_)), modifications = smod)),
1687 attr)
1688 algorithm
1689 ✗ (_, cls, _) := Lookup.lookupClass(outCache, outEnv, cls_path, SOME(c.info));
1690 /* adrpo: TODO: merge also the attributes, i.e.:
1691 type A = input discrete flow Integer[3];
1692 A x; <-- input discrete flow IS NOT propagated even if it should. FIXME!
1693 */
1694 //SOME(attr3) = SCodeUtil.mergeAttributes(attr,SOME(absynAttr));
1695
1696 ✗ smod := InstUtil.chainRedeclares(inMod, smod);
1697 ✗ (_, mod) := Mod.elabMod(outCache, outEnv, outIH, inPrefix, smod, inImpl, Mod.DERIVED(cls_path), inInfo);
1698 ✗ mod := Mod.merge(inMod, mod);
1699 ✗ then
1700 (cls, mod, attr, {});
1701
1702 case (cls, attr) then (cls, inMod, attr, inInstDims);
1703 end match;
1704
1705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70573 times.
337439 for i in inDimensionSize:-1:1 loop
1706 266876 e := DAE.ICONST(i);
1707 266876 imod := Mod.lookupIdxModification(mod, e);
1708 266876 s := DAE.INDEX(e);
1709
1710 266876 (outCache, outEnv, outIH, outStore, dae, outSets, outType, outGraph) :=
1711 instVar2(outCache, inEnv, outIH, outStore, inState, imod, inPrefix,
1712 inName, cls, attr, inPrefixes, inRestDimensions, s :: inSubscripts,
1713 inst_dims, inImpl, inComment, inInfo, outGraph, outSets);
1714 266866 outDae := DAEUtil.joinDaes(dae, outDae);
1715 end for;
1716 end instArrayDimInteger;
1717
1718 protected function instArrayDimEnum
1719 input FCore.Cache inCache;
1720 input FCore.Graph inEnv;
1721 input InnerOuter.InstHierarchy inIH;
1722 input UnitAbsyn.InstStore inStore;
1723 input ClassInf.State inState;
1724 input DAE.Mod inMod;
1725 input DAE.Prefix inPrefix;
1726 input String inName;
1727 input SCode.Element inClass;
1728 input SCode.Attributes inAttributes;
1729 input SCode.Prefixes inPrefixes;
1730 input DAE.Dimension inDimension;
1731 input DAE.Dimensions inRestDimensions;
1732 input list<DAE.Subscript> inSubscripts;
1733 input list<list<DAE.Dimension>> inInstDims;
1734 input Boolean inImpl;
1735 input SCode.Comment inComment;
1736 input SourceInfo inInfo;
1737 input ConnectionGraph.ConnectionGraph inGraph;
1738 input Connect.Sets inSets;
1739 output FCore.Cache outCache = inCache;
1740 output FCore.Graph outEnv = inEnv;
1741 output InnerOuter.InstHierarchy outIH = inIH;
1742 output UnitAbsyn.InstStore outStore = inStore;
1743 output DAE.DAElist outDae = DAE.emptyDae;
1744 output Connect.Sets outSets = inSets;
1745 output DAE.Type outType = DAE.T_UNKNOWN_DEFAULT;
1746 output ConnectionGraph.ConnectionGraph outGraph = inGraph;
1747 protected
1748 Absyn.Path enum_path, enum_lit_path;
1749 list<String> literals;
1750 Integer i = 1;
1751 DAE.Exp e;
1752 DAE.Mod mod;
1753 DAE.DAElist dae;
1754 algorithm
1755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
511 DAE.DIM_ENUM(enumTypeName = enum_path, literals = literals) := inDimension;
1756
1757
2/2
✓ Branch 0 taken 3842 times.
✓ Branch 1 taken 511 times.
4353 for lit in literals loop
1758 3842 enum_lit_path := AbsynUtil.joinPaths(enum_path, Absyn.IDENT(lit));
1759 3842 e := DAE.ENUM_LITERAL(enum_lit_path, i);
1760 3842 mod := Mod.lookupIdxModification(inMod, e);
1761 3842 i := i + 1;
1762
1763 7684 (outCache, outEnv, outIH, outStore, dae, outSets, outType, outGraph) :=
1764 instVar2(outCache, inEnv, outIH, outStore, inState, mod, inPrefix,
1765 inName, inClass, inAttributes, inPrefixes, inRestDimensions,
1766 DAE.INDEX(e) :: inSubscripts, inInstDims, inImpl, inComment, inInfo,
1767 outGraph, outSets);
1768
1769 3842 outDae := DAEUtil.joinDaes(outDae, dae);
1770 end for;
1771 end instArrayDimEnum;
1772
1773 annotation(__OpenModelica_Interface="frontend");
1774 end InstVar;
1775