/
FunctionRecordArg4.mo
52 lines (47 loc) · 1022 Bytes
/
FunctionRecordArg4.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// name: FunctionRecordArg4
// keywords:
// status: correct
// cflags: -d=newInst
//
record BaseR
constant Integer n;
final parameter Real x[n] = ones(n);
end BaseR;
function f
input BaseR r;
output Real x;
algorithm
x := r.x * r.x;
end f;
record R = BaseR(final n = 2);
model FunctionRecordArg4
R r;
Real x = f(r);
end FunctionRecordArg4;
// Result:
// function BaseR "Automatically generated record constructor for BaseR"
// input Integer n;
// protected Real[n] x = fill(1.0, n);
// output BaseR res;
// end BaseR;
//
// function R "Automatically generated record constructor for R"
// protected Integer n = 2;
// protected Real[2] x = fill(1.0, n);
// output R res;
// end R;
//
// function f
// input BaseR r;
// output Real x;
// algorithm
// x := r.x * r.x;
// end f;
//
// class FunctionRecordArg4
// final constant Integer r.n = 2;
// final parameter Real r.x[1] = 1.0;
// final parameter Real r.x[2] = 1.0;
// Real x = f(r);
// end FunctionRecordArg4;
// endResult