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

Commit 70d5639

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Deduce dimensions from the start attribute.
- Try to use the start attribute to deduce unknown dimensions if a component doesn't have a binding. Belonging to [master]: - #2159 - OpenModelica/OpenModelica-testsuite#840
1 parent 0f8a7d1 commit 70d5639

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Compiler/NFFrontEnd/NFClass.mo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ uniontype Class
177177
output Modifier attribute = Modifier.NOMOD();
178178
algorithm
179179
() := match cls
180+
case PARTIAL_BUILTIN()
181+
algorithm
182+
attribute := Modifier.lookupModifier(name, cls.modifier);
183+
then
184+
();
185+
180186
case INSTANCED_BUILTIN()
181187
algorithm
182188
for attr in cls.attributes loop

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,14 @@ algorithm
492492
// If the dimension is unknown in a class, try to infer it from the components binding.
493493
case Dimension.UNKNOWN()
494494
algorithm
495-
dim := match binding
495+
// If the component doesn't have a binding, try to use the start attribute instead.
496+
b := match binding
497+
case Binding.UNBOUND()
498+
then Modifier.binding(Class.lookupAttribute("start", InstNode.getClass(component)));
499+
else binding;
500+
end match;
501+
502+
dim := match b
496503
// Print an error if there's no binding.
497504
case Binding.UNBOUND()
498505
algorithm
@@ -506,8 +513,8 @@ algorithm
506513
case Binding.UNTYPED_BINDING()
507514
algorithm
508515
prop_dims := InstNode.countDimensions(InstNode.parent(component),
509-
InstNode.level(component) - BindingOrigin.level(binding.origin));
510-
dim := typeExpDim(binding.bindingExp, index + prop_dims,
516+
InstNode.level(component) - BindingOrigin.level(b.origin));
517+
dim := typeExpDim(b.bindingExp, index + prop_dims,
511518
intBitOr(origin, ExpOrigin.DIMENSION), info);
512519
then
513520
dim;
@@ -516,8 +523,8 @@ algorithm
516523
case Binding.TYPED_BINDING()
517524
algorithm
518525
prop_dims := InstNode.countDimensions(InstNode.parent(component),
519-
InstNode.level(component) - BindingOrigin.level(binding.origin));
520-
dim := nthDimensionBoundsChecked(binding.bindingType, index + prop_dims);
526+
InstNode.level(component) - BindingOrigin.level(b.origin));
527+
dim := nthDimensionBoundsChecked(b.bindingType, index + prop_dims);
521528
then
522529
dim;
523530

0 commit comments

Comments
 (0)