Skip to content

Commit

Permalink
Merging
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 19, 2010
2 parents 974004e + d5dbc8d commit ee3b79e
Show file tree
Hide file tree
Showing 38 changed files with 797 additions and 716 deletions.
17 changes: 14 additions & 3 deletions Compiler/Algorithm.mo
Expand Up @@ -67,6 +67,7 @@ protected import Exp;
protected import Print;
protected import Types;
protected import Util;
protected import System;

public function algorithmEmpty "Returns true if algorithm is empty, i.e. no statements"
input Algorithm alg;
Expand All @@ -78,6 +79,16 @@ algorithm
end matchcontinue;
end algorithmEmpty;

public function isReinitStatement "returns true if statement is a reinit"
input Statement stmt;
output Boolean res;
algorithm
res := matchcontinue(stmt)
case(DAE.STMT_REINIT(var = _)) then true;
case(_) then false;
end matchcontinue;
end isReinitStatement;

public function splitReinits ""
input list<Algorithm> inAlgs;
output list<Algorithm> reinits;
Expand Down Expand Up @@ -322,7 +333,7 @@ algorithm
DAE.C_CONST() = Util.listReduce(bvals, Types.constOr);
sl = Util.listMap(lhs, Exp.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = Util.stringAppendList({"(",s,")"});
lhs_str = System.stringAppendList({"(",s,")"});
rhs_str = Exp.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_CONSTANT_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
Expand All @@ -333,7 +344,7 @@ algorithm
DAE.C_PARAM() = Util.listReduce(bvals, Types.constOr);
sl = Util.listMap(lhs, Exp.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = Util.stringAppendList({"(",s,")"});
lhs_str = System.stringAppendList({"(",s,")"});
rhs_str = Exp.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_PARAM_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
Expand Down Expand Up @@ -364,7 +375,7 @@ algorithm
true = RTOpts.debugFlag("failtrace");
sl = Util.listMap(lhs, Exp.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = Util.stringAppendList({"(",s,")"});
lhs_str = System.stringAppendList({"(",s,")"});
rhs_str = Exp.printExpStr(rhs);
str1 = Util.stringDelimitList(Util.listMap(lprop, Types.printPropStr), ", ");
str2 = Types.printPropStr(rprop);
Expand Down
10 changes: 5 additions & 5 deletions Compiler/Ceval.mo
Expand Up @@ -1828,7 +1828,7 @@ algorithm
false = Types.dimensionsKnown(tp);
cr_str = Exp.printComponentRefStr(cr);
dim_str = Exp.printExpStr(dim);
size_str = Util.stringAppendList({"size(",cr_str,", ",dim_str,")"});
size_str = System.stringAppendList({"size(",cr_str,", ",dim_str,")"});
Error.addMessage(Error.DIMENSION_NOT_KNOWN, {size_str});
then
fail();
Expand Down Expand Up @@ -2479,14 +2479,14 @@ algorithm
case (_, _, _, false)
equation
fill_size = minLength - stringLength;
str = Util.stringAppendList(Util.listFill(" ", fill_size)) +& inString;
str = System.stringAppendList(Util.listFill(" ", fill_size)) +& inString;
then
str;
// leftJustified is true, append spaces at the end of the string.
case (_, _, _, true)
equation
fill_size = minLength - stringLength;
str = inString +& Util.stringAppendList(Util.listFill(" ", fill_size));
str = inString +& System.stringAppendList(Util.listFill(" ", fill_size));
then
str;
end matchcontinue;
Expand Down Expand Up @@ -2887,7 +2887,7 @@ algorithm
// WARNING: This can be very, very slow for long lists - it grows as O(n^2)
// TODO: When implemented, use listStringCharString (OMC name) or stringCharListString (RML name) directly
chList = Util.listMap(valList, extractValueStringChar);
str = Util.stringAppendList(chList);
str = System.stringAppendList(chList);
then
(cache,Values.STRING(str),st);
end matchcontinue;
Expand Down Expand Up @@ -5162,7 +5162,7 @@ algorithm
s1 = Exp.printComponentRefStr(e1);
s2 = Types.printBindingStr(inBinding);
str = Env.printEnvPathStr(env);
str = Util.stringAppendList({"- Ceval.cevalCrefBinding: ",
str = System.stringAppendList({"- Ceval.cevalCrefBinding: ",
s1, " = [", s2, "] in env:", str, " failed\n"});
Debug.fprint("ceval", str);
then
Expand Down
100 changes: 50 additions & 50 deletions Compiler/CevalScript.mo

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Compiler/CevalScript_stub.mo
Expand Up @@ -679,7 +679,7 @@ algorithm
omhome = System.trim(omhome, "\""); //Remove any quotation marks from omhome.
cflags = System.getCFlags();
ldflags = System.getLDFlags();
header = Util.stringAppendList({
header = System.stringAppendList({
"#Makefile generated by OpenModelica\n\n",
"CC=",ccompiler,"\n",
"CXX=",cxxcompiler,"\n",
Expand All @@ -697,7 +697,7 @@ protected function generateMakefilename "function generateMakefilename"
input String filenameprefix;
output String makefilename;
algorithm
makefilename := Util.stringAppendList({filenameprefix,".makefile"});
makefilename := System.stringAppendList({filenameprefix,".makefile"});
end generateMakefilename;

public function cevalGenerateFunction "function: cevalGenerateFunction
Expand Down Expand Up @@ -747,7 +747,7 @@ algorithm
omhome_1 = System.trim(omhome, "\"");
pd = System.pathDelimiter();
cit = winCitation();
dir_1 = Util.stringAppendList({cit,omhome_1,pd,"work",cit});
dir_1 = System.stringAppendList({cit,omhome_1,pd,"work",cit});
then
dir_1;
case (_,_) then ""; /* this function should never fail */
Expand Down
13 changes: 6 additions & 7 deletions Compiler/Cevalfunc.mo
Expand Up @@ -39,19 +39,18 @@ protected import ValuesUtil;
protected import ErrorExt;
protected import OptManager;
protected import Dump;
protected import System;

public function cevalUserFunc "Function: cevalUserFunc
This is the main funciton for the class. It will take a userdefined function and \"try\" to
evaluate it. This is to prevent multiple compilation of c files.

NOTE: this function operates on Absyn and not DAE therefore static elaboration on expressions is done twice
"
NOTE: this function operates on Absyn and not DAE therefore static elaboration on expressions is done twice"
input Env.Env env "enviroment for the user-function";
input DAE.Exp callExp "DAE.CALL(userFunc)";
input list<Values.Value> inArgs "arguments evaluated so no envirnoment is needed";
input SCode.Class sc "function body";
output Values.Value outVal "The output value";

algorithm
outVal := matchcontinue(env,callExp,inArgs,sc)
local
Expand Down Expand Up @@ -84,7 +83,7 @@ algorithm
str = Absyn.pathString(funcpath);
replacements = createReplacementRules(inArgs,elementList);
ht2 = generateHashMap(replacements,HashTable2.emptyHashTable());
str = Util.stringAppendList({"cevalfunc_",str});
str = System.stringAppendList({"cevalfunc_",str});
env3 = Env.openScope(env, false, SOME(str), SOME(Env.FUNCTION_SCOPE));
env1 = extendEnvWithInputArgs(env3,elementList,inArgs,crefArgs, ht2) "also output arguments";
// print("evalfunc env: " +& Env.printEnvStr(env) +& "\n");
Expand Down Expand Up @@ -113,7 +112,7 @@ algorithm
true = RTOpts.debugFlag("failtrace");
_ = extendEnvWithInputArgs(env,elementList,inArgs,crefArgs,HashTable2.emptyHashTable());
str = Absyn.pathString(funcpath);
str = Util.stringAppendList({"- Cevalfunc.evaluateStatements failed for function /* ",str," */\n"});
str = System.stringAppendList({"- Cevalfunc.evaluateStatements failed for function /* ",str," */\n"});
Debug.fprint("failtrace", str);
then
fail();
Expand All @@ -124,7 +123,7 @@ algorithm
true = RTOpts.debugFlag("failtrace");
failure(_ = extendEnvWithInputArgs(env,elementList,inArgs,crefArgs,HashTable2.emptyHashTable()));
str = Absyn.pathString(funcpath);
str = Util.stringAppendList({"- Cevalfunc.extendEnvWithInputArgs failed for function /* ",str," */"});
str = System.stringAppendList({"- Cevalfunc.extendEnvWithInputArgs failed for function /* ",str," */"});
Debug.fprint("failtrace", str);
then
fail();
Expand Down Expand Up @@ -1092,7 +1091,7 @@ algorithm outVal := matchcontinue(inVal,env,toAssign)
true = RTOpts.debugFlag("failtrace");
//(Absyn.CREF_IDENT(dbgString,_)) = Absyn.crefGetFirst(dbgcr);
dbgString = Dump.printComponentRefStr(dbgcr);
dbgString = Util.stringAppendList({"- Cevalfunc.setValue failed for ", dbgString,"\n"});
dbgString = System.stringAppendList({"- Cevalfunc.setValue failed for ", dbgString,"\n"});
Debug.fprint("failtrace", dbgString);
then fail();
end matchcontinue;
Expand Down
18 changes: 9 additions & 9 deletions Compiler/ClassLoader.mo
Expand Up @@ -164,7 +164,7 @@ algorithm
mp = System.trim(mp_1, " \"\t");
pd = System.pathDelimiter();
classfile = stringAppend(class_, ".mo");
classfile_1 = Util.stringAppendList({mp,pd,classfile});
classfile_1 = System.stringAppendList({mp,pd,classfile});
existRegularFile(classfile_1);
p = Parser.parse(classfile_1);
then
Expand All @@ -175,8 +175,8 @@ algorithm
ts = Absyn.getNewTimeStamp();
mp = System.trim(mp_1, " \"\t");
pd = System.pathDelimiter();
dirfile = Util.stringAppendList({mp,pd,class_});
packfile = Util.stringAppendList({dirfile,pd,"package.mo"});
dirfile = System.stringAppendList({mp,pd,class_});
packfile = System.stringAppendList({dirfile,pd,"package.mo"});
existDirectoryFile(dirfile);
existRegularFile(packfile);
Print.printBuf("Class is package stored in a directory, loading whole package(incl. subdir)\n");
Expand Down Expand Up @@ -241,8 +241,8 @@ algorithm
case (pack,mp,(within_ as Absyn.TOP()),Absyn.PROGRAM(classes = oldc))
equation
pd = System.pathDelimiter();
mp_1 = Util.stringAppendList({mp,pd,pack});
packagefile = Util.stringAppendList({mp_1,pd,"package.mo"});
mp_1 = System.stringAppendList({mp,pd,pack});
packagefile = System.stringAppendList({mp_1,pd,"package.mo"});
existRegularFile(packagefile);
Absyn.PROGRAM(p1,w1,ts) = Parser.parse(packagefile);
Print.printBuf("loading ");
Expand All @@ -260,8 +260,8 @@ algorithm
case (pack,mp,(within_ as Absyn.WITHIN(path = wpath)),Absyn.PROGRAM(classes = oldc))
equation
pd = System.pathDelimiter();
mp_1 = Util.stringAppendList({mp,pd,pack});
packagefile = Util.stringAppendList({mp_1,pd,"package.mo"});
mp_1 = System.stringAppendList({mp,pd,pack});
packagefile = System.stringAppendList({mp_1,pd,"package.mo"});
existRegularFile(packagefile);
Absyn.PROGRAM(p1,w1,ts) = Parser.parse(packagefile);
Print.printBuf("loading ");
Expand Down Expand Up @@ -404,7 +404,7 @@ algorithm
case ((f :: fs),mp,within_,Absyn.PROGRAM(classes = oldc,globalBuildTimes = ts))
equation
pd = System.pathDelimiter();
f_1 = Util.stringAppendList({mp,pd,f});
f_1 = System.stringAppendList({mp,pd,f});
Absyn.PROGRAM(cls,_,_) = Parser.parse(f_1);
p_1 = Interactive.updateProgram(Absyn.PROGRAM(cls,within_,ts), Absyn.PROGRAM(oldc,Absyn.TOP(),ts));
p_2 = loadSubpackageFiles(fs, mp, within_, p_1);
Expand Down Expand Up @@ -437,7 +437,7 @@ algorithm
(dir,"package.mo") = Util.getAbsoluteDirectoryAndFile(name);
p1_1 = Parser.parse(name);
pd = System.pathDelimiter();
dir_1 = Util.stringAppendList({dir,pd,".."});
dir_1 = System.stringAppendList({dir,pd,".."});
p1 = loadModelFromEachClass(p1_1, dir_1);
then
p1;
Expand Down
12 changes: 6 additions & 6 deletions Compiler/ConnectUtil.mo
Expand Up @@ -1021,7 +1021,7 @@ algorithm
equation
strs = Util.listMap(cs, printStreamRefStr);
str = Util.stringDelimitList(strs, ", ");
str = Util.stringAppendList({"stream set: {",str,"}"});
str = System.stringAppendList({"stream set: {",str,"}"});
print("Only one-to-one connections of streams are supported: unsupported connection set:" +& str);
then DAEUtil.emptyDae;
end matchcontinue;
Expand Down Expand Up @@ -1586,7 +1586,7 @@ algorithm
s2 = printSetCrsStr(crs);
s3 = Util.stringDelimitList(Util.listMap(dc,Exp.printComponentRefStr), ",");
s4 = printOuterConnectsStr(outerConn);
res = Util.stringAppendList({"Connect.SETS(\n\t",
res = System.stringAppendList({"Connect.SETS(\n\t",
s1_1,", \n\t",
s2,", \n\tdeleted comps: ",s3,", \n\touter connections:",s4,")\n"});
then
Expand Down Expand Up @@ -1629,23 +1629,23 @@ algorithm
equation
strs = Util.listMap(Util.listMap(cs, Util.tuple21), Exp.printComponentRefStr);
s1 = Util.stringDelimitList(strs, ", ");
res = Util.stringAppendList({"\n\tnon-flow set: {",s1,"}"});
res = System.stringAppendList({"\n\tnon-flow set: {",s1,"}"});
then
res;
case Connect.FLOW(tplExpComponentRefFaceLst = cs)
local list<Connect.FlowSetElement> cs;
equation
strs = Util.listMap(cs, printFlowRefStr);
s1 = Util.stringDelimitList(strs, ", ");
res = Util.stringAppendList({"\n\tflow set: {",s1,"}"});
res = System.stringAppendList({"\n\tflow set: {",s1,"}"});
then
res;
case Connect.STREAM(tplExpComponentRefFaceLst = cs)
local list<Connect.StreamSetElement> cs;
equation
strs = Util.listMap(cs, printStreamRefStr);
s1 = Util.stringDelimitList(strs, ", ");
res = Util.stringAppendList({"\n\tstream set: {",s1,"}"});
res = System.stringAppendList({"\n\tstream set: {",s1,"}"});
then
res;
end matchcontinue;
Expand Down Expand Up @@ -1707,7 +1707,7 @@ protected function printSetCrsStr
algorithm
c_strs := Util.listMap(crs, Exp.printComponentRefStr);
s := Util.stringDelimitList(c_strs, ", ");
res := Util.stringAppendList({"connect crs: {",s,"}"});
res := System.stringAppendList({"connect crs: {",s,"}"});
end printSetCrsStr;

public function componentFace
Expand Down
4 changes: 2 additions & 2 deletions Compiler/ConnectionGraph.mo
Expand Up @@ -1526,7 +1526,7 @@ algorithm
labelFontSize = Util.if_(isBroken, "labelfontsize = 20.0, ", "");
sc1 = Exp.printComponentRefStr(c1);
sc2 = Exp.printComponentRefStr(c2);
strDaeEdge = Util.stringAppendList({
strDaeEdge = System.stringAppendList({
"\"", sc1, "\" -- \"", sc2, "\" [",
"dir = \"none\", ",
"style = ", style, ", ",
Expand Down Expand Up @@ -1630,7 +1630,7 @@ algorithm
"// Final Roots: ", nrFR, "\n",
"// Broken Connections: ", nrBC, "\n"
};
infoNodeStr = Util.stringAppendList(infoNode);
infoNodeStr = System.stringAppendList(infoNode);
// replace \n with \\l (left align), replace \t with " "
infoNodeStr = System.stringReplace(infoNodeStr, "\n", "\\l"); infoNodeStr = System.stringReplace(infoNodeStr, "\t", " ");
// replace / with ""
Expand Down

0 comments on commit ee3b79e

Please sign in to comment.