Skip to content

Commit

Permalink
Remove some unused function calls
Browse files Browse the repository at this point in the history
Refecatored some code using `_ = f()`
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Jun 14, 2016
1 parent d59e2f8 commit 4936316
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 57 deletions.
7 changes: 2 additions & 5 deletions Compiler/FrontEnd/ExpressionDump.mo
Expand Up @@ -598,9 +598,9 @@ algorithm
s2 = printExp2Str(e2, stringDelimiter, opcreffunc, opcallfunc);
p = expPriority(e);
p1 = expPriority(e1);
_ = expPriority(e2);
p2 = expPriority(e2);
s1_1 = parenthesize(s1, p1, p,false);
s2_1 = parenthesize(s2, p1, p,true);
s2_1 = parenthesize(s2, p2, p,true);
s = stringAppendList({s1_1, sym, s2_1});
then
s;
Expand Down Expand Up @@ -1105,7 +1105,6 @@ algorithm

case(DAE.PARTEVALFUNCTION(path = fcn,expList = args))
equation
_ = Absyn.pathString(fcn);
argnodes = List.map(args, dumpExpGraphviz);
then
Graphviz.NODE("PARTEVALFUNCTION",{},argnodes);
Expand Down Expand Up @@ -1425,7 +1424,6 @@ algorithm
equation
gen_str = genStringNTime(" |", level);
new_level1 = level + 1;
_ = Types.unparseType(ty);
ct = dumpExpStr(e, new_level1);
res_str = stringAppendList({gen_str,"CAST ","\n",ct,""});
then
Expand Down Expand Up @@ -1476,7 +1474,6 @@ algorithm
gen_str = genStringNTime(" |", level);
new_level1 = level + 1;
new_level2 = level + 1;
_ = Absyn.pathString(fcn);
expt = dumpExpStr(exp, new_level1);
itert = dumpExpStr(iterexp, new_level2);
res_str = stringAppendList({gen_str,"REDUCTION ","\n",expt,itert,""});
Expand Down
11 changes: 6 additions & 5 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -333,8 +333,11 @@ algorithm

// other subscripting/asub simplifications where e is not simplified first.
case (_,_,_)
equation
_ = List.map(inSubs,Expression.expInt);
algorithm
// Are all expressions integers?
for exp in inSubs loop
Expression.expInt(exp);
end for;
then List.foldr(inSubs,simplifyAsub,inExp);
else origExp;
end matchcontinue;
Expand Down Expand Up @@ -2021,13 +2024,11 @@ algorithm

case (e1,op as DAE.MUL_ARR(),e2)
equation
_ = Expression.typeof(e1);
a1 = simplifyVectorBinary(e1, op, e2);
then a1;

case (e1,op as DAE.DIV_ARR(),e2)
equation
_ = Expression.typeof(e1);
a1 = simplifyVectorBinary(e1, op, e2);
then a1;

Expand Down Expand Up @@ -4484,7 +4485,7 @@ algorithm
* Exponentation is very expensive compared to the inner expressions.
*/
((exp_lst as (_ :: _ :: _ :: _))) = Expression.factors(e1);
_ = List.find(exp_lst,Expression.isConstValue);
true = List.exist(exp_lst,Expression.isConstValue);
exp_lst_1 = simplifyBinaryDistributePow(exp_lst, e2);
then Expression.makeProductLst(exp_lst_1);
// (e1^e2)^e3 => e1^(e2*e3)
Expand Down
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -7520,8 +7520,6 @@ algorithm
slots = makeEmptySlots(fargs);
(cache,_,newslots,constInputArgs,_) = elabInputArgs(cache, env, args, nargs, slots, true, false /*checkTypes*/ ,impl,NOT_EXTERNAL_OBJECT_MODEL_SCOPE(), st,pre,info,DAE.T_UNKNOWN_DEFAULT,fn);
(cache,newslots2,constDefaultArgs,_) = fillGraphicsDefaultSlots(cache, newslots, cl, env_2, impl, pre, info);
_ = listAppend(constInputArgs, constDefaultArgs);
// _ = List.fold(constlist, Types.constAnd, DAE.C_CONST());
args_2 = slotListArgs(newslots2);

tp = complexTypeFromSlots(newslots2,ClassInf.UNKNOWN(Absyn.IDENT("")));
Expand Down
1 change: 0 additions & 1 deletion Compiler/FrontEnd/Types.mo
Expand Up @@ -3052,7 +3052,6 @@ algorithm
equation
s = unparseType(ty);
cs = DAEUtil.constStrFriendly(c);
_ = DAEUtil.dumpVarParallelismStr(p);
// res = stringAppendList({ps,cs,s," ",n});
res = stringAppendList({cs,s," ",n});
then
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/ValuesUtil.mo
Expand Up @@ -500,10 +500,10 @@ algorithm
str;
case ((Values.STRING(string = sval) :: xs))
equation
_ = unparseDescription(xs);
s1 = unparseDescription(xs);
slen = stringLength(sval);
slenstr = intString(slen);
str = stringAppendList({"# s! 1 ",slenstr,"\n"});
str = stringAppendList({"# s! 1 ",slenstr,"\n",s1});
then
str;
case ((Values.ARRAY(valueLst = vallst) :: xs))
Expand Down
77 changes: 37 additions & 40 deletions Compiler/Script/CevalScriptBackend.mo
Expand Up @@ -1451,10 +1451,16 @@ algorithm
then (cache,v,st);

case (cache,_,"saveModel",{Values.STRING(filename),Values.CODE(Absyn.C_TYPENAME(classpath))},(st as GlobalScript.SYMBOLTABLE(ast = p)),_)
equation
absynClass = Interactive.getPathedClassInProgram(classpath, p);
str = Dump.unparseStr(Absyn.PROGRAM({absynClass},Absyn.TOP()),true);
System.writeFile(filename, str);
algorithm
b := false;
absynClass := Interactive.getPathedClassInProgram(classpath, p);
str := Dump.unparseStr(Absyn.PROGRAM({absynClass},Absyn.TOP()),true);
try
System.writeFile(filename, str);
b := true;
else
Error.addMessage(Error.WRITING_FILE_ERROR, {filename});
end try;
then
(cache,Values.BOOL(true),st);

Expand All @@ -1476,14 +1482,6 @@ algorithm
then
(cache,Values.BOOL(true),st);

case (cache,_,"saveModel",{Values.STRING(name),Values.CODE(Absyn.C_TYPENAME(classpath))},
(st as GlobalScript.SYMBOLTABLE(ast = p)),_)
equation
_ = Interactive.getPathedClassInProgram(classpath, p);
Error.addMessage(Error.WRITING_FILE_ERROR, {name});
then
(cache,Values.BOOL(false),st);

case (cache,_,"saveModel",{Values.STRING(_),Values.CODE(Absyn.C_TYPENAME(classpath))},st,_)
equation
cname = Absyn.pathString(classpath);
Expand Down Expand Up @@ -2085,9 +2083,9 @@ algorithm
(cache,v,st);

case (cache,_,"removeComponentModifiers",
Values.CODE(Absyn.C_TYPENAME(path))::
Values.STRING(str1)::
Values.BOOL(keepRedeclares)::_,(st as GlobalScript.SYMBOLTABLE(ast = p)),_)
Values.CODE(Absyn.C_TYPENAME(path))::
Values.STRING(str1)::
Values.BOOL(keepRedeclares)::_,(st as GlobalScript.SYMBOLTABLE(ast = p)),_)
equation
(p,b) = Interactive.removeComponentModifiers(path, str1, p, keepRedeclares);
st = GlobalScriptUtil.setSymbolTableAST(st, p);
Expand All @@ -2097,7 +2095,7 @@ algorithm
case (cache,_,"removeExtendsModifiers",
Values.CODE(Absyn.C_TYPENAME(classpath))::
Values.CODE(Absyn.C_TYPENAME(baseClassPath))::
Values.BOOL(keepRedeclares)::_,st as GlobalScript.SYMBOLTABLE(ast=p),_)
Values.BOOL(keepRedeclares)::_,st as GlobalScript.SYMBOLTABLE(ast=p),_)
equation
(p,b) = Interactive.removeExtendsModifiers(classpath, baseClassPath, p, keepRedeclares);
st = GlobalScriptUtil.setSymbolTableAST(st, p);
Expand Down Expand Up @@ -2534,7 +2532,7 @@ algorithm
Boolean b;
case (_, GlobalScript.SYMBOLTABLE(ast=p))
equation
_ = Interactive.getPathedClassInProgram(className, p, true);
Interactive.getPathedClassInProgram(className, p, true);
then inSt;
case (_, GlobalScript.SYMBOLTABLE(p,fp,ic,iv,cf,lf))
equation
Expand Down Expand Up @@ -2716,27 +2714,27 @@ algorithm
(cache, st, indexed_dlow, libs, file_dir, resultValues) :=
SimCodeMain.translateModel(cache,env,className,st,fileNamePrefix,addDummy,inSimSettingsOpt,Absyn.FUNCTIONARGS({},{}));
else
// read the __OpenModelica_commandLineOptions
Absyn.STRING(commandLineOptions) := Interactive.getNamedAnnotation(className, st.ast, Absyn.IDENT("__OpenModelica_commandLineOptions"), SOME(Absyn.STRING("")), Interactive.getAnnotationExp);
haveAnnotation := boolNot(stringEq(commandLineOptions, ""));
// backup the flags.
flags := if haveAnnotation then Flags.backupFlags() else Flags.loadFlags();
try
// apply if there are any new flags
if haveAnnotation then
args := System.strtok(commandLineOptions, " ");
_ := Flags.readArgs(args);
end if;

(cache, st, indexed_dlow, libs, file_dir, resultValues) :=
SimCodeMain.translateModel(cache,env,className,st,fileNamePrefix,addDummy,inSimSettingsOpt,Absyn.FUNCTIONARGS({},{}));
// reset to the original flags
Flags.saveFlags(flags);
else
Flags.saveFlags(flags);
fail();
end try;
end if;
// read the __OpenModelica_commandLineOptions
Absyn.STRING(commandLineOptions) := Interactive.getNamedAnnotation(className, st.ast, Absyn.IDENT("__OpenModelica_commandLineOptions"), SOME(Absyn.STRING("")), Interactive.getAnnotationExp);
haveAnnotation := boolNot(stringEq(commandLineOptions, ""));
// backup the flags.
flags := if haveAnnotation then Flags.backupFlags() else Flags.loadFlags();
try
// apply if there are any new flags
if haveAnnotation then
args := System.strtok(commandLineOptions, " ");
_ := Flags.readArgs(args);
end if;

(cache, st, indexed_dlow, libs, file_dir, resultValues) :=
SimCodeMain.translateModel(cache,env,className,st,fileNamePrefix,addDummy,inSimSettingsOpt,Absyn.FUNCTIONARGS({},{}));
// reset to the original flags
Flags.saveFlags(flags);
else
Flags.saveFlags(flags);
fail();
end try;
end if;
then
(cache,st,indexed_dlow,libs,file_dir,resultValues);

Expand Down Expand Up @@ -5218,7 +5216,7 @@ algorithm
// normal call
case (cache,env,{Values.CODE(Absyn.C_TYPENAME(classname)),_,_,_,_, _,Values.STRING(filenameprefix),_},(st as GlobalScript.SYMBOLTABLE(ast = p as Absyn.PROGRAM())),msg)
equation
_ = Interactive.getPathedClassInProgram(classname,p);
Interactive.getPathedClassInProgram(classname,p);
Error.clearMessages() "Clear messages";
compileDir = System.pwd() + System.pathDelimiter();
(cache,simSettings) = calculateSimulationSettings(cache,env,vals,st,msg);
Expand All @@ -5237,7 +5235,6 @@ algorithm
Debug.trace("buildModel: Compiling done.\n");
end if;
// SimCodegen.generateMakefileBeast(makefilename, filenameprefix, libs, file_dir);
_ = getWithinStatement(classname);
CevalScript.compileModel(filenameprefix, libs);
// (p as Absyn.PROGRAM(globalBuildTimes=Absyn.TIMESTAMP(r1,r2))) = Interactive.updateProgram2(p2,p,false);
st2 = st; // Interactive.replaceSymbolTableProgram(st,p);
Expand Down
2 changes: 0 additions & 2 deletions Compiler/Util/BaseHashTable.mo
Expand Up @@ -210,7 +210,6 @@ algorithm
(varr,newpos) = valueArrayAdd(varr, v);
indexes = hashvec[indx];
hashvec = arrayUpdate(hashvec, indx, ((key, newpos) :: indexes));
_ = valueArrayLength(varr);
then
((hashvec, varr, bsize, fntpl));

Expand Down Expand Up @@ -250,7 +249,6 @@ algorithm
(varr,newpos) = valueArrayAdd(varr, v);
indexes = hashvec[indx];
hashvec = arrayUpdate(hashvec, indx, ((key, newpos) :: indexes));
_ = valueArrayLength(varr);
then
((hashvec, varr, bsize, fntpl));

Expand Down

0 comments on commit 4936316

Please sign in to comment.