Skip to content

Commit

Permalink
+ unquote more. make sure to unquote each ident and not just the whol…
Browse files Browse the repository at this point in the history
…e cref/path string.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21201 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
mahge committed Jun 19, 2014
1 parent 7beba6b commit 8aa7544
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 44 deletions.
22 changes: 11 additions & 11 deletions Compiler/BackEnd/SimCodeUtil.mo
Expand Up @@ -3175,7 +3175,7 @@ algorithm
// true = ComponentReference.crefEqualNoStringCompare(cr, cr2);
(tp as DAE.T_COMPLEX(varLst=varLst, complexClassType=ClassInf.RECORD(path))) = Expression.typeof(e1);
// tmp
ident = Absyn.pathStringReplaceDot(path, "_");
ident = Absyn.pathStringUnquoteReplaceDot(path, "_");
crtmp = ComponentReference.makeCrefIdent("$TMP_" +& ident +& intString(iuniqueEqIndex), tp, {});
tempvars = createTempVars(varLst, crtmp, itempvars);
// 0 = a - tmp
Expand All @@ -3197,7 +3197,7 @@ algorithm
// ((e2_1, (_, _))) = BackendDAEUtil.extendArrExp((e2, (NONE(), false)));
(tp as DAE.T_COMPLEX(varLst=varLst, complexClassType=ClassInf.RECORD(path))) = Expression.typeof(e2);
// tmp
ident = Absyn.pathStringReplaceDot(path, "_");
ident = Absyn.pathStringUnquoteReplaceDot(path, "_");
crtmp = ComponentReference.makeCrefIdent("$TMP_" +& ident +& intString(iuniqueEqIndex), tp, {});
tempvars = createTempVars(varLst, crtmp, itempvars);
// 0 = a - tmp
Expand All @@ -3218,7 +3218,7 @@ algorithm
((e2_1, (_, _))) = BackendDAEUtil.extendArrExp((e2, (NONE(), false)));
// true = ComponentReference.crefEqualNoStringCompare(cr, cr2);
// tmp = f()
ident = Absyn.pathStringReplaceDot(path, "_");
ident = Absyn.pathStringUnquoteReplaceDot(path, "_");
cr = ComponentReference.makeCrefIdent("$TMP_" +& ident +& intString(iuniqueEqIndex), tp, {});
e1_1 = Expression.crefExp(cr);
stms = DAE.STMT_ASSIGN(tp, e1_1, e2_1, source);
Expand All @@ -3239,7 +3239,7 @@ algorithm
((e1_1, (_, _))) = BackendDAEUtil.extendArrExp((e2, (NONE(), false)));
// true = ComponentReference.crefEqualNoStringCompare(cr, cr2);
// tmp = f()
ident = Absyn.pathStringReplaceDot(path, "_");
ident = Absyn.pathStringUnquoteReplaceDot(path, "_");
cr = ComponentReference.makeCrefIdent("$TMP_" +& ident +& intString(iuniqueEqIndex), tp, {});
e2_1 = Expression.crefExp(cr);
stms = DAE.STMT_ASSIGN(tp, e2_1, e1_1, source);
Expand All @@ -3259,7 +3259,7 @@ algorithm
// true = ComponentReference.crefEqualNoStringCompare(cr, cr2);
// tmp = f()
tp = Expression.typeof(e1);
ident = Absyn.pathStringReplaceDot(path, "_");
ident = Absyn.pathStringUnquoteReplaceDot(path, "_");
cr = ComponentReference.makeCrefIdent("$TMP_" +& ident +& intString(iuniqueEqIndex), tp, {});
crexplst = List.map1(expl, Expression.generateCrefsExpFromExp, cr);
stms = DAE.STMT_TUPLE_ASSIGN(tp, crexplst, e2, source);
Expand Down Expand Up @@ -5234,7 +5234,7 @@ algorithm

case (DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(name), varLst = varlst, source = {_}), accRecDecls, rt)
equation
sname = Absyn.pathStringReplaceDot(name, "_");
sname = Absyn.pathStringUnquoteReplaceDot(name, "_");
false = listMember(sname, rt);
vars = List.map(varlst, typesVarNoBinding);
vars = List.sort(vars,compareVariable);
Expand All @@ -5249,7 +5249,7 @@ algorithm

case (DAE.T_METARECORD( fields = varlst, source = {path}), accRecDecls, rt)
equation
sname = Absyn.pathStringReplaceDot(path, "_");
sname = Absyn.pathStringUnquoteReplaceDot(path, "_");
false = listMember(sname, rt);
fieldNames = List.map(varlst, generateVarName);
accRecDecls = SimCode.RECORD_DECL_DEF(path, fieldNames) :: accRecDecls;
Expand Down Expand Up @@ -5327,7 +5327,7 @@ algorithm
case ({}, accRecDecls, rt) then (accRecDecls, rt);
case (DAE.METARECORDCALL(path=path, fieldNames=fieldNames)::rest, accRecDecls, rt)
equation
name = Absyn.pathStringReplaceDot(path, "_");
name = Absyn.pathStringUnquoteReplaceDot(path, "_");
b = listMember(name, rt);
accRecDecls = List.consOnTrue(not b, SimCode.RECORD_DECL_DEF(path, fieldNames), accRecDecls);
rt_1 = List.consOnTrue(not b, name, rt);
Expand Down Expand Up @@ -5946,7 +5946,7 @@ algorithm
((e2_1, (_, _))) = BackendDAEUtil.extendArrExp((e2, (NONE(), false)));
// true = ComponentReference.crefEqualNoStringCompare(cr, cr2);
// tmp = f()
ident = Absyn.pathStringReplaceDot(path, "_");
ident = Absyn.pathStringUnquoteReplaceDot(path, "_");
cr1 = ComponentReference.makeCrefIdent("$TMP_" +& ident +& intString(iuniqueEqIndex), tp, {});
e1_1 = Expression.crefExp(cr1);
stms = DAE.STMT_ASSIGN(tp, e1_1, e2_1, source);
Expand All @@ -5971,7 +5971,7 @@ algorithm
((e1_1, (_, _))) = BackendDAEUtil.extendArrExp((e1, (NONE(), false)));
// true = ComponentReference.crefEqualNoStringCompare(cr, cr2);
// tmp = f()
ident = Absyn.pathStringReplaceDot(path, "_");
ident = Absyn.pathStringUnquoteReplaceDot(path, "_");
cr1 = ComponentReference.makeCrefIdent("$TMP_" +& ident +& intString(iuniqueEqIndex), tp, {});
e2_1 = Expression.crefExp(cr1);
stms = DAE.STMT_ASSIGN(tp, e2_1, e1_1, source);
Expand Down Expand Up @@ -12107,7 +12107,7 @@ algorithm
String aliasStr;
case (_,_,_)
equation
aliasStr = Absyn.pathStringReplaceDot(BaseHashTable.get(str, inHt),"_");
aliasStr = Absyn.pathStringUnquoteReplaceDot(BaseHashTable.get(str, inHt),"_");
then (SOME(aliasStr),inHt);
else
equation
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/XMLDump.mo
Expand Up @@ -2356,7 +2356,7 @@ algorithm
case (s :: remaining)
equation
s_path = Absyn.pathStringNoQual(s);
fn_name_str = Absyn.pathStringReplaceDot(s, "_");
fn_name_str = Absyn.pathStringUnquoteReplaceDot(s, "_");
fn_name_str = stringAppend("_", fn_name_str);
Print.printBuf("\n<");Print.printBuf(FUNCTION);
Print.printBuf(" ");Print.printBuf(FUNCTION_ORIGNAME);Print.printBuf("=\"");Print.printBuf(s_path);Print.printBuf("\"");
Expand Down
43 changes: 17 additions & 26 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -2571,34 +2571,25 @@ algorithm
outString := stringDelimitList(pathToStringList(path),delimiter);
end pathString2NoLeadingDot;

public function pathStringReplaceDot "Helper function to pathString."
public function pathStringUnquoteReplaceDot
" Changes a path to string. Uses the input string as separator.
If the separtor exists in the string then it is doubled (sep _ then
a_b changes to a__b) before delimiting
(Replaces dots with that separator). And also unquotes each ident.
"
input Path inPath;
input String inString;
input String repStr;
output String outString;
algorithm
outString:=
match (inPath,inString)
local
String s,ns,s1,ss,str,dstr,safe_s;
Path n;
case (IDENT(name = s),str)
equation
dstr = stringAppend(str, str);
safe_s = System.stringReplace(s, str, dstr);
then
safe_s;
case(FULLYQUALIFIED(n),str) then pathStringReplaceDot(n,str);
case (QUALIFIED(name = s,path = n),str)
equation
ns = pathStringReplaceDot(n, str);
dstr = stringAppend(str, str);
safe_s = System.stringReplace(s, str, dstr);
s1 = stringAppend(safe_s, str);
ss = stringAppend(s1, ns);
then
ss;
end match;
end pathStringReplaceDot;
protected
list<String> strlst;
String rep_rep;
algorithm
rep_rep := repStr +& repStr;
strlst := pathToStringList(inPath);
strlst := List.map2(strlst,System.stringReplace, repStr, rep_rep);
strlst := List.map(strlst,System.unquoteIdentifier);
outString := stringDelimitList(strlst,repStr);
end pathStringUnquoteReplaceDot;

public function stringPath
"Converts a string into a qualified path."
Expand Down
8 changes: 3 additions & 5 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -5038,7 +5038,7 @@ protected function generateFunctionName
input Absyn.Path functionPath;
output String functionName;
algorithm
functionName := System.unquoteIdentifier(Absyn.pathStringReplaceDot(functionPath, "_"));
functionName := Absyn.pathStringUnquoteReplaceDot(functionPath, "_");
end generateFunctionName;

protected function generateFunctionFileName
Expand All @@ -5051,8 +5051,7 @@ algorithm
local String name, n1, n2; Integer len;
case (_)
equation
name = Absyn.pathStringReplaceDot(functionPath, "_");
name = System.unquoteIdentifier(name);
name = Absyn.pathStringUnquoteReplaceDot(functionPath, "_");
len = stringLength(name);
// not bigger than
true = len > Global.maxFunctionFileLength;
Expand All @@ -5064,8 +5063,7 @@ algorithm
name;
case (_)
equation
name = Absyn.pathStringReplaceDot(functionPath, "_");
name = System.unquoteIdentifier(name);
name = Absyn.pathStringUnquoteReplaceDot(functionPath, "_");
then
name;
end matchcontinue;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Script/Interactive.mo
Expand Up @@ -9356,7 +9356,7 @@ algorithm
case (GlobalScript.CFunction(functionInCf,_,funcHandle,_,_) :: rest, _)
equation
true = Absyn.pathEqual(functionInCf, functionName);
_ = Absyn.pathStringReplaceDot(functionName, "_");
// _ = Absyn.pathStringUnquoteReplaceDot(functionName, "_");
System.freeFunction(funcHandle, Flags.isSet(Flags.DYN_LOAD));
res = removeCf(rest, functionName);
then
Expand Down

0 comments on commit 8aa7544

Please sign in to comment.