Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#1657
- Removed use of unary operators .- and .+
- Removed operator DAE.UPLUS and DAE.UPLUS_ARR; these are handled directly by elabExp

NOTE: YOU NEED TO MAKE CLEAN BECAUSE RML DOES NOT RECOGNIZE WHEN AN OPERATOR HAS BEEN REMOVED FROM DAE.mo


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10596 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 29, 2011
1 parent d0948de commit bdb83cb
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 140 deletions.
2 changes: 0 additions & 2 deletions Compiler/BackEnd/XMLDump.mo
Expand Up @@ -3763,9 +3763,7 @@ algorithm
outString:=
match (inOperator)
case (DAE.UMINUS(ty = _)) then MathMLMinus;
case (DAE.UPLUS(ty = _)) then "";//Not necessay
case (DAE.UMINUS_ARR(ty = _)) then MathMLMinus;
case (DAE.UPLUS_ARR(ty = _)) then "";//Not necessary
end match;
end unaryopSymbol;

Expand Down
7 changes: 0 additions & 7 deletions Compiler/FrontEnd/Ceval.mo
Expand Up @@ -576,13 +576,6 @@ algorithm
then
(cache,v_1,stOpt);

// unary plus of expression
case (cache,env,DAE.UNARY(operator = DAE.UPLUS(ty = _),exp = daeExp),impl,stOpt,msg)
equation
(cache,v,stOpt) = ceval(cache,env, daeExp, impl, stOpt, msg);
then
(cache,v,stOpt);

// Logical operations false AND rhs
// special case when leftside is false...
// We allow errors on right hand side. and even if there is no errors, the performance
Expand Down
8 changes: 0 additions & 8 deletions Compiler/FrontEnd/DAE.mo
Expand Up @@ -1393,18 +1393,10 @@ uniontype Operator "Operators which are overloaded in the abstract syntax are he
ExpType ty;
end UMINUS;

record UPLUS
ExpType ty;
end UPLUS;

record UMINUS_ARR
ExpType ty;
end UMINUS_ARR;

record UPLUS_ARR
ExpType ty;
end UPLUS_ARR;

record ADD_ARR
ExpType ty;
end ADD_ARR;
Expand Down
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/DAEDump.mo
Expand Up @@ -172,9 +172,7 @@ algorithm
case(DAE.DIV(ty=ty)) then " DIV ";
case(DAE.POW(ty=ty)) then " POW ";
case(DAE.UMINUS(ty=ty)) then " UMINUS ";
case(DAE.UPLUS(ty=ty)) then " UPLUS ";
case(DAE.UMINUS_ARR(ty=ty)) then " UMINUS_ARR ";
case(DAE.UPLUS_ARR(ty=ty)) then " UPLUS_ARR ";
case(DAE.ADD_ARR(ty=ty)) then " ADD_ARR ";
case(DAE.SUB_ARR(ty=ty)) then " SUB_ARR ";
case(DAE.MUL_ARR(ty=ty)) then " MUL_ARR ";
Expand Down
21 changes: 0 additions & 21 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -317,9 +317,7 @@ algorithm
case(DAE.DIV(_)) then Absyn.DIV();
case(DAE.POW(_)) then Absyn.POW();
case(DAE.UMINUS(_)) then Absyn.UMINUS();
case(DAE.UPLUS(_)) then Absyn.UPLUS();
case(DAE.UMINUS_ARR(_)) then Absyn.UMINUS();
case(DAE.UPLUS_ARR(_)) then Absyn.UPLUS();
case(DAE.ADD_ARR(_)) then Absyn.ADD();
case(DAE.SUB_ARR(_)) then Absyn.SUB();
case(DAE.MUL_ARR(_)) then Absyn.MUL();
Expand Down Expand Up @@ -947,9 +945,7 @@ algorithm
case (DAE.DIV(ty = _), _) then DAE.DIV(inType);
case (DAE.POW(ty = _), _) then DAE.POW(inType);
case (DAE.UMINUS(ty = _), _) then DAE.UMINUS(inType);
case (DAE.UPLUS(ty = _), _) then DAE.UPLUS(inType);
case (DAE.UMINUS_ARR(ty = _), _) then DAE.UMINUS_ARR(inType);
case (DAE.UPLUS_ARR(ty = _), _) then DAE.UPLUS_ARR(inType);
case (DAE.ADD_ARR(ty = _), _) then DAE.ADD_ARR(inType);
case (DAE.SUB_ARR(ty = _), _) then DAE.SUB_ARR(inType);
case (DAE.MUL_ARR(ty = _), _) then DAE.MUL_ARR(inType);
Expand Down Expand Up @@ -1695,9 +1691,7 @@ algorithm
case (DAE.DIV(ty = t)) then t;
case (DAE.POW(ty = t)) then t;
case (DAE.UMINUS(ty = t)) then t;
case (DAE.UPLUS(ty = t)) then t;
case (DAE.UMINUS_ARR(ty = t)) then t;
case (DAE.UPLUS_ARR(ty = t)) then t;
case (DAE.ADD_ARR(ty = t)) then t;
case (DAE.SUB_ARR(ty = t)) then t;
case (DAE.MUL_ARR(ty = t)) then t;
Expand Down Expand Up @@ -2202,13 +2196,6 @@ algorithm
nonxt = DAE.BINARY(nonxt1,DAE.SUB(ty),nonxt2);
then
(xt,nonxt);
case (DAE.UNARY(operator = DAE.UPLUS(ty = ty),exp = e),(cr as DAE.CREF(componentRef = _)))
equation
(xt1,nonxt1) = getTermsContainingX(e, cr);
xt = DAE.UNARY(DAE.UPLUS(ty),xt1);
nonxt = DAE.UNARY(DAE.UPLUS(ty),nonxt1);
then
(xt,nonxt);
case (DAE.UNARY(operator = DAE.UMINUS(ty = ty),exp = e),(cr as DAE.CREF(componentRef = _)))
equation
(xt1,nonxt1) = getTermsContainingX(e, cr);
Expand All @@ -2232,13 +2219,6 @@ algorithm
nonxt = DAE.BINARY(nonxt1,DAE.SUB_ARR(ty),nonxt2);
then
(xt,nonxt);
case (DAE.UNARY(operator = DAE.UPLUS_ARR(ty = ty),exp = e),(cr as DAE.CREF(componentRef = _)))
equation
(xt1,nonxt1) = getTermsContainingX(e, cr);
xt = DAE.UNARY(DAE.UPLUS_ARR(ty),xt1);
nonxt = DAE.UNARY(DAE.UPLUS_ARR(ty),nonxt1);
then
(xt,nonxt);
case (DAE.UNARY(operator = DAE.UMINUS_ARR(ty = ty),exp = e),(cr as DAE.CREF(componentRef = _)))
equation
(xt1,nonxt1) = getTermsContainingX(e, cr);
Expand Down Expand Up @@ -6346,7 +6326,6 @@ algorithm
case (DAE.POW(ty = _),DAE.POW(ty = _)) then true;
case (DAE.UMINUS(ty = _),DAE.UMINUS(ty = _)) then true;
case (DAE.UMINUS_ARR(ty = _),DAE.UMINUS_ARR(ty = _)) then true;
case (DAE.UPLUS_ARR(ty = _),DAE.UPLUS_ARR(ty = _)) then true;
case (DAE.ADD_ARR(ty = _),DAE.ADD_ARR(ty = _)) then true;
case (DAE.SUB_ARR(ty = _),DAE.SUB_ARR(ty = _)) then true;
case (DAE.MUL_ARR(ty = _),DAE.MUL_ARR(ty = _)) then true;
Expand Down
6 changes: 0 additions & 6 deletions Compiler/FrontEnd/ExpressionDump.mo
Expand Up @@ -310,9 +310,7 @@ algorithm
outString:=
match (inOperator)
case (DAE.UMINUS(ty = _)) then "-";
case (DAE.UPLUS(ty = _)) then "+";
case (DAE.UMINUS_ARR(ty = _)) then "-";
case (DAE.UPLUS_ARR(ty = _)) then "+";
end match;
end unaryopSymbol;

Expand Down Expand Up @@ -1066,10 +1064,8 @@ algorithm
case (DAE.BINARY(operator = DAE.MUL_ARRAY_SCALAR(_))) then 7;
case (DAE.BINARY(operator = DAE.MUL_SCALAR_PRODUCT(_))) then 7;
case (DAE.BINARY(operator = DAE.MUL_MATRIX_PRODUCT(_))) then 7;
case (DAE.UNARY(operator = DAE.UPLUS(_))) then 8;
case (DAE.UNARY(operator = DAE.UMINUS(_))) then 8;
case (DAE.UNARY(operator = DAE.UMINUS_ARR(_))) then 8;
case (DAE.UNARY(operator = DAE.UPLUS_ARR(_))) then 8;
case (DAE.BINARY(operator = DAE.ADD(_))) then 9;
case (DAE.BINARY(operator = DAE.ADD_ARR(_))) then 9;
case (DAE.BINARY(operator = DAE.ADD_ARRAY_SCALAR(_))) then 9;
Expand Down Expand Up @@ -2289,9 +2285,7 @@ public function unaryopPriority
algorithm
outInteger := match (inOperator)
case (DAE.UMINUS(ty = _)) then 37;
case (DAE.UPLUS(ty = _)) then 37;
case (DAE.UMINUS_ARR(ty = _)) then 37;
case (DAE.UPLUS_ARR(ty = _)) then 37;
end match;
end unaryopPriority;

Expand Down
16 changes: 0 additions & 16 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -2766,16 +2766,6 @@ algorithm
then
exp;

case (DAE.UNARY(operator = DAE.UPLUS_ARR(ty = t),exp = e),sub)
equation
e_1 = simplifyAsub(e, sub);
t2 = Expression.typeof(e_1);
b = DAEUtil.expTypeArray(t2);
op2 = Util.if_(b,DAE.UPLUS_ARR(t2),DAE.UPLUS(t2));
exp = DAE.UNARY(op2,e_1);
then
exp;

case (DAE.LUNARY(operator = DAE.NOT(ty = t), exp = e), sub)
equation
e_1 = simplifyAsub(e, sub);
Expand Down Expand Up @@ -3755,12 +3745,6 @@ algorithm
then
DAE.BCONST(b1);

// +e => e
case (DAE.UPLUS(ty = ty),e1)
then e1;
case (DAE.UPLUS_ARR(ty = ty),e1)
then e1;

// -x => 0 - x
case (DAE.UMINUS(ty = ty),DAE.ICONST(integer = i))
equation
Expand Down
60 changes: 14 additions & 46 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -402,6 +402,13 @@ algorithm
then
(cache,exp_1,prop,st_2);

case (cache,env,(e as Absyn.UNARY(op = Absyn.UPLUS(),exp = e1)),impl,st,doVect,pre,info,_)
equation
(cache,exp_1,DAE.PROP(t,c),st_1) = elabExp(cache,env,e1,impl,st,doVect,pre,info);
true = Types.isIntegerOrRealOrSubTypeOfEither(Types.arrayElementType(t));
prop = DAE.PROP(t,c);
then
(cache,exp_1,prop,st_1);
case (cache,env,(e as Absyn.UNARY(op = op,exp = e1)),impl,st,doVect,pre,info,_)
equation
(cache,e_1,DAE.PROP(t,c),st_1) = elabExp(cache,env,e1,impl,st,doVect,pre,info);
Expand Down Expand Up @@ -1577,6 +1584,13 @@ algorithm
(op_1,e1_2,e2_2,rtype) = operatorDeoverloadBinary(op,t1,e1_1,t2,e2_1,exp,pre,info);
then
(cache,DAE.BINARY(e1_2,op_1,e2_2),DAE.PROP(rtype,c));
case (cache,env,(e as Absyn.UNARY(op = Absyn.UPLUS(),exp = e1)),impl,pre,info)
equation
(cache,e_1,DAE.PROP(t,c)) = elabGraphicsExp(cache,env, e, impl,pre,info);
true = Types.isRealOrSubTypeReal(Types.arrayElementType(t));
prop = DAE.PROP(t,c);
then
(cache,e_1,prop);
case (cache,env,(exp as Absyn.UNARY(op = op,exp = e)),impl,pre,info)
equation
(cache,e_1,DAE.PROP(t,c)) = elabGraphicsExp(cache,env, e, impl,pre,info);
Expand Down Expand Up @@ -12154,10 +12168,6 @@ algorithm

case (DAE.UMINUS_ARR(ty = _),(typ1 :: _),_,_, _) then typ1;

case (DAE.UPLUS(ty = _),_,typ,_, _) then typ;

case (DAE.UPLUS_ARR(ty = _),(typ1 :: _),_,_, _) then typ1;

case (DAE.AND(ty = _), {typ1, typ2}, _, _, _)
equation
true = Types.equivtypes(typ1, typ2);
Expand Down Expand Up @@ -12786,48 +12796,6 @@ algorithm
types = List.flatten({scalars,intarrs,realarrs});
then types;

case Absyn.UPLUS()
equation
scalars = {
(DAE.UPLUS(DAE.ET_INT()),{DAE.T_INTEGER_DEFAULT},
DAE.T_INTEGER_DEFAULT),
(DAE.UPLUS(DAE.ET_REAL()),{DAE.T_REAL_DEFAULT},
DAE.T_REAL_DEFAULT)} "The UPLUS operator, unary plus." ;
intarrs = operatorReturnUnary(DAE.UPLUS(DAE.ET_ARRAY(DAE.ET_INT(), {DAE.DIM_UNKNOWN()})),
intarrtypes, intarrtypes);
realarrs = operatorReturnUnary(DAE.UPLUS(DAE.ET_ARRAY(DAE.ET_REAL(), {DAE.DIM_UNKNOWN()})),
realarrtypes, realarrtypes);
types = List.flatten({scalars,intarrs,realarrs});
then types;

case (Absyn.UMINUS_EW())
equation
scalars = {
(DAE.UMINUS(DAE.ET_INT()),{DAE.T_INTEGER_DEFAULT},
DAE.T_INTEGER_DEFAULT),
(DAE.UMINUS(DAE.ET_REAL()),{DAE.T_REAL_DEFAULT},
DAE.T_REAL_DEFAULT)} "The UMINUS operator, unary minus" ;
intarrs = operatorReturnUnary(DAE.UMINUS_ARR(DAE.ET_ARRAY(DAE.ET_INT(), {DAE.DIM_UNKNOWN()})),
intarrtypes, intarrtypes);
realarrs = operatorReturnUnary(DAE.UMINUS_ARR(DAE.ET_ARRAY(DAE.ET_REAL(), {DAE.DIM_UNKNOWN()})),
realarrtypes, realarrtypes);
types = List.flatten({scalars,intarrs,realarrs});
then types;

case Absyn.UPLUS_EW()
equation
scalars = {
(DAE.UPLUS(DAE.ET_INT()),{DAE.T_INTEGER_DEFAULT},
DAE.T_INTEGER_DEFAULT),
(DAE.UPLUS(DAE.ET_REAL()),{DAE.T_REAL_DEFAULT},
DAE.T_REAL_DEFAULT)} "The UPLUS operator, unary plus." ;
intarrs = operatorReturnUnary(DAE.UPLUS(DAE.ET_ARRAY(DAE.ET_INT(), {DAE.DIM_UNKNOWN()})),
intarrtypes, intarrtypes);
realarrs = operatorReturnUnary(DAE.UPLUS(DAE.ET_ARRAY(DAE.ET_REAL(), {DAE.DIM_UNKNOWN()})),
realarrtypes, realarrtypes);
types = List.flatten({scalars,intarrs,realarrs});
then types;

case Absyn.NOT()
equation
scalars = {(DAE.NOT(DAE.ET_BOOL()), {DAE.T_BOOL_DEFAULT}, DAE.T_BOOL_DEFAULT)};
Expand Down
8 changes: 2 additions & 6 deletions Compiler/susan_codegen/SimCode/CodegenC.tpl
Expand Up @@ -4786,13 +4786,11 @@ case UNARY(__) then
let e = daeExp(exp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/)
match operator
case UMINUS(__) then '(-<%e%>)'
case UPLUS(__) then '(<%e%>)'
case UMINUS_ARR(ty=ET_ARRAY(ty=ET_REAL(__))) then
let &preExp += 'usub_real_array(&<%e%>);<%\n%>'
'<%e%>'
case UMINUS_ARR(__) then 'unary minus for non-real arrays not implemented'
case UPLUS_ARR(__) then "UPLUS_ARR_NOT_IMPLEMENTED"
else "daeExpUnary:ERR"
case UMINUS_ARR(__) then error(sourceInfo(),"unary minus for non-real arrays not implemented")
else error(sourceInfo(),"daeExpUnary:ERR")
end daeExpUnary;


Expand Down Expand Up @@ -6211,9 +6209,7 @@ template expTypeFromOpFlag(Operator op, Integer flag)
case o as POW(__)

case o as UMINUS(__)
case o as UPLUS(__)
case o as UMINUS_ARR(__)
case o as UPLUS_ARR(__)
case o as ADD_ARR(__)
case o as SUB_ARR(__)
case o as MUL_ARR(__)
Expand Down
4 changes: 0 additions & 4 deletions Compiler/susan_codegen/SimCode/SimCodeAdevs.tpl
Expand Up @@ -3527,12 +3527,10 @@ case UNARY(__) then
let e = daeExp(exp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/)
match operator
case UMINUS(__) then '(-<%e%>)'
case UPLUS(__) then '(<%e%>)'
case UMINUS_ARR(ty=ET_ARRAY(ty=ET_REAL(__))) then
let &preExp += 'usub_real_array(&<%e%>);<%\n%>'
'<%e%>'
case UMINUS_ARR(__) then 'unary minus for non-real arrays not implemented'
case UPLUS_ARR(__) then "UPLUS_ARR_NOT_IMPLEMENTED"
else "daeExpUnary:ERR"
end daeExpUnary;

Expand Down Expand Up @@ -4978,9 +4976,7 @@ template expTypeFromOpFlag(Operator op, Integer flag)
case o as POW(__)

case o as UMINUS(__)
case o as UPLUS(__)
case o as UMINUS_ARR(__)
case o as UPLUS_ARR(__)
case o as ADD_ARR(__)
case o as SUB_ARR(__)
case o as MUL_ARR(__)
Expand Down
8 changes: 2 additions & 6 deletions Compiler/susan_codegen/SimCode/SimCodeC.tpl
Expand Up @@ -4961,13 +4961,11 @@ case UNARY(__) then
let e = daeExp(exp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/)
match operator
case UMINUS(__) then '(-<%e%>)'
case UPLUS(__) then '(<%e%>)'
case UMINUS_ARR(ty=ET_ARRAY(ty=ET_REAL(__))) then
let &preExp += 'usub_real_array(&<%e%>);<%\n%>'
'<%e%>'
case UMINUS_ARR(__) then 'unary minus for non-real arrays not implemented'
case UPLUS_ARR(__) then "UPLUS_ARR_NOT_IMPLEMENTED"
else "daeExpUnary:ERR"
case UMINUS_ARR(__) then error(sourceInfo(),"unary minus for non-real arrays not implemented")
else error(sourceInfo(),"daeExpUnary:ERR")
end daeExpUnary;


Expand Down Expand Up @@ -6365,9 +6363,7 @@ template expTypeFromOpFlag(Operator op, Integer flag)
case o as POW(__)

case o as UMINUS(__)
case o as UPLUS(__)
case o as UMINUS_ARR(__)
case o as UPLUS_ARR(__)
case o as ADD_ARR(__)
case o as SUB_ARR(__)
case o as MUL_ARR(__)
Expand Down
4 changes: 0 additions & 4 deletions Compiler/susan_codegen/SimCode/SimCodeCSharp.tpl
Expand Up @@ -1841,10 +1841,8 @@ template daeExpUnary(Operator it, Exp exp, Context context, Text &preExp, SimCod
let e = daeExp(exp, context, &preExp, simCode)
match it
case UMINUS(__) then '(-<%e%>)'
case UPLUS(__) then '(<%e%>)'
case NOT(__) then '(!<%e%>)'
case UMINUS_ARR(__) then "UMINUS_ARR_NOT_IMPLEMENTED"
case UPLUS_ARR(__) then "UPLUS_ARR_NOT_IMPLEMENTED"
case _ then "daeExpUnary:ERR"

end daeExpUnary;
Expand Down Expand Up @@ -2231,9 +2229,7 @@ template expTypeFromOp(Operator it) ::=
case DIV(__)
case POW(__)
case UMINUS(__)
case UPLUS(__)
case UMINUS_ARR(__)
case UPLUS_ARR(__)
case ADD_ARR(__)
case SUB_ARR(__)
case MUL_ARR(__)
Expand Down
6 changes: 0 additions & 6 deletions Compiler/susan_codegen/SimCode/SimCodeCpp.tpl
Expand Up @@ -4136,12 +4136,10 @@ case UNARY(__) then
let e = daeExp(exp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
match operator
case UMINUS(__) then '(-<%e%>)'
case UPLUS(__) then '(<%e%>)'
case UMINUS_ARR(ty=ET_ARRAY(ty=ET_REAL(__))) then
let &preExp += 'usub_real_array(&<%e%>);<%\n%>'
'<%e%>'
case UMINUS_ARR(__) then 'unary minus for non-real arrays not implemented'
case UPLUS_ARR(__) then "UPLUS_ARR_NOT_IMPLEMENTED"
else "daeExpUnary:ERR"
end daeExpUnary;

Expand Down Expand Up @@ -4457,9 +4455,7 @@ template expTypeFromOp(Operator it) ::=
case DIV(__)
case POW(__)
case UMINUS(__)
case UPLUS(__)
case UMINUS_ARR(__)
case UPLUS_ARR(__)
case ADD_ARR(__)
case SUB_ARR(__)
case MUL_ARR(__)
Expand Down Expand Up @@ -5217,9 +5213,7 @@ template expTypeFromOpFlag(Operator op, Integer flag)
case o as POW(__)

case o as UMINUS(__)
case o as UPLUS(__)
case o as UMINUS_ARR(__)
case o as UPLUS_ARR(__)
case o as ADD_ARR(__)
case o as SUB_ARR(__)
case o as MUL_ARR(__)
Expand Down

0 comments on commit bdb83cb

Please sign in to comment.