Skip to content

Commit

Permalink
- Added flag to return correct cref types
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15912 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Leonardo Laguna committed Apr 25, 2013
1 parent b23c6b1 commit c88e38a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Compiler/FrontEnd/ComponentReference.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ algorithm
outCref := match(inCref,expandRecord)
local
DAE.Ident id;
DAE.Type ty;
DAE.Type ty,correctTy;
list<DAE.Dimension> dims;
list<DAE.Subscript> subs;
ComponentRef cref;
Expand All @@ -2601,26 +2601,26 @@ algorithm
expandCrefLst(crefs,varLst,{});

// A simple cref without subscripts but array type.
case (DAE.CREF_IDENT(id, DAE.T_ARRAY(ty = ty, dims = dims), {}),_)
case (DAE.CREF_IDENT(id, correctTy as DAE.T_ARRAY(ty = ty, dims = dims), {}),_)
equation
// Create a list of : subscripts to generate all elements.
subs = List.fill(DAE.WHOLEDIM(), listLength(dims));
then
expandCref2(id, ty, subs, dims);
expandCref2(id, Util.if_(Flags.getConfigBool(Flags.CORRECT_CREF_TYPES),correctTy,ty), subs, dims);

// A simple cref with subscripts and array type.
case (DAE.CREF_IDENT(id, DAE.T_ARRAY(ty = ty as DAE.T_COMPLEX(varLst=varLst,complexClassType=ClassInf.RECORD(_)), dims = dims), subs),true)
case (DAE.CREF_IDENT(id, correctTy as DAE.T_ARRAY(ty = ty as DAE.T_COMPLEX(varLst=varLst,complexClassType=ClassInf.RECORD(_)), dims = dims), subs),true)
equation
// Use the subscripts to generate only the wanted elements.
crefs = expandCref2(id, ty, subs, dims);
crefs = expandCref2(id, Util.if_(Flags.getConfigBool(Flags.CORRECT_CREF_TYPES),correctTy,ty), subs, dims);
then
expandCrefLst(crefs,varLst,{});

// A simple cref with subscripts and array type.
case (DAE.CREF_IDENT(id, DAE.T_ARRAY(ty = ty, dims = dims), subs),_)
case (DAE.CREF_IDENT(id, correctTy as DAE.T_ARRAY(ty = ty, dims = dims), subs),_)
// Use the subscripts to generate only the wanted elements.
then
expandCref2(id, ty, subs, dims);
expandCref2(id, Util.if_(Flags.getConfigBool(Flags.CORRECT_CREF_TYPES),correctTy,ty), subs, dims);


// A qualified cref with array type.
Expand Down
6 changes: 5 additions & 1 deletion Compiler/Util/Flags.mo
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,9 @@ constant ConfigFlag SCALARIZE_MINMAX = CONFIG_FLAG(47, "scalarizeMinMax",
constant ConfigFlag RUNNING_WSM_TESTSUITE = CONFIG_FLAG(48, "wsm-testsuite",
NONE(), INTERNAL(), BOOL_FLAG(false), NONE(),
Util.gettext("Used when running the WSM testsuite."));
constant ConfigFlag CORRECT_CREF_TYPES = CONFIG_FLAG(49, "correctCrefTypes",
NONE(), INTERNAL(), BOOL_FLAG(false), NONE(),
Util.gettext("Set to true to set correct types in component references. Doesn't work for OpenModelica backend."));

// This is a list of all configuration flags. A flag can not be used unless it's
// in this list, and the list is checked at initialization so that all flags are
Expand Down Expand Up @@ -814,7 +817,8 @@ constant list<ConfigFlag> allConfigFlags = {
DELAY_BREAK_LOOP,
TEARING_METHOD,
SCALARIZE_MINMAX,
RUNNING_WSM_TESTSUITE
RUNNING_WSM_TESTSUITE,
CORRECT_CREF_TYPES
};

public function new
Expand Down

0 comments on commit c88e38a

Please sign in to comment.