001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package EDU.purdue.cs.bloat.editor;
022:
023: /**
024: * TryCatch holds the labels for the start and end of a protected block and the
025: * beginning of a catch block and the type of the exception to catch.
026: *
027: * @author Nate Nystrom (<a
028: * href="mailto:nystrom@cs.purdue.edu">nystrom@cs.purdue.edu</a>)
029: */
030: public class TryCatch {
031: private Label start;
032:
033: private Label end;
034:
035: private Label handler;
036:
037: private Type type;
038:
039: /**
040: * Constructor.
041: *
042: * @param start
043: * The start label of the protected block.
044: * @param end
045: * The label of the instruction after the end of the protected
046: * block.
047: * @param handler
048: * The start label of the exception handler.
049: * @param type
050: * The type of exception to catch.
051: */
052: public TryCatch(final Label start, final Label end,
053: final Label handler, final Type type) {
054: this .start = start;
055: this .end = end;
056: this .handler = handler;
057: this .type = type;
058: }
059:
060: /**
061: * Get the start label of the protected block.
062: *
063: * @return The start label.
064: */
065: public Label start() {
066: return start;
067: }
068:
069: /**
070: * Get the end label of the protected block.
071: *
072: * @return The end label.
073: */
074: public Label end() {
075: return end;
076: }
077:
078: /**
079: * Get the start label of the catch block.
080: *
081: * @return The handler label.
082: */
083: public Label handler() {
084: return handler;
085: }
086:
087: /**
088: * Set the start label of the catch block.
089: */
090: public void setHandler(final Label handler) {
091: this .handler = handler;
092: }
093:
094: /**
095: * Get the type of the exception to catch.
096: *
097: * @return The type of the exception to catch.
098: */
099: public Type type() {
100: return type;
101: }
102:
103: public String toString() {
104: return "try " + start + ".." + end + " catch (" + type + ") "
105: + handler;
106: }
107: }
|