1
/*******************************************************************************
2
* Copyright (c) 2005, 2008 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
* IBM Rational Software - Initial API and implementation
10
* Markus Schorn (Wind River Systems)
11
*******************************************************************************/
12
package org.eclipse.cdt.internal.core.dom.parser.c;
14
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
15
import org.eclipse.cdt.core.dom.ast.IASTExpression;
16
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IASTNode;
23
public class CASTFieldDeclarator extends CASTDeclarator implements IASTFieldDeclarator {
24
private IASTExpression bitFieldSize;
26
public CASTFieldDeclarator() {
29
public CASTFieldDeclarator(IASTName name, IASTExpression bitFieldSize) {
31
setBitFieldSize(bitFieldSize);
35
public CASTFieldDeclarator copy() {
36
CASTFieldDeclarator copy = new CASTFieldDeclarator();
37
copyBaseDeclarator(copy);
38
copy.setBitFieldSize(bitFieldSize == null ? null : bitFieldSize.copy());
42
public IASTExpression getBitFieldSize() {
47
public void setBitFieldSize(IASTExpression size) {
52
size.setPropertyInParent(FIELD_SIZE);
57
protected boolean postAccept(ASTVisitor action) {
58
if (bitFieldSize != null && !bitFieldSize.accept(action))
61
return super.postAccept(action);
65
public void replace(IASTNode child, IASTNode other) {
66
if( child == bitFieldSize) {
67
other.setPropertyInParent( child.getPropertyInParent() );
68
other.setParent( child.getParent() );
69
bitFieldSize = (IASTExpression) other;
71
super.replace(child, other);