Skip to content

Commit

Permalink
- Removed elabBuiltinDiv
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10013 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 5, 2011
1 parent dc9ce93 commit 74f12aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 46 deletions.
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/Builtin.mo
Expand Up @@ -513,8 +513,6 @@ algorithm
env = Env.extendFrameT(env, "change", real2bool);
env = Env.extendFrameT(env, "cardinality", anyNonExpandableConnector2int);
env = Env.extendFrameT(env, "cardinality", anyExpandableConnector2int);
env = Env.extendFrameT(env, "div", realReal2real) "non-differentiable functions" ;
env = Env.extendFrameT(env, "div", intInt2int) "non-differentiable functions" ;
env = Env.extendFrameT(env, "rem", realReal2real);
env = Env.extendFrameT(env, "rem", intInt2int);
env = Env.extendFrameT(env, "Integer", enumeration2int);
Expand Down
20 changes: 16 additions & 4 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -219,10 +219,7 @@ end homotopy;
// SCodeFlatten to define which builtin functions exist (SCodeFlatten doesn't
// care how the functions are defined, only if they exist or not).

function div
/* Real or Integer in/output */
external "builtin";
end div;
function div = overload(OpenModelica.Internal.intDiv,OpenModelica.Internal.realDiv);

function mod
/* Real or Integer in/output */
Expand Down Expand Up @@ -435,6 +432,21 @@ package Internal "Contains internal implementations, e.g. overloaded builtin fun
output Real o;
external "builtin" o=abs(v);
end realAbs;

function intDiv
input Integer x;
input Integer y;
output Integer z;
external "builtin" z=div(x,y);
end intDiv;

function realDiv
input Real x;
input Real y;
output Real z;
external "builtin" z=div(x,y);
end realDiv;

end Internal;

package Scripting
Expand Down
40 changes: 0 additions & 40 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -4396,45 +4396,6 @@ algorithm
end matchcontinue;
end elabBuiltinMinMaxCommon;

protected function elabBuiltinDiv "function: elabBuiltinDiv
This function elaborates on the builtin operator div."
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) := match (inCache,inEnv,inAbsynExpLst,inNamedArg,inBoolean,inPrefix,info)
local
DAE.Exp s1_1,s2_1;
DAE.Const c1,c2;
list<Env.Frame> env;
Absyn.Exp s1,s2;
Boolean impl;
Env.Cache cache;
DAE.Type cty1,cty2;
DAE.Properties prop;
Prefix.Prefix pre;
case (cache,env,{s1,s2},_,impl,pre,info)
equation
// TODO: this is not so nice. s1,s2 are elaborated twice, first in the calls below and then in elabCallArgs.
(cache,s1_1,DAE.PROP(cty1,c1),_) = elabExp(cache,env, s1, impl,NONE(),true,pre,info);
(cache,s2_1,DAE.PROP(cty2,c2),_) = elabExp(cache,env, s2, impl,NONE(),true,pre,info);
cty1 = Types.arrayElementType(cty1);
Types.integerOrReal(cty1);
cty2 = Types.arrayElementType(cty2);
Types.integerOrReal(cty2);
(cache,s1_1,prop) = elabCallArgs(cache,env, Absyn.IDENT("div"), {s1,s2}, {}, impl,NONE(),pre,info);
then
(cache,s1_1,prop);
end match;
end elabBuiltinDiv;

protected function elabBuiltinDelay "
Author BZ
TODO: implement,
Expand Down Expand Up @@ -6214,7 +6175,6 @@ algorithm
case "sum" then elabBuiltinSum;
case "product" then elabBuiltinProduct;
case "pre" then elabBuiltinPre;
case "div" then elabBuiltinDiv;
case "boolean" then elabBuiltinBoolean;
case "mod" then elabBuiltinMod;
case "rem" then elabBuiltinRem;
Expand Down

0 comments on commit 74f12aa

Please sign in to comment.