Skip to content

Commit

Permalink
fix to handle array variables attributes if we dont do scalarization
Browse files Browse the repository at this point in the history
- the each qualifier will be lost as we cannot represent it yet in DAE.Var

Belonging to [master]:
  - OpenModelica/OMCompiler#2673
  - OpenModelica/OpenModelica-testsuite#1038
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Sep 20, 2018
1 parent 9646ce4 commit d671df5
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions Compiler/NFFrontEnd/NFConvertDAE.mo
Expand Up @@ -197,6 +197,9 @@ function convertVarAttributes
output Option<DAE.VariableAttributes> attributes;
protected
Option<Boolean> is_final;
Type elTy;
Option<Type> arrayTy = NONE();
Boolean is_array = false;
algorithm
if listEmpty(attrs) and not compAttrs.isFinal then
attributes := NONE();
Expand All @@ -205,19 +208,26 @@ algorithm

is_final := SOME(compAttrs.isFinal);

attributes := match ty
case Type.REAL() then convertRealVarAttributes(attrs, is_final);
case Type.INTEGER() then convertIntVarAttributes(attrs, is_final);
case Type.BOOLEAN() then convertBoolVarAttributes(attrs, is_final);
case Type.STRING() then convertStringVarAttributes(attrs, is_final);
case Type.ENUMERATION() then convertEnumVarAttributes(attrs, is_final);
elTy := ty;
if Type.isArray(ty) then
elTy := Type.arrayElementType(ty);
arrayTy := SOME(ty);
end if;

attributes := match elTy
case Type.REAL() then convertRealVarAttributes(attrs, is_final, arrayTy);
case Type.INTEGER() then convertIntVarAttributes(attrs, is_final, arrayTy);
case Type.BOOLEAN() then convertBoolVarAttributes(attrs, is_final, arrayTy);
case Type.STRING() then convertStringVarAttributes(attrs, is_final, arrayTy);
case Type.ENUMERATION() then convertEnumVarAttributes(attrs, is_final, arrayTy);
else NONE();
end match;
end convertVarAttributes;

function convertRealVarAttributes
input list<tuple<String, Binding>> attrs;
input Option<Boolean> isFinal;
input Option<Type> arrayTy;
output Option<DAE.VariableAttributes> attributes;
protected
String name;
Expand Down Expand Up @@ -260,6 +270,7 @@ end convertRealVarAttributes;
function convertIntVarAttributes
input list<tuple<String, Binding>> attrs;
input Option<Boolean> isFinal;
input Option<Type> arrayTy;
output Option<DAE.VariableAttributes> attributes;
protected
String name;
Expand Down Expand Up @@ -295,6 +306,7 @@ end convertIntVarAttributes;
function convertBoolVarAttributes
input list<tuple<String, Binding>> attrs;
input Option<Boolean> isFinal;
input Option<Type> arrayTy;
output Option<DAE.VariableAttributes> attributes;
protected
String name;
Expand Down Expand Up @@ -326,6 +338,7 @@ end convertBoolVarAttributes;
function convertStringVarAttributes
input list<tuple<String, Binding>> attrs;
input Option<Boolean> isFinal;
input Option<Type> arrayTy;
output Option<DAE.VariableAttributes> attributes;
protected
String name;
Expand Down Expand Up @@ -357,6 +370,7 @@ end convertStringVarAttributes;
function convertEnumVarAttributes
input list<tuple<String, Binding>> attrs;
input Option<Boolean> isFinal;
input Option<Type> arrayTy;
output Option<DAE.VariableAttributes> attributes;
protected
String name;
Expand Down

0 comments on commit d671df5

Please sign in to comment.