Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit bbc0127

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Record binding fixes.
- Fix type in Expression.recordElement. - Fix parents in Binding.recordFieldBinding. Belonging to [master]: - #2880
1 parent ef2d3b4 commit bbc0127

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

Compiler/NFFrontEnd/NFBinding.mo

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,39 +260,41 @@ public
260260
end isRecordExp;
261261

262262
function recordFieldBinding
263-
input String fieldName;
263+
input InstNode fieldNode;
264264
input Binding recordBinding;
265265
output Binding fieldBinding = recordBinding;
266266
protected
267267
Expression exp;
268268
Type ty;
269269
Variability var;
270+
String field_name = InstNode.name(fieldNode);
270271
algorithm
271272
fieldBinding := match fieldBinding
272273
case UNTYPED_BINDING()
273274
algorithm
274-
fieldBinding.bindingExp := Expression.recordElement(fieldName, fieldBinding.bindingExp);
275+
fieldBinding.bindingExp := Expression.recordElement(field_name, fieldBinding.bindingExp);
275276
then
276277
fieldBinding;
277278

278279
case TYPED_BINDING()
279280
algorithm
280-
exp := Expression.recordElement(fieldName, fieldBinding.bindingExp);
281+
exp := Expression.recordElement(field_name, fieldBinding.bindingExp);
281282
ty := Expression.typeOf(exp);
282283
var := Expression.variability(exp);
283284
then
284-
TYPED_BINDING(exp, ty, var, fieldBinding.parents, fieldBinding.isEach, fieldBinding.evaluated, fieldBinding.isFlattened, fieldBinding.info);
285+
TYPED_BINDING(exp, ty, var, fieldNode :: fieldBinding.parents, fieldBinding.isEach,
286+
fieldBinding.evaluated, fieldBinding.isFlattened, fieldBinding.info);
285287

286288
case FLAT_BINDING()
287289
algorithm
288-
exp := Expression.recordElement(fieldName, fieldBinding.bindingExp);
290+
exp := Expression.recordElement(field_name, fieldBinding.bindingExp);
289291
var := Expression.variability(exp);
290292
then
291293
FLAT_BINDING(exp, var);
292294

293295
case CEVAL_BINDING()
294296
algorithm
295-
fieldBinding.bindingExp := Expression.recordElement(fieldName, fieldBinding.bindingExp);
297+
fieldBinding.bindingExp := Expression.recordElement(field_name, fieldBinding.bindingExp);
296298
then
297299
fieldBinding;
298300

Compiler/NFFrontEnd/NFExpression.mo

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4588,6 +4588,7 @@ public
45884588
Class cls;
45894589
Type ty;
45904590
Integer index;
4591+
list<Expression> expl;
45914592

45924593
case RECORD(ty = Type.COMPLEX(cls = node))
45934594
algorithm
@@ -4607,9 +4608,11 @@ public
46074608
case ARRAY(ty = Type.ARRAY(elementType = Type.COMPLEX(cls = node)))
46084609
algorithm
46094610
index := Class.lookupComponentIndex(elementName, InstNode.getClass(node));
4610-
recordExp.elements := list(nthRecordElement(index, e) for e in recordExp.elements);
4611+
expl := list(nthRecordElement(index, e) for e in recordExp.elements);
4612+
ty := Type.liftArrayLeft(Expression.typeOf(listHead(expl)),
4613+
Dimension.fromInteger(listLength(expl)));
46114614
then
4612-
recordExp;
4615+
Expression.makeArray(ty, expl, recordExp.literal);
46134616

46144617
else
46154618
algorithm

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ algorithm
698698

699699
// If we found a binding, get the binding for the field from it.
700700
if Binding.isBound(binding) then
701-
binding := Binding.recordFieldBinding(InstNode.name(component), binding);
701+
binding := Binding.recordFieldBinding(component, binding);
702702
end if;
703703
else
704704
binding := NFBinding.EMPTY_BINDING;

0 commit comments

Comments
 (0)