Skip to content

Commit

Permalink
- Removed elabBuiltinRem elabBuiltinMod
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10014 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 5, 2011
1 parent 74f12aa commit cec9b11
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 100 deletions.
4 changes: 0 additions & 4 deletions Compiler/FrontEnd/Builtin.mo
Expand Up @@ -513,16 +513,12 @@ algorithm
env = Env.extendFrameT(env, "change", real2bool);
env = Env.extendFrameT(env, "cardinality", anyNonExpandableConnector2int);
env = Env.extendFrameT(env, "cardinality", anyExpandableConnector2int);
env = Env.extendFrameT(env, "rem", realReal2real);
env = Env.extendFrameT(env, "rem", intInt2int);
env = Env.extendFrameT(env, "Integer", enumeration2int);
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);
env = Env.extendFrameT(env, "linspace", realRealInt2vectorreal);
env = Env.extendFrameT(env, "noEvent", real2real);
env = Env.extendFrameT(env, "mod", realReal2real);
env = Env.extendFrameT(env, "mod", intInt2int);
env = Env.extendFrameT(env, "constrain", realrealreal2real);
env = Env.extendFrameT(env, "constrain", array1dimrealarray1dimrealarray1dimreal2array1dimreal);
env = Env.extendFrameT(env, "actualStream", real2real);
Expand Down
50 changes: 36 additions & 14 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -215,28 +215,22 @@ function homotopy
external "builtin";
end homotopy;

// Dummy functions that can't be properly defined in Modelica, but used by
// SCodeFlatten to define which builtin functions exist (SCodeFlatten doesn't
// care how the functions are defined, only if they exist or not).

function div = overload(OpenModelica.Internal.intDiv,OpenModelica.Internal.realDiv);

function mod
/* Real or Integer in/output */
external "builtin";
end mod;
function mod = overload(OpenModelica.Internal.intMod,OpenModelica.Internal.realMod);

function rem
/* Real or Integer in/output */
external "builtin";
end rem;
function rem = overload(OpenModelica.Internal.intRem,OpenModelica.Internal.realRem);

function abs = overload(OpenModelica.Internal.intAbs,OpenModelica.Internal.realAbs);

// Dummy functions that can't be properly defined in Modelica, but used by
// SCodeFlatten to define which builtin functions exist (SCodeFlatten doesn't
// care how the functions are defined, only if they exist or not).

function delay
external "builtin";
end delay;

function abs = overload(OpenModelica.Internal.intAbs,OpenModelica.Internal.realAbs);

function min
external "builtin";
end min;
Expand Down Expand Up @@ -447,6 +441,34 @@ package Internal "Contains internal implementations, e.g. overloaded builtin fun
external "builtin" z=div(x,y);
end realDiv;

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

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

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

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

end Internal;

package Scripting
Expand Down
82 changes: 0 additions & 82 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -4454,86 +4454,6 @@ algorithm
end match;
end elabBuiltinDelay2;

protected function elabBuiltinMod
"function: elabBuiltinMod
This function elaborates on the builtin operator mod."
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
(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("mod"), {s1,s2}, {}, impl,NONE(),pre,info);
then
(cache,s1_1,prop);
end match;
end elabBuiltinMod;

protected function elabBuiltinRem "function: elabBuiltinRem
This function elaborates on the builtin operator rem."
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
(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("rem"), {s1,s2}, {}, impl,NONE(),pre,info);
then
(cache,s1_1,prop);
end match;
end elabBuiltinRem;

protected function elabBuiltinBoolean
"function: elabBuiltinBoolean
This function elaborates on the builtin operator boolean, which extracts
Expand Down Expand Up @@ -6176,8 +6096,6 @@ algorithm
case "product" then elabBuiltinProduct;
case "pre" then elabBuiltinPre;
case "boolean" then elabBuiltinBoolean;
case "mod" then elabBuiltinMod;
case "rem" then elabBuiltinRem;
case "diagonal" then elabBuiltinDiagonal;
case "differentiate" then elabBuiltinDifferentiate;
case "noEvent" then elabBuiltinNoevent;
Expand Down

0 comments on commit cec9b11

Please sign in to comment.