01: /*
02: * xtc - The eXTensible Compiler
03: * Copyright (C) 2005-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.util.List;
22:
23: /**
24: * A function type. Note that a C function with an old-style
25: * declarator must be annotated with the {@link
26: * xtc.Constants#ATT_STYLE_OLD} attribute. An old-style definition
27: * must also be annotated with the {@link xtc.Constants#ATT_DEFINED}
28: * attribute.
29: *
30: * @author Robert Grimm
31: * @version $Revision: 1.31 $
32: */
33: public class FunctionT extends FunctionOrMethodT {
34:
35: /**
36: * Create a new function type.
37: *
38: * @param result The result type.
39: */
40: public FunctionT(Type result) {
41: super (null, result, null, null, false, null);
42: }
43:
44: /**
45: * Create a new function type.
46: *
47: * @param result The result type.
48: * @param parameters The list of parameter types.
49: * @param varargs The flag for accepting a variable number of arguments.
50: */
51: public FunctionT(Type result, List<Type> parameters, boolean varargs) {
52: super (null, result, null, parameters, varargs, null);
53: }
54:
55: /**
56: * Create a new function type.
57: *
58: * @param template The type whose annotations to copy.
59: * @param result The result type.
60: * @param parameters The list of parameter types.
61: * @param varargs The flag for accepting a variable number of arguments.
62: */
63: public FunctionT(Type template, Type result, List<Type> parameters,
64: boolean varargs) {
65: super (template, result, null, parameters, varargs, null);
66: }
67:
68: public FunctionT copy() {
69: FunctionT copy = new FunctionT(this , result.copy(),
70: copy(parameters), varargs);
71: if (null != exceptions) {
72: copy.exceptions = copy(exceptions);
73: }
74: return copy;
75: }
76:
77: public Type.Tag tag() {
78: return Type.Tag.FUNCTION;
79: }
80:
81: public boolean isFunction() {
82: return true;
83: }
84:
85: public FunctionT toFunction() {
86: return this;
87: }
88:
89: }
|