Changeset 13940


Ignore:
Timestamp:
Nov 4, 2019 8:44:10 AM (2 weeks ago)
Author:
molsson
Message:

#5843 Reverted r13927 and r13932.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Compiler/ModelicaFrontEnd/src/jastadd/errorcheck/ErrorCheck.jrag

    r13932 r13940  
    852852                    getFArraySubscripts().collectErrors(checkType);
    853853                }
    854                 if (hasConditionalAttribute()) {
    855                     FExp cond = getConditionalAttribute();
    856                     cond.collectErrors(checkType);
    857                     if (!cond.type().isUnknown()) {
    858                         if (!cond.type().isScalar() || !cond.type().isBoolean()) {
    859                             NON_BOOLEAN_CONDITIONAL_GUARD.invoke(this);
    860                         }
    861                         if (!cond.variability().fixedParameterOrLess()) {
    862                             NON_FIXED_CONDITIONAL_GUARD.invoke(this);
    863                         } else {
    864                             cond.markAsStructuralParameter(checkType);
    865                         }
    866                     }
     854                if (hasConditionalAttribute())  {
     855                    getConditionalAttribute().collectErrors(checkType);
    867856                }
    868857                if (!isDisabled() && hasInstModification()) {
  • trunk/Compiler/ModelicaFrontEnd/src/jastadd/errorcheck/TypeCheck.jrag

    r13932 r13940  
    190190            new ErrorProducerUnlessDisabled("ARRAY_SIZE_MISMATCH_IN_MODIFICATION_DUE_TO_EACH", ProblemKind.SEMANTIC,
    191191                    "Array size mismatch in modification of %s, expected size is (due to 'each') %s and size of binding expression is %s");
     192    public static final SimpleProblemProducer ASTNode.NON_SCALAR_CONDITIONAL_GUARD =
     193            new SimpleErrorProducer("NON_SCALAR_CONDITIONAL_GUARD", ProblemKind.SEMANTIC,
     194                    "The guard expression of a conditional component should be a scalar expression");
    192195    public static final SimpleProblemProducer ASTNode.NON_BOOLEAN_CONDITIONAL_GUARD =
    193196            new SimpleErrorProducer("NON_BOOLEAN_CONDITIONAL_GUARD", ProblemKind.SEMANTIC,
    194                     "The guard expression of a conditional component should be a scalar Boolean expression");
     197                    "The guard expression of a conditional component should be a boolean expression");
    195198    public static final SimpleProblemProducer ASTNode.NON_FIXED_CONDITIONAL_GUARD =
    196199            new SimpleErrorProducer("NON_FIXED_CONDITIONAL_GUARD", ProblemKind.SEMANTIC,
    197                     "The guard expression of a conditional component must be a fixed parameter expression");
    198 
    199     @Override
     200                    "The guard expression of a conditional component should have parameter or constant variability");
     201
    200202    public void InstAssignable.typeCheck(ErrorCheckType checkType) {
    201203        FExp bexp = myBindingInstExp();
     
    260262                        typeCheckCell(expected, actual, bexp, unknownAllowed);
    261263                    }
     264                }
     265            }
     266        }
     267       
     268        if (hasConditionalAttribute()) {
     269            FExp cond = getConditionalAttribute();
     270            if (!cond.type().isUnknown()) {
     271                if (!cond.type().isScalar())
     272                    NON_SCALAR_CONDITIONAL_GUARD.invoke(this);
     273                if (!cond.type().isBoolean())
     274                    NON_BOOLEAN_CONDITIONAL_GUARD.invoke(this);
     275                if (!cond.variability().parameterOrLess()) {
     276                    NON_FIXED_CONDITIONAL_GUARD.invoke(this);
     277                } else {
     278                    cond.markAsStructuralParameter(checkType);
    262279                }
    263280            }
  • trunk/Compiler/ModelicaFrontEnd/src/jastadd/flattening/Flattening.jrag

    r13927 r13940  
    17341734        }
    17351735        if (isConnectorVariable()) {
    1736             return connectorVariablePrefix();
     1736            if (isInput()) {
     1737                return CausalityConnectorPrefix.INPUT;
     1738            } else if (isOutput()) {
     1739                return CausalityConnectorPrefix.OUTPUT;
     1740            } else if (isFlow()) {
     1741                return CausalityConnectorPrefix.FLOW;
     1742            } else if (isStream()) {
     1743                return CausalityConnectorPrefix.STREAM;
     1744            } else if (!variability().parameterOrLess()) {
     1745                return CausalityConnectorPrefix.POTENTIAL;
     1746            } else {
     1747                return CausalityConnectorPrefix.NONE;
     1748            }
    17371749        } else {
    17381750            if (isInput()) {
     
    17431755                return CausalityConnectorPrefix.NONE;
    17441756            }
    1745         }
    1746     }
    1747    
    1748     /**
    1749      * Computes the {@link CausalityConnectorPrefix} this variable would have if it
    1750      * was a connector variable in a top-level connector.
    1751      */
    1752     public CausalityConnectorPrefix InstAssignable.connectorVariablePrefix() {
    1753         if (isInput()) {
    1754             return CausalityConnectorPrefix.INPUT;
    1755         } else if (isOutput()) {
    1756             return CausalityConnectorPrefix.OUTPUT;
    1757         } else if (isFlow()) {
    1758             return CausalityConnectorPrefix.FLOW;
    1759         } else if (isStream()) {
    1760             return CausalityConnectorPrefix.STREAM;
    1761         } else if (!variability().parameterOrLess()) {
    1762             return CausalityConnectorPrefix.POTENTIAL;
    1763         } else {
    1764             return CausalityConnectorPrefix.NONE;
    17651757        }
    17661758    }
  • trunk/Compiler/ModelicaFrontEnd/src/jastadd/instance/InnerOuter.jrag

    r13927 r13940  
    113113    eq BaseNode.getChild().isGeneratedInner()                       = false;
    114114
    115     inh boolean InstComponentDecl.isInGeneratedInner();
    116     eq InstGeneratedInner.getInstComponentDecl().isInGeneratedInner() = true;
    117     eq InstClassDecl.getChild().isInGeneratedInner()                  = false;
    118 
    119115}
    120116
  • trunk/Compiler/ModelicaFrontEnd/src/jastadd/util/Util.jrag

    r13927 r13940  
    13131313   
    13141314
    1315     syn boolean SrcComponentDecl.isParameter() = myComponentClause().isParameter();
    1316     syn boolean SrcComponentDecl.isConstant()  = myComponentClause().isConstant();
    1317     syn boolean SrcComponentDecl.isDiscrete()  = myComponentClause().isDiscrete();
    1318    
    1319     syn boolean SrcComponentClause.isParameter() = hasSrcTypePrefixVariability() && getSrcTypePrefixVariability().parameterVariability();
    1320     syn boolean SrcComponentClause.isConstant()  = hasSrcTypePrefixVariability() && getSrcTypePrefixVariability().constantVariability();
    1321     syn boolean SrcComponentClause.isDiscrete()  = hasSrcTypePrefixVariability() && getSrcTypePrefixVariability().discreteVariability();
     1315    /**
     1316     * Check if this component is declared parameter.
     1317     */
     1318    syn boolean SrcComponentDecl.isParameter() = hasSrcTypePrefixVariability() && getSrcTypePrefixVariability().parameterVariability();
     1319   
     1320    /**
     1321     * Check if this component is declared constant.
     1322     */
     1323    syn boolean SrcComponentDecl.isConstant() = hasSrcTypePrefixVariability() && getSrcTypePrefixVariability().constantVariability();
     1324   
     1325    /**
     1326     * Check if this component clause is declared constant.
     1327     */
     1328    syn boolean SrcComponentClause.isConstant() = hasSrcTypePrefixVariability() && getSrcTypePrefixVariability().constantVariability();
     1329   
     1330    /**
     1331     * Check if this component is declared discrete.
     1332     */
     1333    syn boolean SrcComponentDecl.isDiscrete() = hasSrcTypePrefixVariability() && getSrcTypePrefixVariability().discreteVariability();
    13221334
    13231335    /**
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/CheckTests.mo

    r13932 r13940  
    174174    parameter Boolean b = false;
    175175
    176 annotation(__JModelica(UnitTesting(tests={
    177     FlatteningTestCase(
    178         name="ConditionalError2",
    179         description="Check that inactive conditional components aren't error checked in compile mode",
    180         flatModel="
     176    annotation(__JModelica(UnitTesting(tests={
     177        FlatteningTestCase(
     178            name="ConditionalError2",
     179            description="Check that inactive conditional components aren't error checked in compile mode",
     180            flatModel="
    181181fclass CheckTests.ConditionalError2
    182  structural parameter Boolean b = false /* false */;
     182 parameter Boolean b = false /* false */;
    183183end CheckTests.ConditionalError2;
    184184")})));
     
    203203    parameter Boolean b = false;
    204204
    205 annotation(__JModelica(UnitTesting(tests={
    206     FlatteningTestCase(
    207         name="ConditionalError3",
    208         description="Check that inactive conditional components aren't searched for used functions and enums when flattening in compile mode",
    209         flatModel="
     205    annotation(__JModelica(UnitTesting(tests={
     206        FlatteningTestCase(
     207            name="ConditionalError3",
     208            description="Check that inactive conditional components aren't searched for used functions and enums when flattening in compile mode",
     209            flatModel="
    210210fclass CheckTests.ConditionalError3
    211  structural parameter Boolean b = false /* false */;
     211 parameter Boolean b = false /* false */;
    212212end CheckTests.ConditionalError3;
    213213")})));
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/ConnectTests.mo

    r13932 r13940  
    31013101    connect(a.c, c);
    31023102
    3103 annotation(__JModelica(UnitTesting(tests={
    3104     FlatteningTestCase(
    3105         name="ConditionalNoErrTest6",
    3106         description="Ensure that components in conditionaly false components aren't error checked due to connections",
    3107         flatModel="
     3103    annotation(__JModelica(UnitTesting(tests={
     3104        FlatteningTestCase(
     3105            name="ConditionalNoErrTest6",
     3106            description="Ensure that components in conditionaly false components aren't error checked due to connections",
     3107            flatModel="
    31083108fclass ConnectTests.ConditionalNoErrTest6
    3109  structural parameter Boolean on = false /* false */;
     3109 parameter Boolean on = false /* false */;
    31103110 Real c;
    31113111end ConnectTests.ConditionalNoErrTest6;
     
    31623162        flatModel="
    31633163fclass ConnectTests.ConditionalCompInConnector1
    3164  structural parameter Boolean c1.b = false /* false */;
     3164 parameter Boolean c1.b = false /* false */;
    31653165 potential Real c1.y;
    3166  structural parameter Boolean c2.b = false /* false */;
     3166 parameter Boolean c2.b = false /* false */;
    31673167 potential Real c2.y;
    31683168equation
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo

    r13932 r13940  
    30163016  parameter Real x = 1 if 1;
    30173017
    3018 annotation(__JModelica(UnitTesting(tests={
    3019     ErrorTestCase(
    3020         name="ConditionalComponentTest1_Err",
    3021         description="Test of type checking of conditional components.",
    3022         errorMessage="
    3023 
    3024 
    3025 Error at line 2, column 3, in file '...', NON_BOOLEAN_CONDITIONAL_GUARD:
    3026   The guard expression of a conditional component should be a scalar Boolean expression
     3018    annotation(__JModelica(UnitTesting(tests={
     3019        ErrorTestCase(
     3020            name="ConditionalComponentTest1_Err",
     3021            description="Test of type checking of conditional components.",
     3022            errorMessage="
     30231 errors found:
     3024
     3025Error at line 2, column 3, in file 'Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo', NON_BOOLEAN_CONDITIONAL_GUARD:
     3026  The guard expression of a conditional component should be a boolean expression
    30273027")})));
    30283028end ConditionalComponentTest1_Err;
     
    30323032  parameter Real x = 1 if b;
    30333033
    3034 annotation(__JModelica(UnitTesting(tests={
    3035     ErrorTestCase(
    3036         name="ConditionalComponentTest2_Err",
    3037         description="Test of type checking of conditional components.",
    3038         errorMessage="
    3039 
    3040 
    3041 Error at line 3, column 3, in file '...', NON_BOOLEAN_CONDITIONAL_GUARD:
    3042   The guard expression of a conditional component should be a scalar Boolean expression
     3034    annotation(__JModelica(UnitTesting(tests={
     3035        ErrorTestCase(
     3036            name="ConditionalComponentTest2_Err",
     3037            description="Test of type checking of conditional components.",
     3038            errorMessage="
     30391 errors found:
     3040
     3041Error at line 3, column 3, in file 'Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo', NON_SCALAR_CONDITIONAL_GUARD:
     3042  The guard expression of a conditional component should be a scalar expression
    30433043")})));
    30443044end ConditionalComponentTest2_Err;
     
    30483048  parameter Real x = 1 if b;
    30493049
    3050 annotation(__JModelica(UnitTesting(tests={
    3051     ErrorTestCase(
    3052         name="ConditionalComponentTest3_Err",
    3053         description="Test of type checking of conditional components.",
    3054         errorMessage="
    3055 
    3056 
    3057 Error at line 3, column 3, in file '...', NON_BOOLEAN_CONDITIONAL_GUARD:
    3058   The guard expression of a conditional component should be a scalar Boolean expression
     3050    annotation(__JModelica(UnitTesting(tests={
     3051        ErrorTestCase(
     3052            name="ConditionalComponentTest3_Err",
     3053            description="Test of type checking of conditional components.",
     3054            errorMessage="
     30552 errors found:
     3056
     3057Error at line 3, column 3, in file 'Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo', NON_BOOLEAN_CONDITIONAL_GUARD:
     3058  The guard expression of a conditional component should be a boolean expression
     3059
     3060Error at line 3, column 3, in file 'Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo', NON_SCALAR_CONDITIONAL_GUARD:
     3061  The guard expression of a conditional component should be a scalar expression
    30593062")})));
    30603063end ConditionalComponentTest3_Err;
     
    31443147            flatModel="
    31453148fclass NameTests.ConditionalComponentTest8
    3146  structural parameter Boolean b = false /* false */;
     3149 parameter Boolean b = false /* false */;
    31473150
    31483151end NameTests.ConditionalComponentTest8;
     
    31753178            flatModel="
    31763179fclass NameTests.ConditionalComponentTest9
    3177  structural parameter Boolean b = false /* false */;
     3180 parameter Boolean b = false /* false */;
    31783181
    31793182end NameTests.ConditionalComponentTest9;
     
    33773380")})));
    33783381end ConditionalComponentTest14;
    3379 
    3380 
    3381 model ConditionalComponentTest15_Err
    3382     connector C
    3383         Real x;
    3384     end C;
    3385    
    3386     parameter Integer b[2] = {1,1};
    3387     C c if b;
    3388 annotation(__JModelica(UnitTesting(tests={
    3389     ErrorTestCase(
    3390         name="ConditionalComponentTest15_Err",
    3391         description="Test of type checking of conditional composite component.",
    3392         errorMessage="
    3393 
    3394 
    3395 Error at line 7, column 5, in file '...', NON_BOOLEAN_CONDITIONAL_GUARD:
    3396   The guard expression of a conditional component should be a scalar Boolean expression
    3397 ")})));
    3398 end ConditionalComponentTest15_Err;
    3399 
    3400 
    3401 model ConditionalComponentTest16
    3402     connector C
    3403         Real x;
    3404     end C;
    3405    
    3406     parameter Boolean b = false;
    3407     C c if b;
    3408 annotation(__JModelica(UnitTesting(tests={
    3409     FlatteningTestCase(
    3410         description="Flattening conditional composite component",
    3411         flatModel="
    3412 fclass NameTests.ConditionalComponentTest16
    3413  structural parameter Boolean b = false /* false */;
    3414 end NameTests.ConditionalComponentTest16;
    3415 ")})));
    3416 end ConditionalComponentTest16;
    3417 
    3418 
    3419 model ConditionalComponentTest17
    3420     connector C
    3421         Real x;
    3422     end C;
    3423    
    3424     parameter Boolean b = true;
    3425     C c if b;
    3426 annotation(__JModelica(UnitTesting(tests={
    3427     FlatteningTestCase(
    3428         description="Flattening conditional composite component",
    3429         flatModel="
    3430 fclass NameTests.ConditionalComponentTest17
    3431  structural parameter Boolean b = true /* true */;
    3432  potential Real c.x;
    3433 end NameTests.ConditionalComponentTest17;
    3434 ")})));
    3435 end ConditionalComponentTest17;
    3436 
    3437 
    3438 model ConditionalComponentTest18_Err
    3439     parameter Boolean b(start = false, fixed = false);
    3440     Real x if b;
    3441     Real y if time > 5;
    3442 annotation(__JModelica(UnitTesting(tests={
    3443     ErrorTestCase(
    3444         description="Checking that conditional guard is a fixed parameter expression.",
    3445         errorMessage="
    3446 Error at line 3, column 5, in file '...', NON_FIXED_CONDITIONAL_GUARD:
    3447   The guard expression of a conditional component must be a fixed parameter expression
    3448 Error at line 4, column 5, in file '...', NON_FIXED_CONDITIONAL_GUARD:
    3449   The guard expression of a conditional component must be a fixed parameter expression
    3450 
    3451 ")})));
    3452 end ConditionalComponentTest18_Err;
    3453 
    3454 
    34553382
    34563383model AttributeDot1
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/RedeclareTests.mo

    r13932 r13940  
    66196619    A a(use_b = false, redeclare C b);
    66206620
    6621 annotation(__JModelica(UnitTesting(tests={
    6622     FlatteningTestCase(
    6623         name="Misc_RedeclareConditional1",
    6624         description="Redeclaring inactive conditional as modification",
    6625         flatModel="
     6621    annotation(__JModelica(UnitTesting(tests={
     6622        FlatteningTestCase(
     6623            name="RedeclareConditional1",
     6624            description="Redeclaring inactive conditional as modification",
     6625            flatModel="
    66266626fclass RedeclareTests.Misc.RedeclareConditional1
    6627  structural parameter Boolean a.use_b = false /* false */;
     6627 parameter Boolean a.use_b = false /* false */;
    66286628end RedeclareTests.Misc.RedeclareConditional1;
    66296629")})));
     
    66536653    D d;
    66546654
    6655 annotation(__JModelica(UnitTesting(tests={
    6656     FlatteningTestCase(
    6657         name="Misc_RedeclareConditional2",
    6658         description="Redeclaring inactive conditional as element",
    6659         flatModel="
     6655    annotation(__JModelica(UnitTesting(tests={
     6656        FlatteningTestCase(
     6657            name="RedeclareConditional2",
     6658            description="Redeclaring inactive conditional as element",
     6659            flatModel="
    66606660fclass RedeclareTests.Misc.RedeclareConditional2
    6661  structural parameter Boolean d.use_b = false /* false */;
     6661 parameter Boolean d.use_b = false /* false */;
    66626662end RedeclareTests.Misc.RedeclareConditional2;
    66636663")})));
  • trunk/Compiler/ModelicaMiddleEnd/src/jastadd/scalarization/Scalarization.jrag

    r13927 r13940  
    619619    public class ScalarizingVariableInstance {
    620620       
    621         private final TypePrefixVariability variability;
    622        
    623         private final VisibilityType visibility;
     621        private TypePrefixVariability variability;
     622       
     623        private VisibilityType visibility;
    624624       
    625625        // Binding expression
    626         private final FExp bExp;
     626        private FExp bExp;
    627627       
    628628        // (Mapped) attributes of this variable
    629         private final Map<String, FAttribute> mattrs;
     629        private Map<String, FAttribute> mattrs;
    630630       
    631631        // Full name of this variable
    632         private final String name;
     632        private String name;
    633633       
    634634        // input/output prefix of top-level variable
    635         private final CausalityConnectorPrefix inputOutput;
    636        
    637         private final Index index;
     635        private CausalityConnectorPrefix inputOutput;
     636       
     637        private Index index;
    638638       
    639639        private ScalarizingVariableInstance(String name, Map<String, FAttribute> mattrs, FExp be,
     
    645645            this.variability = variability;
    646646            this.visibility = visibility;
    647             /* If we have a record with input/output prefix that contains a parameter,
    648              * that parameter should not inherit the input/output prefix */
    649             this.inputOutput = variability.parameterOrLess() ? CausalityConnectorPrefix.NONE : inputOutput;
     647            this.inputOutput = inputOutput;
    650648        }
    651649       
Note: See TracChangeset for help on using the changeset viewer.