01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2006-2007 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.type;
20:
21: import java.io.IOException;
22:
23: /**
24: * An annotated type. This pseudo-type is useful for adding
25: * annotations to a type without modifying the underlying type.
26: *
27: * @author Robert Grimm
28: * @version $Revision: 1.21 $
29: */
30: public class AnnotatedT extends WrappedT {
31:
32: /**
33: * Create a new annotated type.
34: *
35: * @param type The type to annotate.
36: */
37: public AnnotatedT(Type type) {
38: super (type);
39: }
40:
41: /**
42: * Create a new annotated type.
43: *
44: * @param template The type whose annotations to copy.
45: * @param type The type to annotate.
46: */
47: public AnnotatedT(Type template, Type type) {
48: super (template, type);
49: }
50:
51: public AnnotatedT copy() {
52: return new AnnotatedT(this , getType().copy());
53: }
54:
55: public Type.Tag wtag() {
56: return Type.Tag.ANNOTATED;
57: }
58:
59: public boolean isAnnotated() {
60: return true;
61: }
62:
63: public AnnotatedT toAnnotated() {
64: return this ;
65: }
66:
67: public void write(Appendable out) throws IOException {
68: out.append("annotated(");
69: getType().write(out);
70: out.append(')');
71: }
72:
73: }
|