Skip to content

Commit

Permalink
- handling of EnumToInteger directly in Static.mo (just there and in …
Browse files Browse the repository at this point in the history
…Builtin.mo).

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16440 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Jun 22, 2013
1 parent a466cec commit df165d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
1 change: 0 additions & 1 deletion Compiler/FrontEnd/Ceval.mo
Expand Up @@ -1112,7 +1112,6 @@ algorithm
case "promote" then cevalBuiltinPromote;
case "String" then cevalBuiltinString;
case "Integer" then cevalBuiltinIntegerEnumeration;
case "EnumToInteger" then cevalBuiltinIntegerEnumeration;
case "rooted" then cevalBuiltinRooted; //
case "cross" then cevalBuiltinCross;
case "fill" then cevalBuiltinFill;
Expand Down
10 changes: 0 additions & 10 deletions Compiler/FrontEnd/Lookup.mo
Expand Up @@ -1505,16 +1505,6 @@ algorithm
Absyn.Path id, scope;
Absyn.Info info;

// handle EnumToInteger! search directly in the top env, no matter where the function is!
case (cache,env,id,info)
equation
name = Absyn.pathLastIdent(id);
true = stringEq("EnumToInteger", name);
(cache,env as {Env.FRAME(clsAndVars = ht,types = httypes)}) = Builtin.initialEnv(cache);
(cache,res) = lookupFunctionsInFrame(cache, ht, httypes, env, name, info);
then
(cache,res);

// uq paths are different!
case (cache,env,id,info)
equation
Expand Down
16 changes: 11 additions & 5 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -619,6 +619,17 @@ algorithm
then
(cache,e_1,prop,st_2);

// adrpo: deal with EnumToInteger(E) -> transform to Integer(E)
case (cache,env,Absyn.CALL(function_ = fn,functionArgs = Absyn.FUNCTIONARGS(args = args,argNames = nargs)),impl,st,doVect,pre,_,_)
equation
s = Absyn.pathLastIdent(Absyn.crefToPathIgnoreSubs(fn));
true = stringEq(s, "EnumToInteger");
(cache,e_1,prop,st_1) = elabCall(cache, env, Absyn.CREF_IDENT("Integer", {}), args, nargs, impl, st,pre,info,Error.getNumErrorMessages());
c = Types.propAllConst(prop);
(e_1,_) = ExpressionSimplify.simplify1(e_1);
then
(cache,e_1,prop,st_1);

// adrpo: deal with DynamicSelect(literalExp, dynamicExp) by returning literalExp only!
case (cache,env,Absyn.CALL(function_ = Absyn.CREF_IDENT("DynamicSelect",_),functionArgs = Absyn.FUNCTIONARGS(args = (e1 :: _),argNames = _)),impl,st,doVect,pre,_,_)
equation
Expand Down Expand Up @@ -4772,11 +4783,6 @@ algorithm
(cache,s1_1,prop) = verifyBuiltInHandlerType(cache,env,{s1},impl,Types.isEnumeration,"Integer",pre,info);
then
(cache,s1_1,prop);
case (cache,env,{s1},_,impl,pre,_)
equation
(cache,s1_1,prop) = verifyBuiltInHandlerType(cache,env,{s1},impl,Types.isEnumeration,"EnumToInteger",pre,info);
then
(cache,s1_1,prop);
end matchcontinue;
end elabBuiltinIntegerEnum;

Expand Down

0 comments on commit df165d1

Please sign in to comment.