Skip to content

Commit 6dc125b

Browse files
committed
Use Absyn.pathCompare(...) instead of stringCompare(pathString...)
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19563 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 07bc649 commit 6dc125b

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

Compiler/FrontEnd/Absyn.mo

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,6 +2727,53 @@ algorithm
27272727
outString := pathString2(makeNotFullyQualified(inPath), ".");
27282728
end pathStringNoQual;
27292729

2730+
public function pathCompare
2731+
input Path ip1;
2732+
input Path ip2;
2733+
output Integer o;
2734+
algorithm
2735+
o := match (ip1,ip2)
2736+
local
2737+
Path p1,p2;
2738+
String i1,i2;
2739+
case (FULLYQUALIFIED(p1),FULLYQUALIFIED(p2)) then pathCompare(p1,p2);
2740+
case (FULLYQUALIFIED(_),_) then 1;
2741+
case (_,FULLYQUALIFIED(_)) then -1;
2742+
case (QUALIFIED(i1,p1),QUALIFIED(i2,p2))
2743+
equation
2744+
o = stringCompare(i1,i2);
2745+
o = Debug.bcallret2(o == 0, pathCompare, p1, p2, o);
2746+
then o;
2747+
case (QUALIFIED(name=_),_) then 1;
2748+
case (_,QUALIFIED(name=_)) then -1;
2749+
case (IDENT(i1),IDENT(i2))
2750+
then stringCompare(i1,i2);
2751+
end match;
2752+
end pathCompare;
2753+
2754+
public function pathCompareNoQual
2755+
input Path ip1;
2756+
input Path ip2;
2757+
output Integer o;
2758+
algorithm
2759+
o := match (ip1,ip2)
2760+
local
2761+
Path p1,p2;
2762+
String i1,i2;
2763+
case (FULLYQUALIFIED(p1),p2) then pathCompareNoQual(p1,p2);
2764+
case (p1,FULLYQUALIFIED(p2)) then pathCompareNoQual(p1,p2);
2765+
case (QUALIFIED(i1,p1),QUALIFIED(i2,p2))
2766+
equation
2767+
o = stringCompare(i1,i2);
2768+
o = Debug.bcallret2(o == 0, pathCompare, p1, p2, o);
2769+
then o;
2770+
case (QUALIFIED(name=_),_) then 1;
2771+
case (_,QUALIFIED(name=_)) then -1;
2772+
case (IDENT(i1),IDENT(i2))
2773+
then stringCompare(i1,i2);
2774+
end match;
2775+
end pathCompareNoQual;
2776+
27302777
public function pathHashMod "Hashes a path."
27312778
input Path path;
27322779
input Integer mod;

Compiler/FrontEnd/DAEUtil.mo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5050,7 +5050,8 @@ protected function avlKeyCompare
50505050
input DAE.AvlKey key2;
50515051
output Integer c;
50525052
algorithm
5053-
c := stringCompare(Absyn.pathStringNoQual(key1),Absyn.pathStringNoQual(key2));
5053+
c := Absyn.pathCompareNoQual(key1,key2);
5054+
// c := stringCompare(Absyn.pathStringNoQual(key1),Absyn.pathStringNoQual(key2));
50545055
end avlKeyCompare;
50555056

50565057
public function avlTreeNew "Return an empty tree"

0 commit comments

Comments
 (0)