Skip to content

Commit

Permalink
Fixed two bugs that affect the code generation in MathCore backend:
Browse files Browse the repository at this point in the history
   -Fixed a bug in Exp.stringifyComponentRef (last type should be picked up, but it wasn't).
   -Fixed a bug in vectorize call (giving wrong type to component refererences.

-Added some dumping functions for DAE.FunctionTree to DAEUtil.
-Fixed some bugs with function dae not picked up correctly.
-Added some documentation
- Added testcases from MathCore: 
   - instantiation of all examples in MSL221 subset in MathModelica.
   - instantiation of BioChem examples
   - instantiation of Magnetic examples (for MSL221)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5215 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Mar 26, 2010
1 parent 9e8a425 commit 6422011
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Compiler/ConnectUtil.mo
Expand Up @@ -736,7 +736,7 @@ algorithm
case {(c,f,_)}
equation
exp = signFlow(c, f);
// print("Generating flow expresion: " +& Exp.printExpStr(exp) +& "\n");
//print("Generating flow expression: " +& Exp.printExpStr(exp) +& "\n");
then
exp;
case (((c,f,_) :: cs))
Expand Down
50 changes: 48 additions & 2 deletions Compiler/DAEUtil.mo
Expand Up @@ -608,7 +608,9 @@ end printDAE;


public function dump "function: dump
This function prints the DAE in the standard output format."
This function prints the DAE in the standard output format to the Print buffer.
For printing to the stdout use print(dumpStr(dae)) instead.
"
input DAE.DAElist inDAElist;
algorithm
_ := matchcontinue (inDAElist)
Expand All @@ -626,6 +628,40 @@ algorithm
end matchcontinue;
end dump;

public function dumpFunctionNamesStr "return all function names in a string (comma separated)"
input DAE.DAElist dae;
output String str;
algorithm
str := matchcontinue(dae)
local
list<DAE.Element> daelist;
DAE.FunctionTree funcs;
case DAE.DAE(_,funcs) equation
//print("dumping DAE, avltree list length:"+&intString(listLength(avlTreeToList(funcs)))+&"\n");
str = Util.stringDelimitList(Util.listMap(sortFunctions(Util.listMap(avlTreeToList(funcs),Util.tuple22)),functionNameStr),",");
then str;
end matchcontinue;
end dumpFunctionNamesStr;

protected function functionNameStr
"return the name of a function, if element is not function return empty string"
input DAE.Element inElement;
output String res;
algorithm
res := matchcontinue (inElement)
local
Absyn.Path fpath;

case DAE.FUNCTION(path = fpath) equation
res = Absyn.pathString(fpath);
then res;
case DAE.RECORD_CONSTRUCTOR(path = fpath) equation
res = Absyn.pathString(fpath);
then res;
case _ then "";
end matchcontinue;
end functionNameStr;

protected function sortFunctions "sorts the functions in alphabetical order"
input list<DAE.Element> funcs;
output list<DAE.Element> sortedFuncs;
Expand Down Expand Up @@ -6817,7 +6853,6 @@ algorithm
DAE.Element elt;

case(DAE.DAE({},funcs)) then DAE.DAE({},funcs);

/* is function */
case(DAE.DAE(elt::elts,funcs)) equation
true = elementIsFunction(elt);
Expand Down Expand Up @@ -6966,6 +7001,17 @@ algorithm
end matchcontinue;
end joinDaeLst;

public function extractFunctions "Extracts only the functions from a DAE.DAElist and returns an empty element list
Is typically used when no dae should be generated, but functions must be passed along.
"
input DAE.DAElist dae;
output DAE.DAElist outDae;
algorithm
outDae := matchcontinue(dae)
local DAE.FunctionTree funcs;
case(DAE.DAE(_,funcs)) then DAE.DAE({},funcs);
end matchcontinue;
end extractFunctions;
/*AvlTree implementation for DAE functions.*/

public function keyStr "prints a key to a string"
Expand Down
8 changes: 5 additions & 3 deletions Compiler/Exp.mo
Expand Up @@ -4453,7 +4453,9 @@ end arrayEltType;

public function unliftArray
"function: unliftArray
Converts an array type into its element type."
Converts an array type into its element type
See also Types.unliftArray.
."
input Type inType;
output Type outType;
algorithm
Expand Down Expand Up @@ -8295,9 +8297,9 @@ public function stringifyComponentRef
Type ty;
algorithm
subs := crefLastSubs(cr);
cr_1 := crefStripLastSubs(cr) "PA" ;
cr_1 := crefStripLastSubs(cr);
crs := printComponentRefStr(cr_1);
ty := elaborateCrefQualType(cr);
ty := crefLastType(cr) "The type of the stringified cr is taken from the last identifier";
outComponentRef := DAE.CREF_IDENT(crs,ty,subs);
end stringifyComponentRef;

Expand Down

0 comments on commit 6422011

Please sign in to comment.