Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d6f0d88bc7140b1bfc83c3d8ee9b378e4d913756 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*******************************************************************************
 * Copyright (c) 2006, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.core.runtime.PlatformObject;

@SuppressWarnings("restriction")
public class C99Function extends PlatformObject implements IC99Binding, IFunction, ITypeable {
	private String name;
	private IFunctionType type;
	private List<IParameter> parameters = new ArrayList<IParameter>();
	
	private boolean isAuto;
	private boolean isExtern;
	private boolean isInline;
	private boolean isRegister;
	private boolean isStatic;
	private boolean isVarArgs;
	
	// the scope that the function is in (must be the global scope, no?)
	private IScope scope;
	
	// the scope that represents the body of the function
	private IScope bodyScope;

	public C99Function() {
	}
	
	public C99Function(String name) {
		this.name = name;
	}
	
	public C99Function(String name, IFunctionType type) {
		this(name);
		this.type = type;
	}

	public IParameter[] getParameters() {
		return parameters.toArray(new IParameter[parameters.size()]);
	}
	
	public void addParameter(IParameter parameter) {
		parameters.add(parameter);
	}

	public IFunctionType getType() {
		return type;
	}
	
	public void setType(IFunctionType type) {
		this.type = type;
	}

	public boolean isAuto() {
		return isAuto;
	}

	public void setAuto(boolean isAuto) {
		this.isAuto = isAuto;
	}

	public boolean isExtern() {
		return isExtern;
	}

	public void setExtern(boolean isExtern) {
		this.isExtern = isExtern;
	}

	public boolean isInline() {
		return isInline;
	}

	public void setInline(boolean isInline) {
		this.isInline = isInline;
	}

	public boolean isRegister() {
		return isRegister;
	}

	public void setRegister(boolean isRegister) {
		this.isRegister = isRegister;
	}

	public boolean isStatic() {
		return isStatic;
	}

	public void setStatic(boolean isStatic) {
		this.isStatic = isStatic;
	}

	public boolean takesVarArgs() {
		return isVarArgs;
	}

	public void setTakesVarArgs(boolean isVarArgs) {
		this.isVarArgs = isVarArgs;
	}

	public ILinkage getLinkage() {
		return Linkage.C_LINKAGE;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}

	public char[] getNameCharArray() {
		return name.toCharArray();
	}

	public IScope getScope() {
		return scope;
	}
	
	public IScope getFunctionScope() {
		return bodyScope;
	}
	
	public void setFunctionScope(IScope bodyScope) {
		this.bodyScope = bodyScope;
	}

	public void setScope(IScope scope) {
		this.scope = scope;
	}

	public IBinding getOwner() {
		return null;
	}
}

Back to the top