1
/*******************************************************************************
2
* Copyright (c) 2005, 2011 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* John Camelon (IBM Rational Software) - Initial API and implementation
10
* Yuan Zhang / Beth Tibbitts (IBM Research)
11
* Markus Schorn (Wind River Systems)
12
*******************************************************************************/
13
package org.eclipse.cdt.internal.core.dom.parser.c;
15
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
16
import org.eclipse.cdt.core.dom.ast.IASTExpression;
17
import org.eclipse.cdt.core.dom.ast.IASTNode;
18
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
19
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
20
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
22
public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements ICASTSimpleDeclSpecifier,
25
private int simpleType;
26
private boolean isSigned;
27
private boolean isUnsigned;
28
private boolean isShort;
29
private boolean isLong;
30
private boolean longlong;
31
private boolean complex=false;
32
private boolean imaginary=false;
33
private IASTExpression fDeclTypeExpression;
35
public CASTSimpleDeclSpecifier copy() {
36
return copy(CopyStyle.withoutLocations);
39
public CASTSimpleDeclSpecifier copy(CopyStyle style) {
40
CASTSimpleDeclSpecifier copy = new CASTSimpleDeclSpecifier();
41
copySimpleDeclSpec(copy, style);
42
if (style == CopyStyle.withLocations) {
43
copy.setCopyLocation(this);
48
protected void copySimpleDeclSpec(CASTSimpleDeclSpecifier copy, CopyStyle style) {
49
copyBaseDeclSpec(copy);
50
copy.simpleType = simpleType;
51
copy.isSigned = isSigned;
52
copy.isUnsigned = isUnsigned;
53
copy.isShort = isShort;
55
copy.longlong = longlong;
56
copy.complex = complex;
57
copy.imaginary = imaginary;
58
if (fDeclTypeExpression != null)
59
copy.setDeclTypeExpression(fDeclTypeExpression.copy(style));
62
public int getType() {
66
public boolean isSigned() {
70
public boolean isUnsigned() {
74
public boolean isShort() {
78
public boolean isLong() {
82
public void setType(int type) {
87
public void setType(Kind kind) {
88
setType(getType(kind));
91
private int getType(Kind kind) {
107
return t_unspecified;
111
return t_unspecified;
114
public void setShort(boolean value) {
119
public void setLong(boolean value) {
124
public void setUnsigned(boolean value) {
129
public void setSigned(boolean value) {
134
public boolean isLongLong() {
138
public void setLongLong(boolean value) {
144
public boolean accept( ASTVisitor action ){
145
if( action.shouldVisitDeclSpecifiers ){
146
switch( action.visit( this ) ){
147
case ASTVisitor.PROCESS_ABORT : return false;
148
case ASTVisitor.PROCESS_SKIP : return true;
153
if (fDeclTypeExpression != null && !fDeclTypeExpression.accept(action))
156
if( action.shouldVisitDeclSpecifiers ){
157
switch( action.leave( this ) ){
158
case ASTVisitor.PROCESS_ABORT : return false;
159
case ASTVisitor.PROCESS_SKIP : return true;
166
public boolean isComplex() {
170
public void setComplex(boolean value) {
172
this.complex = value;
175
public boolean isImaginary() {
179
public void setImaginary(boolean value) {
181
this.imaginary = value;
184
public IASTExpression getDeclTypeExpression() {
185
return fDeclTypeExpression;
188
public void setDeclTypeExpression(IASTExpression expression) {
190
fDeclTypeExpression= expression;
191
if (expression != null) {
192
expression.setPropertyInParent(DECLTYPE_EXPRESSION);
193
expression.setParent(this);
197
public void replace(IASTNode child, IASTNode other) {
198
if (child == fDeclTypeExpression) {
199
other.setPropertyInParent(child.getPropertyInParent());
200
other.setParent(child.getParent());
201
fDeclTypeExpression= (IASTExpression) other;