Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c8e83c5a84171b2b2dd3ecd83e156a914086588d (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*******************************************************************************
 * Copyright (c) 2006, 2015 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Sergey Prigogin (Google)
 *******************************************************************************/
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<>();

	private boolean isAuto;
	private boolean isExtern;
	private boolean isInline;
	private boolean isRegister;
	private boolean isStatic;
	private boolean isVarArgs;
	private boolean isNoReturn;
	private boolean isNoDiscard;

	// 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;
	}

	@Override
	public IParameter[] getParameters() {
		return parameters.toArray(new IParameter[parameters.size()]);
	}

	public void addParameter(IParameter parameter) {
		parameters.add(parameter);
	}

	@Override
	public IFunctionType getType() {
		return type;
	}

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

	@Override
	public boolean isAuto() {
		return isAuto;
	}

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

	@Override
	public boolean isExtern() {
		return isExtern;
	}

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

	@Override
	public boolean isInline() {
		return isInline;
	}

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

	@Override
	public boolean isRegister() {
		return isRegister;
	}

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

	@Override
	public boolean isStatic() {
		return isStatic;
	}

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

	@Override
	public boolean takesVarArgs() {
		return isVarArgs;
	}

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

	@Override
	public boolean isNoReturn() {
		return isNoReturn;
	}

	public void setNoReturn(boolean isNoReturn) {
		this.isNoReturn = isNoReturn;
	}

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

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

	@Override
	public String getName() {
		return name;
	}

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

	@Override
	public IScope getScope() {
		return scope;
	}

	@Override
	public IScope getFunctionScope() {
		return bodyScope;
	}

	public void setFunctionScope(IScope bodyScope) {
		this.bodyScope = bodyScope;
	}

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

	@Override
	public IBinding getOwner() {
		return null;
	}

	@Override
	public boolean isNoDiscard() {
		return isNoDiscard;
	}

	public void setNoDiscard(boolean isNoDiscard) {
		this.isNoDiscard = isNoDiscard;
	}
}

Back to the top