Skip to content

Commit

Permalink
- Exp.mo
Browse files Browse the repository at this point in the history
  copy all functions for dump and print to ExpressionDump.mo

git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/sjoelund-functiontree@6623 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Oct 26, 2010
1 parent 0208a13 commit 6834be7
Show file tree
Hide file tree
Showing 40 changed files with 2,787 additions and 2,713 deletions.
47 changes: 24 additions & 23 deletions Compiler/Algorithm.mo
Expand Up @@ -62,13 +62,14 @@ public type Else = DAE.Else;

protected import DAEUtil;
protected import Debug;
protected import RTOpts;
protected import Error;
protected import ExpressionDump;
protected import Exp;
protected import Print;
protected import RTOpts;
protected import System;
protected import Types;
protected import Util;
protected import System;

public function algorithmEmpty "Returns true if algorithm is empty, i.e. no statements"
input Algorithm alg;
Expand Down Expand Up @@ -159,8 +160,8 @@ algorithm
case (lhs,lprop,rhs,rprop,_,initial_,source)
equation
DAE.C_CONST() = Types.propAnyConst(lprop);
lhs_str = Exp.printExpStr(lhs);
rhs_str = Exp.printExpStr(rhs);
lhs_str = ExpressionDump.printExpStr(lhs);
rhs_str = ExpressionDump.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_CONSTANT_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
fail();
Expand All @@ -177,16 +178,16 @@ algorithm
case (lhs,lprop,rhs,rprop,_,SCode.NON_INITIAL(),source)
equation
DAE.C_PARAM() = Types.propAnyConst(lprop);
lhs_str = Exp.printExpStr(lhs);
rhs_str = Exp.printExpStr(rhs);
lhs_str = ExpressionDump.printExpStr(lhs);
rhs_str = ExpressionDump.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_PARAM_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
fail();
/* assignment to a constant, report error */
case (lhs,_,rhs,_,SCode.RO(),_,source)
equation
lhs_str = Exp.printExpStr(lhs);
rhs_str = Exp.printExpStr(rhs);
lhs_str = ExpressionDump.printExpStr(lhs);
rhs_str = ExpressionDump.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_READONLY_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
fail();
Expand All @@ -210,8 +211,8 @@ algorithm
lt = Types.getPropType(lprop);
rt = Types.getPropType(rprop);
false = Types.equivtypes(lt, rt);
lhs_str = Exp.printExpStr(lhs);
rhs_str = Exp.printExpStr(rhs);
lhs_str = ExpressionDump.printExpStr(lhs);
rhs_str = ExpressionDump.printExpStr(rhs);
lt_str = Types.unparseType(lt);
rt_str = Types.unparseType(rt);
Error.addSourceMessage(Error.ASSIGN_TYPE_MISMATCH_ERROR,
Expand All @@ -224,9 +225,9 @@ algorithm
equation
Print.printErrorBuf("- Algorithm.makeAssignment failed\n");
Print.printErrorBuf(" ");
Print.printErrorBuf(Exp.printExpStr(lhs));
Print.printErrorBuf(ExpressionDump.printExpStr(lhs));
Print.printErrorBuf(" := ");
Print.printErrorBuf(Exp.printExpStr(rhs));
Print.printErrorBuf(ExpressionDump.printExpStr(rhs));
Print.printErrorBuf("\n");
then
fail();
Expand Down Expand Up @@ -342,21 +343,21 @@ algorithm
equation
bvals = Util.listMap(lprop, Types.propAnyConst);
DAE.C_CONST() = Util.listReduce(bvals, Types.constOr);
sl = Util.listMap(lhs, Exp.printExpStr);
sl = Util.listMap(lhs, ExpressionDump.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = System.stringAppendList({"(",s,")"});
rhs_str = Exp.printExpStr(rhs);
rhs_str = ExpressionDump.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_CONSTANT_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
fail();
case (lhs,lprop,rhs,rprop,SCode.NON_INITIAL(),source)
equation
bvals = Util.listMap(lprop, Types.propAnyConst);
DAE.C_PARAM() = Util.listReduce(bvals, Types.constOr);
sl = Util.listMap(lhs, Exp.printExpStr);
sl = Util.listMap(lhs, ExpressionDump.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = System.stringAppendList({"(",s,")"});
rhs_str = Exp.printExpStr(rhs);
rhs_str = ExpressionDump.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_PARAM_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
fail();
Expand Down Expand Up @@ -384,10 +385,10 @@ algorithm
case (lhs,lprop,rhs,rprop,initial_,source)
equation
true = RTOpts.debugFlag("failtrace");
sl = Util.listMap(lhs, Exp.printExpStr);
sl = Util.listMap(lhs, ExpressionDump.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = System.stringAppendList({"(",s,")"});
rhs_str = Exp.printExpStr(rhs);
rhs_str = ExpressionDump.printExpStr(rhs);
str1 = Util.stringDelimitList(Util.listMap(lprop, Types.printPropStr), ", ");
str2 = Types.printPropStr(rprop);
strInitial = SCode.printInitialStr(initial_);
Expand Down Expand Up @@ -466,7 +467,7 @@ algorithm
DAE.STMT_IF(e,tb,else_,source);
case (e,DAE.PROP(type_ = t),_,_,_,source)
equation
e_str = Exp.printExpStr(e);
e_str = ExpressionDump.printExpStr(e);
t_str = Types.unparseType(t);
Error.addSourceMessage(Error.IF_CONDITION_TYPE_ERROR, {e_str,t_str}, DAEUtil.getElementSourceFileInfo(source));
then
Expand Down Expand Up @@ -499,7 +500,7 @@ algorithm
DAE.ELSEIF(e,b,else_);
case (((e,DAE.PROP(type_ = t),_) :: _),_)
equation
e_str = Exp.printExpStr(e);
e_str = ExpressionDump.printExpStr(e);
t_str = Types.unparseType(t);
Error.addMessage(Error.IF_CONDITION_TYPE_ERROR, {e_str,t_str});
then
Expand Down Expand Up @@ -534,7 +535,7 @@ algorithm
DAE.STMT_FOR(et,array,i,e,stmts,source);
case (_,e,DAE.PROP(type_ = t),_,source)
equation
e_str = Exp.printExpStr(e);
e_str = ExpressionDump.printExpStr(e);
t_str = Types.unparseType(t);
Error.addSourceMessage(Error.FOR_EXPRESSION_TYPE_ERROR, {e_str,t_str}, DAEUtil.getElementSourceFileInfo(source));
then
Expand All @@ -561,7 +562,7 @@ algorithm
case (e,DAE.PROP(type_ = (DAE.T_BOOL(varLstBool = _),_)),stmts,source) then DAE.STMT_WHILE(e,stmts,source);
case (e,DAE.PROP(type_ = t),_,source)
equation
e_str = Exp.printExpStr(e);
e_str = ExpressionDump.printExpStr(e);
t_str = Types.unparseType(t);
Error.addSourceMessage(Error.WHILE_CONDITION_TYPE_ERROR, {e_str,t_str}, DAEUtil.getElementSourceFileInfo(source));
then
Expand Down Expand Up @@ -591,7 +592,7 @@ algorithm
case (e,DAE.PROP(type_ = (DAE.T_ARRAY(arrayType = (DAE.T_BOOL(varLstBool = _),_)),_)),stmts,elsew,source) then DAE.STMT_WHEN(e,stmts,elsew,{},source);
case (e,DAE.PROP(type_ = t),_,_,source)
equation
e_str = Exp.printExpStr(e);
e_str = ExpressionDump.printExpStr(e);
t_str = Types.unparseType(t);
Error.addSourceMessage(Error.WHEN_CONDITION_TYPE_ERROR, {e_str,t_str}, DAEUtil.getElementSourceFileInfo(source));
then
Expand Down
9 changes: 4 additions & 5 deletions Compiler/BackendDAETransform.mo
Expand Up @@ -41,21 +41,20 @@ public import BackendDAE;
public import ComponentReference;
public import DAE;
public import DAELow;
public import Exp;
public import ExpressionSimplify;
public import SCode;
public import Values;
public import BackendVariable;

protected import Algorithm;
protected import BackendDump;
protected import BackendVarTransform;
protected import ClassInf;
protected import DAEUtil;
protected import Debug;
protected import Derive;
protected import Env;
protected import Error;
protected import Exp;
protected import ExpressionDump;
protected import OptManager;
protected import RTOpts;
protected import Util;
Expand Down Expand Up @@ -1154,7 +1153,7 @@ algorithm
case (DAE.WHEN_EQUATION(condition = cond),_,_)
local String scond;
equation
scond = Exp.printExpStr(cond);
scond = ExpressionDump.printExpStr(cond);
print("- DAELow.lowerWhenEqn: Error in lowerWhenEqn. \n when ");
print(scond);
print(" ... \n");
Expand Down Expand Up @@ -3095,7 +3094,7 @@ algorithm
local String messageStr;
equation
true = Exp.isConstFalse(cond);
messageStr = Exp.printExpStr(message);
messageStr = ExpressionDump.printExpStr(message);
Error.addMessage(Error.ASSERT_CONSTANT_FALSE_ERROR,{messageStr});
then fail();
end matchcontinue;
Expand Down
5 changes: 3 additions & 2 deletions Compiler/BackendDAEUtil.mo
Expand Up @@ -60,6 +60,7 @@ protected import Ceval;
protected import DAELow;
protected import Debug;
protected import Error;
protected import ExpressionDump;
protected import HashTable2;
protected import Values;
protected import ValuesUtil;
Expand Down Expand Up @@ -100,7 +101,7 @@ algorithm
true = RTOpts.debugFlag("checkBackendDAE");
strcrefs = Util.listMap(crefs,ComponentReference.crefStr);
crefstring = Util.stringDelimitList(strcrefs,", ");
expstr = Exp.printExpStr(e);
expstr = ExpressionDump.printExpStr(e);
scopestr = System.stringAppendList({crefstring," from Expression: ",expstr});
Error.addMessage(Error.LOOKUP_VARIABLE_ERROR, {scopestr,"BackendDAE object"});
printcheckBackendDAEWithErrorMsg(res);
Expand Down Expand Up @@ -1202,7 +1203,7 @@ algorithm
case (e,vars)
equation
// adrpo: TODO! FIXME! this function fails for some of the expressions: cr.cr.cr[{1,2,3}] for example.
// Debug.fprintln("daelow", "- DAELow.statesAndVarsExp failed to extract states or vars from expression: " +& Exp.dumpExpStr(e,0));
// Debug.fprintln("daelow", "- DAELow.statesAndVarsExp failed to extract states or vars from expression: " +& ExpressionDump.dumpExpStr(e,0));
then {};
end matchcontinue;
end statesAndVarsExp;
Expand Down

0 comments on commit 6834be7

Please sign in to comment.