-
Notifications
You must be signed in to change notification settings - Fork 298
/
NFBinding.mo
851 lines (749 loc) · 22.5 KB
/
NFBinding.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
encapsulated uniontype NFBinding
public
import Expression = NFExpression;
import NFInstNode.InstNode;
import Type = NFType;
import NFPrefixes.Variability;
import ErrorTypes;
import Mutable;
import Subscript = NFSubscript;
protected
import Binding = NFBinding;
import Dump;
import Error;
public
constant Binding EMPTY_BINDING = UNBOUND();
type EachType = enumeration(
NOT_EACH,
EACH
);
type EvalState = enumeration(
NOT_EVALUATED,
EVALUATING,
EVALUATED
);
type Source = enumeration(
BINDING "The binding comes from a binding equation.",
TYPE "The binding comes from a type.",
MODIFIER "The binding comes from a modifier.",
GENERATED "The binding was generated by the frontend."
);
record UNBOUND
end UNBOUND;
record RAW_BINDING
Absyn.Exp bindingExp;
InstNode scope;
list<Subscript> subs;
EachType eachType;
Source source;
SourceInfo info;
end RAW_BINDING;
record UNTYPED_BINDING
Expression bindingExp;
Boolean isProcessing;
InstNode scope;
EachType eachType;
Source source;
SourceInfo info;
end UNTYPED_BINDING;
record TYPED_BINDING
Expression bindingExp;
Type bindingType;
Variability variability;
EachType eachType;
Mutable<EvalState> evalState;
Boolean isFlattened;
Source source;
SourceInfo info;
end TYPED_BINDING;
record FLAT_BINDING
Expression bindingExp;
Variability variability;
Source source;
end FLAT_BINDING;
record CEVAL_BINDING
"Used by the constant evaluation for generated bindings (e.g. record
bindings constructed from the record fields) that should be discarded
during flattening."
Expression bindingExp;
end CEVAL_BINDING;
record INVALID_BINDING
Binding binding;
list<ErrorTypes.TotalMessage> errors;
end INVALID_BINDING;
record WILD end WILD;
public
function fromAbsyn
input Option<Absyn.Exp> bindingExp;
input Boolean eachPrefix;
input Boolean fromType;
input InstNode scope;
input SourceInfo info;
output Binding binding;
algorithm
binding := match bindingExp
local
Absyn.Exp exp;
EachType each_ty;
Source source;
case SOME(exp)
algorithm
each_ty := if eachPrefix then EachType.EACH else EachType.NOT_EACH;
source := if fromType then Source.TYPE else Source.BINDING;
then
RAW_BINDING(exp, scope, {}, each_ty, source, info);
else EMPTY_BINDING;
end match;
end fromAbsyn;
function isBound
input Binding binding;
output Boolean isBound;
algorithm
isBound := match binding
case UNBOUND() then false;
case INVALID_BINDING() then false;
else true;
end match;
end isBound;
function isExplicitlyBound
input Binding binding;
output Boolean isBound;
algorithm
isBound := match binding
case UNBOUND() then false;
case CEVAL_BINDING() then false;
case INVALID_BINDING() then false;
else true;
end match;
end isExplicitlyBound;
function isUnbound
input Binding binding;
output Boolean isUnbound;
algorithm
isUnbound := match binding
case UNBOUND() then true;
else false;
end match;
end isUnbound;
function isInvalid
input Binding binding;
output Boolean isInvalid;
algorithm
isInvalid := match binding
case INVALID_BINDING() then true;
else false;
end match;
end isInvalid;
function untypedExp
input Binding binding;
output Option<Expression> exp;
algorithm
exp := match binding
case UNTYPED_BINDING() then SOME(binding.bindingExp);
else NONE();
end match;
end untypedExp;
function typedExp
input Binding binding;
output Option<Expression> exp;
algorithm
exp := match binding
case TYPED_BINDING() then SOME(binding.bindingExp);
case FLAT_BINDING() then SOME(binding.bindingExp);
else NONE();
end match;
end typedExp;
function getUntypedExp
input Binding binding;
output Expression exp;
algorithm
UNTYPED_BINDING(bindingExp = exp) := binding;
end getUntypedExp;
function getTypedExp
input Binding binding;
output Expression exp;
algorithm
exp := match binding
case TYPED_BINDING() then binding.bindingExp;
case FLAT_BINDING() then binding.bindingExp;
end match;
end getTypedExp;
function setTypedExp
input Expression exp;
input output Binding binding;
protected
Type ty1, ty2;
algorithm
() := match binding
case TYPED_BINDING()
algorithm
binding.bindingExp := exp;
then
();
case FLAT_BINDING()
algorithm
binding.bindingExp := exp;
then
();
end match;
end setTypedExp;
function hasExp
input Binding binding;
output Boolean hasExp;
algorithm
hasExp := match binding
case UNTYPED_BINDING() then true;
case TYPED_BINDING() then true;
case FLAT_BINDING() then true;
else false;
end match;
end hasExp;
function getExp
input Binding binding;
output Expression exp;
algorithm
exp := match binding
case UNTYPED_BINDING() then binding.bindingExp;
case TYPED_BINDING() then binding.bindingExp;
case FLAT_BINDING() then binding.bindingExp;
end match;
end getExp;
function getExpOpt
input Binding binding;
output Option<Expression> exp;
algorithm
exp := match binding
case UNTYPED_BINDING() then SOME(binding.bindingExp);
case TYPED_BINDING() then SOME(binding.bindingExp);
case FLAT_BINDING() then SOME(binding.bindingExp);
else NONE();
end match;
end getExpOpt;
function setExp
input Expression exp;
input output Binding binding;
algorithm
() := match binding
case UNTYPED_BINDING()
algorithm
binding.bindingExp := exp;
then
();
case TYPED_BINDING()
algorithm
binding.bindingExp := exp;
then
();
case FLAT_BINDING()
algorithm
binding.bindingExp := exp;
then
();
end match;
end setExp;
function isRecordExp
input Binding binding;
output Boolean isRecordExp;
algorithm
isRecordExp := match binding
case TYPED_BINDING() then Expression.isRecord(binding.bindingExp);
else false;
end match;
end isRecordExp;
function isCrefExp
input Binding binding;
output Boolean isCref;
algorithm
isCref := match binding
case TYPED_BINDING() then Expression.isCref(binding.bindingExp);
else false;
end match;
end isCrefExp;
function recordFieldBinding
input InstNode fieldNode;
input Binding recordBinding;
output Binding fieldBinding = recordBinding;
protected
Expression exp;
Type ty;
Variability var;
String field_name = InstNode.name(fieldNode);
algorithm
fieldBinding := match fieldBinding
case UNTYPED_BINDING()
algorithm
fieldBinding.bindingExp := Expression.recordElement(field_name, fieldBinding.bindingExp);
then
fieldBinding;
case TYPED_BINDING()
algorithm
exp := Expression.recordElement(field_name, fieldBinding.bindingExp);
ty := Expression.typeOf(exp);
var := Expression.variability(exp);
then
TYPED_BINDING(exp, ty, var, fieldBinding.eachType, fieldBinding.evalState,
fieldBinding.isFlattened, fieldBinding.source, fieldBinding.info);
case FLAT_BINDING()
algorithm
exp := Expression.recordElement(field_name, fieldBinding.bindingExp);
var := Expression.variability(exp);
then
FLAT_BINDING(exp, var, fieldBinding.source);
case CEVAL_BINDING()
algorithm
fieldBinding.bindingExp := Expression.recordElement(field_name, fieldBinding.bindingExp);
then
fieldBinding;
end match;
end recordFieldBinding;
function variability
input Binding binding;
output Variability var;
algorithm
var := match binding
case TYPED_BINDING() then binding.variability;
case FLAT_BINDING() then binding.variability;
else
algorithm
Error.assertion(false, getInstanceName() + " got unknown binding", sourceInfo());
then
fail();
end match;
end variability;
function getInfo
input Binding binding;
output SourceInfo info;
algorithm
info := match binding
case RAW_BINDING() then binding.info;
case UNTYPED_BINDING() then binding.info;
case TYPED_BINDING() then binding.info;
else AbsynUtil.dummyInfo;
end match;
end getInfo;
function getType
input Binding binding;
output Type ty;
algorithm
ty := match binding
case UNBOUND() then Type.UNKNOWN();
case RAW_BINDING() then Type.UNKNOWN();
case UNTYPED_BINDING() then Type.UNKNOWN();
case TYPED_BINDING() then binding.bindingType;
case FLAT_BINDING() then Expression.typeOf(binding.bindingExp);
case CEVAL_BINDING() then Expression.typeOf(binding.bindingExp);
case INVALID_BINDING() then getType(binding.binding);
end match;
end getType;
function isEach
input Binding binding;
output Boolean isEach;
algorithm
isEach := match binding
case RAW_BINDING() then binding.eachType == EachType.EACH;
case UNTYPED_BINDING() then binding.eachType == EachType.EACH;
case TYPED_BINDING() then binding.eachType == EachType.EACH;
else false;
end match;
end isEach;
function isTyped
input Binding binding;
output Boolean isTyped;
algorithm
isTyped := match binding
case TYPED_BINDING() then true;
case FLAT_BINDING() then true;
else false;
end match;
end isTyped;
function toString
input Binding binding;
input String prefix = "";
output String string;
algorithm
string := match binding
case UNBOUND() then "";
case RAW_BINDING() then prefix + Dump.printExpStr(binding.bindingExp);
case UNTYPED_BINDING() then prefix + Expression.toString(binding.bindingExp);
case TYPED_BINDING() then prefix + Expression.toString(binding.bindingExp);
case FLAT_BINDING() then prefix + Expression.toString(binding.bindingExp);
case CEVAL_BINDING() then prefix + Expression.toString(binding.bindingExp);
case INVALID_BINDING() then toString(binding.binding, prefix);
end match;
end toString;
function toFlatString
input Binding binding;
input String prefix = "";
output String string;
algorithm
string := match binding
case UNBOUND() then "";
case RAW_BINDING() then prefix + Dump.printExpStr(binding.bindingExp);
case UNTYPED_BINDING() then prefix + Expression.toFlatString(binding.bindingExp);
case TYPED_BINDING() then prefix + Expression.toFlatString(binding.bindingExp);
case FLAT_BINDING() then prefix + Expression.toFlatString(binding.bindingExp);
case CEVAL_BINDING() then prefix + Expression.toFlatString(binding.bindingExp);
case INVALID_BINDING() then toFlatString(binding.binding, prefix);
end match;
end toFlatString;
function toDebugString
input Binding binding;
output String string;
algorithm
string := match binding
case UNBOUND() then "UNBOUND";
case RAW_BINDING() then "RAW_BINDING";
case UNTYPED_BINDING() then "UNTYPED_BINDING";
case TYPED_BINDING() then "TYPED_BINDING";
case FLAT_BINDING() then "FLAT_BINDING";
case CEVAL_BINDING() then "CEVAL_BINDING";
case INVALID_BINDING() then "INVALID_BINDING";
end match;
end toDebugString;
function isEqual
input Binding binding1;
input Binding binding2;
output Boolean equal;
algorithm
equal := match (binding1, binding2)
case (UNBOUND(), UNBOUND()) then true;
// TODO: Handle propagated dims.
case (RAW_BINDING(), RAW_BINDING())
then AbsynUtil.expEqual(binding1.bindingExp, binding2.bindingExp);
case (UNTYPED_BINDING(), UNTYPED_BINDING())
then Expression.isEqual(binding1.bindingExp, binding2.bindingExp);
case (TYPED_BINDING(), TYPED_BINDING())
then Expression.isEqual(binding1.bindingExp, binding2.bindingExp);
else false;
end match;
end isEqual;
function toDAE
input Binding binding;
output DAE.Binding outBinding;
algorithm
outBinding := match binding
case UNBOUND() then DAE.UNBOUND();
case TYPED_BINDING() then makeDAEBinding(binding.bindingExp, binding.variability);
case FLAT_BINDING() then makeDAEBinding(binding.bindingExp, binding.variability);
case CEVAL_BINDING() then DAE.UNBOUND();
case INVALID_BINDING()
algorithm
Error.addTotalMessages(binding.errors);
then
fail();
else
algorithm
Error.assertion(false, getInstanceName() + " got untyped binding", sourceInfo());
then
fail();
end match;
end toDAE;
function makeDAEBinding
input Expression exp;
input Variability var;
output DAE.Binding binding;
algorithm
binding := DAE.EQBOUND(
Expression.toDAE(exp),
NONE(),
Variability.variabilityToDAEConst(var),
DAE.BINDING_FROM_DEFAULT_VALUE() // TODO: revise this.
);
end makeDAEBinding;
function toDAEExp
input Binding binding;
output Option<DAE.Exp> bindingExp;
algorithm
bindingExp := match binding
case UNBOUND() then NONE();
case TYPED_BINDING() then SOME(Expression.toDAE(binding.bindingExp));
case FLAT_BINDING() then SOME(Expression.toDAE(binding.bindingExp));
case CEVAL_BINDING() then NONE();
else
algorithm
Error.assertion(false, getInstanceName() + " got untyped binding", sourceInfo());
then
fail();
end match;
end toDAEExp;
function mapExp
input output Binding binding;
input MapFunc mapFn;
partial function MapFunc
input output Expression exp;
end MapFunc;
protected
Expression e1, e2;
algorithm
() := match binding
case UNTYPED_BINDING(bindingExp = e1)
algorithm
e2 := Expression.map(e1, mapFn);
if not referenceEq(e1, e2) then
binding.bindingExp := e2;
end if;
then
();
case TYPED_BINDING(bindingExp = e1)
algorithm
e2 := Expression.map(e1, mapFn);
if not referenceEq(e1, e2) then
binding.bindingExp := e2;
end if;
then
();
case FLAT_BINDING(bindingExp = e1)
algorithm
e2 := Expression.map(e1, mapFn);
if not referenceEq(e1, e2) then
binding.bindingExp := e2;
end if;
then
();
case CEVAL_BINDING(bindingExp = e1)
algorithm
e2 := Expression.map(e1, mapFn);
if not referenceEq(e1, e2) then
binding.bindingExp := e2;
end if;
then
();
else ();
end match;
end mapExp;
function mapExpShallow
input output Binding binding;
input MapFunc mapFn;
partial function MapFunc
input output Expression exp;
end MapFunc;
protected
Expression e1, e2;
algorithm
() := match binding
case UNTYPED_BINDING(bindingExp = e1)
algorithm
e2 := mapFn(e1);
if not referenceEq(e1, e2) then
binding.bindingExp := e2;
end if;
then
();
case TYPED_BINDING(bindingExp = e1)
algorithm
e2 := mapFn(e1);
if not referenceEq(e1, e2) then
binding.bindingExp := e2;
end if;
then
();
case FLAT_BINDING(bindingExp = e1)
algorithm
e2 := mapFn(e1);
if not referenceEq(e1, e2) then
binding.bindingExp := e2;
end if;
then
();
case CEVAL_BINDING(bindingExp = e1)
algorithm
e2 := mapFn(e1);
if not referenceEq(e1, e2) then
binding.bindingExp := e2;
end if;
then
();
else ();
end match;
end mapExpShallow;
function foldExp<ArgT>
input Binding binding;
input FoldFunc foldFn;
input output ArgT arg;
partial function FoldFunc
input Expression exp;
input output ArgT arg;
end FoldFunc;
algorithm
arg := match binding
case UNTYPED_BINDING() then Expression.fold(binding.bindingExp, foldFn, arg);
case TYPED_BINDING() then Expression.fold(binding.bindingExp, foldFn, arg);
case FLAT_BINDING() then Expression.fold(binding.bindingExp, foldFn, arg);
case CEVAL_BINDING() then Expression.fold(binding.bindingExp, foldFn, arg);
else arg;
end match;
end foldExp;
function containsExp
input Binding binding;
input PredFunc predFn;
output Boolean res;
partial function PredFunc
input Expression exp;
output Boolean res;
end PredFunc;
algorithm
res := match binding
case UNTYPED_BINDING() then Expression.contains(binding.bindingExp, predFn);
case TYPED_BINDING() then Expression.contains(binding.bindingExp, predFn);
case FLAT_BINDING() then Expression.contains(binding.bindingExp, predFn);
case CEVAL_BINDING() then Expression.contains(binding.bindingExp, predFn);
else false;
end match;
end containsExp;
function update
input output Binding binding;
input Expression exp;
algorithm
binding := match binding
case UNBOUND()
then TYPED_BINDING(
bindingExp = exp,
bindingType = Expression.typeOf(exp),
variability = Expression.variability(exp),
eachType = EachType.NOT_EACH,
evalState = if Expression.isConstNumber(exp)
then Mutable.create(EvalState.EVALUATED)
else Mutable.create(EvalState.NOT_EVALUATED),
isFlattened = true,
source = Source.BINDING,
info = sourceInfo()
);
case UNTYPED_BINDING() algorithm
binding.bindingExp := exp;
then binding;
case TYPED_BINDING() algorithm
binding.bindingExp := exp;
then binding;
case FLAT_BINDING() algorithm
binding.bindingExp := exp;
then binding;
case CEVAL_BINDING() algorithm
binding.bindingExp := exp;
then binding;
case INVALID_BINDING() algorithm
binding.binding := update(binding.binding, exp);
then binding;
case RAW_BINDING() algorithm
Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed because a raw binding cannot be updated."});
then fail();
else algorithm
Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed."});
then fail();
end match;
end update;
function setAttr
"sets a specific attribute value and adds it if it does not exist"
input output list<tuple<String, Binding>> ty_attr;
input String attr_name;
input Binding attr_value;
algorithm
ty_attr := match ty_attr
local
tuple<String, Binding> at;
list<tuple<String, Binding>> rest;
String name;
case (name, _ ) :: rest guard(name == attr_name) then (attr_name, attr_value) :: rest;
case at :: rest then at :: setAttr(rest, attr_name, attr_value);
case {} then {(attr_name, attr_value)};
end match;
end setAttr;
function propagate
"Propagates a modifier through an element, given as a list of split subscript."
input output Binding binding;
input list<Subscript> subs;
algorithm
() := match binding
case RAW_BINDING()
algorithm
binding.subs := listAppend(binding.subs, subs);
binding.source := Source.MODIFIER;
then
();
else ();
end match;
end propagate;
function source
input Binding binding;
output Source source;
algorithm
source := match binding
case RAW_BINDING() then binding.source;
case UNTYPED_BINDING() then binding.source;
case TYPED_BINDING() then binding.source;
case FLAT_BINDING() then binding.source;
else Source.BINDING;
end match;
end source;
function makeTyped
input Expression exp;
input EachType eachType;
input Source source;
input SourceInfo info;
input EvalState state = EvalState.NOT_EVALUATED;
output Binding binding;
algorithm
binding := TYPED_BINDING(exp, Expression.typeOf(exp),
Expression.variability(exp), eachType, Mutable.create(state), false, source, info);
end makeTyped;
function makeFlat
input Expression exp;
input Variability var;
input Source source;
output Binding binding;
algorithm
binding := FLAT_BINDING(exp, var, source);
end makeFlat;
function isEvaluated
input Binding binding;
output Boolean evaluated;
algorithm
evaluated := match binding
case TYPED_BINDING()
then Mutable.access(binding.evalState) == EvalState.EVALUATED;
case CEVAL_BINDING() then true;
else false;
end match;
end isEvaluated;
function hasTypeOrigin
input Binding binding;
output Boolean res;
algorithm
res := match binding
case RAW_BINDING()
guard not listEmpty(binding.subs)
then Subscript.isSplitClassProxy(listHead(binding.subs));
else false;
end match;
end hasTypeOrigin;
annotation(__OpenModelica_Interface="frontend");
end NFBinding;