Skip to content

Commit

Permalink
- enumerations works now
Browse files Browse the repository at this point in the history
  - ToDo: replaceable enumerations in models with equations/algorithms containig explicit
    enumeration literals does not work because the componentRef have to be replaced
    and the numbers of enumeration litterals from both enumerations should be equal
  - ToDo: do not replace enumeration litteral with it value inside loops
- update workplan-status


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4697 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Dec 15, 2009
1 parent 98253ef commit e841f6e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
37 changes: 36 additions & 1 deletion Compiler/Inst.mo
Expand Up @@ -8493,7 +8493,19 @@ algorithm
(cache,l) = elabArraydimDecl(cache,env, cref, ds, impl, st,doVect);
then
(cache,SOME(DIMINT(i)) :: l);

// Frenkel TUD try next enum
case (cache,env,cref,(Absyn.SUBSCRIPT(subScript = Absyn.CREF(cr)) :: ds),impl,st,doVect)
local Absyn.ComponentRef cr; Absyn.Path typePath; list<SCode.Enum> enumLst;
equation
typePath = Absyn.crefToPath(cr);
// make sure is an enumeration!
(_, SCode.CLASS(_, _, _, SCode.R_TYPE(),
SCode.ENUMERATION(enumLst=enumLst)), _) =
Lookup.lookupClass(cache, env, typePath, false);
i = listLength(enumLst);
(cache,l) = elabArraydimDecl(cache,env, cref, ds, impl, st,doVect);
then
(cache,SOME(DIMINT(i)) :: l);
// Constant dimension creates DIMINT
case (cache,env,cref,(Absyn.SUBSCRIPT(subScript = d) :: ds),impl,st,doVect)
equation
Expand Down Expand Up @@ -10524,6 +10536,29 @@ algorithm
ci_state_1 = instEquationCommonCiTrans(ci_state, initial_) " //Debug.fprintln (\"insti\", \"for expression unrolled\") & & //Debug.fprintln (\"insttr\", \"inst_equation_common_eqfor_1 succeeded\")" ;
then
(cache,env,ih,dae,csets_1,ci_state_1,graph);
// Frenkel TUD: enumeration again
case (cache,env,ih,mod,pre,csets,ci_state,SCode.EQ_FOR(index = i,range = Absyn.CREF(cr),eEquationLst = el),initial_,impl,graph)
local
Absyn.ComponentRef cr;
Absyn.Path typePath;
Integer len;
list<SCode.Enum> enumLst;
list<Values.Value> vals;
equation

typePath = Absyn.crefToPath(cr);
/* make sure is an enumeration! */
(_, SCode.CLASS(_, _, _, SCode.R_TYPE(), SCode.ENUMERATION(enumLst = enumLst)), _) =
Lookup.lookupClass(cache, env, typePath, false);
len = listLength(enumLst);
env_1 = addForLoopScope(env, i, (DAE.T_INTEGER({}),NONE())) "//Debug.fprintln (\"insti\", \"for expression elaborated\") &" ;
(cache,DAE.ATTR(false,false,SCode.RW(),SCode.VAR(),_,_),(DAE.T_INTEGER(_),_),DAE.UNBOUND(),_,_)
= Lookup.lookupVar(cache,env_1, DAE.CREF_IDENT(i,DAE.ET_OTHER(),{})) " //Debug.fprintln (\"insti\", \"loop-variable added to scope\") &" ;
vals = Ceval.cevalRange(1,1,len);
(cache,dae,csets_1,graph) = unroll(cache,env_1, mod, pre, csets, ci_state, i, Values.ARRAY(vals), el, initial_, impl,graph) " //Debug.fprintln (\"insti\", \"for expression evaluated\") &" ;
ci_state_1 = instEquationCommonCiTrans(ci_state, initial_) " //Debug.fprintln (\"insti\", \"for expression unrolled\") & & //Debug.fprintln (\"insttr\", \"inst_equation_common_eqfor_1 succeeded\")" ;
then
(cache,env,ih,dae,csets_1,ci_state_1,graph);

case (cache,env,ih,mod,pre,csets,ci_state,SCode.EQ_FOR(index = i,range = Absyn.END(),eEquationLst = el),initial_,impl,graph) // Implicit range
equation
Expand Down
1 change: 1 addition & 0 deletions Compiler/Mod.mo
Expand Up @@ -1341,6 +1341,7 @@ algorithm outMod:= matchcontinue (inMod1,inMod2,inEnv3,inPrefix4)
DAE.Mod m;
case (DAE.NOMOD(),DAE.NOMOD(),_,_) then DAE.NOMOD();
case (DAE.NOMOD(),m,_,_) then m;
case (m,DAE.NOMOD(),_,_) then m;

case(inMod1,inMod2,inEnv3,inPrefix4)
equation
Expand Down

0 comments on commit e841f6e

Please sign in to comment.