Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…navigation=true

- 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
  • Loading branch information
perost committed Mar 30, 2010
1 parent deff1a3 commit 1d602c5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
9 changes: 7 additions & 2 deletions Compiler/CevalScript.mo
Expand Up @@ -77,6 +77,7 @@ protected import Inst;
protected import InnerOuter;
protected import Lookup;
protected import ModUtil;
protected import OptManager;
protected import Prefix;
protected import Parser;
protected import Print;
Expand Down Expand Up @@ -306,8 +307,10 @@ algorithm
instClsLst = ic,
lstVarVal = iv,
compiledFunctions = cf)),msg)
equation
(cache,ret_val,st_1) = checkModel(cache, env, className, st, msg);
equation
_ = OptManager.setOption("checkModel", true);
(cache,ret_val,st_1) = checkModel(cache, env, className, st, msg);
_ = OptManager.setOption("checkModel", false);
then
(cache,ret_val,st_1);

Expand Down Expand Up @@ -3895,7 +3898,9 @@ algorithm
false = Interactive.isType(cr, p);
print("Checking: " +& Dump.unparseClassAttributesStr(c) +& " " +& Absyn.pathString(className) +& "... ");
t1 = clock();
_ = OptManager.setOption("checkModel", true);
(cache,Values.STRING(str),_) = checkModel(cache, env, className, st, msg);
_ = OptManager.setOption("checkModel", false);
t2 = clock(); elapsedTime = t2 -. t1; s = realString(elapsedTime);
print (s +& " seconds -> " +& failOrSuccess(str) +& "\n\t");
print (System.stringReplace(str, "\n", "\n\t"));
Expand Down
6 changes: 6 additions & 0 deletions Compiler/DAELow.mo
Expand Up @@ -419,6 +419,7 @@ protected import Derive;
protected import Env;
protected import Error;
protected import Exp;
protected import OptManager;
protected import Print;
protected import RTOpts;
protected import SimCodegen;
Expand Down Expand Up @@ -5010,6 +5011,11 @@ protected function checkAssertCondition "Succeds if condition of assert is not c
input DAE.Exp message;
algorithm
_ := matchcontinue(cond,message)
case(_, _)
equation
// Don't check assertions when checking models
true = OptManager.getOption("checkModel");
then ();
case(cond,message) equation
false = Exp.isConstFalse(cond);
then ();
Expand Down
17 changes: 15 additions & 2 deletions Compiler/Static.mo
Expand Up @@ -11292,8 +11292,8 @@ algorithm
then
(cache,sub_1::subs_1,const,dae);

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

// If the previous case failed and we're just checking the model, try again
// but skip the constant evaluation.
case (cache,env,(sub :: subs),(SOME(dim) :: restdims),impl)
equation
true = OptManager.getOption("checkModel");
(cache,sub_1,const1,dae1) = elabSubscript(cache,env, sub, impl);
(cache,subs_1,const2,dae2) = elabSubscriptsDims2(cache,env, subs, restdims, impl);
const = Types.constAnd(const1, const2);
true = Types.isParameterOrConstant(const);
dae = DAEUtil.joinDaes(dae1,dae2);
then
(cache,sub_1::subs_1,const,dae);

// if not constant, keep as is.
case (cache,env,(sub :: subs),(SOME(_) :: restdims),impl)
equation
Expand Down

0 comments on commit 1d602c5

Please sign in to comment.