Skip to content

Commit

Permalink
- Removed more Builtin.isXXX functions (Modelica.Math.min/max/cross/t…
Browse files Browse the repository at this point in the history
…ranspose do not even exist!)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7726 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 20, 2011
1 parent b7d1f95 commit 73ce75c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 86 deletions.
12 changes: 4 additions & 8 deletions Compiler/BackEnd/Derive.mo
Expand Up @@ -438,16 +438,14 @@ algorithm
then
DAE.BINARY(e_1,DAE.DIV(DAE.ET_REAL()),e);

case (DAE.CALL(path = fname,expLst = expl,tuple_=false,builtin = true,ty=tp,inlineType=inl),(timevars,functions))
case (DAE.CALL(path = fname as Absyn.IDENT("max"),expLst = expl,tuple_=false,builtin = true,ty=tp,inlineType=inl),(timevars,functions))
equation
Builtin.isMax(fname);
expl_1 = Util.listMap1(expl, differentiateExpTime, (timevars,functions));
then
DAE.CALL(fname,expl_1,false,true,tp,inl);

case (DAE.CALL(path = fname,expLst = expl,tuple_=false,builtin = true,ty=tp,inlineType=inl),(timevars,functions))
case (DAE.CALL(path = fname as Absyn.IDENT("min"),expLst = expl,tuple_=false,builtin = true,ty=tp,inlineType=inl),(timevars,functions))
equation
Builtin.isMin(fname);
expl_1 = Util.listMap1(expl, differentiateExpTime, (timevars,functions));
then
DAE.CALL(fname,expl_1,false,true,tp,inl);
Expand All @@ -459,17 +457,15 @@ algorithm
DAE.BINARY(e_1,DAE.DIV(DAE.ET_REAL()),
DAE.BINARY(DAE.RCONST(2.0),DAE.MUL(DAE.ET_REAL()),e0));

case (DAE.CALL(path = fname,expLst = {e1,e2},tuple_=false,builtin = true,ty=tp,inlineType=inl),(timevars,functions))
case (DAE.CALL(path = fname as Absyn.IDENT("cross"),expLst = {e1,e2},tuple_=false,builtin = true,ty=tp,inlineType=inl),(timevars,functions))
equation
Builtin.isCross(fname);
e1_1 = differentiateExpTime(e1, (timevars,functions));
e2_1 = differentiateExpTime(e2, (timevars,functions));
then
DAE.BINARY(DAE.CALL(fname,{e1,e2_1},false,true,tp,inl),DAE.ADD_ARR(tp),DAE.CALL(fname,{e1_1,e2},false,true,tp,inl));

case (DAE.CALL(path = fname,expLst = expl,tuple_=false,builtin = true,ty=tp,inlineType=inl),(timevars,functions))
case (DAE.CALL(path = fname as Absyn.IDENT("transpose"),expLst = expl,tuple_=false,builtin = true,ty=tp,inlineType=inl),(timevars,functions))
equation
Builtin.isTranspose(fname);
expl_1 = Util.listMap1(expl, differentiateExpTime, (timevars,functions));
then
DAE.CALL(fname,expl_1,false,true,tp,inl);
Expand Down
61 changes: 3 additions & 58 deletions Compiler/FrontEnd/Builtin.mo
Expand Up @@ -797,10 +797,10 @@ Currently only 'time' is a builtin variable.
input DAE.ComponentRef cref;
output Boolean b;
algorithm
b := matchcontinue(cref)
b := match (cref)
case(DAE.CREF_IDENT(ident="time")) then true;
case(_) then false;
end matchcontinue;
else false;
end match;
end variableIsBuiltin;

public function isSubstring
Expand All @@ -814,61 +814,6 @@ algorithm
end match;
end isSubstring;

public function isCross ""
input Absyn.Path inPath;
algorithm
_:=
match (inPath)
case (Absyn.IDENT(name = "cross")) then ();
case (Absyn.QUALIFIED(name = "Modelica",path = Absyn.QUALIFIED(name = "Math",path = Absyn.IDENT(name = "cross")))) then ();
case (Absyn.FULLYQUALIFIED(inPath)) equation isCross(inPath); then ();
end match;
end isCross;

public function isMax
input Absyn.Path inPath;
algorithm
_:=
match (inPath)
case (Absyn.IDENT(name = "max")) then ();
case (Absyn.QUALIFIED(name = "Modelica",path = Absyn.QUALIFIED(name = "Math",path = Absyn.IDENT(name = "max")))) then ();
case (Absyn.FULLYQUALIFIED(inPath)) equation isMax(inPath); then ();
end match;
end isMax;

public function isMin
input Absyn.Path inPath;
algorithm
_:=
match (inPath)
case (Absyn.IDENT(name = "min")) then ();
case (Absyn.QUALIFIED(name = "Modelica",path = Absyn.QUALIFIED(name = "Math",path = Absyn.IDENT(name = "min")))) then ();
case (Absyn.FULLYQUALIFIED(inPath)) equation isMin(inPath); then ();
end match;
end isMin;

public function isTranspose
input Absyn.Path inPath;
algorithm
_:=
match (inPath)
case (Absyn.IDENT(name = "transpose")) then ();
case (Absyn.QUALIFIED(name = "Modelica",path = Absyn.QUALIFIED(name = "Math",path = Absyn.IDENT(name = "transpose")))) then ();
case (Absyn.FULLYQUALIFIED(inPath)) equation isTranspose(inPath); then ();
end match;
end isTranspose;

public function isSkew
input Absyn.Path inPath;
algorithm
_:=
matchcontinue (inPath)
case (Absyn.IDENT(name = "skew")) then ();
case (Absyn.QUALIFIED(name = "Modelica",path = Absyn.QUALIFIED(name = "Math",path = Absyn.IDENT(name = "skew")))) then ();
case (Absyn.FULLYQUALIFIED(inPath)) equation isSkew(inPath); then ();
end matchcontinue;
end isSkew;

public function isDer
input Absyn.Path inPath;
algorithm
Expand Down
31 changes: 11 additions & 20 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -51,7 +51,6 @@ public type Type = DAE.ExpType;
public type Subscript = DAE.Subscript;

// protected imports
protected import Builtin;
protected import ComponentReference;
protected import DAEUtil;
protected import Debug;
Expand Down Expand Up @@ -586,11 +585,11 @@ algorithm
Absyn.Path path; DAE.Exp e,e1;

// der(constant) ==> 0
case(DAE.CALL(path=Absyn.IDENT("der"),expLst ={e}))
case(DAE.CALL(path=Absyn.IDENT("der"),expLst ={e}))
equation
true = Expression.isConst(e);
e1 = simplifyBuiltinConstantDer(e);
then e1;
e1 = simplifyBuiltinConstantDer(e);
then e1;

// sqrt function
case(DAE.CALL(path=Absyn.IDENT("sqrt"),expLst={e}))
Expand Down Expand Up @@ -658,40 +657,32 @@ algorithm
DAE.RCONST(r);

// min function on integers
case(DAE.CALL(path=path,expLst={DAE.ICONST(i), DAE.ICONST(j)}))
case(DAE.CALL(path=Absyn.IDENT("min"),expLst={DAE.ICONST(i), DAE.ICONST(j)}))
equation
Builtin.isMin(path);
i = intMin(i, j);
then
DAE.ICONST(i);
then DAE.ICONST(i);

// min function on reals
case(DAE.CALL(path=path,expLst={e, e1}))
case(DAE.CALL(path=Absyn.IDENT("min"),expLst={e, e1}))
equation
Builtin.isMin(path);
v1 = Expression.getRealConst(e);
v2 = Expression.getRealConst(e1);
r = realMin(v1, v2);
then
DAE.RCONST(r);
then DAE.RCONST(r);

// min function on integers
case(DAE.CALL(path=path,expLst={DAE.ICONST(i), DAE.ICONST(j)}))
case(DAE.CALL(path=Absyn.IDENT("max"),expLst={DAE.ICONST(i), DAE.ICONST(j)}))
equation
Builtin.isMax(path);
i = intMax(i, j);
then
DAE.ICONST(i);
then DAE.ICONST(i);

// max function on reals
case(DAE.CALL(path=path,expLst={e, e1}))
case(DAE.CALL(path=Absyn.IDENT("max"),expLst={e, e1}))
equation
Builtin.isMax(path);
v1 = Expression.getRealConst(e);
v2 = Expression.getRealConst(e1);
r = realMax(v1, v2);
then
DAE.RCONST(r);
then DAE.RCONST(r);
end matchcontinue;
end simplifyBuiltinConstantCalls;

Expand Down

0 comments on commit 73ce75c

Please sign in to comment.