blob: 38b8e335c7bb670efd2beef9eaac1c8c579e8271 (
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
|
/*******************************************************************************
* Copyright (c) 2005, 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 Rational Software - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
public abstract class CASTBaseDeclSpecifier extends ASTAttributeOwner
implements ICASTDeclSpecifier, IASTAmbiguityParent {
protected int storageClass;
protected boolean isConst;
protected boolean isVolatile;
protected boolean isRestrict;
protected boolean isInline;
protected IASTAlignmentSpecifier[] alignmentSpecifiers =
IASTAlignmentSpecifier.EMPTY_ALIGNMENT_SPECIFIER_ARRAY;
@Override
public boolean isRestrict() {
return isRestrict;
}
@Override
public int getStorageClass() {
return storageClass;
}
@Override
public boolean isConst() {
return isConst;
}
@Override
public boolean isVolatile() {
return isVolatile;
}
@Override
public boolean isInline() {
return isInline;
}
@Override
public IASTAlignmentSpecifier[] getAlignmentSpecifiers() {
return alignmentSpecifiers;
}
@Override
public void setStorageClass(int storageClass) {
assertNotFrozen();
this.storageClass = storageClass;
}
@Override
public void setConst(boolean value) {
assertNotFrozen();
this.isConst = value;
}
@Override
public void setVolatile(boolean value) {
assertNotFrozen();
this.isVolatile = value;
}
@Override
public void setRestrict(boolean value) {
assertNotFrozen();
this.isRestrict = value;
}
@Override
public void setInline(boolean value) {
assertNotFrozen();
this.isInline = value;
}
@Override
public void setAlignmentSpecifiers(IASTAlignmentSpecifier[] alignmentSpecifiers) {
assertNotFrozen();
for (IASTAlignmentSpecifier specifier : alignmentSpecifiers) {
specifier.setParent(this);
specifier.setPropertyInParent(ALIGNMENT_SPECIFIER);
}
this.alignmentSpecifiers = alignmentSpecifiers;
}
protected <T extends CASTBaseDeclSpecifier> T copy(T copy, CopyStyle style) {
copy.storageClass = storageClass;
copy.isConst = isConst;
copy.isVolatile = isVolatile;
copy.isRestrict = isRestrict;
copy.isInline = isInline;
copy.alignmentSpecifiers = new IASTAlignmentSpecifier[alignmentSpecifiers.length];
for (int i = 0; i < alignmentSpecifiers.length; ++i) {
copy.alignmentSpecifiers[i] = alignmentSpecifiers[i].copy(style);
copy.alignmentSpecifiers[i].setParent(copy);
}
return super.copy(copy, style);
}
protected boolean visitAlignmentSpecifiers(ASTVisitor visitor) {
for (IASTAlignmentSpecifier specifier : alignmentSpecifiers) {
if (!specifier.accept(visitor)) {
return false;
}
}
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (child instanceof IASTAlignmentSpecifier && other instanceof IASTAlignmentSpecifier) {
for (int i = 0; i < alignmentSpecifiers.length; ++i) {
if (alignmentSpecifiers[i] == child) {
alignmentSpecifiers[i] = (IASTAlignmentSpecifier) other;
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
return;
}
}
}
}
}
|