Skip to content

Commit 1d602c5

Browse files
committed
- The checkModel flag is now set in CevalScript when checkModel is run. - Static.elabSubscriptsDims2 now avoids printing error messages for out of bounds indices when checking a model. - DAELow.checkAssertCondition now skips checking assertions when checking models. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5236 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent deff1a3 commit 1d602c5

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

Compiler/CevalScript.mo

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ protected import Inst;
7777
protected import InnerOuter;
7878
protected import Lookup;
7979
protected import ModUtil;
80+
protected import OptManager;
8081
protected import Prefix;
8182
protected import Parser;
8283
protected import Print;
@@ -306,8 +307,10 @@ algorithm
306307
instClsLst = ic,
307308
lstVarVal = iv,
308309
compiledFunctions = cf)),msg)
309-
equation
310-
(cache,ret_val,st_1) = checkModel(cache, env, className, st, msg);
310+
equation
311+
_ = OptManager.setOption("checkModel", true);
312+
(cache,ret_val,st_1) = checkModel(cache, env, className, st, msg);
313+
_ = OptManager.setOption("checkModel", false);
311314
then
312315
(cache,ret_val,st_1);
313316

@@ -3895,7 +3898,9 @@ algorithm
38953898
false = Interactive.isType(cr, p);
38963899
print("Checking: " +& Dump.unparseClassAttributesStr(c) +& " " +& Absyn.pathString(className) +& "... ");
38973900
t1 = clock();
3901+
_ = OptManager.setOption("checkModel", true);
38983902
(cache,Values.STRING(str),_) = checkModel(cache, env, className, st, msg);
3903+
_ = OptManager.setOption("checkModel", false);
38993904
t2 = clock(); elapsedTime = t2 -. t1; s = realString(elapsedTime);
39003905
print (s +& " seconds -> " +& failOrSuccess(str) +& "\n\t");
39013906
print (System.stringReplace(str, "\n", "\n\t"));

Compiler/DAELow.mo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ protected import Derive;
419419
protected import Env;
420420
protected import Error;
421421
protected import Exp;
422+
protected import OptManager;
422423
protected import Print;
423424
protected import RTOpts;
424425
protected import SimCodegen;
@@ -5010,6 +5011,11 @@ protected function checkAssertCondition "Succeds if condition of assert is not c
50105011
input DAE.Exp message;
50115012
algorithm
50125013
_ := matchcontinue(cond,message)
5014+
case(_, _)
5015+
equation
5016+
// Don't check assertions when checking models
5017+
true = OptManager.getOption("checkModel");
5018+
then ();
50135019
case(cond,message) equation
50145020
false = Exp.isConstFalse(cond);
50155021
then ();

Compiler/Static.mo

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11292,8 +11292,8 @@ algorithm
1129211292
then
1129311293
(cache,sub_1::subs_1,const,dae);
1129411294

11295-
// if the subscript contains a param or const the it should be evaluated to the value
11296-
case (cache,env,(sub :: subs),(SOME(dim) :: restdims),impl) /* If param, call ceval. */
11295+
// If the subscript contains a param or const then it should be evaluated to the value
11296+
case (cache,env,(sub :: subs),(SOME(dim) :: restdims),impl) /* If param or const, call ceval. */
1129711297
equation
1129811298
(cache,sub_1,const1,dae1) = elabSubscript(cache,env, sub, impl);
1129911299
(cache,subs_1,const2,dae2) = elabSubscriptsDims2(cache,env, subs, restdims, impl);
@@ -11304,6 +11304,19 @@ algorithm
1130411304
then
1130511305
(cache,sub_1::subs_1,const,dae);
1130611306

11307+
// If the previous case failed and we're just checking the model, try again
11308+
// but skip the constant evaluation.
11309+
case (cache,env,(sub :: subs),(SOME(dim) :: restdims),impl)
11310+
equation
11311+
true = OptManager.getOption("checkModel");
11312+
(cache,sub_1,const1,dae1) = elabSubscript(cache,env, sub, impl);
11313+
(cache,subs_1,const2,dae2) = elabSubscriptsDims2(cache,env, subs, restdims, impl);
11314+
const = Types.constAnd(const1, const2);
11315+
true = Types.isParameterOrConstant(const);
11316+
dae = DAEUtil.joinDaes(dae1,dae2);
11317+
then
11318+
(cache,sub_1::subs_1,const,dae);
11319+
1130711320
// if not constant, keep as is.
1130811321
case (cache,env,(sub :: subs),(SOME(_) :: restdims),impl)
1130911322
equation

0 commit comments

Comments
 (0)