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
* Andrew Ferguson (Symbian)
11
* Markus Schorn (Wind River Systems)
12
*******************************************************************************/
13
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.ITypedef;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
21
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
22
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance;
23
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
24
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
25
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
26
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
27
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
28
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
29
import org.eclipse.core.runtime.CoreException;
32
* Result of instantiating a class template.
34
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
36
private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
39
* The size in bytes of a PDOMCPPClassInstance record in the database.
41
@SuppressWarnings("hiding")
42
protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE + 4;
44
public PDOMCPPClassInstance(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding orig)
45
throws CoreException {
46
super(linkage, parent, classType, orig);
47
final ICPPTemplateInstance asInstance= (ICPPTemplateInstance) classType;
48
final long argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
49
getDB().putRecPtr(record + ARGUMENTS, argListRec);
52
public PDOMCPPClassInstance(PDOMLinkage linkage, long bindingRecord) {
53
super(linkage, bindingRecord);
57
protected int getRecordSize() {
62
public int getNodeType() {
63
return IIndexCPPBindingConstants.CPP_CLASS_INSTANCE;
66
public ICPPTemplateDefinition getTemplateDefinition() {
67
return (ICPPTemplateDefinition) getSpecializedBinding();
70
public ICPPTemplateArgument[] getTemplateArguments() {
72
final long rec= getPDOM().getDB().getRecPtr(record + ARGUMENTS);
73
return PDOMCPPArgumentList.getArguments(this, rec);
74
} catch (CoreException e) {
76
return ICPPTemplateArgument.EMPTY_ARGUMENTS;
80
public boolean isExplicitSpecialization() {
81
return !(getCompositeScope() instanceof ICPPClassSpecializationScope);
85
public boolean isSameType(IType type) {
86
if (type instanceof ITypedef) {
87
return type.isSameType(this);
90
if (type instanceof PDOMNode) {
91
PDOMNode node= (PDOMNode) type;
92
if (node.getPDOM() == getPDOM()) {
93
return node.getRecord() == getRecord();
97
return CPPClassInstance.isSameClassInstance(this, type);
101
public IType[] getArguments() {
102
return CPPTemplates.getArguments(getTemplateArguments());