Skip to content

Commit

Permalink
Workaround for missing support of 'switch type'
Browse files Browse the repository at this point in the history
--HG--
branch : com.mozilla.es4.smlnj
extra : convert_revision : f52f995430e2dade5dd15e7dc2b9d863018951e1
  • Loading branch information
[email protected] committed Apr 25, 2007
1 parent a7bc7d8 commit 24e8a29
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions builtins/string_primitive.es
Original file line number Diff line number Diff line change
Expand Up @@ -410,23 +410,24 @@ package
type matcher = (string,RegExp!);

function splitMatch(R: matcher, S: string, q: uint) : [uint, [string]] {
switch type (R : matcher) {
case (x : string) {
/* FIXME: use "switch type" when it works */
if (R is string) {
let x : string = R cast string;
let r : uint = x.length;
if (q + r <= S.length && S.substring(q, q + r) === R)
return [q+r, []];
else
return null;
}

case (xx : RegExp!) { /* FIXME: rename back to x when Jeff has fixed the definer */
let mr : MatchResult = xx.match(S, q);
if (R is RegExp) {
let x : RegExp! = R cast RegExp;
let mr : MatchResult = x.match(S, q);
if (mr === null)
return null;
else
return [mr.endIndex, mr.cap];
}
}
}

/* 1-6 */
Expand Down

0 comments on commit 24e8a29

Please sign in to comment.