1
/*******************************************************************************
2
* Copyright (c) 2007, 2010 QNX Software Systems 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
* Bryan Wilkinson (QNX) - Initial API and implementation
10
* Markus Schorn (Wind River Systems)
11
*******************************************************************************/
12
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
14
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.dom.ast.IType;
16
import org.eclipse.cdt.core.dom.ast.ITypedef;
17
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
18
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
19
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedefSpecialization;
20
import org.eclipse.cdt.internal.core.index.CPPTypedefClone;
21
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
22
import org.eclipse.cdt.internal.core.index.IIndexType;
23
import org.eclipse.cdt.internal.core.pdom.db.Database;
24
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
25
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
26
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
27
import org.eclipse.core.runtime.CoreException;
29
class PDOMCPPTypedefSpecialization extends PDOMCPPSpecialization implements ITypedef, ITypeContainer,
32
private static final int TYPE_OFFSET = PDOMCPPSpecialization.RECORD_SIZE + 0;
34
@SuppressWarnings("hiding")
35
protected static final int RECORD_SIZE = TYPE_OFFSET + Database.TYPE_SIZE;
37
public PDOMCPPTypedefSpecialization(PDOMLinkage linkage, PDOMNode parent, ITypedef typedef, PDOMBinding specialized)
38
throws CoreException {
39
super(linkage, parent, (ICPPSpecialization) typedef, specialized);
41
// The following may try to add the same typedef specialization to the index again.
42
// We protect against infinite recursion using a counter inside typedef.
44
if (typedef instanceof CPPTypedefSpecialization) {
45
if (((CPPTypedefSpecialization) typedef).incResolutionDepth(1) >
46
CPPTypedefSpecialization.MAX_RESOLUTION_DEPTH) {
50
linkage.storeType(record + TYPE_OFFSET, typedef.getType());
51
if (PDOMCPPTypedef.introducesRecursion(getType(), getParentNodeRec(), getNameCharArray())) {
52
linkage.storeType(record + TYPE_OFFSET, null);
56
if (typedef instanceof CPPTypedefSpecialization) {
57
((CPPTypedefSpecialization) typedef).incResolutionDepth(-1);
62
public PDOMCPPTypedefSpecialization(PDOMLinkage linkage, long record) {
63
super(linkage, record);
67
protected int getRecordSize() {
72
public int getNodeType() {
73
return IIndexCPPBindingConstants.CPP_TYPEDEF_SPECIALIZATION;
76
public IType getType() {
78
return getLinkage().loadType(record + TYPE_OFFSET);
79
} catch (CoreException e) {
85
public boolean isSameType(IType o) {
88
if( o instanceof ITypedef ) {
91
return t.isSameType( ((ITypedef)o).getType());
97
return t.isSameType( o );
101
public void setType(IType type) {
102
throw new UnsupportedOperationException();
106
* @see java.lang.Object#clone()
109
public Object clone() {
110
return new CPPTypedefClone(this);