Changeset 11559


Ignore:
Timestamp:
Sep 4, 2018 11:40:22 AM (15 months ago)
Author:
Jonathan Kämpe
Message:

#5670 Fixed record variability calculation bug from r11543 which lead to nullpointerexception

Location:
trunk/Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/ModelicaFlatTree/src/jastadd/Variability.jrag

    r11547 r11559  
    547547
    548548    syn TypePrefixVariability CommonAccess.variability();
    549     eq FAccess.variability() = myTopFV().variability().combine(indexVariability());
     549    eq FAccess.variability()     = myFV()   .variability()                   .combine(indexVariability());
     550    eq FAccessFull.variability() = myTopFV().variabilityHierarchical(this, 1).combine(indexVariability());
     551
     552    syn TypePrefixVariability FAbstractVariable.variabilityHierarchical(FAccessFull name, int i) {
     553        TypePrefixVariability res = variability();
     554        if (i < name.getNumFAccessPart()) {
     555            FAccessPart part = name.getFAccessPart(i);
     556            res = res.combine().combineDown(myFRecordDecl().lookupFV(part.getName()).variabilityHierarchical(name, i + 1));
     557        }
     558        return res;
     559    }
     560    eq FFunctionVariable.variabilityHierarchical(FAccessFull name, int i) = variability();
    550561
    551562    syn TypePrefixVariability FSubscript.variability() = Variability.CONSTANT;
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/VariabilityTests.mo

    r11477 r11559  
    11421142end BindingExpVariability1;
    11431143
     1144model RecordVariabilityScalarization1
     1145        record R1
     1146            Real x;
     1147            constant Real y = 2;
     1148        end R1;
     1149       
     1150        record R2
     1151            Real x;
     1152            constant Real z = 2;
     1153        end R2;
     1154       
     1155        parameter R1 r1(x=time);
     1156        parameter R2 r2(x=time);
     1157        parameter Real[:] x = {r1.x, r2.x};
     1158
     1159    annotation(__JModelica(UnitTesting(tests={
     1160        TransformCanonicalTestCase(
     1161            name="RecordVariabilityScalarization1",
     1162            description="",
     1163            flatModel="
     1164fclass VariabilityTests.RecordVariabilityScalarization1
     1165 parameter Real r1.x;
     1166 constant Real r1.y = 2;
     1167 parameter Real r2.x;
     1168 parameter Real x[1];
     1169 parameter Real x[2];
     1170parameter equation
     1171 r1.x = time;
     1172 r2.x = time;
     1173 x[1] = r1.x;
     1174 x[2] = r2.x;
     1175end VariabilityTests.RecordVariabilityScalarization1;
     1176")})));
     1177end RecordVariabilityScalarization1;
     1178
    11441179end VariabilityTests;
Note: See TracChangeset for help on using the changeset viewer.