Skip to content

Commit

Permalink
- comment for Print.writeBuf
Browse files Browse the repository at this point in the history
- dumpXMLDAE improvements: 
  do not use Print.getString as the string is huge, just write it directly to file

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18027 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 6, 2013
1 parent 51140fb commit 9179cfe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
26 changes: 11 additions & 15 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -3040,7 +3040,7 @@ algorithm

case (cache,env,"dumpXMLDAE",vals,st,_)
equation
(cache,st,xml_contents,xml_filename) = dumpXMLDAE(cache,env,vals,st, msg);
(cache,st,xml_filename) = dumpXMLDAE(cache,env,vals,st, msg);
then
(cache,ValuesUtil.makeTuple({Values.BOOL(true),Values.STRING(xml_filename)}),st);

Expand Down Expand Up @@ -4292,10 +4292,9 @@ protected function dumpXMLDAE " author: fildo
input Absyn.Msg inMsg;
output Env.Cache outCache;
output GlobalScript.SymbolTable outInteractiveSymbolTable3;
output String xml_contents;
output String xml_filename;
algorithm
(outCache,outInteractiveSymbolTable3,xml_contents,xml_filename) :=
(outCache,outInteractiveSymbolTable3,xml_filename) :=
match (inCache,inEnv,vals,inInteractiveSymbolTable,inMsg)
local
String cname_str,filenameprefix,compileDir;
Expand Down Expand Up @@ -4325,12 +4324,11 @@ algorithm
xml_filename = stringAppendList({filenameprefix,".xml"});
Print.clearBuf();
XMLDump.dumpBackendDAE(dlow_1,addOriginalIncidenceMatrix,addSolvingInfo,addMathMLCode,dumpResiduals,false);
xml_contents = Print.getString();
Print.writeBuf(xml_filename);
Print.clearBuf();
System.writeFile(xml_filename,xml_contents);
compileDir = Util.if_(Config.getRunningTestsuite(),"",compileDir);
then
(cache,st,xml_contents,stringAppendList({compileDir,xml_filename}));
(cache,st,stringAppendList({compileDir,xml_filename}));

case (cache,env,{Values.CODE(Absyn.C_TYPENAME(classname)),Values.STRING(string="optimiser"),Values.BOOL(addOriginalIncidenceMatrix),Values.BOOL(addSolvingInfo),Values.BOOL(addMathMLCode),Values.BOOL(dumpResiduals),Values.STRING(filenameprefix)},(st as GlobalScript.SYMBOLTABLE(ast = p)),msg)
equation
Expand All @@ -4349,12 +4347,11 @@ algorithm
xml_filename = stringAppendList({filenameprefix,".xml"});
Print.clearBuf();
XMLDump.dumpBackendDAE(dlow_1,addOriginalIncidenceMatrix,addSolvingInfo,addMathMLCode,dumpResiduals,false);
xml_contents = Print.getString();
Print.writeBuf(xml_filename);
Print.clearBuf();
System.writeFile(xml_filename,xml_contents);
compileDir = Util.if_(Config.getRunningTestsuite(),"",compileDir);
then
(cache,st,xml_contents,stringAppendList({compileDir,xml_filename}));
(cache,st,stringAppendList({compileDir,xml_filename}));

case (cache,env,{Values.CODE(Absyn.C_TYPENAME(classname)),Values.STRING(string="backEnd"),Values.BOOL(addOriginalIncidenceMatrix),Values.BOOL(addSolvingInfo),Values.BOOL(addMathMLCode),Values.BOOL(dumpResiduals),Values.STRING(filenameprefix)},(st as GlobalScript.SYMBOLTABLE(ast = p)),msg)
equation
Expand All @@ -4371,12 +4368,11 @@ algorithm
xml_filename = stringAppendList({filenameprefix,".xml"});
Print.clearBuf();
XMLDump.dumpBackendDAE(indexed_dlow,addOriginalIncidenceMatrix,addSolvingInfo,addMathMLCode,dumpResiduals,false);
xml_contents = Print.getString();
Print.writeBuf(xml_filename);
Print.clearBuf();
System.writeFile(xml_filename,xml_contents);
compileDir = Util.if_(Config.getRunningTestsuite(),"",compileDir);
then
(cache,st,xml_contents,stringAppendList({compileDir,xml_filename}));
(cache,st,stringAppendList({compileDir,xml_filename}));

case (cache,env,{Values.CODE(Absyn.C_TYPENAME(classname)),Values.STRING(string="stateSpace"),Values.BOOL(addOriginalIncidenceMatrix),Values.BOOL(addSolvingInfo),Values.BOOL(addMathMLCode),Values.BOOL(dumpResiduals),Values.STRING(filenameprefix)},(st as GlobalScript.SYMBOLTABLE(ast = p)),msg)
equation
Expand All @@ -4393,12 +4389,12 @@ algorithm
xml_filename = stringAppendList({filenameprefix,".xml"});
Print.clearBuf();
XMLDump.dumpBackendDAE(indexed_dlow,addOriginalIncidenceMatrix,addSolvingInfo,addMathMLCode,dumpResiduals,true);
xml_contents = Print.getString();
Print.writeBuf(xml_filename);
Print.clearBuf();
System.writeFile(xml_filename,xml_contents);
compileDir = Util.if_(Config.getRunningTestsuite(),"",compileDir);
then
(cache,st,xml_contents,stringAppendList({compileDir,xml_filename}));
(cache,st,stringAppendList({compileDir,xml_filename}));

end match;
end dumpXMLDAE;

Expand Down
6 changes: 3 additions & 3 deletions Compiler/Util/Print.mo
Expand Up @@ -85,10 +85,10 @@ public function getString "Does not clear the buffer"
external "C" outString = Print_getString(OpenModelica.threadData()) annotation(Library = "omcruntime");
end getString;

public function writeBuf
input String inString;
public function writeBuf "Writes the buffer to a file"
input String filename;

external "C" Print_writeBuf(OpenModelica.threadData(),inString) annotation(Library = "omcruntime");
external "C" Print_writeBuf(OpenModelica.threadData(), filename) annotation(Library = "omcruntime");
end writeBuf;

public function writeBufConvertLines
Expand Down

0 comments on commit 9179cfe

Please sign in to comment.