Skip to content

Commit

Permalink
Send options to SCodeDumpTpl. Replace some old unparsing functions wi…
Browse files Browse the repository at this point in the history
…th the template ones.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19336 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 27, 2014
1 parent 3e21f10 commit d057cbe
Show file tree
Hide file tree
Showing 26 changed files with 260 additions and 454 deletions.
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/DAEDump.mo
Expand Up @@ -1075,7 +1075,7 @@ algorithm
case (SOME(SCode.COMMENT(annotation_ = SOME(SCode.ANNOTATION(ann_mod)))), _, _)
equation
true = Config.showAnnotations();
ann = inPrefix +& "annotation" +& SCodeDump.printModStr(ann_mod) +& inSuffix;
ann = inPrefix +& "annotation" +& SCodeDump.printModStr(ann_mod,SCodeDump.defaultOptions) +& inSuffix;
then
ann;

Expand Down
8 changes: 4 additions & 4 deletions Compiler/FrontEnd/Env.mo
Expand Up @@ -730,7 +730,7 @@ algorithm

case (_, e, classEnv)
equation
print("- Env.updateFrameC failed on class: " +& SCodeDump.unparseElementStr(e) +& "\n");
print("- Env.updateFrameC failed on class: " +& SCodeDump.unparseElementStr(e,SCodeDump.defaultOptions) +& "\n");
then
fail();

Expand Down Expand Up @@ -1962,7 +1962,7 @@ algorithm
case ((n,VAR(instantiated = (tv as DAE.TYPES_VAR(attributes = DAE.ATTR(variability = var),ty = tp,binding = bind)),var = elt,instStatus = i,env = (compframe :: _))))
equation
s = SCodeDump.variabilityString(var);
elt_str = SCodeDump.printElementStr(elt);
elt_str = SCodeDump.unparseElementStr(elt,SCodeDump.defaultOptions);
tp_str = Types.unparseType(tp);
var_str = Types.unparseVar(tv);
frame_str = printFrameVarsStr(compframe);
Expand All @@ -1976,7 +1976,7 @@ algorithm
case ((n,VAR(instantiated = (tv as DAE.TYPES_VAR(attributes = DAE.ATTR(variability = var),ty = tp)),var = elt,instStatus = i,env = {})))
equation
s = SCodeDump.variabilityString(var);
elt_str = SCodeDump.printElementStr(elt);
elt_str = SCodeDump.unparseElementStr(elt,SCodeDump.defaultOptions);
tp_str = Types.unparseType(tp);
var_str = Types.unparseVar(tv);
res = stringAppendList(
Expand Down Expand Up @@ -2118,7 +2118,7 @@ protected function printElement
output String str;
algorithm
str := match(el)
case (_) then "[el:" +& SCodeDump.unparseElementStr(el) +& "], ";
case (_) then "[el:" +& SCodeDump.unparseElementStr(el,SCodeDump.defaultOptions) +& "], ";
end match;
end printElement;

Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Inst.mo
Expand Up @@ -3999,7 +3999,7 @@ algorithm
case (_, env, _, _, _, _, _, (comp, mod), _, _, _, _, _)
equation
true = Flags.isSet(Flags.FAILTRACE);
Debug.traceln("- Inst.instElement failed: " +& SCodeDump.printElementStr(comp));
Debug.traceln("- Inst.instElement failed: " +& SCodeDump.unparseElementStr(comp,SCodeDump.defaultOptions));
Debug.traceln(" Scope: " +& Env.printEnvPathStr(env));
then
fail();
Expand Down
22 changes: 11 additions & 11 deletions Compiler/FrontEnd/InstExtends.mo
Expand Up @@ -266,7 +266,7 @@ algorithm
"className: " +& className +& "\n\t" +&
"env: " +& Env.printEnvPathStr(env) +& "\n\t" +&
"mods: " +& Mod.printModStr(mod) +& "\n\t" +&
"elems: " +& stringDelimitList(List.map(rest, SCodeDump.printElementStr), ", ")
"elems: " +& stringDelimitList(List.map1(rest, SCodeDump.unparseElementStr, SCodeDump.defaultOptions), ", ")
);
then
fail();
Expand Down Expand Up @@ -693,7 +693,7 @@ algorithm

case (_,_,_,_,_,_,_,_,true,_)
equation
str1 = SCodeDump.printElementStr(inClass);
str1 = SCodeDump.unparseElementStr(inClass,SCodeDump.defaultOptions);
str2 = Env.printEnvPathStr(inEnv);
strDepth = intString(Global.recursionDepthLimit);
// print("instDerivedClassesWork recursion depth... " +& str1 +& " " +& str2 +& "\n");
Expand Down Expand Up @@ -827,7 +827,7 @@ algorithm
"\nmod = " +& Mod.printModStr(inMod) +&
"\ncmod = " +& Mod.printModStr(cmod) +&
"\nbool = " +& Util.if_(b, "true", "false") +& "\n" +&
SCodeDump.printElementStr(comp)
SCodeDump.unparseElementStr(comp,SCodeDump.defaultOptions)
);
then
fail();
Expand Down Expand Up @@ -964,7 +964,7 @@ algorithm
case (_,env,(elt,mod,b)::elts,_)
equation
Debug.traceln("- InstExtends.fixLocalIdents failed for element:" +&
SCodeDump.unparseElementStr(elt) +& " mods: " +&
SCodeDump.unparseElementStr(elt,SCodeDump.defaultOptions) +& " mods: " +&
Mod.printModStr(mod) +& " class extends:" +&
Util.if_(b, "true", "false") +& " in env: " +& Env.printEnvPathStr(env)
);
Expand Down Expand Up @@ -1014,7 +1014,7 @@ algorithm
case (cache,env,SCode.COMPONENT(name, prefixes as SCode.PREFIXES(replaceablePrefix = SCode.REPLACEABLE(_)),
SCode.ATTR(ad, ct, prl, var, dir), typeSpec, modifications, comment, condition, info),ht)
equation
//Debug.fprintln(Flags.DEBUG,"fix comp " +& SCodeDump.printElementStr(elt));
//Debug.fprintln(Flags.DEBUG,"fix comp " +& SCodeDump.unparseElementStr(elt,SCodeDump.defaultOptions));
// lookup as it might have been redeclared!!!
(_, _, elt as SCode.COMPONENT(name, prefixes, SCode.ATTR(ad, ct, prl, var, dir), typeSpec, modifications, comment, condition, info),
_, _, _) = Lookup.lookupIdentLocal(cache, env, name);
Expand All @@ -1027,7 +1027,7 @@ algorithm
// we failed above
case (cache,env,SCode.COMPONENT(name, prefixes, SCode.ATTR(ad, ct, prl, var, dir), typeSpec, modifications, comment, condition, info),ht)
equation
//Debug.fprintln(Flags.DEBUG,"fix comp " +& SCodeDump.printElementStr(elt));
//Debug.fprintln(Flags.DEBUG,"fix comp " +& SCodeDump.unparseElementStr(elt,SCodeDump.defaultOptions));
(cache,modifications) = fixModifications(cache,env,modifications,ht);
(cache,typeSpec) = fixTypeSpec(cache,env,typeSpec,ht);
(cache,SOME(ad)) = fixArrayDim(cache, env, SOME(ad), ht);
Expand Down Expand Up @@ -1074,7 +1074,7 @@ algorithm

case (cache,env,SCode.EXTENDS(extendsPath,vis,modifications,optAnnotation,info),ht)
equation
//Debug.fprintln(Flags.DEBUG,"fix extends " +& SCodeDump.printElementStr(elt));
//Debug.fprintln(Flags.DEBUG,"fix extends " +& SCodeDump.unparseElementStr(elt,SCodeDump.defaultOptions));
(cache,extendsPath) = fixPath(cache,env,extendsPath,ht);
(cache,modifications) = fixModifications(cache,env,modifications,ht);
then
Expand All @@ -1084,7 +1084,7 @@ algorithm

case (cache,env,elt,ht)
equation
Debug.fprintln(Flags.FAILTRACE, "InstExtends.fixElement failed: " +& SCodeDump.printElementStr(elt));
Debug.fprintln(Flags.FAILTRACE, "InstExtends.fixElement failed: " +& SCodeDump.unparseElementStr(elt,SCodeDump.defaultOptions));
then fail();

end matchcontinue;
Expand Down Expand Up @@ -1156,7 +1156,7 @@ algorithm

case (cache,env,cd,ht)
equation
Debug.fprintln(Flags.FAILTRACE, "InstExtends.fixClassDef failed: " +& SCodeDump.printClassdefStr(cd));
Debug.fprintln(Flags.FAILTRACE, "InstExtends.fixClassDef failed: " +& SCodeDump.classDefStr(cd,SCodeDump.defaultOptions));
then
fail();

Expand Down Expand Up @@ -1189,7 +1189,7 @@ algorithm
(cache,SCode.EQUATION(eeq));
case (cache,env,SCode.EQUATION(eeq),ht)
equation
Debug.fprintln(Flags.FAILTRACE, "- Inst.fixEquation failed: " +& SCodeDump.equationStr(eeq));
Debug.fprintln(Flags.FAILTRACE, "- Inst.fixEquation failed: " +& SCodeDump.equationStr(eeq,SCodeDump.defaultOptions));
then
fail();
end match;
Expand Down Expand Up @@ -1731,7 +1731,7 @@ algorithm

case (cache,env,mod,ht)
equation
Debug.fprintln(Flags.FAILTRACE,"InstExtends.fixModifications failed: " +& SCodeDump.printModStr(mod));
Debug.fprintln(Flags.FAILTRACE,"InstExtends.fixModifications failed: " +& SCodeDump.printModStr(mod,SCodeDump.defaultOptions));
then
fail();

Expand Down
6 changes: 3 additions & 3 deletions Compiler/FrontEnd/InstFunction.mo
Expand Up @@ -648,8 +648,8 @@ algorithm

case (_,_,_,SCode.CLASS(name=id))
equation
Debug.fprintln(Flags.FAILTRACE, "- Inst.implicitFunctionTypeInstantiation failed " +& id +& "\nenv: " +& Env.getEnvNameStr(inEnv)
+& "\nelelement: " +& SCodeDump.unparseElementStr(inClass));
true = Flags.isSet(Flags.FAILTRACE);
Debug.traceln("- Inst.implicitFunctionTypeInstantiation failed " +& id +& "\nenv: " +& Env.getEnvNameStr(inEnv) +& "\nelelement: " +& SCodeDump.unparseElementStr(inClass,SCodeDump.defaultOptions));
then fail();
end matchcontinue;
end implicitFunctionTypeInstantiation;
Expand Down Expand Up @@ -866,7 +866,7 @@ algorithm
equation
true = Flags.isSet(Flags.FAILTRACE);
Debug.trace("- Inst.instRecordConstructorElt failed.,elt:");
Debug.traceln(SCodeDump.printElementStr(elt));
Debug.traceln(SCodeDump.unparseElementStr(elt,SCodeDump.defaultOptions));
then
fail();
end matchcontinue;
Expand Down
11 changes: 6 additions & 5 deletions Compiler/FrontEnd/InstSection.mo
Expand Up @@ -137,7 +137,7 @@ algorithm
case (_,_,_,_,_,_,_,SCode.EQUATION(eEquation = eqn),impl,_,graph)
equation
true = Flags.isSet(Flags.FAILTRACE);
str= SCodeDump.equationStr(eqn);
str= SCodeDump.equationStr(eqn,SCodeDump.defaultOptions);
Debug.fprint(Flags.FAILTRACE, "- instEquation failed eqn:");
Debug.fprint(Flags.FAILTRACE, str);
Debug.fprint(Flags.FAILTRACE, "\n");
Expand Down Expand Up @@ -191,7 +191,8 @@ algorithm
// failure
case(cache,env,ih,mods,pre,csets,ci_state,eq,impl,_,graph)
equation
Debug.fprint(Flags.FAILTRACE,"Inst.instEEquation failed for "+&SCodeDump.equationStr(eq)+&"\n");
true = Flags.isSet(Flags.FAILTRACE);
Debug.traceln("Inst.instEEquation failed for " +& SCodeDump.equationStr(eq,SCodeDump.defaultOptions));
then fail();

end matchcontinue;
Expand Down Expand Up @@ -377,7 +378,7 @@ algorithm
case (_,_,_,_,_,_,_,_,_,_,_,_)
equation
true = errorCount == Error.getNumErrorMessages();
s = "\n" +& SCodeDump.equationStr(inEEquation);
s = "\n" +& SCodeDump.equationStr(inEEquation,SCodeDump.defaultOptions);
Error.addSourceMessage(Error.EQUATION_GENERIC_FAILURE, {s}, SCode.equationFileInfo(inEEquation));
then
fail();
Expand Down Expand Up @@ -843,7 +844,7 @@ algorithm
case (_,env,ih,_,_,_,_,eqn,_,impl,graph,_)
equation
true = Flags.isSet(Flags.FAILTRACE);
s = SCodeDump.equationStr(eqn);
s = SCodeDump.equationStr(eqn,SCodeDump.defaultOptions);
Debug.fprint(Flags.FAILTRACE, "- instEquationCommonWork failed for eqn: ");
Debug.fprint(Flags.FAILTRACE, s +& " in scope:" +& Env.getEnvNameStr(env) +& "\n");
//print("ENV: " +& Env.printEnvStr(env) +& "\n");
Expand Down Expand Up @@ -3013,7 +3014,7 @@ algorithm
equation
true = Flags.isSet(Flags.FAILTRACE);
Debug.fprintln(Flags.FAILTRACE, "InstSection.instIfTrueBranches failed on equations: " +&
stringDelimitList(List.map(e, SCodeDump.equationStr), "\n"));
stringDelimitList(List.map1(e, SCodeDump.equationStr, SCodeDump.defaultOptions), "\n"));
then
fail();
end matchcontinue;
Expand Down
20 changes: 10 additions & 10 deletions Compiler/FrontEnd/InstUtil.mo
Expand Up @@ -1271,7 +1271,7 @@ algorithm
case ({}) then ();
case (((el,mod) :: els))
equation
s = SCodeDump.printElementStr(el);
s = SCodeDump.unparseElementStr(el,SCodeDump.defaultOptions);
print(s);
print(", ");
print(Mod.printModStr(mod));
Expand Down Expand Up @@ -1637,7 +1637,7 @@ algorithm

case (_)
equation
print("Inst.getCrefFromMod: could not retrieve crefs from SCode.Mod: " +& SCodeDump.printModStr(inMod) +& "\n");
print("Inst.getCrefFromMod: could not retrieve crefs from SCode.Mod: " +& SCodeDump.printModStr(inMod,SCodeDump.defaultOptions) +& "\n");
then
fail();

Expand Down Expand Up @@ -3242,8 +3242,8 @@ algorithm
// the classes are the same!
true = SCode.elementEqual(c1, c2);
// add a warning and let it continue!
s1 = SCodeDump.unparseElementStr(oldElt);
s2 = SCodeDump.unparseElementStr(newElt);
s1 = SCodeDump.unparseElementStr(oldElt,SCodeDump.defaultOptions);
s2 = SCodeDump.unparseElementStr(newElt,SCodeDump.defaultOptions);
s = "Inherited elements are not identical: bug: https://trac.modelica.org/Modelica/ticket/627\n\tfirst: " +&
s1 +& "\n\tsecond: " +& s2 +& "\nContinue ....";
Error.addMultiSourceMessage(Error.COMPILER_WARNING, {s}, {old_info, new_info});
Expand All @@ -3253,8 +3253,8 @@ algorithm
case (cache, env, (oldElt as SCode.COMPONENT(info = old_info),oldMod),
(newElt as SCode.COMPONENT(info = new_info),newMod))
equation
s1 = SCodeDump.unparseElementStr(oldElt);
s2 = SCodeDump.unparseElementStr(newElt);
s1 = SCodeDump.unparseElementStr(oldElt,SCodeDump.defaultOptions);
s2 = SCodeDump.unparseElementStr(newElt,SCodeDump.defaultOptions);
Error.addMultiSourceMessage(Error.DUPLICATE_ELEMENTS_NOT_IDENTICAL,
{s1, s2}, {old_info, new_info});
then
Expand Down Expand Up @@ -3303,8 +3303,8 @@ algorithm

case (oldCl,newCl)
equation
s1 = SCodeDump.printClassStr(oldCl);
s2 = SCodeDump.printClassStr(newCl);
s1 = SCodeDump.unparseElementStr(oldCl,SCodeDump.defaultOptions);
s2 = SCodeDump.unparseElementStr(newCl,SCodeDump.defaultOptions);
info1 = SCode.elementInfo(oldCl);
info2 = SCode.elementInfo(newCl);
Error.addMultiSourceMessage(Error.DUPLICATE_CLASSES_NOT_EQUIVALENT,
Expand Down Expand Up @@ -3832,7 +3832,7 @@ algorithm
case (_, _, _, _, SCode.CLASS(name = id), _, _)
equation
true = Flags.isSet(Flags.FAILTRACE);
id = SCodeDump.printClassStr(inClass);
id = SCodeDump.unparseElementStr(inClass,SCodeDump.defaultOptions);
Debug.traceln("Inst.getUsertypeDimensions failed: " +& id);
then
fail();
Expand Down Expand Up @@ -8121,7 +8121,7 @@ algorithm

case ((e,m)::rest)
equation
s1 = SCodeDump.unparseElementStr(e);
s1 = SCodeDump.unparseElementStr(e,SCodeDump.defaultOptions);
s2 = Mod.printModStr(m);
s3 = printElementAndModList(rest);
s = "Element:\n" +& s1 +& "\nModifier: " +& s2 +& "\n" +& s3;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/InstVar.mo
Expand Up @@ -415,7 +415,7 @@ algorithm
(cache,cref) = PrefixUtil.prefixCref(cache,env,ih,pre, ComponentReference.makeCrefIdent(n, DAE.T_UNKNOWN_DEFAULT, {}));
Debug.fprintln(Flags.FAILTRACE, "- Inst.instVar failed while instatiating variable: " +&
ComponentReference.printComponentRefStr(cref) +& " " +& Mod.prettyPrintMod(mod, 0) +&
"\nin scope: " +& Env.printEnvPathStr(env) +& " class:\n" +& SCodeDump.unparseElementStr(cl));
"\nin scope: " +& Env.printEnvPathStr(env) +& " class:\n" +& SCodeDump.unparseElementStr(cl,SCodeDump.defaultOptions));
then
fail();
end matchcontinue;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/Lookup.mo
Expand Up @@ -2047,7 +2047,7 @@ algorithm

// fail
case(cache,env,_,_) equation
Debug.traceln("buildRecordConstructorClass2 failed, cl:"+&SCodeDump.printClassStr(cl)+&"\n");
Debug.traceln("buildRecordConstructorClass2 failed, cl:"+&SCodeDump.unparseElementStr(cl,SCodeDump.defaultOptions)+&"\n");
then fail();
/* TODO: short class defs */
end matchcontinue;
Expand Down Expand Up @@ -2219,7 +2219,7 @@ algorithm
case ((comp,cmod)::_,_,_)
equation
true = Flags.isSet(Flags.FAILTRACE);
Debug.traceln("- Lookup.buildRecordConstructorElts failed " +& SCodeDump.printElementStr(comp) +& " with mod: " +& Mod.printModStr(cmod) +& " and: " +& Mod.printModStr(mods));
Debug.traceln("- Lookup.buildRecordConstructorElts failed " +& SCodeDump.unparseElementStr(comp,SCodeDump.defaultOptions) +& " with mod: " +& Mod.printModStr(cmod) +& " and: " +& Mod.printModStr(mods));
then fail();
end matchcontinue;
end buildRecordConstructorElts;
Expand Down
10 changes: 5 additions & 5 deletions Compiler/FrontEnd/Mod.mo
Expand Up @@ -332,7 +332,7 @@ algorithm
// redeclare failure?
case(cache,env,ih,pre,f,element,_,_)
equation
print("Unhandled element redeclare (we keep it as it is!): " +& SCodeDump.unparseElementStr(element) +& "\n");
print("Unhandled element redeclare (we keep it as it is!): " +& SCodeDump.unparseElementStr(element,SCodeDump.defaultOptions) +& "\n");
then
((element,DAE.NOMOD()));

Expand Down Expand Up @@ -725,7 +725,7 @@ algorithm
case (mod,env,pre)
equation
print("- elab_untyped_mod ");
s = SCodeDump.printModStr(mod);
s = SCodeDump.printModStr(mod,SCodeDump.defaultOptions);
print(s);
print(" failed\n");
then
Expand Down Expand Up @@ -2383,7 +2383,7 @@ algorithm
equation
elist_1 = List.map(elist, Util.tuple21);
prefix = SCodeDump.finalStr(finalPrefix) +& SCodeDump.eachStr(eachPrefix);
str_lst = List.map(elist_1, SCodeDump.unparseElementStr);
str_lst = List.map1(elist_1, SCodeDump.unparseElementStr, SCodeDump.defaultOptions);
str = stringDelimitList(str_lst, ", ");
res = stringAppendList({"(",prefix,str,")"});
then
Expand Down Expand Up @@ -2442,7 +2442,7 @@ algorithm

case(DAE.REDECL(tplSCodeElementModLst = tup),_)
equation
str = stringDelimitList(List.map(List.map(tup,Util.tuple21),SCodeDump.unparseElementStr),", ");
str = stringDelimitList(List.map1(List.map(tup,Util.tuple21),SCodeDump.unparseElementStr,SCodeDump.defaultOptions),", ");
then
str;

Expand Down Expand Up @@ -2504,7 +2504,7 @@ algorithm

case(DAE.NAMEMOD(id,(m as DAE.REDECL(fp, ep, elist))))
equation
s1 = stringDelimitList(List.map(List.map(elist, Util.tuple21), SCodeDump.printElementStr), ", ");
s1 = stringDelimitList(List.map1(List.map(elist, Util.tuple21), SCodeDump.unparseElementStr, SCodeDump.defaultOptions), ", ");
s2 = id +& "(redeclare " +&
Util.if_(SCode.eachBool(ep),"each ","") +&
Util.if_(SCode.finalBool(fp),"final ","") +& s1 +& ")";
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/NFEnvExtends.mo
Expand Up @@ -1345,7 +1345,7 @@ algorithm
case (_, _)
equation
info = SCode.elementInfo(inClassExtends);
el_str = SCodeDump.printElementStr(inClassExtends);
el_str = SCodeDump.unparseElementStr(inClassExtends,SCodeDump.defaultOptions);
env_str = NFSCodeEnv.getEnvName(inEnv);
err_msg = "NFSCodeFlattenRedeclare.extendEnvWithClassExtends failed on unknown element " +&
el_str +& " in " +& env_str;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/NFInst.mo
Expand Up @@ -3743,7 +3743,7 @@ algorithm
else
equation
true = Flags.isSet(Flags.FAILTRACE);
str = SCodeDump.equationStr(inEquation);
str = SCodeDump.equationStr(inEquation,SCodeDump.defaultOptions);
Debug.traceln("Unknown or failed equation in NFInst.instEEquation: " +& str);
then
fail();
Expand Down Expand Up @@ -3866,7 +3866,7 @@ algorithm

else
equation
print("NFInst.instStatement failed: " +& SCodeDump.statementStr(statement) +& "\n");
print("NFInst.instStatement failed: " +& SCodeDump.statementStr(statement,SCodeDump.defaultOptions) +& "\n");
then fail();

end match;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/NFMod.mo
Expand Up @@ -1008,7 +1008,7 @@ algorithm
equation
fstr = SCodeDump.finalStr(fp);
estr = SCodeDump.eachStr(ep);
el_str = SCodeDump.unparseElementStr(el);
el_str = SCodeDump.unparseElementStr(el,SCodeDump.defaultOptions);
then
"REDECL(" +& fstr +& estr +& el_str +& ")";

Expand Down

0 comments on commit d057cbe

Please sign in to comment.