@@ -2065,23 +2065,51 @@ algorithm outPaths := matchcontinue(path)
2065
2065
end matchcontinue;
2066
2066
end pathToStringList;
2067
2067
2068
- public function pathPrefixOf "returns true if prefix_path is a prefix of path"
2069
- input Path prefix_path;
2068
+ public function pathPrefixOf
2069
+ "
2070
+ funcion: pathPrefixOf
2071
+ Alternative names: isPrefixOf, pathIsPrefixOf, prefixOf
2072
+
2073
+ Returns true if prefixPath is a prefix of path, false otherwise.
2074
+ "
2075
+ input Path prefixPath;
2070
2076
input Path path;
2071
- output Boolean res ;
2077
+ output Boolean out ;
2072
2078
algorithm
2073
- res := matchcontinue(prefix_path,path)
2074
- local Path p;
2075
- case(prefix_path,path)
2079
+ out := matchcontinue(prefixPath, path)
2080
+ case(prefixPath, path)
2076
2081
equation
2077
- true = ModUtil.pathEqual(prefix_path, path);
2082
+ true = ModUtil.pathEqual(prefixPath, path);
2078
2083
then true ;
2079
- case(prefix_path, path)
2080
- then pathPrefixOf(prefix_path, stripLast(path));
2081
- case(_,_) then false ;
2084
+ case(prefixPath, path)
2085
+ then pathPrefixOf(prefixPath, stripLast(path));
2086
+ case(_, _) then false ;
2082
2087
end matchcontinue;
2083
2088
end pathPrefixOf;
2084
2089
2090
+ public function crefPrefixOf
2091
+ "
2092
+ function: crefPrefixOf
2093
+ Alternative names: crefIsPrefixOf, isPrefixOf, prefixOf
2094
+ Author: DH 2010-03
2095
+
2096
+ Returns true if prefixCr is a prefix of cr, i.e., false otherwise.
2097
+ Subscripts are NOT checked.
2098
+ "
2099
+ input ComponentRef prefixCr;
2100
+ input ComponentRef cr;
2101
+ output Boolean out;
2102
+ algorithm
2103
+ out := matchcontinue(prefixCr, cr)
2104
+ case(prefixCr, cr)
2105
+ equation
2106
+ true = crefEqualNoSubs(prefixCr, cr);
2107
+ then true ;
2108
+ case(prefixCr, cr)
2109
+ then crefPrefixOf(prefixCr, crefStripLast(cr));
2110
+ case(_, _) then false ;
2111
+ end matchcontinue;
2112
+ end crefPrefixOf;
2085
2113
2086
2114
public function removePrefix "removes the prefix_path from path, and returns the rest of path"
2087
2115
input Path prefix_path;
@@ -2101,6 +2129,38 @@ algorithm
2101
2129
end matchcontinue;
2102
2130
end removePrefix;
2103
2131
2132
+ public function crefRemovePrefix
2133
+ "
2134
+ function: crefRemovePrefix
2135
+ Alternative names: removePrefix
2136
+ Author: DH 2010-03
2137
+
2138
+ If prefixCr is a prefix of cr, removes prefixCr from cr and returns the remaining reference,
2139
+ otherwise fails. Subscripts are NOT checked.
2140
+ "
2141
+ input ComponentRef prefixCr;
2142
+ input ComponentRef cr;
2143
+ output ComponentRef out;
2144
+ algorithm
2145
+ out := matchcontinue(prefixCr, cr)
2146
+ local
2147
+ Ident prefixIdent, ident;
2148
+ ComponentRef prefixRestCr, restCr;
2149
+ case(CREF_QUAL(name = prefixIdent, componentRef = prefixRestCr), CREF_QUAL(name = ident, componentRef = restCr))
2150
+ equation
2151
+ equality(prefixIdent = ident);
2152
+ then crefRemovePrefix(prefixRestCr, restCr);
2153
+ case(CREF_IDENT(name = prefixIdent), CREF_QUAL(name = ident, componentRef = restCr))
2154
+ equation
2155
+ equality(prefixIdent = ident);
2156
+ then restCr;
2157
+ case(CREF_IDENT(name = prefixIdent), CREF_IDENT(name = ident))
2158
+ equation
2159
+ equality(prefixIdent = ident);
2160
+ then CREF_IDENT("" , {});
2161
+ end matchcontinue;
2162
+ end crefRemovePrefix;
2163
+
2104
2164
public function pathContains "
2105
2165
Author BZ,
2106
2166
checks if one Absyn.IDENT(..) is contained in path.
0 commit comments