Skip to content

Commit 5f67ec6

Browse files
authored
Declare DynamicSelect to be impure (#9806)
- Declare DynamicSelect to be impure to make sure the compiler doesn't try to evaluate it.
1 parent 6351983 commit 5f67ec6

File tree

3 files changed

+104
-1
lines changed

3 files changed

+104
-1
lines changed

OMCompiler/Compiler/NFFrontEnd/NFModelicaBuiltin.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ function size "Returns dimensions of an array"
626626
</html>"));
627627
end size;
628628

629-
function DynamicSelect<__Any> "select static or dynamic expressions in the annotations"
629+
impure function DynamicSelect<__Any> "select static or dynamic expressions in the annotations"
630630
input __Any static;
631631
input __Any dynamic;
632632
output __Any selected;
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// name: GetModelInstanceAnnotation5
2+
// keywords:
3+
// status: correct
4+
// cflags: -d=newInst
5+
//
6+
//
7+
8+
loadString("
9+
model M
10+
annotation(Icon(graphics = {
11+
Rectangle(extent = DynamicSelect({{0, 0}, {20, 20}}, {{0, 0}, {20, 30}}))
12+
}));
13+
end M;
14+
");
15+
16+
getModelInstance(M, prettyPrint=true);
17+
18+
// Result:
19+
// true
20+
// "{
21+
// \"name\": \"M\",
22+
// \"restriction\": \"model\",
23+
// \"annotation\": {
24+
// \"Icon\": {
25+
// \"graphics\": [
26+
// {
27+
// \"$kind\": \"record\",
28+
// \"name\": \"Rectangle\",
29+
// \"elements\": [
30+
// true,
31+
// [
32+
// 0,
33+
// 0
34+
// ],
35+
// 0,
36+
// [
37+
// 0,
38+
// 0,
39+
// 0
40+
// ],
41+
// [
42+
// 0,
43+
// 0,
44+
// 0
45+
// ],
46+
// {
47+
// \"$kind\": \"enum\",
48+
// \"name\": \"LinePattern.Solid\",
49+
// \"index\": 2
50+
// },
51+
// {
52+
// \"$kind\": \"enum\",
53+
// \"name\": \"FillPattern.None\",
54+
// \"index\": 1
55+
// },
56+
// 0.25,
57+
// {
58+
// \"$kind\": \"enum\",
59+
// \"name\": \"BorderPattern.None\",
60+
// \"index\": 1
61+
// },
62+
// {
63+
// \"$kind\": \"call\",
64+
// \"name\": \"DynamicSelect\",
65+
// \"arguments\": [
66+
// [
67+
// [
68+
// 0,
69+
// 0
70+
// ],
71+
// [
72+
// 20,
73+
// 20
74+
// ]
75+
// ],
76+
// [
77+
// [
78+
// 0,
79+
// 0
80+
// ],
81+
// [
82+
// 20,
83+
// 30
84+
// ]
85+
// ]
86+
// ]
87+
// },
88+
// 0
89+
// ]
90+
// }
91+
// ]
92+
// }
93+
// },
94+
// \"source\": {
95+
// \"filename\": \"<interactive>\",
96+
// \"lineStart\": 2,
97+
// \"columnStart\": 3,
98+
// \"lineEnd\": 6,
99+
// \"columnEnd\": 8
100+
// }
101+
// }"
102+
// endResult

testsuite/openmodelica/instance-API/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ GetModelInstanceAnnotation1.mos \
55
GetModelInstanceAnnotation2.mos \
66
GetModelInstanceAnnotation3.mos \
77
GetModelInstanceAnnotation4.mos \
8+
GetModelInstanceAnnotation5.mos \
89
GetModelInstanceAttributes1.mos \
910
GetModelInstanceAttributes2.mos \
1011
GetModelInstanceComment1.mos \

0 commit comments

Comments
 (0)