diff options
author | Adrian Taylor <adrian@macrobug.com> | 2012-02-10 23:11:34 +0000 |
---|---|---|
committer | Adrian Taylor <adrian@macrobug.com> | 2012-02-20 08:50:04 +0000 |
commit | e6f092d69f1806153571e6e808caea76f8bf5190 (patch) | |
tree | 0ed8e824e097d43cd3b6a03e39bb79c627a2deef /src/parseTools.js | |
parent | 1d5093e31274f666b052e0ac392a396f3e3b1875 (diff) |
Polymorphic exception handling.
Previously exception handling only worked if there were a 'catch' block which precisely matched
the type of the thrown exception.
That's not always the case if we're trying to catch subclasses.
This change enhances behaviour to match subclasses, and also covers some other cases where
we weren't catching the right thing.
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 1b48737e..2ab43ebf 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -227,7 +227,11 @@ function getTokenIndexByText(tokens, text) { } function findTokenText(item, text) { - for (var i = 0; i < item.tokens.length; i++) { + return findTokenTextAfter(item, text, 0); +} + +function findTokenTextAfter(item, text, startAt) { + for (var i = startAt; i < item.tokens.length; i++) { if (item.tokens[i].text == text) return i; } return -1; |