Skip to content

Commit

Permalink
- Improved MetaModelica error messages by performing the conversion t…
Browse files Browse the repository at this point in the history
…o list() when elaborating an array

  - This is only performed if MetaModelica grammar is specified and the type cannot be a Modelica array (only boxed types)
  - Added a debug flag +d=rml which will improve the error messages even further by also transforming arrays of basic types into lists
- Bugfix Types.isBoxed: T_METARECORD was previously missing


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6326 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 10, 2010
1 parent 1f55acc commit 56aa74c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Compiler/MetaUtil.mo
Expand Up @@ -1497,4 +1497,35 @@ algorithm
end matchcontinue;
end extractListFromTuple;

public function tryToConvertArrayToList
"Convert an array, T[:], of a MetaModelica type into list. MetaModelica types
can only be of array<T> type, not T[:].
This is mainly to produce better error messages."
input DAE.Exp exp;
input DAE.Type ty;
output DAE.Exp outExp;
output DAE.Type outTy;
algorithm
(outExp,outTy) := matchcontinue (exp,ty)
local
DAE.Type flatType;
case (exp,ty)
equation
true = RTOpts.acceptMetaModelicaGrammar();
(flatType,_) = Types.flattenArrayType(ty);
true = Types.isBoxedType(flatType) or RTOpts.debugFlag("rml") "debug flag to produce better error messages by converting all arrays into lists; the compiler does not use Modelica-style arrays anyway";
(exp,ty) = Types.matchType(exp, ty, (DAE.T_LIST((DAE.T_NOTYPE(),NONE())),NONE()), false);
then (exp,ty);
case (exp,ty)
equation
false = Types.isBoxedType(ty);
then (exp,ty);

case (exp,ty)
equation
Debug.fprintln("failtrace", "- Static.tryToConvertArrayToList failed");
then fail();
end matchcontinue;
end tryToConvertArrayToList;

end MetaUtil;
1 change: 1 addition & 0 deletions Compiler/Static.mo
Expand Up @@ -523,6 +523,7 @@ algorithm
a = Types.isArray(t);
a = boolNot(a); // scalar = !array
arrexp = DAE.ARRAY(at,a,es_1);
(arrexp,arrtp) = MetaUtil.tryToConvertArrayToList(arrexp,arrtp) "converts types that cannot be arrays into lists";
arrexp = tryToConvertArrayToMatrix(arrexp);
then
(cache,arrexp,DAE.PROP(arrtp,const),st,dae);
Expand Down
1 change: 1 addition & 0 deletions Compiler/Types.mo
Expand Up @@ -5134,6 +5134,7 @@ algorithm
case ((DAE.T_LIST(_),_)) then true;
case ((DAE.T_METATUPLE(_),_)) then true;
case ((DAE.T_UNIONTYPE(_),_)) then true;
case ((DAE.T_METARECORD(_,_),_)) then true;
case ((DAE.T_POLYMORPHIC(_),_)) then true;
case ((DAE.T_META_ARRAY(_),_)) then true;
case ((DAE.T_FUNCTION(_,_,_),_)) then true;
Expand Down

0 comments on commit 56aa74c

Please sign in to comment.