Skip to content

Commit

Permalink
- Moved abs() from Builtin.mo to ModelicaBuiltin.mo
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10012 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 5, 2011
1 parent 2618207 commit dc9ce93
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 43 deletions.
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/Builtin.mo
Expand Up @@ -518,8 +518,6 @@ algorithm
env = Env.extendFrameT(env, "rem", realReal2real);
env = Env.extendFrameT(env, "rem", intInt2int);
env = Env.extendFrameT(env, "Integer", enumeration2int);
env = Env.extendFrameT(env, "abs", real2real) "differentiable functions" ;
env = Env.extendFrameT(env, "abs", int2int) "differentiable functions" ;
env = Env.extendFrameT(env, "substring", stringIntInt2string);
env = Env.extendFrameT(env, "outerproduct", vectorVector2int) "Only real and int makes sense here. And maybe bool." ;
env = Env.extendFrameT(env, "outerproduct", vectorVector2real);
Expand Down
19 changes: 15 additions & 4 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -238,10 +238,7 @@ function delay
external "builtin";
end delay;

function abs
/* Real or Integer in/output */
external "builtin";
end abs;
function abs = overload(OpenModelica.Internal.intAbs,OpenModelica.Internal.realAbs);

function min
external "builtin";
Expand Down Expand Up @@ -426,6 +423,20 @@ type VariableNames "An array of variable names, e.g. {a.b,a[1].b[3].c}, or a sin

end Code;

package Internal "Contains internal implementations, e.g. overloaded builtin functions"
function intAbs
input Integer v;
output Integer o;
external "builtin" o=abs(v);
end intAbs;

function realAbs
input Real v;
output Real o;
external "builtin" o=abs(v);
end realAbs;
end Internal;

package Scripting

import OpenModelica.Code.TypeName;
Expand Down
37 changes: 0 additions & 37 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -4396,42 +4396,6 @@ algorithm
end matchcontinue;
end elabBuiltinMinMaxCommon;

protected function elabBuiltinAbs "function: elabBuiltinAbs
This function elaborates on the builtin operator abs"
input Env.Cache inCache;
input Env.Env inEnv;
input list<Absyn.Exp> inAbsynExpLst;
input list<Absyn.NamedArg> inNamedArg;
input Boolean inBoolean;
input Prefix.Prefix inPrefix;
input Absyn.Info info;
output Env.Cache outCache;
output DAE.Exp outExp;
output DAE.Properties outProperties;
algorithm
(outCache,outExp,outProperties) := matchcontinue (inCache,inEnv,inAbsynExpLst,inNamedArg,inBoolean,inPrefix,info)
local
DAE.Exp s1_1;
list<Env.Frame> env;
Absyn.Exp s1;
Boolean impl;
Env.Cache cache;
DAE.Properties prop;
Prefix.Prefix pre;

case (cache,env,{s1},_,impl,pre,info)
equation
(cache,s1_1,prop) = verifyBuiltInHandlerType(cache,env,{s1},impl,Types.isRealOrSubTypeReal,"abs",pre,info);
then
(cache,s1_1,prop);
case (cache,env,{s1},_,impl,pre,info)
equation
(cache,s1_1,prop) = verifyBuiltInHandlerType(cache,env,{s1},impl,Types.isIntegerOrSubTypeInteger,"abs",pre,info);
then
(cache,s1_1,prop);
end matchcontinue;
end elabBuiltinAbs;

protected function elabBuiltinDiv "function: elabBuiltinDiv
This function elaborates on the builtin operator div."
input Env.Cache inCache;
Expand Down Expand Up @@ -6250,7 +6214,6 @@ algorithm
case "sum" then elabBuiltinSum;
case "product" then elabBuiltinProduct;
case "pre" then elabBuiltinPre;
case "abs" then elabBuiltinAbs;
case "div" then elabBuiltinDiv;
case "boolean" then elabBuiltinBoolean;
case "mod" then elabBuiltinMod;
Expand Down

0 comments on commit dc9ce93

Please sign in to comment.