Skip to content

Commit

Permalink
- fix the inst of some of the failing new Media models (add locals to…
Browse files Browse the repository at this point in the history
… ht in classes with parts!)

- fix some code generation issues for handling crefs of arrays of records.
- some models might fail, I'll see.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17308 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Sep 20, 2013
1 parent 2b8b41c commit 83437fb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
11 changes: 7 additions & 4 deletions Compiler/FrontEnd/InstExtends.mo
Expand Up @@ -1077,11 +1077,13 @@ algorithm
SCode.Mod mod;
Env.Cache cache;
Env.Env env;
HashTableStringToPath.HashTable ht;
HashTableStringToPath.HashTable ht, htParent;
SCode.ClassDef cd;

case (cache,env,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed),ht)
case (cache,env,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed),htParent)
equation
ht = List.fold(BaseHashTable.hashTableList(htParent), BaseHashTable.add, HashTableStringToPath.emptyHashTable());
ht = getLocalIdentList(elts,ht,getLocalIdentElement);
(cache,elts) = fixList(cache,env,elts,ht,fixElement);
(cache,ne) = fixList(cache,env,ne,ht,fixEquation);
(cache,ie) = fixList(cache,env,ie,ht,fixEquation);
Expand All @@ -1090,8 +1092,9 @@ algorithm
(cache,nc) = fixList(cache,env,nc,ht,fixConstraint);
then (cache,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed));

case (cache,env,SCode.CLASS_EXTENDS(name,mod,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed)),ht)
case (cache,env,SCode.CLASS_EXTENDS(name,mod,SCode.PARTS(elts,ne,ie,na,ia,nc,clats,ed)),htParent)
equation
ht = List.fold(BaseHashTable.hashTableList(htParent), BaseHashTable.add, HashTableStringToPath.emptyHashTable());
(cache,mod) = fixModifications(cache,env,mod,ht);
(cache,elts) = fixList(cache,env,elts,ht,fixElement);
(cache,ne) = fixList(cache,env,ne,ht,fixEquation);
Expand Down Expand Up @@ -1609,7 +1612,7 @@ algorithm
cref = Env.crefStripEnvPrefix(cref, env);
//Debug.fprintln(Flags.DEBUG, "Cref VAR fixed: " +& Absyn.printComponentRefStr(cref));
then (cache,cref);

case (cache,env,cref,ht)
equation
id = Absyn.crefFirstIdent(cref);
Expand Down
18 changes: 15 additions & 3 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -6923,9 +6923,21 @@ template daeExpCrefRhs2(Exp ecr, Context context, Text &preExp /*BUFP*/,
let dimsValuesStr = (crefSubs(cr) |> INDEX(__) =>
daeExp(exp, context, &preExp, &varDecls)
;separator=", ")
<<
(*<%arrayType%>_element_addr(&<%arrName%>, <%dimsLenStr%>, <%dimsValuesStr%>))
>>
match ty
case (T_ARRAY(ty = T_COMPLEX(complexClassType = record_state))) then
let rec_name = underscorePath(ClassInf.getStateName(record_state))
<<
(*((<%rec_name%>*)(generic_array_element_addr(&<%arrName%>, sizeof(<%rec_name%>), <%dimsLenStr%>, <%dimsValuesStr%>))))
>>
case (T_COMPLEX(complexClassType = record_state)) then
let rec_name = underscorePath(ClassInf.getStateName(record_state))
<<
(*((<%rec_name%>*)(generic_array_element_addr(&<%arrName%>, sizeof(<%rec_name%>), <%dimsLenStr%>, <%dimsValuesStr%>))))
>>
else
<<
(*<%arrayType%>_element_addr(&<%arrName%>, <%dimsLenStr%>, <%dimsValuesStr%>))
>>
case PARALLEL_FUNCTION_CONTEXT(__) then
let dimsValuesStr = (crefSubs(cr) |> INDEX(__) =>
daeExp(exp, context, &preExp, &varDecls)
Expand Down

0 comments on commit 83437fb

Please sign in to comment.