Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Fixed the boolean array assignment. DoublePendulum test should work now.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23733 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Dec 11, 2014
1 parent f59b12a commit 9541f6e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
7 changes: 2 additions & 5 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -3914,15 +3914,11 @@ case eqn as SES_ARRAY_CALL_ASSIGN(__) then
let expPart = daeExp(exp, context, &preExp, &varDecls, &auxFunction)
match expTypeFromExpShort(eqn.exp)
case "boolean" then
let tvar = tempDecl("boolean_array", &varDecls)
//let &preExp += 'cast_integer_array_to_real(&<%expPart%>, &<%tvar%>);<%\n%>'
<<
<%preExp%>
copy_boolean_array_data_mem(<%expPart%>, &<%cref(eqn.componentRef)%>);
>>
case "integer" then
let tvar = tempDecl("integer_array", &varDecls)
//let &preExp += 'cast_integer_array_to_real(&<%expPart%>, &<%tvar%>);<%\n%>'
<<
<%preExp%>
copy_integer_array_data_mem(<%expPart%>, &<%cref(eqn.componentRef)%>);
Expand Down Expand Up @@ -8503,7 +8499,7 @@ case LUNARY(__) then
match operator
case NOT(ty = T_ARRAY(__)) then
let var = tempDecl("boolean_array", &varDecls)
let &preExp += 'not_boolean_array(&<%e%>,&<%var%>);<%\n%>'
let &preExp += 'not_boolean_array(<%e%>,&<%var%>);<%\n%>'
'<%var%>'
else
'(!<%e%>)'
Expand Down Expand Up @@ -8558,6 +8554,7 @@ case rel as RELATION(__) then
case EQUAL(ty = T_INTEGER(__)) then '(<%e1%> == <%e2%>)'
case EQUAL(ty = T_REAL(__)) then '(<%e1%> == <%e2%>)'
case EQUAL(ty = T_ENUMERATION(__)) then '(<%e1%> == <%e2%>)'
case EQUAL(ty = T_ARRAY(__)) then '<%e2%>' /* Used for Boolean array. Called from daeExpLunary. */

case NEQUAL(ty = T_BOOL(__)) then '((!<%e1%> && <%e2%>) || (<%e1%> && !<%e2%>))'
case NEQUAL(ty = T_STRING(__)) then '(!stringEqual(<%e1%>, <%e2%>))'
Expand Down
10 changes: 5 additions & 5 deletions SimulationRuntime/c/util/boolean_array.c
Expand Up @@ -143,20 +143,20 @@ void or_boolean_array(const boolean_array_t *source1, const boolean_array_t *sou
}
}

void not_boolean_array(const boolean_array_t *source, boolean_array_t *dest)
void not_boolean_array(const boolean_array_t source, boolean_array_t *dest)
{
size_t i, nr_of_elements;

assert(base_array_ok(source));
assert(base_array_ok(&source));

clone_base_array_spec(source, dest);
clone_base_array_spec(&source, dest);
alloc_boolean_array_data(dest);


nr_of_elements = base_array_nr_of_elements(*source);
nr_of_elements = base_array_nr_of_elements(source);

for(i = 0; i < nr_of_elements; ++i) {
boolean_set(dest, i, !boolean_get(*source, i));
boolean_set(dest, i, !boolean_get(source, i));
}
}

Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/c/util/boolean_array.h
Expand Up @@ -95,7 +95,7 @@ void and_boolean_array(const boolean_array_t *source1, const boolean_array_t *so
void or_boolean_array(const boolean_array_t *source1, const boolean_array_t *source2, boolean_array_t *dest);

/* 'not' a boolean array*/
void not_boolean_array(const boolean_array_t *source, boolean_array_t *dest);
void not_boolean_array(const boolean_array_t source, boolean_array_t *dest);

extern modelica_boolean* calc_boolean_index(int ndims, const _index_t* idx_vec, const boolean_array_t* arr);
extern modelica_boolean* calc_boolean_index_va(const boolean_array_t* source,int ndims,va_list ap);
Expand Down

0 comments on commit 9541f6e

Please sign in to comment.