From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: src/builtins/
Date: Sat, 25 Jun 2011 10:05:49 +0000 (UTC) [thread overview]
Message-ID: <42a50c1fab4780fce1e8ba792d70af43d0da0cec.betelgeuse@gentoo> (raw)
commit: 42a50c1fab4780fce1e8ba792d70af43d0da0cec
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 20 14:00:49 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Jun 23 03:24:40 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=42a50c1f
Core: abstract the role of continue exception
---
src/builtins/builtin_exceptions.h | 46 +++++++++++++++++++++++++++++++-----
1 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/src/builtins/builtin_exceptions.h b/src/builtins/builtin_exceptions.h
index c20ce4c..c535417 100644
--- a/src/builtins/builtin_exceptions.h
+++ b/src/builtins/builtin_exceptions.h
@@ -39,26 +39,58 @@ public:
runtime_error("return exception"){}
};
-class continue_exception: public std::exception
+class loop_control_exception
{
int count;
+
+ virtual void rethrow() = 0;
+
+protected:
+ virtual ~loop_control_exception() {}
+
public:
- explicit continue_exception(int c): count(c)
- {
- if(c < 1)
- throw libbash::interpreter_exception("continue: argument should be greater than or equal to 1");
- }
+ explicit loop_control_exception(int c): count(c) {}
void rethrow_unless_correct_frame()
{
if(count != 1)
{
--count;
- throw *this;
+ rethrow();
}
}
};
+class continue_exception: public loop_control_exception
+{
+protected:
+ virtual void rethrow()
+ {
+ throw *this;
+ }
+
+public:
+ explicit continue_exception(int c): loop_control_exception(c) {
+ if(c < 1)
+ throw libbash::interpreter_exception("continue: argument should be greater than or equal to 1");
+ }
+};
+
+class break_exception: public loop_control_exception
+{
+protected:
+ virtual void rethrow()
+ {
+ throw *this;
+ }
+
+public:
+ explicit break_exception(int c): loop_control_exception(c) {
+ if(c < 1)
+ throw libbash::interpreter_exception("break: argument should be greater than or equal to 1");
+ }
+};
+
class suppress_output: public std::exception
{
};
next reply other threads:[~2011-06-25 10:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-25 10:05 Petteri Räty [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-07-03 20:21 [gentoo-commits] proj/libbash:master commit in: src/builtins/ Petteri Räty
2011-06-15 21:18 Petteri Räty
2011-06-03 12:43 Petteri Räty
2011-05-08 13:07 Petteri Räty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42a50c1fab4780fce1e8ba792d70af43d0da0cec.betelgeuse@gentoo \
--to=betelgeuse@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox