Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Support size(cr) in codegen


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13307 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 11, 2012
1 parent 2efbebb commit 6ee75dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Compiler/Template/CodegenC.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7037,7 +7037,12 @@ template daeExpSize(Exp exp, Context context, Text &preExp /*BUFP*/,
let typeStr = '<%expTypeArray(exp.ty)%>'
let &preExp += '<%resVar%> = size_of_dimension_<%typeStr%>(<%expPart%>, <%dimPart%>);<%\n%>'
resVar
else "size(X) not implemented"
case SIZE(exp=CREF(__)) then
let expPart = daeExp(exp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/)
let resVar = tempDecl("integer_array", &varDecls /*BUFD*/)
let &preExp += 'sizes_of_dimensions_base_array(&<%expPart%>, &<%resVar%>);<%\n%>'
resVar
else error(sourceInfo(), printExpStr(exp) + " not implemented")
end daeExpSize;


Expand Down
9 changes: 9 additions & 0 deletions SimulationRuntime/c/util/integer_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -1637,3 +1637,12 @@ void convert_alloc_integer_array_from_f77(const integer_array_t * a,
}
transpose_integer_array (a,dest);
}

void sizes_of_dimensions_base_array(const base_array_t *a, integer_array_t *dest)
{
int i = ndims_base_array(a);
simple_alloc_1d_integer_array(dest, i);
while (i--) {
integer_set(dest, i, a->dim_size[i]);
}
}
2 changes: 2 additions & 0 deletions SimulationRuntime/c/util/integer_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ static inline int ndims_integer_array(const integer_array_t * a)
{ return ndims_base_array(a); }
static inline int size_of_dimension_integer_array(integer_array_t a, int i)
{ return size_of_dimension_base_array(a, i); }
/* This is defined in integer_array since we return an integer array */
extern void sizes_of_dimensions_base_array(const base_array_t *a, integer_array_t *dest);

extern void size_integer_array(const integer_array_t * a,integer_array_t* dest);
extern modelica_integer scalar_integer_array(const integer_array_t * a);
Expand Down

0 comments on commit 6ee75dd

Please sign in to comment.