01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2004 Robert Grimm
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * version 2 as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17: * USA.
18: */
19: package xtc.tree;
20:
21: /**
22: * The superclass of all utilities. A utility provides state and
23: * functionality for visitors. Utilities are implemented as separate
24: * classes (instead of visitors inheriting from utilities) so that the
25: * same utility can be reused across visitors and also shared amongst
26: * several, composed visitors.
27: *
28: * @author Robert Grimm
29: * @version $Revision: 1.5 $
30: */
31: public abstract class Utility {
32:
33: /** The visitor for this utility. */
34: Visitor visitor;
35:
36: /** Create a new utility. */
37: public Utility() { /* Nothing to do. */
38: }
39:
40: /**
41: * Set the visitor for this utility.
42: *
43: * @param visitor The new visitor.
44: */
45: public void register(Visitor visitor) {
46: this .visitor = visitor;
47: }
48:
49: /**
50: * Get the visitor for this utility.
51: *
52: * @return The visitor.
53: */
54: public Visitor visitor() {
55: return visitor;
56: }
57:
58: }
|