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% 4 / 0 / 4
Functions: -% 0 / 1 / 1
Branches: 100.0% 12 / 0 / 12

OMCompiler/Compiler/NFFrontEnd/NFDuplicateTree.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 NFDuplicateTree
37
38 type EntryType = enumeration(DUPLICATE, REDECLARE, ENTRY);
39
40 public
41 import NFLookupTree;
42 import NFInstNode;
43 import List;
44
45 uniontype Entry
46 record ENTRY
47 NFLookupTree.Entry entry;
48 Option<NFInstNode.InstNode> node;
49 list<Entry> children;
50 EntryType ty;
51 end ENTRY;
52 end Entry;
53
54 function newRedeclare
55 input NFLookupTree.Entry entry;
56 output Entry redecl = ENTRY(entry, NONE(), {}, EntryType.REDECLARE);
57 end newRedeclare;
58
59 function newDuplicate
60 input NFLookupTree.Entry kept;
61 input NFLookupTree.Entry duplicate;
62 output Entry entry = ENTRY(kept, NONE(), {newEntry(duplicate)}, EntryType.DUPLICATE);
63 end newDuplicate;
64
65 function newEntry
66 input NFLookupTree.Entry lentry;
67 output Entry entry = ENTRY(lentry, NONE(), {}, EntryType.ENTRY);
68 end newEntry;
69
70 function idExistsInEntry
71 input NFLookupTree.Entry id;
72 input Entry entry;
73 output Boolean exists;
74 algorithm
75
4/4
✓ Branch 2 taken 4384 times.
✓ Branch 3 taken 974 times.
✓ Branch 6 taken 914 times.
✓ Branch 7 taken 3470 times.
5358 exists := NFLookupTree.Entry.isEqual(id, entry.entry) or
76 List.any(entry.children, function idExistsInEntry(id = id));
77 end idExistsInEntry;
78
79 function getLookupEntries
80 input Entry entry;
81 output list<NFLookupTree.Entry> entries;
82 algorithm
83
4/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 2 times.
3 entries := entry.entry :: listAppend(getLookupEntries(c) for c in entry.children);
84 end getLookupEntries;
85
86 function entryToList
87 input Entry entry;
88 output list<Entry> entries;
89 algorithm
90
4/4
✓ Branch 0 taken 33044 times.
✓ Branch 1 taken 66000 times.
✓ Branch 2 taken 33044 times.
✓ Branch 3 taken 66000 times.
99044 entries := entry :: listAppend(entryToList(c) for c in entry.children);
91 end entryToList;
92
93 import BaseAvlTree;
94 extends BaseAvlTree(redeclare type Key = String,
95 redeclare type Value = Entry);
96
97 redeclare function extends keyStr
98 algorithm
99 outString := inKey;
100 end keyStr;
101
102 redeclare function extends valueStr
103 algorithm
104 outString := "";
105 end valueStr;
106
107 redeclare function extends keyCompare
108 algorithm
109 181627 outResult := stringCompare(inKey1, inKey2);
110 end keyCompare;
111
112 annotation(__OpenModelica_Interface="nf_frontend");
113 end NFDuplicateTree;
114