Skip to content

Commit

Permalink
- changed stringEqual to stringEq
Browse files Browse the repository at this point in the history
- YOU NEED A NEW OMDEV/MetaModelica/RML:
  OMDev: http://www.ida.liu.se/~adrpo/omc/omdev/mingw/
  MetaModelica/RML for Linux, revision 183.

- moved functions from System into MetaModelica/RML:
  + System.strcmp           -> stringCompare
  + System.stringAppendList -> stringAppendList
  + System.refEqual         -> referenceEq
  + System.enableTrace      -> enableTrace
  + System.disableTrace     -> disableTrace
  + System.hash             -> stringHashDjb2
  + System.log              -> realLog
  + System.log10            -> realLog10
  + System.MORE_TRIG_FUNC   -> realTRIG_FUNC
  + more functions I don't remember
- added some of these functions to c_runtime/meta_modelica_builtin.cpp
  



git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/sjoelund-functiontree@6676 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Oct 28, 2010
1 parent ff06bd7 commit dc7a066
Show file tree
Hide file tree
Showing 63 changed files with 1,049 additions and 1,525 deletions.
38 changes: 19 additions & 19 deletions Compiler/Absyn.mo
Expand Up @@ -2270,11 +2270,11 @@ algorithm
String id, id2;
case (FULLYQUALIFIED(p), p2) then pathPrefixOf(p, p2);
case (p, FULLYQUALIFIED(p2)) then pathPrefixOf(p, p2);
case (IDENT(id), IDENT(id2)) then stringEqual(id, id2);
case (IDENT(id), QUALIFIED(name = id2)) then stringEqual(id, id2);
case (IDENT(id), IDENT(id2)) then stringEq(id, id2);
case (IDENT(id), QUALIFIED(name = id2)) then stringEq(id, id2);
case (QUALIFIED(id, p), QUALIFIED(id2, p2))
equation
true = stringEqual(id, id2);
true = stringEq(id, id2);
true = pathPrefixOf(p, p2);
then
true;
Expand Down Expand Up @@ -2316,13 +2316,13 @@ algorithm
// qual
case (QUALIFIED(name=id1,path=p),QUALIFIED(name=id2,path=p2))
equation
true = stringEqual(id1, id2);
true = stringEq(id1, id2);
then
removePrefix(p,p2);
// ids
case(IDENT(id1),QUALIFIED(name=id2,path=p2))
equation
true = stringEqual(id1, id2);
true = stringEq(id1, id2);
then p2;
end matchcontinue;
end removePrefix;
Expand Down Expand Up @@ -2351,18 +2351,18 @@ algorithm
// qual
case(CREF_QUAL(name = prefixIdent, componentRef = prefixRestCr), CREF_QUAL(name = ident, componentRef = restCr))
equation
true = stringEqual(prefixIdent, ident);
true = stringEq(prefixIdent, ident);
then
crefRemovePrefix(prefixRestCr, restCr);
// id vs. qual
case(CREF_IDENT(name = prefixIdent), CREF_QUAL(name = ident, componentRef = restCr))
equation
true = stringEqual(prefixIdent, ident);
true = stringEq(prefixIdent, ident);
then restCr;
// id vs. id
case(CREF_IDENT(name = prefixIdent), CREF_IDENT(name = ident))
equation
true = stringEqual(prefixIdent, ident);
true = stringEq(prefixIdent, ident);
then CREF_IDENT("", {});
end matchcontinue;
end crefRemovePrefix;
Expand All @@ -2378,10 +2378,10 @@ algorithm b := matchcontinue(p1,p2)
Path qp;
Boolean b1,b2;
case(IDENT(str1),IDENT(str2))
then stringEqual(str1,str2);
then stringEq(str1,str2);
case(QUALIFIED(str1,qp),(p2 as IDENT(str2)))
equation
b1 = stringEqual(str1,str2);
b1 = stringEq(str1,str2);
b2 = pathContains(qp,p2);
b1 = boolOr(b1,b2);
then
Expand Down Expand Up @@ -3635,13 +3635,13 @@ algorithm
list<Subscript> ss1,ss2;
case (CREF_IDENT(name = id,subscripts=ss1),CREF_IDENT(name = id2,subscripts = ss2))
equation
true = stringEqual(id, id2);
true = stringEq(id, id2);
true = subscriptsEqual(ss1,ss2);
then
true;
case (CREF_QUAL(name = id,subScripts = ss1, componentRef = cr1),CREF_QUAL(name = id2,subScripts = ss2, componentRef = cr2))
equation
true = stringEqual(id, id2);
true = stringEq(id, id2);
true = subscriptsEqual(ss1,ss2);
true = crefEqual(cr1, cr2);
then
Expand Down Expand Up @@ -3684,12 +3684,12 @@ algorithm
Ident id,id2;
case (CREF_IDENT(name = id),CREF_IDENT(name = id2))
equation
true = stringEqual(id, id2);
true = stringEq(id, id2);
then
true;
case (CREF_QUAL(name = id,componentRef = cr1),CREF_QUAL(name = id2,componentRef = cr2))
equation
true = stringEqual(id, id2);
true = stringEq(id, id2);
true = crefEqualNoSubs(cr1, cr2);
then
true;
Expand Down Expand Up @@ -3767,7 +3767,7 @@ algorithm
then crefEqual(cr1,cr2);
case(STRING(s1),STRING(s2))
local String s1,s2;
then stringEqual(s1,s2);
then stringEq(s1,s2);
case (BOOL(b1),BOOL(b2))
local Boolean b1,b2;
then Util.boolEqual(b1,b2);
Expand Down Expand Up @@ -4015,7 +4015,7 @@ algorithm
case (id,{}) then false;
case (id,(id1,_)::rest)
equation
true = stringEqual(id, id1);
true = stringEq(id, id1);
then true;
case (id,(id1,_)::rest)
equation
Expand Down Expand Up @@ -4132,7 +4132,7 @@ algorithm
case (_,{}) then (false,{});
case (id,(id_1,_)::_)
equation
true = stringEqual(id, id_1);
true = stringEq(id, id_1);
then
(true,{});
case (id,(_,NONE())::rest)
Expand Down Expand Up @@ -4305,7 +4305,7 @@ algorithm
case (_,{},_) then {};
case (id,SUBSCRIPT(CREF(CREF_IDENT(name,{})))::rest,n)
equation
true = stringEqual(id, name);
true = stringEq(id, name);
n_1=n+1;
lst=findIteratorInSubscripts(id,rest,n_1);
then n::lst;
Expand Down Expand Up @@ -4453,7 +4453,7 @@ algorithm
Path p1,p2;
case (NAMED_IMPORT(name = id,path=p1),NAMED_IMPORT(name = id2,path=p2))
equation
true = stringEqual(id, id2);
true = stringEq(id, id2);
true = ModUtil.pathEqual(p1,p2);
then
true;
Expand Down
8 changes: 4 additions & 4 deletions Compiler/AbsynDep.mo
Expand Up @@ -349,7 +349,7 @@ algorithm
/* Insert to right */
case (AVLTREENODE(value = SOME(AVLTREEVALUE(rkey,rval)),height=h,left = left,right = (right)),key,value)
equation
true = System.strcmp(Absyn.pathString(key),Absyn.pathString(rkey)) > 0;
true = stringCompare(Absyn.pathString(key),Absyn.pathString(rkey)) > 0;
t = createEmptyAvlIfNone(right);
t_1 = avlTreeAdd(t, key, value);
bt = balance(AVLTREENODE(SOME(AVLTREEVALUE(rkey,rval)),h,left,SOME(t_1)));
Expand All @@ -359,7 +359,7 @@ algorithm
/* Insert to left subtree */
case (AVLTREENODE(value = SOME(AVLTREEVALUE(rkey,rval)),height=h,left = left ,right = right),key,value)
equation
/*true = System.strcmp(key,rkey) < 0;*/
/*true = stringCompare(key,rkey) < 0;*/
t = createEmptyAvlIfNone(left);
t_1 = avlTreeAdd(t, key, value);
bt = balance(AVLTREENODE(SOME(AVLTREEVALUE(rkey,rval)),h,SOME(t_1),right));
Expand Down Expand Up @@ -620,7 +620,7 @@ algorithm
case (AVLTREENODE(value = SOME(AVLTREEVALUE(rkey,rval)),left = left,right = SOME(right)),key)
local AvlTree right;
equation
true = System.strcmp(Absyn.pathString(key),Absyn.pathString(rkey)) > 0;
true = stringCompare(Absyn.pathString(key),Absyn.pathString(rkey)) > 0;
res = avlTreeGet(right, key);
then
res;
Expand All @@ -629,7 +629,7 @@ algorithm
case (AVLTREENODE(value = SOME(AVLTREEVALUE(rkey,rval)),left = SOME(left),right = right),key)
local AvlTree left;
equation
/*true = System.strcmp(key,rkey) < 0;*/
/*true = stringCompare(key,rkey) < 0;*/
res = avlTreeGet(left, key);
then
res;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/Algorithm.mo
Expand Up @@ -345,7 +345,7 @@ algorithm
DAE.C_CONST() = Util.listReduce(bvals, Types.constOr);
sl = Util.listMap(lhs, ExpressionDump.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = System.stringAppendList({"(",s,")"});
lhs_str = stringAppendList({"(",s,")"});
rhs_str = ExpressionDump.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_CONSTANT_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
Expand All @@ -356,7 +356,7 @@ algorithm
DAE.C_PARAM() = Util.listReduce(bvals, Types.constOr);
sl = Util.listMap(lhs, ExpressionDump.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = System.stringAppendList({"(",s,")"});
lhs_str = stringAppendList({"(",s,")"});
rhs_str = ExpressionDump.printExpStr(rhs);
Error.addSourceMessage(Error.ASSIGN_PARAM_ERROR, {lhs_str,rhs_str}, DAEUtil.getElementSourceFileInfo(source));
then
Expand Down Expand Up @@ -387,7 +387,7 @@ algorithm
true = RTOpts.debugFlag("failtrace");
sl = Util.listMap(lhs, ExpressionDump.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = System.stringAppendList({"(",s,")"});
lhs_str = stringAppendList({"(",s,")"});
rhs_str = ExpressionDump.printExpStr(rhs);
str1 = Util.stringDelimitList(Util.listMap(lprop, Types.printPropStr), ", ");
str2 = Types.printPropStr(rprop);
Expand Down
28 changes: 14 additions & 14 deletions Compiler/BackendDAEUtil.mo
Expand Up @@ -112,7 +112,7 @@ algorithm
strcrefs = Util.listMap(crefs,ComponentReference.crefStr);
crefstring = Util.stringDelimitList(strcrefs,", ");
expstr = ExpressionDump.printExpStr(e);
scopestr = System.stringAppendList({crefstring," from Expression: ",expstr});
scopestr = stringAppendList({crefstring," from Expression: ",expstr});
Error.addMessage(Error.LOOKUP_VARIABLE_ERROR, {scopestr,"BackendDAE object"});
printcheckBackendDAEWithErrorMsg(res);
then
Expand Down Expand Up @@ -2414,14 +2414,14 @@ algorithm
case (BackendDAE.TREENODE(value = SOME(BackendDAE.TREEVALUE(rkey,rval)),leftSubTree = left,rightSubTree = right),keystr)
equation
rkeystr = ComponentReference.printComponentRefStr(rkey);
0 = System.strcmp(rkeystr, keystr);
0 = stringCompare(rkeystr, keystr);
then
rval;
case (BackendDAE.TREENODE(value = SOME(BackendDAE.TREEVALUE(rkey,rval)),leftSubTree = left,rightSubTree = SOME(right)),keystr)
local BackendDAE.BinTree right;
equation
rkeystr = ComponentReference.printComponentRefStr(rkey) "Search to the right" ;
cmpval = System.strcmp(rkeystr, keystr);
cmpval = stringCompare(rkeystr, keystr);
(cmpval > 0) = true;
res = treeGet2(right, keystr);
then
Expand All @@ -2430,7 +2430,7 @@ algorithm
local BackendDAE.BinTree left;
equation
rkeystr = ComponentReference.printComponentRefStr(rkey) "Search to the left" ;
cmpval = System.strcmp(rkeystr, keystr);
cmpval = stringCompare(rkeystr, keystr);
(cmpval > 0) = false;
res = treeGet2(left, keystr);
then
Expand Down Expand Up @@ -2490,14 +2490,14 @@ algorithm
equation
rkeystr = ComponentReference.printComponentRefStr(rkey) "Replace this node" ;
keystr = ComponentReference.printComponentRefStr(key);
0 = System.strcmp(rkeystr, keystr);
0 = stringCompare(rkeystr, keystr);
then
BackendDAE.TREENODE(SOME(BackendDAE.TREEVALUE(rkey,value)),left,right);
case (BackendDAE.TREENODE(value = SOME(BackendDAE.TREEVALUE(rkey,rval)),leftSubTree = left,rightSubTree = (right as SOME(t))),key,value)
equation
keystr = ComponentReference.printComponentRefStr(key) "Insert to right subtree";
rkeystr = ComponentReference.printComponentRefStr(rkey);
cmpval = System.strcmp(rkeystr, keystr);
cmpval = stringCompare(rkeystr, keystr);
(cmpval > 0) = true;
t_1 = treeAdd(t, key, value);
then
Expand All @@ -2506,7 +2506,7 @@ algorithm
equation
keystr = ComponentReference.printComponentRefStr(key) "Insert to right node";
rkeystr = ComponentReference.printComponentRefStr(rkey);
cmpval = System.strcmp(rkeystr, keystr);
cmpval = stringCompare(rkeystr, keystr);
(cmpval > 0) = true;
right_1 = treeAdd(BackendDAE.TREENODE(NONE(),NONE(),NONE()), key, value);
then
Expand All @@ -2515,7 +2515,7 @@ algorithm
equation
keystr = ComponentReference.printComponentRefStr(key) "Insert to left subtree";
rkeystr = ComponentReference.printComponentRefStr(rkey);
cmpval = System.strcmp(rkeystr, keystr);
cmpval = stringCompare(rkeystr, keystr);
(cmpval > 0) = false;
t_1 = treeAdd(t, key, value);
then
Expand All @@ -2524,7 +2524,7 @@ algorithm
equation
keystr = ComponentReference.printComponentRefStr(key) "Insert to left node";
rkeystr = ComponentReference.printComponentRefStr(rkey);
cmpval = System.strcmp(rkeystr, keystr);
cmpval = stringCompare(rkeystr, keystr);
(cmpval > 0) = false;
left_1 = treeAdd(BackendDAE.TREENODE(NONE(),NONE(),NONE()), key, value);
then
Expand Down Expand Up @@ -2561,7 +2561,7 @@ algorithm
equation
rkeystr = ComponentReference.printComponentRefStr(rkey) "delete this node, when existing right node" ;
keystr = ComponentReference.printComponentRefStr(key);
0 = System.strcmp(rkeystr, keystr);
0 = stringCompare(rkeystr, keystr);
(rightmost,right_1) = treeDeleteRightmostValue(right);
optright_1 = treePruneEmptyNodes(right_1);
then
Expand All @@ -2570,22 +2570,22 @@ algorithm
equation
rkeystr = ComponentReference.printComponentRefStr(rkey) "delete this node, when no right node, but left node" ;
keystr = ComponentReference.printComponentRefStr(key);
0 = System.strcmp(rkeystr, keystr);
0 = stringCompare(rkeystr, keystr);
then
BackendDAE.TREENODE(leftval,lleft,lright);
case (BackendDAE.TREENODE(value = SOME(BackendDAE.TREEVALUE(rkey,rval)),leftSubTree = NONE(),rightSubTree = NONE()),key)
equation
rkeystr = ComponentReference.printComponentRefStr(rkey) "delete this node, when no left or right node" ;
keystr = ComponentReference.printComponentRefStr(key);
0 = System.strcmp(rkeystr, keystr);
0 = stringCompare(rkeystr, keystr);
then
BackendDAE.TREENODE(NONE(),NONE(),NONE());
case (BackendDAE.TREENODE(value = SOME(BackendDAE.TREEVALUE(rkey,rval)),leftSubTree = left,rightSubTree = (right as SOME(t))),key)
local Option<BackendDAE.BinTree> right;
equation
keystr = ComponentReference.printComponentRefStr(key) "delete in right subtree" ;
rkeystr = ComponentReference.printComponentRefStr(rkey);
cmpval = System.strcmp(rkeystr, keystr);
cmpval = stringCompare(rkeystr, keystr);
(cmpval > 0) = true;
t_1 = treeDelete(t, key);
topt_1 = treePruneEmptyNodes(t_1);
Expand All @@ -2596,7 +2596,7 @@ algorithm
equation
keystr = ComponentReference.printComponentRefStr(key) "delete in left subtree" ;
rkeystr = ComponentReference.printComponentRefStr(rkey);
cmpval = System.strcmp(rkeystr, keystr);
cmpval = stringCompare(rkeystr, keystr);
(cmpval > 0) = false;
t_1 = treeDelete(t, key);
topt_1 = treePruneEmptyNodes(t_1);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackendVariable.mo
Expand Up @@ -2429,7 +2429,7 @@ algorithm
hashvec_1 = arrayUpdate(hashvec, indx + 1, (BackendDAE.CREFINDEX(cr,newpos) :: indexes));
n_1 = vararrayLength(varr_1);
name_str = ComponentReference.printComponentRefStr(cr);
hvalold = System.hash(name_str);
hvalold = stringHashDjb2(name_str);
indxold = intMod(hvalold, bsize);
indexexold = oldhashvec[indxold + 1];
oldhashvec_1 = arrayUpdate(oldhashvec, indxold + 1,
Expand Down
7 changes: 6 additions & 1 deletion Compiler/Builtin.mo
Expand Up @@ -2991,8 +2991,11 @@ algorithm
env = Env.extendFrameT(env, "stringGetStringChar", stringInt2string);
env = Env.extendFrameT(env, "stringAppend", stringString2string);
env = Env.extendFrameT(env, "stringUpdateStringChar", stringStringInteger2string);
env = Env.extendFrameT(env, "stringEqual", stringString2boolean);
env = Env.extendFrameT(env, "stringEq", stringString2boolean);
env = Env.extendFrameT(env, "stringCompare", stringString2int);
env = Env.extendFrameT(env, "stringHash", string2int);
env = Env.extendFrameT(env, "stringHashDjb2", string2int);
env = Env.extendFrameT(env, "stringHashSdbm", string2int);

// List Operations
env = Env.extendFrameT(env, "listAppend", listAListA2listA);
Expand Down Expand Up @@ -3031,6 +3034,8 @@ algorithm
env = Env.extendFrameT(env, "getGlobalRoot", int2boxed);
env = Env.extendFrameT(env, "setGlobalRoot", intBoxedNoRetcall);
env = Env.extendFrameT(env, "valueConstructor", boxed2int);
env = Env.extendFrameT(env, "valueSlots", boxed2int);
env = Env.extendFrameT(env, "valueEq", AA2bool);
then env;
case env then env;
end matchcontinue;
Expand Down

0 comments on commit dc7a066

Please sign in to comment.