Skip to content

Commit

Permalink
- send in the file info in BackendDAEUtil.checkAssertCondition so we …
Browse files Browse the repository at this point in the history
…know where the assertion got triggered

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14053 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 24, 2012
1 parent d9c0001 commit 726d959
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAECreate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,7 @@ algorithm
(cond,source,_) = Inline.inlineExp(cond,(SOME(functionTree),{DAE.NORM_INLINE()}),source);
(msg,source,_) = Inline.inlineExp(msg,(SOME(functionTree),{DAE.NORM_INLINE()}),source);
(level,source,_) = Inline.inlineExp(level,(SOME(functionTree),{DAE.NORM_INLINE()}),source);
BackendDAEUtil.checkAssertCondition(cond,msg,level);
BackendDAEUtil.checkAssertCondition(cond,msg,level,DAEUtil.getElementSourceFileInfo(source));
alg = DAE.ALGORITHM_STMTS({DAE.STMT_ASSERT(cond,msg,level,source)});
then
(inEquations,BackendDAE.ALGORITHM(0,alg,source)::inREquations,inIEquations);
Expand Down
15 changes: 8 additions & 7 deletions Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ encapsulated package BackendDAEUtil
public import BackendDAE;
public import DAE;
public import Env;
public import Absyn;

protected import Absyn;
protected import Algorithm;
protected import BackendDump;
protected import BackendDAECreate;
Expand Down Expand Up @@ -395,28 +395,29 @@ public function checkAssertCondition "Succeds if condition of assert is not cons
input DAE.Exp cond;
input DAE.Exp message;
input DAE.Exp level;
input Absyn.Info info;
algorithm
_ := matchcontinue(cond,message,level)
_ := matchcontinue(cond,message,level,info)
local
String messageStr;
case(_, _, _)
case(_, _, _,_)
equation
// Don't check assertions when checking models
true = Flags.getConfigBool(Flags.CHECK_MODEL);
then ();
case (_,_,_)
case (_,_,_,_)
equation
false = Expression.isConstFalse(cond);
then ();
case (_,_,_)
case (_,_,_,_)
equation
failure(DAE.ENUM_LITERAL(index=1) = level);
then ();
case(_,_,_)
case(_,_,_,_)
equation
true = Expression.isConstFalse(cond);
messageStr = ExpressionDump.printExpStr(message);
Error.addMessage(Error.ASSERT_CONSTANT_FALSE_ERROR,{messageStr});
Error.addSourceMessage(Error.ASSERT_CONSTANT_FALSE_ERROR,{messageStr},info);
then fail();
end matchcontinue;
end checkAssertCondition;
Expand Down
5 changes: 2 additions & 3 deletions Compiler/BackEnd/BackendVariable.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ algorithm
);
// do not add if const true
false = Expression.isConstTrue(cond);
BackendDAEUtil.checkAssertCondition(cond,msg,DAE.ASSERTIONLEVEL_WARNING);
BackendDAEUtil.checkAssertCondition(cond,msg,DAE.ASSERTIONLEVEL_WARNING,DAEUtil.getElementSourceFileInfo(source));
then
{DAE.ALGORITHM_STMTS({DAE.STMT_ASSERT(cond,msg,DAE.ASSERTIONLEVEL_WARNING,source)})};
case(_,_,_,_,_) then {};
Expand Down Expand Up @@ -2001,14 +2001,13 @@ algorithm
);
// do not add if const true
false = Expression.isConstTrue(cond);
BackendDAEUtil.checkAssertCondition(cond,msg,DAE.ASSERTIONLEVEL_WARNING);
BackendDAEUtil.checkAssertCondition(cond,msg,DAE.ASSERTIONLEVEL_WARNING,DAEUtil.getElementSourceFileInfo(source));
then
{DAE.ALGORITHM_STMTS({DAE.STMT_ASSERT(cond,msg,DAE.ASSERTIONLEVEL_WARNING,source)})};
case(_,_,_,_,_) then {};
end matchcontinue;
end getNominalAssert;


public function varSortFunc "function varSortFun
A sorting function (greatherThan) for Variables based on crefs"
input BackendDAE.Var v1;
Expand Down

0 comments on commit 726d959

Please sign in to comment.