~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
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;
 
14
 
 
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;
 
30
 
 
31
/**
 
32
 * Result of instantiating a class template.
 
33
 */
 
34
class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance {
 
35
        
 
36
        private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
 
37
        
 
38
        /**
 
39
         * The size in bytes of a PDOMCPPClassInstance record in the database.
 
40
         */
 
41
        @SuppressWarnings("hiding")
 
42
        protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE + 4;
 
43
        
 
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);
 
50
        }
 
51
        
 
52
        public PDOMCPPClassInstance(PDOMLinkage linkage, long bindingRecord) {
 
53
                super(linkage, bindingRecord);
 
54
        }
 
55
        
 
56
        @Override
 
57
        protected int getRecordSize() {
 
58
                return RECORD_SIZE;
 
59
        }
 
60
 
 
61
        @Override
 
62
        public int getNodeType() {
 
63
                return IIndexCPPBindingConstants.CPP_CLASS_INSTANCE;
 
64
        }
 
65
 
 
66
        public ICPPTemplateDefinition getTemplateDefinition() {
 
67
                return (ICPPTemplateDefinition) getSpecializedBinding();
 
68
        }
 
69
                
 
70
        public ICPPTemplateArgument[] getTemplateArguments() {
 
71
                try {
 
72
                        final long rec= getPDOM().getDB().getRecPtr(record + ARGUMENTS);
 
73
                        return PDOMCPPArgumentList.getArguments(this, rec);
 
74
                } catch (CoreException e) {
 
75
                        CCorePlugin.log(e);
 
76
                        return ICPPTemplateArgument.EMPTY_ARGUMENTS;
 
77
                }
 
78
        }
 
79
        
 
80
        public boolean isExplicitSpecialization() {
 
81
                return !(getCompositeScope() instanceof ICPPClassSpecializationScope);
 
82
        }
 
83
 
 
84
        @Override
 
85
        public boolean isSameType(IType type) {
 
86
                if (type instanceof ITypedef) {
 
87
                        return type.isSameType(this);
 
88
                }
 
89
                
 
90
                if (type instanceof PDOMNode) {
 
91
                        PDOMNode node= (PDOMNode) type;
 
92
                        if (node.getPDOM() == getPDOM()) {
 
93
                                return node.getRecord() == getRecord();
 
94
                        }
 
95
                }
 
96
                
 
97
                return CPPClassInstance.isSameClassInstance(this, type);
 
98
        }
 
99
        
 
100
        @Deprecated
 
101
        public IType[] getArguments() {
 
102
                return CPPTemplates.getArguments(getTemplateArguments());
 
103
        }
 
104
}