View | Details | Raw Unified | Return to bug 167098 | Differences between
and this patch

Collapse All | Expand All

(-)parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java (-2 / +5 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Markus Schorn (Wind River Systems)
10
 * Markus Schorn (Wind River Systems)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
/*
13
/*
13
 * Created on Mar 11, 2005
14
 * Created on Mar 11, 2005
Lines 1107-1116 Link Here
1107
		assertTrue( B2 instanceof ICPPSpecialization );
1108
		assertTrue( B2 instanceof ICPPSpecialization );
1108
		assertSame( ((ICPPSpecialization)B2).getSpecializedBinding(), B );
1109
		assertSame( ((ICPPSpecialization)B2).getSpecializedBinding(), B );
1109
		
1110
		
1110
		//we might want this to be a specialization of a specialization, but for now, this is easier
1111
		ICPPMethod f1 = (ICPPMethod) col.getName(20).resolveBinding();
1111
		ICPPMethod f1 = (ICPPMethod) col.getName(20).resolveBinding();
1112
		assertTrue( f1 instanceof ICPPSpecialization );
1112
		assertTrue( f1 instanceof ICPPSpecialization );
1113
		assertSame( ((ICPPSpecialization)f1).getSpecializedBinding(), f );
1113
		assertTrue( ((ICPPSpecialization)f1).getSpecializedBinding() instanceof ICPPMethod );
1114
		ICPPMethod f2 = (ICPPMethod) ((ICPPSpecialization)f1).getSpecializedBinding();
1115
		assertTrue( f2 instanceof ICPPSpecialization );
1116
		assertSame( ((ICPPSpecialization)f2).getSpecializedBinding(), f );
1114
		
1117
		
1115
		IFunctionType ft = f1.getType();
1118
		IFunctionType ft = f1.getType();
1116
		assertTrue( ft.getReturnType() instanceof IBasicType );
1119
		assertTrue( ft.getReturnType() instanceof IBasicType );
(-)parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java (-1 / +1 lines)
Lines 72-78 Link Here
72
	//	class Int {};
72
	//	class Int {};
73
	//	Int a,b;
73
	//	Int a,b;
74
	//	Int c= left(a,b);
74
	//	Int c= left(a,b);
75
	public void _testSimpleFunctionTemplate() {
75
	public void testSimpleFunctionTemplate() {
76
		IBinding b0 = getBindingFromASTName("sanity();", 6);
76
		IBinding b0 = getBindingFromASTName("sanity();", 6);
77
		IBinding b1 = getBindingFromASTName("left(a,b)", 4);
77
		IBinding b1 = getBindingFromASTName("left(a,b)", 4);
78
	}
78
	}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMQualifierType.java (-5 / +43 lines)
Lines 134-144 Link Here
134
	}
134
	}
135
135
136
	public Object clone() {
136
	public Object clone() {
137
		try {
137
		return new PDOMQualifierTypeClone(this);
138
			return super.clone();
138
	}
139
		} catch (CloneNotSupportedException e) {
139
	
140
			CCorePlugin.log(e);
140
	private static class PDOMQualifierTypeClone implements IQualifierType, ITypeContainer, IIndexType {
141
			return null;
141
		private final IQualifierType delegate;
142
		private IType type = null;
143
		
144
		public PDOMQualifierTypeClone(IQualifierType qualifier) {
145
			this.delegate = qualifier;
146
		}
147
		public IType getType() throws DOMException {
148
			if (type == null) {
149
				return delegate.getType();
150
			}
151
			return type;
152
		}
153
		public boolean isConst() throws DOMException {
154
			return delegate.isConst();
155
		}
156
		public boolean isVolatile() throws DOMException {
157
			return delegate.isVolatile();
158
		}
159
		public boolean isSameType(IType type) {
160
		    if( type instanceof ITypedef )
161
		        return type.isSameType( this );
162
		    if( !( type instanceof IQualifierType ) ) 
163
		        return false;
164
		    
165
		    IQualifierType pt = (IQualifierType) type;
166
		    try {
167
				if( isConst() == pt.isConst() && isVolatile() == pt.isVolatile() ) {
168
					IType myType= getType();
169
				    return myType != null && myType.isSameType( pt.getType() );
170
				}
171
			} catch (DOMException e) {
172
			}
173
		    return false;
174
		}
175
		public void setType(IType type) {
176
			this.type = type;
177
		}
178
		public Object clone() {
179
			return new PDOMQualifierTypeClone(this);
142
		}
180
		}
143
	}
181
	}
144
}
182
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMBinding.java (-2 / +3 lines)
Lines 20-25 Link Here
20
import org.eclipse.cdt.core.dom.ast.DOMException;
20
import org.eclipse.cdt.core.dom.ast.DOMException;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
22
import org.eclipse.cdt.core.dom.ast.IScope;
22
import org.eclipse.cdt.core.dom.ast.IScope;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
23
import org.eclipse.cdt.core.index.IIndexBinding;
24
import org.eclipse.cdt.core.index.IIndexBinding;
24
import org.eclipse.cdt.internal.core.index.IIndexFragment;
25
import org.eclipse.cdt.internal.core.index.IIndexFragment;
25
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
26
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
Lines 168-174 Link Here
168
		return null;
169
		return null;
169
	}
170
	}
170
	
171
	
171
	public final IScope getScope() throws DOMException {
172
	public final IScope getScope() {
172
		try {
173
		try {
173
			IBinding parent = getParentBinding(); 
174
			IBinding parent = getParentBinding(); 
174
			if(parent instanceof IScope) {
175
			if(parent instanceof IScope) {
Lines 224-230 Link Here
224
		try {
225
		try {
225
			PDOMNode node = this;
226
			PDOMNode node = this;
226
			while (node != null) {
227
			while (node != null) {
227
				if (node instanceof PDOMBinding) {							
228
				if (node instanceof PDOMBinding && !(node instanceof ICPPTemplateInstance)) {							
228
					result.add(0, ((PDOMBinding)node).getName());
229
					result.add(0, ((PDOMBinding)node).getName());
229
				}
230
				}
230
				node = node.getParentNode();
231
				node = node.getParentNode();
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMPointerType.java (-6 / +47 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 QNX Software Systems and others.
2
 * Copyright (c) 2006, 2007 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 136-146 Link Here
136
	}
136
	}
137
137
138
	public Object clone() {
138
	public Object clone() {
139
		try {
139
		return new PDOMPointerTypeClone(this);
140
			return super.clone();
140
	}
141
		} catch (CloneNotSupportedException e) {
141
	
142
			CCorePlugin.log(e);
142
	protected static class PDOMPointerTypeClone implements IPointerType, ITypeContainer, IIndexType {
143
			return null;
143
		protected final IPointerType delegate;
144
		private IType type = null;
145
		
146
		public PDOMPointerTypeClone(IPointerType pointer) {
147
			this.delegate = pointer;
148
		}
149
		public IType getType() throws DOMException {
150
			if (type == null) {
151
				return delegate.getType();
152
			}
153
			return type;
154
		}
155
		public boolean isConst() throws DOMException {
156
			return delegate.isConst();
157
		}
158
		public boolean isVolatile() throws DOMException {
159
			return delegate.isVolatile();
160
		}
161
		public boolean isSameType(IType type) {
162
			if( type instanceof ITypedef )
163
			    return ((ITypedef)type).isSameType( this );
164
			
165
			if( !( type instanceof IPointerType )) 
166
			    return false;
167
			
168
			IPointerType rhs = (IPointerType) type;
169
			try {
170
				if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) {
171
					IType type1= getType();
172
					if (type1 != null) {
173
						return type1.isSameType(rhs.getType());
174
					}
175
				}
176
			} catch (DOMException e) {
177
			}
178
			return false;
179
		}
180
		public void setType(IType type) {
181
			this.type = type;
182
		}
183
		public Object clone() {
184
			return new PDOMPointerTypeClone(this);
144
		}
185
		}
145
	}
186
	}
146
}
187
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java (+12 lines)
Lines 195-200 Link Here
195
		}
195
		}
196
	}
196
	}
197
197
198
	public String toString() {
199
		try {
200
			Database db = pdom.getDB();
201
			int bindingRec = db.getInt(record + BINDING_REC_OFFSET);
202
			PDOMBinding binding = pdom.getBinding(bindingRec);
203
			return binding != null ? binding.getName() : null;
204
		} catch (CoreException e) {
205
			CCorePlugin.log(e);
206
			return null;
207
		}
208
	}
209
	
198
	private byte getFlags(int mask) throws CoreException {
210
	private byte getFlags(int mask) throws CoreException {
199
		return (byte) (pdom.getDB().getByte(record + FLAGS) & mask);
211
		return (byte) (pdom.getDB().getByte(record + FLAGS) & mask);
200
	}
212
	}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMArrayType.java (-2 / +44 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 93-98 Link Here
93
	}
93
	}
94
	
94
	
95
	public Object clone() {
95
	public Object clone() {
96
		throw new PDOMNotImplementedError();
96
		return new PDOMArrayTypeClone(this);
97
	}
98
	
99
	private static class PDOMArrayTypeClone implements IIndexType, IArrayType, ITypeContainer {
100
		private final IArrayType delegate;
101
		private IType type = null;
102
		
103
		public PDOMArrayTypeClone(IArrayType array) {
104
			this.delegate = array;
105
		}
106
		public boolean isSameType(IType type) {
107
			if( type instanceof ITypedef )
108
			    return ((ITypedef)type).isSameType( this );
109
			
110
			if( !( type instanceof IArrayType )) 
111
			    return false;
112
			
113
			try {
114
				IType type1= this.getType();
115
				if( type1 == null )
116
				    return false;
117
				
118
				IArrayType rhs = (IArrayType) type;
119
				return type1.isSameType( rhs.getType() );
120
			} catch (DOMException e) {
121
			}
122
			return false;
123
		}
124
		public IASTExpression getArraySizeExpression() throws DOMException {
125
			return delegate.getArraySizeExpression();
126
		}
127
		public IType getType() throws DOMException {
128
			if (type == null) {
129
				return delegate.getType();
130
			}
131
			return type;
132
		}
133
		public void setType(IType type) {
134
			this.type = type;
135
		}
136
		public Object clone() {
137
			return new PDOMArrayTypeClone(this);
138
		}
97
	}
139
	}
98
}
140
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java (-20 / +35 lines)
Lines 31-36 Link Here
31
import org.eclipse.cdt.core.dom.ast.IType;
31
import org.eclipse.cdt.core.dom.ast.IType;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
33
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
33
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
34
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
34
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
35
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
35
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
36
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
36
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
37
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
Lines 191-201 Link Here
191
	 * @throws CoreException
192
	 * @throws CoreException
192
	 */
193
	 */
193
	protected PDOMNode getAdaptedParent(IBinding binding, boolean createFileLocalScope, boolean addParent) throws CoreException {
194
	protected PDOMNode getAdaptedParent(IBinding binding, boolean createFileLocalScope, boolean addParent) throws CoreException {
195
		IBinding scopeBinding = null;
196
		
197
		if (binding instanceof ICPPTemplateInstance) {
198
			scopeBinding = ((ICPPTemplateInstance)binding).getTemplateDefinition();
199
		} else {
194
		try {
200
		try {
195
		IScope scope = binding.getScope();
201
		IScope scope = binding.getScope();
196
		if (scope == null) {
202
		if (scope == null) {
197
			if (binding instanceof IIndexBinding) {
203
			if (binding instanceof ICPPDeferredTemplateInstance) {
198
				IIndexBinding ib= (IIndexBinding) binding;
204
				ICPPDeferredTemplateInstance deferred = (ICPPDeferredTemplateInstance) binding;
205
				ICPPTemplateDefinition template = deferred.getTemplateDefinition();
206
				scope = template.getScope();
207
			} 
208
			
209
			IIndexBinding ib = (binding instanceof IIndexBinding) ? (IIndexBinding) binding : null;
210
			
211
			if (ib == null && binding instanceof ICPPSpecialization) {
212
				IBinding spec = ((ICPPSpecialization)binding).getSpecializedBinding();
213
				if (spec instanceof IIndexBinding) {
214
					ib = (IIndexBinding) spec;
215
				}
216
			}
217
			
218
			if (ib != null) {
199
				// don't adapt file local bindings from other fragments to this one.
219
				// don't adapt file local bindings from other fragments to this one.
200
				if (ib.isFileLocal()) {
220
				if (ib.isFileLocal()) {
201
					return null;
221
					return null;
Lines 204-216 Link Here
204
				return this;
224
				return this;
205
			}
225
			}
206
			
226
			
207
			if (binding instanceof ICPPDeferredTemplateInstance) {
227
			return null;
208
				ICPPDeferredTemplateInstance deferred = (ICPPDeferredTemplateInstance) binding;
209
				ICPPTemplateDefinition template = deferred.getTemplateDefinition();
210
				scope = template.getScope();
211
			} else {
212
				return null;
213
			}
214
		}
228
		}
215
		 		
229
		 		
216
		if(scope instanceof IIndexScope) {
230
		if(scope instanceof IIndexScope) {
Lines 245-251 Link Here
245
			return this;
259
			return this;
246
		}
260
		}
247
		else {
261
		else {
248
			IBinding scopeBinding = null;
249
			if (scope instanceof CPPClassSpecializationScope) {
262
			if (scope instanceof CPPClassSpecializationScope) {
250
				scopeBinding = ((CPPClassSpecializationScope)scope).getClassType();
263
				scopeBinding = ((CPPClassSpecializationScope)scope).getClassType();
251
			} else {
264
			} else {
Lines 254-273 Link Here
254
					scopeBinding = ((IASTName) scopeName).resolveBinding();
267
					scopeBinding = ((IASTName) scopeName).resolveBinding();
255
				}	
268
				}	
256
			}
269
			}
257
			if (scopeBinding != null) {
258
				PDOMBinding scopePDOMBinding = null;
259
				if (addParent) {
260
					scopePDOMBinding = addBinding(scopeBinding);
261
				} else {
262
					scopePDOMBinding = adaptBinding(scopeBinding);
263
				}
264
				if (scopePDOMBinding != null)
265
					return scopePDOMBinding;
266
			}
267
		}
270
		}
268
		} catch (DOMException e) {
271
		} catch (DOMException e) {
269
			throw new CoreException(Util.createStatus(e));
272
			throw new CoreException(Util.createStatus(e));
270
		}
273
		}
274
		}
275
		
276
		if (scopeBinding != null) {
277
			PDOMBinding scopePDOMBinding = null;
278
			if (addParent) {
279
				scopePDOMBinding = addBinding(scopeBinding);
280
			} else {
281
				scopePDOMBinding = adaptBinding(scopeBinding);
282
			}
283
			if (scopePDOMBinding != null)
284
				return scopePDOMBinding;
285
		}
271
		return null;
286
		return null;
272
	}
287
	}
273
	
288
	
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java (-272 / +87 lines)
Lines 17-40 Link Here
17
17
18
import org.eclipse.cdt.core.dom.IName;
18
import org.eclipse.cdt.core.dom.IName;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
20
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
21
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.IASTName;
22
import org.eclipse.cdt.core.dom.ast.IASTNode;
21
import org.eclipse.cdt.core.dom.ast.IASTNode;
23
import org.eclipse.cdt.core.dom.ast.IBinding;
22
import org.eclipse.cdt.core.dom.ast.IBinding;
24
import org.eclipse.cdt.core.dom.ast.IScope;
23
import org.eclipse.cdt.core.dom.ast.IScope;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
28
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
29
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
30
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
31
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
28
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
29
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
30
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
33
import org.eclipse.cdt.core.parser.util.ArrayUtil;
31
import org.eclipse.cdt.core.parser.util.ArrayUtil;
34
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
35
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
32
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
36
import org.eclipse.cdt.core.parser.util.ObjectMap;
33
import org.eclipse.cdt.core.parser.util.ObjectMap;
37
import org.eclipse.cdt.core.parser.util.ObjectSet;
38
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
34
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
39
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
35
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
40
36
Lines 42-152 Link Here
42
 * @author aniefer
38
 * @author aniefer
43
 */
39
 */
44
public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternalScope {
40
public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternalScope {
45
	private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray();  //$NON-NLS-1$
46
47
	private CharArrayObjectMap bindings;
48
	private ObjectMap instanceMap = ObjectMap.EMPTY_MAP;
41
	private ObjectMap instanceMap = ObjectMap.EMPTY_MAP;
49
	
42
	final private ICPPSpecialization specialization;
50
	private ICPPSpecialization specialization;
51
	private boolean isFullyCached = false;
52
	private boolean doneConstructors = false;
53
	
43
	
54
	/**
44
	/**
55
	 * @param instance
45
	 * @param instance
56
	 */
46
	 */
57
	public CPPClassSpecializationScope(CPPClassSpecialization specialization ) {
47
	public CPPClassSpecializationScope( ICPPSpecialization specialization ) {
58
		this.specialization = specialization;
48
		this.specialization = specialization;
59
	}
49
	}
60
	
61
	/**
62
	 * @param instance
63
	 */
64
	public CPPClassSpecializationScope(CPPClassInstance instance ) {
65
		this.specialization = instance;
66
	}
67
50
68
	private ICPPClassType getOriginalClass(){
51
	private ICPPClassType getOriginalClass(){
69
		return (ICPPClassType) specialization.getSpecializedBinding();
52
		return (ICPPClassType) specialization.getSpecializedBinding();
70
	}
53
	}
71
	public boolean isFullyCached(){
54
	
72
		if( !isFullyCached ){
55
	private IBinding getInstance(IBinding binding) {
73
			CPPSemantics.LookupData data = new CPPSemantics.LookupData();
56
		if( instanceMap.containsKey( binding ) ) {
74
			try {
57
			return (IBinding) instanceMap.get( binding );
75
				CPPSemantics.lookupInScope( data, this, null );
58
		} else if (!(binding instanceof ICPPClassTemplatePartialSpecialization)) {
76
			} catch (DOMException e) {
59
			IBinding spec = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() );
77
			}
60
			if( instanceMap == ObjectMap.EMPTY_MAP )
61
				instanceMap = new ObjectMap(2);
62
			instanceMap.put( binding, spec );
63
			return spec;
78
		}
64
		}
79
		return true;
65
		return null;
80
	}
66
	}
81
	
67
	
82
	public IBinding getBinding( IASTName name, boolean forceResolve ) {
68
	public IBinding getBinding( IASTName name, boolean forceResolve ) throws DOMException {
83
		char [] c = name.toCharArray();
69
		char [] c = name.toCharArray();
84
	    if( bindings == null )
70
		
85
	        return null;
71
	    if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) )
86
	    
72
	    	if (!CPPClassScope.isConstructorReference( name ))
87
	    if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) ){
73
	    		return specialization;
88
            if (CPPClassScope.isConstructorReference( name ))
74
89
            	c = CONSTRUCTOR_KEY;
75
		ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
90
            else
76
		IScope classScope = specialized.getCompositeScope();
91
            	return specialization;
77
		IBinding[] bindings = classScope != null ? classScope.find(name.toString()) : null;
92
        }
78
		
93
	        
79
		if (bindings == null) return null;
94
	    Object cache = bindings.get( c );
80
    	
95
	    if( cache != null ){
81
		IBinding[] specs = new IBinding[0];
96
	    	int i = ( cache instanceof ObjectSet ) ? 0 : -1;
82
		for (int i = 0; i < bindings.length; i++) {
97
	    	ObjectSet set = ( cache instanceof ObjectSet ) ? (ObjectSet) cache : null;
83
			specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i]));
98
	    	Object obj = ( set != null ) ? set.keyAt( i ) : cache;
84
		}
99
	    	IBinding [] bs = null;
85
		specs = (IBinding[]) ArrayUtil.trim(IBinding.class, specs);
100
	    	IBinding binding = null;
86
    	return CPPSemantics.resolveAmbiguities( name, specs );
101
	    	while( obj != null ){
102
	    		if( obj instanceof IASTName ){
103
	    			IASTName n = (IASTName) obj;
104
	    			if( n instanceof ICPPASTQualifiedName ){
105
    					IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
106
    					n = ns[ ns.length - 1 ];
107
    				}
108
	    			if( instanceMap.containsKey( n ) ){
109
	    				binding = (IBinding) instanceMap.get( n );
110
	    			} else {
111
		    			binding = CPPClassScope.shouldResolve(forceResolve, n, name) ? n.resolveBinding() : n.getBinding();
112
		    			if (binding instanceof ICPPClassTemplatePartialSpecialization ){
113
		    			    binding = null;
114
		    			}
115
		    			if( binding != null ){
116
		    				binding = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() );
117
		    				if( instanceMap == ObjectMap.EMPTY_MAP )
118
		    					instanceMap = new ObjectMap(2);
119
			        		instanceMap.put( n, binding );
120
		    			}
121
	    			}
122
	    		} else if( obj instanceof IBinding ){
123
	    			if( instanceMap.containsKey( obj ) ){
124
	    				binding = (IBinding) instanceMap.get( obj );
125
	    			} else {
126
	    				binding = CPPTemplates.createSpecialization( this, (IBinding) obj, specialization.getArgumentMap()  );
127
	    				if( instanceMap == ObjectMap.EMPTY_MAP )
128
	    					instanceMap = new ObjectMap(2);
129
		        		instanceMap.put( obj, binding );
130
	    			}
131
	    		}
132
	    		if( binding != null ){
133
	    			if( i == -1 )
134
	    				return binding;
135
    				bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, binding );
136
    				binding = null;
137
	    		}
138
	    		if( i != -1 && ++i < set.size() ){
139
	    			obj = set.keyAt( i );
140
	    		} else {
141
	    			obj = null;
142
	    		}
143
	    	}
144
	    	bs = (IBinding[]) ArrayUtil.trim( IBinding.class, bs );
145
	    	if( bs.length  == 1 )
146
	    		return bs[0];
147
	    	return CPPSemantics.resolveAmbiguities( name, bs );
148
	    }
149
		return null;
150
	}
87
	}
151
88
152
	/* (non-Javadoc)
89
	/* (non-Javadoc)
Lines 160-287 Link Here
160
	 * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
97
	 * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
161
	 */
98
	 */
162
	public ICPPMethod[] getImplicitMethods() {
99
	public ICPPMethod[] getImplicitMethods() {
163
		// TODO Auto-generated method stub
100
		//implicit methods shouldn't have implicit specializations
164
		return null;
101
		return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
165
	}
102
	}
166
103
167
	/* (non-Javadoc)
104
	/* (non-Javadoc)
168
	 * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
105
	 * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
169
	 */
106
	 */
170
	public IName getScopeName() {
107
	public IName getScopeName() {
171
		return (IASTName) ((ICPPInternalBinding)specialization).getDefinition();
108
		if (specialization instanceof ICPPInternalBinding)
109
			return (IASTName) ((ICPPInternalBinding)specialization).getDefinition();
110
		//TODO: get the scope name for non-internal bindings
111
		return null;
172
	}
112
	}
173
113
174
	public void addName(IASTName name) {
114
	protected ICPPConstructor [] getConstructors() throws DOMException {
175
		if( name instanceof ICPPASTQualifiedName )
115
		ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
176
			return;
116
		ICPPConstructor[] bindings = specialized.getConstructors();
177
		
117
		
178
		if( bindings == null )
118
		if (bindings == null) return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
179
			bindings = new CharArrayObjectMap(1);		
180
		char [] c = name.toCharArray();
181
		
182
		IASTNode parent = name.getParent();
183
		if( parent instanceof IASTDeclarator && CPPVisitor.isConstructor( this, (IASTDeclarator) parent ) ){
184
			c = CONSTRUCTOR_KEY;
185
		}
186
		Object o = bindings.get( c );
187
		if( o != null ){
188
		    if( o instanceof ObjectSet ){
189
		    	((ObjectSet)o).put( name );
190
		    } else {
191
		    	ObjectSet temp = new ObjectSet( 2 );
192
		    	temp.put( o );
193
		    	temp.put( name );
194
		        bindings.put( c, temp );
195
		    }
196
		} else {
197
		    bindings.put( c, name );
198
		}
199
	}
200
201
	protected ICPPConstructor [] getConstructors( ){
202
		if( bindings == null ) 
203
			return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
204
		
119
		
205
		if( !doneConstructors ){
120
    	ICPPConstructor[] specs = new ICPPConstructor[0];
206
			ICPPConstructor[] ctors;
121
		for (int i = 0; i < bindings.length; i++) {
207
			try {
122
			specs = (ICPPConstructor[]) ArrayUtil.append(ICPPConstructor.class, specs, getInstance(bindings[i]));
208
				ctors = ((ICPPClassType)specialization.getSpecializedBinding()).getConstructors();
209
				for (int i = 0; i < ctors.length; i++) {
210
					addBinding( ctors[i] );
211
				}
212
				doneConstructors = true;
213
			} catch (DOMException e) {
214
			}
215
		}
216
		ICPPConstructor[] ctors =  CPPClassScope.getConstructors( bindings, true );
217
		for (int i = 0; i < ctors.length; i++) {
218
			if( instanceMap.containsKey( ctors[i] ) ){
219
				ctors[i] = (ICPPConstructor) instanceMap.get( ctors[i] );
220
			} else {
221
				IBinding b = CPPTemplates.createSpecialization( this, ctors[i], specialization.getArgumentMap() ); 
222
				if( instanceMap == ObjectMap.EMPTY_MAP )
223
					instanceMap = new ObjectMap(2);
224
        		instanceMap.put( ctors[i], b );
225
        		ctors[i] = (ICPPConstructor) b;
226
			}
227
		}
123
		}
228
		return ctors;
124
		return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, specs);
229
	}
125
	}
230
	
126
	
231
	protected ICPPMethod[] getConversionOperators() {
127
	protected ICPPMethod[] getConversionOperators() {
232
		if( bindings == null ) 
128
		ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
233
			return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
234
		
235
		ICPPMethod [] result = null;
236
		
129
		
237
		Object[] values = bindings.valueArray();
130
		if (!(specialized instanceof ICPPInternalClassType)) {
238
		for (int i = 0; i < values.length; i++) {
131
			return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
239
	    	int j = ( values[i] instanceof ObjectSet ) ? 0 : -1;
240
	    	ObjectSet set = ( values[i] instanceof ObjectSet ) ? (ObjectSet) values[i] : null;
241
	    	Object obj = ( set != null ) ? set.keyAt( j ) : values[i];
242
	    	IBinding binding = null;
243
	    	while( obj != null ){
244
	    		if( obj instanceof IASTName ){
245
	    			IASTName n = (IASTName) obj;
246
	    			if( n instanceof ICPPASTQualifiedName ){
247
    					IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
248
    					n = ns[ ns.length - 1 ];
249
    				}
250
	    			
251
	    			if (n instanceof ICPPASTConversionName) {
252
		    			if( instanceMap.containsKey( n ) ){
253
		    				binding = (IBinding) instanceMap.get( n );
254
		    			} else {
255
			    			binding = n.resolveBinding();
256
			    			if( binding != null ){
257
			    				binding = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() );
258
			    				if( instanceMap == ObjectMap.EMPTY_MAP )
259
			    					instanceMap = new ObjectMap(2);
260
				        		instanceMap.put( n, binding );
261
			    			}
262
		    			}
263
	    			}
264
	    		} 
265
	    		if( binding != null ){
266
    				result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
267
    				binding = null;
268
	    		}
269
	    		if( j != -1 && ++j < set.size() ){
270
	    			obj = set.keyAt( j );
271
	    		} else {
272
	    			obj = null;
273
	    		}
274
	    	}
275
		}
132
		}
133
 		
134
		ICPPMethod[] bindings = ((ICPPInternalClassType)specialized).getConversionOperators();
276
		
135
		
277
		return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result );
136
		if (bindings == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
278
	}
137
		
279
	
138
    	ICPPMethod[] specs = new ICPPMethod[0];
280
	/* (non-Javadoc)
139
		for (int i = 0; i < bindings.length; i++) {
281
	 * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#setFullyCached(boolean)
140
			specs = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, specs, getInstance(bindings[i]));
282
	 */
141
		}
283
	public void setFullyCached(boolean b) {
142
		return (ICPPMethod[]) ArrayUtil.trim(ICPPMethod.class, specs);
284
		isFullyCached = b;
285
	}
143
	}
286
144
287
	/* (non-Javadoc)
145
	/* (non-Javadoc)
Lines 303-391 Link Here
303
	/* (non-Javadoc)
161
	/* (non-Javadoc)
304
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
162
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
305
	 */
163
	 */
306
	public IBinding[] find(String name) {
164
	public IBinding[] find(String name) throws DOMException {
307
		return find(name, false);
165
		return find(name, false);
308
	}
166
	}
309
	
167
	
310
	/* (non-Javadoc)
168
	/* (non-Javadoc)
311
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
169
	 * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
312
	 */
170
	 */
313
	public IBinding[] find(String name, boolean prefixLookup) {
171
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException {		
314
		if( name != null ) {}
172
		ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
315
		return null;
173
		IBinding[] bindings = specialized.getCompositeScope().find(name.toString(), prefixLookup);
174
		
175
		if (bindings == null) return null;
176
		
177
		IBinding[] specs = new IBinding[0];
178
		for (int i = 0; i < bindings.length; i++) {
179
			specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i]));
180
		}
181
    	return (IBinding[]) ArrayUtil.trim(IBinding.class, specs);
316
	}
182
	}
317
183
318
	/* (non-Javadoc)
184
	/* (non-Javadoc)
319
	 * @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode()
185
	 * @see org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope#isFullyCached()
320
	 */
186
	 */
321
	public IASTNode getPhysicalNode() throws DOMException {
187
	public boolean isFullyCached() throws DOMException {
322
		ICPPClassType cls = getOriginalClass();
188
		ICPPScope origScope = (ICPPScope) getOriginalClass().getCompositeScope();
323
		ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope();
189
		if (!ASTInternal.isFullyCached(origScope)) {
324
		
190
			CPPSemantics.LookupData data = new CPPSemantics.LookupData();
325
		IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope);
191
			try {
326
		if (node != null) {
192
				CPPSemantics.lookupInScope( data, origScope, null );
327
			return node;
193
			} catch (DOMException e) {
194
			}
328
		}
195
		}
329
		
196
		return true;
330
		IASTNode[] nds= ASTInternal.getDeclarationsOfBinding(cls);
331
332
		if( nds != null && nds.length > 0 )
333
			return nds[0];
334
335
		return null;
336
	}
337
338
    /* (non-Javadoc)
339
     * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
340
     */
341
	public void removeBinding(IBinding binding) {
342
	    char [] name = binding.getNameCharArray();
343
	    if( ! bindings.containsKey( name ) )
344
	        return;
345
	    
346
	    Object obj = bindings.get( name );
347
	    if( obj instanceof ObjectSet ){
348
	        ObjectSet set = (ObjectSet) obj;
349
	        set.remove( binding );
350
	        if( set.size() == 0 )
351
	            bindings.remove( name, 0, name.length );
352
	    } else {
353
	        bindings.remove( name, 0, name.length );
354
	    }
355
	
356
		if( instanceMap != null && instanceMap.containsKey( binding ) )
357
			instanceMap.remove( binding );
358
		isFullyCached = false;
359
	}
360
361
	public void flushCache() {
362
		if( bindings != null )
363
			bindings.clear();
364
		isFullyCached = false;
365
	}
366
367
	public void addBinding(IBinding binding) {
368
        if( bindings == null )
369
            bindings = new CharArrayObjectMap(1);
370
        char [] c = (binding instanceof ICPPConstructor) ? CONSTRUCTOR_KEY : binding.getNameCharArray();
371
        Object o = bindings.get( c );
372
        if( o != null ){
373
            if( o instanceof ObjectSet ){
374
                ((ObjectSet)o).put( binding );
375
            } else {
376
                ObjectSet set = new ObjectSet(2);
377
                set.put( o );
378
                set.put( binding );
379
                bindings.put( c, set );
380
            }
381
        } else {
382
            bindings.put( c, binding );
383
        }
384
	}
197
	}
385
	
198
	
386
	public IBinding getInstance( IBinding binding ){
199
	//this scope does not cache its own names
387
		if( instanceMap != null && instanceMap.containsKey( binding ) )
200
	public void setFullyCached(boolean b) {}
388
			return (IBinding) instanceMap.get( binding );
201
	public void flushCache() {}
389
		return null;
202
	public void addName(IASTName name) {}
390
	}
203
	public IASTNode getPhysicalNode() {return null;}
204
	public void removeBinding(IBinding binding) {}
205
	public void addBinding(IBinding binding) {}
391
}
206
}
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java (-3 / +3 lines)
Lines 690-697 Link Here
690
			}
690
			}
691
		} else if( type instanceof ICPPTemplateParameter && argMap.containsKey( type ) ){
691
		} else if( type instanceof ICPPTemplateParameter && argMap.containsKey( type ) ){
692
			newType = (IType) argMap.get( type );
692
			newType = (IType) argMap.get( type );
693
		} else if( type instanceof CPPDeferredClassInstance ){
693
		} else if( type instanceof ICPPInternalDeferredClassInstance ){
694
			newType = ((CPPDeferredClassInstance)type).instantiate( argMap );
694
			newType = ((ICPPInternalDeferredClassInstance)type).instantiate( argMap );
695
		} else if( type instanceof ICPPInternalUnknown ){
695
		} else if( type instanceof ICPPInternalUnknown ){
696
		    IBinding binding;
696
		    IBinding binding;
697
            try {
697
            try {
Lines 1145-1151 Link Here
1145
		}
1145
		}
1146
		return false;
1146
		return false;
1147
	}
1147
	}
1148
	static protected boolean deduceTemplateArgument( ObjectMap map, IType p, IType a ) throws DOMException {
1148
	static public boolean deduceTemplateArgument( ObjectMap map, IType p, IType a ) throws DOMException {
1149
		boolean pIsAReferenceType = ( p instanceof ICPPReferenceType );
1149
		boolean pIsAReferenceType = ( p instanceof ICPPReferenceType );
1150
		p = getParameterTypeForDeduction( p );
1150
		p = getParameterTypeForDeduction( p );
1151
		a = getArgumentTypeForDeduction( a, pIsAReferenceType );
1151
		a = getArgumentTypeForDeduction( a, pIsAReferenceType );
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java (-1 / +4 lines)
Lines 58-64 Link Here
58
    		    IBinding base = bindings[i].getBaseClass();
58
    		    IBinding base = bindings[i].getBaseClass();
59
    		    if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
59
    		    if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
60
    		    	IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
60
    		    	IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
61
    		    	((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase);
61
    		    	specBase = CPPSemantics.getUltimateType(specBase, false);
62
    		    	if (specBase instanceof ICPPClassType) {
63
    		    		((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase);
64
    		    	}
62
    		    }
65
    		    }
63
			}
66
			}
64
			return bindings;
67
			return bindings;
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 122-128 Link Here
122
		if( template instanceof IProblemBinding )
122
		if( template instanceof IProblemBinding )
123
			return template;
123
			return template;
124
		if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
124
		if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
125
			return ((CPPTemplateDefinition)template).instantiate( arguments );	
125
			return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments );	
126
		}
126
		}
127
		
127
		
128
		return CPPTemplates.instantiateTemplate( this, arguments, null );
128
		return CPPTemplates.instantiateTemplate( this, arguments, null );
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java (-4 / +19 lines)
Lines 1038-1043 Link Here
1038
						IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
1038
						IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
1039
						if (parent == null) {
1039
						if (parent == null) {
1040
							IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup);
1040
							IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup);
1041
							bindings = appendClassType(bindings, scope, data);
1041
							mergeResults(data, bindings, true);
1042
							mergeResults(data, bindings, true);
1042
							useASTResults = false;
1043
							useASTResults = false;
1043
						} else {
1044
						} else {
Lines 1158-1163 Link Here
1158
		}
1159
		}
1159
	}
1160
	}
1160
1161
1162
	private static IBinding[] appendClassType(IBinding[] bindings, ICPPScope scope, CPPSemantics.LookupData data) throws DOMException {
1163
		if (scope instanceof ICPPClassScope) {
1164
			IBinding binding = ((ICPPClassScope)scope).getClassType();
1165
			char[] c = binding.getNameCharArray();
1166
			char[] n = data.astName.toCharArray();
1167
			if ((data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, true))
1168
					|| (!data.prefixLookup && CharArrayUtils.equals(c, n))) {
1169
				return (IBinding[]) ArrayUtil.append(IBinding.class, bindings, binding);
1170
			}
1171
		}
1172
		return bindings;
1173
	}
1174
	
1161
	private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
1175
	private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
1162
		IScope parentScope= scope.getParent();
1176
		IScope parentScope= scope.getParent();
1163
		// the index cannot return the translation unit as parent scope
1177
		// the index cannot return the translation unit as parent scope
Lines 1213-1224 Link Here
1213
				//is circular inheritance
1227
				//is circular inheritance
1214
				if( ! data.inheritanceChain.containsKey( parent ) ){
1228
				if( ! data.inheritanceChain.containsKey( parent ) ){
1215
					//is this name define in this scope?
1229
					//is this name define in this scope?
1216
					if( data.astName != null && !data.contentAssist && ASTInternal.isFullyCached(parent) )
1230
					if( ASTInternal.isFullyCached(parent) && data.astName != null && !data.contentAssist )
1217
						inherited = parent.getBinding( data.astName, true );
1231
						inherited = parent.getBinding( data.astName, true );
1218
					else if (ASTInternal.getPhysicalNodeOfScope(lookIn) != null
1232
					else if (ASTInternal.getPhysicalNodeOfScope(parent) == null) {
1219
							&& ASTInternal.getPhysicalNodeOfScope(parent) == null)
1220
						inherited = parent.find(data.astName.toString(), data.prefixLookup);
1233
						inherited = parent.find(data.astName.toString(), data.prefixLookup);
1221
					else
1234
						inherited = appendClassType((IBinding[]) inherited, parent, data);
1235
					} else
1222
						inherited = lookupInScope( data, parent, null );
1236
						inherited = lookupInScope( data, parent, null );
1223
					
1237
					
1224
					if( inherited == null || data.contentAssist ){
1238
					if( inherited == null || data.contentAssist ){
Lines 1617-1622 Link Here
1617
					}
1631
					}
1618
				} else if (ASTInternal.getPhysicalNodeOfScope(temp) == null) {
1632
				} else if (ASTInternal.getPhysicalNodeOfScope(temp) == null) {
1619
					IBinding[] bindings = temp.find(data.astName.toString(), data.prefixLookup);
1633
					IBinding[] bindings = temp.find(data.astName.toString(), data.prefixLookup);
1634
					bindings = appendClassType(bindings, temp, data);
1620
					if (bindings != null && bindings.length > 0) {
1635
					if (bindings != null && bindings.length > 0) {
1621
						mergeResults( data, bindings, true );
1636
						mergeResults( data, bindings, true );
1622
						found = true;
1637
						found = true;
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 496-502 Link Here
496
    }
496
    }
497
497
498
	static public boolean hasStorageClass( ICPPInternalFunction function, int storage ){
498
	static public boolean hasStorageClass( ICPPInternalFunction function, int storage ){
499
	    ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) function.getDefinition();
499
		IASTNode def = function.getDefinition();
500
		while (def instanceof IASTName) {
501
			def = def.getParent();
502
		}
503
	    ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) def;
500
        ICPPASTFunctionDeclarator[] ds = (ICPPASTFunctionDeclarator[]) function.getDeclarations();
504
        ICPPASTFunctionDeclarator[] ds = (ICPPASTFunctionDeclarator[]) function.getDeclarations();
501
        int i = -1;
505
        int i = -1;
502
        do{
506
        do{
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java (-1 / +1 lines)
Lines 103-109 Link Here
103
		if( template instanceof IProblemBinding )
103
		if( template instanceof IProblemBinding )
104
			return template;
104
			return template;
105
		if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
105
		if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
106
			return ((CPPTemplateDefinition)template).instantiate( arguments );	
106
			return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments );	
107
		}
107
		}
108
		
108
		
109
		return CPPTemplates.instantiateTemplate( this, arguments, argumentMap );
109
		return CPPTemplates.instantiateTemplate( this, arguments, argumentMap );
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java (-4 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * IBM - Initial API and implementation
9
 * IBM - Initial API and implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
/*
12
/*
12
 * Created on Apr 22, 2005
13
 * Created on Apr 22, 2005
Lines 97-105 Link Here
97
	}
98
	}
98
	public boolean isStatic(boolean resolveAll) {
99
	public boolean isStatic(boolean resolveAll) {
99
		//TODO resolveAll
100
		//TODO resolveAll
100
		ICPPInternalFunction f = (ICPPInternalFunction) getSpecializedBinding();
101
		IBinding f = getSpecializedBinding();
101
		if( f != null )
102
		if( f instanceof ICPPInternalFunction)
102
			return f.isStatic( resolveAll );
103
			return ((ICPPInternalFunction)f).isStatic( resolveAll );
103
		return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_static );
104
		return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_static );
104
	}
105
	}
105
106
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java (-2 / +5 lines)
Lines 80-86 Link Here
80
    		    IBinding base = bindings[i].getBaseClass();
80
    		    IBinding base = bindings[i].getBaseClass();
81
    		    if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
81
    		    if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
82
    		    	IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
82
    		    	IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
83
    		    	((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase);
83
    		    	specBase = CPPSemantics.getUltimateType(specBase, false);
84
    		    	if (specBase instanceof ICPPClassType) {
85
    		    		((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase);
86
    		    	}
84
    		    }
87
    		    }
85
			}
88
			}
86
			return bindings;
89
			return bindings;
Lines 217-223 Link Here
217
			if (scope != null && scope.getClassType() == this) {
220
			if (scope != null && scope.getClassType() == this) {
218
				//explicit specialization: can use composite type specifier scope
221
				//explicit specialization: can use composite type specifier scope
219
				specScope = scope;
222
				specScope = scope;
220
			} else if (scope != null) {
223
			} else {
221
				//implicit specialization: must specialize bindings in scope
224
				//implicit specialization: must specialize bindings in scope
222
				specScope = new CPPClassSpecializationScope(this);
225
				specScope = new CPPClassSpecializationScope(this);
223
			}	
226
			}	
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 34-40 Link Here
34
 * @author aniefer
34
 * @author aniefer
35
 */
35
 */
36
public class CPPDeferredClassInstance extends CPPInstance implements
36
public class CPPDeferredClassInstance extends CPPInstance implements
37
		ICPPClassType, ICPPDeferredTemplateInstance {
37
		ICPPClassType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
38
38
39
	public IType [] arguments = null;
39
	public IType [] arguments = null;
40
	public ICPPClassTemplate classTemplate = null;
40
	public ICPPClassTemplate classTemplate = null;
Lines 160-166 Link Here
160
			classTemplate = (ICPPClassTemplate) argMap.get( classTemplate );
160
			classTemplate = (ICPPClassTemplate) argMap.get( classTemplate );
161
		}
161
		}
162
		
162
		
163
		return (IType) ((ICPPInternalTemplate)classTemplate).instantiate( newArgs );
163
		return (IType) ((ICPPInternalTemplateInstantiator)classTemplate).instantiate( newArgs );
164
	}
164
	}
165
165
166
	/* (non-Javadoc)
166
	/* (non-Javadoc)
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java (-42 / +185 lines)
Lines 11-16 Link Here
11
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
11
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
12
12
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.Collections;
14
import java.util.List;
15
import java.util.List;
15
16
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.core.CCorePlugin;
Lines 30-38 Link Here
30
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
31
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
31
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
33
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
34
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
33
import org.eclipse.cdt.core.index.IIndexBinding;
35
import org.eclipse.cdt.core.index.IIndexBinding;
36
import org.eclipse.cdt.core.parser.util.ArrayUtil;
37
import org.eclipse.cdt.core.parser.util.ObjectMap;
34
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
38
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
35
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
39
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
40
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
36
import org.eclipse.cdt.internal.core.index.IIndexScope;
41
import org.eclipse.cdt.internal.core.index.IIndexScope;
37
import org.eclipse.cdt.internal.core.index.IIndexType;
42
import org.eclipse.cdt.internal.core.index.IIndexType;
38
import org.eclipse.cdt.internal.core.pdom.PDOM;
43
import org.eclipse.cdt.internal.core.pdom.PDOM;
Lines 40-45 Link Here
40
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
45
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
41
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
46
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
42
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
47
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
48
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
43
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
49
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
44
import org.eclipse.core.runtime.CoreException;
50
import org.eclipse.core.runtime.CoreException;
45
51
Lines 50-61 Link Here
50
class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
56
class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
51
		ICPPClassType, ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
57
		ICPPClassType, ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
52
58
53
	private static final int MEMBERLIST = PDOMCPPSpecialization.RECORD_SIZE + 0;
59
	private static final int FIRSTBASE = PDOMCPPSpecialization.RECORD_SIZE + 0;
60
	private static final int MEMBERLIST = PDOMCPPSpecialization.RECORD_SIZE + 4;
54
	
61
	
55
	/**
62
	/**
56
	 * The size in bytes of a PDOMCPPClassSpecialization record in the database.
63
	 * The size in bytes of a PDOMCPPClassSpecialization record in the database.
57
	 */
64
	 */
58
	protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 4;
65
	protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 8;
59
	
66
	
60
	public PDOMCPPClassSpecialization(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized)
67
	public PDOMCPPClassSpecialization(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized)
61
			throws CoreException {
68
			throws CoreException {
Lines 79-90 Link Here
79
		return PDOMCPPLinkage.CPP_CLASS_SPECIALIZATION;
86
		return PDOMCPPLinkage.CPP_CLASS_SPECIALIZATION;
80
	}
87
	}
81
88
89
	public PDOMCPPBase getFirstBase() throws CoreException {
90
		int rec = pdom.getDB().getInt(record + FIRSTBASE);
91
		return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
92
	}
93
94
	private void setFirstBase(PDOMCPPBase base) throws CoreException {
95
		int rec = base != null ? base.getRecord() : 0;
96
		pdom.getDB().putInt(record + FIRSTBASE, rec);
97
	}
98
	
99
	public void addBase(PDOMCPPBase base) throws CoreException {
100
		PDOMCPPBase firstBase = getFirstBase();
101
		base.setNextBase(firstBase);
102
		setFirstBase(base);
103
	}
104
	
105
	public void removeBase(PDOMName pdomName) throws CoreException {
106
		PDOMCPPBase base= getFirstBase();
107
		PDOMCPPBase predecessor= null;
108
		int nameRec= pdomName.getRecord();
109
		while (base != null) {
110
			PDOMName name = base.getBaseClassSpecifierNameImpl();
111
			if (name != null && name.getRecord() == nameRec) {
112
				break;
113
			}
114
			predecessor= base;
115
			base= base.getNextBase();
116
		}
117
		if (base != null) {
118
			if (predecessor != null) {
119
				predecessor.setNextBase(base.getNextBase());
120
			}
121
			else {
122
				setFirstBase(base.getNextBase());
123
			}
124
			base.delete();
125
		}
126
	}
127
	
82
	public IField findField(String name) throws DOMException { fail(); return null; }
128
	public IField findField(String name) throws DOMException { fail(); return null; }
83
	public ICPPMethod[] getAllDeclaredMethods() throws DOMException { fail(); return null; }
129
	public ICPPMethod[] getAllDeclaredMethods() throws DOMException { fail(); return null; }
84
130
85
	public ICPPBase[] getBases() throws DOMException {
131
	public ICPPBase[] getBases() throws DOMException {
86
		//TODO Get bases
132
		if (!(this instanceof ICPPTemplateDefinition) && 
87
		return ICPPBase.EMPTY_BASE_ARRAY;
133
				getSpecializedBinding() instanceof ICPPTemplateDefinition) {
134
			//this is an explicit specialization
135
			try {
136
				List list = new ArrayList();
137
				for (PDOMCPPBase base = getFirstBase(); base != null; base = base.getNextBase())
138
					list.add(base);
139
				Collections.reverse(list);
140
				ICPPBase[] bases = (ICPPBase[])list.toArray(new ICPPBase[list.size()]);
141
				return bases;
142
			} catch (CoreException e) {
143
				CCorePlugin.log(e);
144
			}
145
		} else {
146
			//this is an implicit specialization
147
			ICPPBase[] pdomBases = ((ICPPClassType) getSpecializedBinding()).getBases();
148
149
			if (pdomBases != null) {
150
				ICPPBase[] result = new ICPPBase[pdomBases.length];
151
				
152
				for (int i = 0; i < pdomBases.length; i++) {
153
					PDOMCPPBase pdomBase = (PDOMCPPBase) pdomBases[i];
154
					IType type = (IType) pdomBase.getBaseClass();
155
					type = CPPTemplates.instantiateType(type, getArgumentMap());
156
					type = CPPSemantics.getUltimateType(type, false);
157
					if (type instanceof IBinding) {
158
						result[i] = pdomBase.createSpecialization((IBinding)type);
159
					}
160
				}
161
				
162
				return (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result);
163
			}
164
		}
165
		
166
		return new ICPPBase[0];
88
	}
167
	}
89
168
90
	private static class ConstructorCollector implements IPDOMVisitor {
169
	private static class ConstructorCollector implements IPDOMVisitor {
Lines 103-115 Link Here
103
182
104
	public ICPPConstructor[] getConstructors() throws DOMException {
183
	public ICPPConstructor[] getConstructors() throws DOMException {
105
		try {
184
		try {
106
			if (hasDefinition()) {
185
			ConstructorCollector visitor= new ConstructorCollector();
107
				ConstructorCollector visitor= new ConstructorCollector();
186
			accept(visitor);
108
				accept(visitor);
187
			return visitor.getConstructors();
109
				return visitor.getConstructors();
110
			} else {
111
				return ((ICPPClassType)getSpecializedBinding()).getConstructors();
112
			}
113
		} catch (CoreException e) {
188
		} catch (CoreException e) {
114
			CCorePlugin.log(e);
189
			CCorePlugin.log(e);
115
			return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
190
			return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
Lines 125-140 Link Here
125
	public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
200
	public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
126
201
127
	public IScope getCompositeScope() throws DOMException {
202
	public IScope getCompositeScope() throws DOMException {
128
		try {
203
		return this;
129
			if (hasDefinition()) {
130
				return this;
131
			} else {
132
				return ((ICPPClassType)getSpecializedBinding()).getCompositeScope();
133
			}
134
		} catch (CoreException e) {
135
			CCorePlugin.log(e);
136
			return null;
137
		}
138
	}
204
	}
139
205
140
	public int getKey() throws DOMException {
206
	public int getKey() throws DOMException {
Lines 160-198 Link Here
160
		return this;
226
		return this;
161
	}
227
	}
162
228
229
	private class SpecializationFinder implements IPDOMVisitor {
230
		private ObjectMap specMap;
231
		public SpecializationFinder(IBinding[] specialized) {
232
			specMap = new ObjectMap(specialized.length);
233
			for (int i = 0; i < specialized.length; i++) {
234
				specMap.put(specialized[i], null);
235
			}
236
		}
237
		public boolean visit(IPDOMNode node) throws CoreException {
238
			if (node instanceof ICPPSpecialization) {
239
				IBinding specialized = ((ICPPSpecialization)node).getSpecializedBinding();
240
				if (specMap.containsKey(specialized)) {
241
					ICPPSpecialization specialization = (ICPPSpecialization) specMap.get(node);
242
					if (specialization == null) {
243
						specMap.remove(specialized);
244
						specMap.put(specialized, node);
245
					}
246
				}
247
			}
248
			return false;
249
		}
250
		public void leave(IPDOMNode node) throws CoreException {
251
		}
252
		public ICPPSpecialization[] getSpecializations() {
253
			ICPPSpecialization[] result = new ICPPSpecialization[specMap.size()];
254
			for (int i = 0; i < specMap.size(); i++) {
255
				ICPPSpecialization specialization = (ICPPSpecialization) specMap.getAt(i);
256
				if (specialization != null) {
257
					result[i] = specialization;
258
				} else {
259
					result[i] = CPPTemplates.createSpecialization(
260
							PDOMCPPClassSpecialization.this, (IBinding) specMap
261
									.keyAt(i), getArgumentMap());
262
				}
263
			}
264
			return result;
265
		}
266
	}
267
	
163
	public IBinding[] find(String name) throws DOMException {
268
	public IBinding[] find(String name) throws DOMException {
164
		return find(name, false);
269
		return find(name, false);
165
	}
270
	}
166
271
167
	public IBinding[] find(String name, boolean prefixLookup)
272
	public IBinding[] find(String name, boolean prefixLookup)
168
			throws DOMException {
273
			throws DOMException {
169
		try {
274
		if (!(this instanceof ICPPTemplateDefinition) && 
170
			BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
275
				getSpecializedBinding() instanceof ICPPTemplateDefinition) {
171
			accept(visitor);
276
			//this is an explicit specialization
172
			return visitor.getBindings();
277
			try {
173
		} catch (CoreException e) {
278
				BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
174
			CCorePlugin.log(e);
279
				accept(visitor);
280
				return visitor.getBindings();
281
			} catch (CoreException e) {
282
				CCorePlugin.log(e);
283
			}
284
		} else {
285
			//this is an implicit specialization
286
			try {						
287
				IBinding[] specialized = ((ICPPClassType) getSpecializedBinding())
288
						.getCompositeScope().find(name.toString(), prefixLookup);			
289
				SpecializationFinder visitor = new SpecializationFinder(specialized);
290
				accept(visitor);
291
				return visitor.getSpecializations();
292
			} catch (CoreException e) {
293
				CCorePlugin.log(e);
294
			}
175
		}
295
		}
176
		return null;
296
		return null;
177
	}
297
	}
178
298
	
179
	public IBinding getBinding(IASTName name, boolean resolve)
299
	public IBinding getBinding(IASTName name, boolean resolve)
180
			throws DOMException {
300
			throws DOMException {
181
		try {
301
		if (!(this instanceof ICPPTemplateDefinition) && 
182
		    if (getDBName().equals(name.toCharArray())) {
302
				getSpecializedBinding() instanceof ICPPTemplateDefinition) {
183
		        if (CPPClassScope.isConstructorReference(name)){
303
			//this is an explicit specialization
184
		            return CPPSemantics.resolveAmbiguities(name, getConstructors());
304
			try {
185
		        }
305
			    if (getDBName().equals(name.toCharArray())) {
186
	            //9.2 ... The class-name is also inserted into the scope of the class itself
306
			        if (CPPClassScope.isConstructorReference(name)){
187
	            return this;
307
			            return CPPSemantics.resolveAmbiguities(name, getConstructors());
188
		    }
308
			        }
189
			
309
		            //9.2 ... The class-name is also inserted into the scope of the class itself
190
		    BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
310
		            return this;
191
			accept(visitor);
311
			    }
192
			return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
312
				
193
		} catch (CoreException e) {
313
			    BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
194
			CCorePlugin.log(e);
314
				accept(visitor);
315
				return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
316
			} catch (CoreException e) {
317
				CCorePlugin.log(e);
318
			}
319
		} else {
320
			//this is an implicit specialization
321
			try {			
322
			    if (getDBName().equals(name.toCharArray())) {
323
			        if (!CPPClassScope.isConstructorReference(name)){
324
			        	//9.2 ... The class-name is also inserted into the scope of the class itself
325
			        	return this;
326
			        }
327
			    }
328
				
329
				IBinding[] specialized = ((ICPPClassType) getSpecializedBinding())
330
						.getCompositeScope().find(name.toString());			
331
				SpecializationFinder visitor = new SpecializationFinder(specialized);
332
				accept(visitor);
333
				return CPPSemantics.resolveAmbiguities(name, visitor.getSpecializations());
334
			} catch (CoreException e) {
335
				CCorePlugin.log(e);
336
			}
195
		}
337
		}
338
		
196
		return null;
339
		return null;
197
	}
340
	}
198
	
341
	
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPReferenceType.java (-6 / +40 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *    Bryan Wilkinson (QNX)
10
 *******************************************************************************/ 
11
 *******************************************************************************/ 
11
12
12
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
13
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
Lines 98-108 Link Here
98
	}
99
	}
99
100
100
	public Object clone() {
101
	public Object clone() {
101
		try {
102
		return new PDOMCPPReferenceTypeClone(this);
102
			return super.clone();
103
	}
103
		} catch (CloneNotSupportedException e) {
104
	
104
			CCorePlugin.log(e);
105
	private static class PDOMCPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, IIndexType {
105
			return null;
106
		private final ICPPReferenceType delegate;
107
		private IType type = null;
108
		
109
		public PDOMCPPReferenceTypeClone(ICPPReferenceType reference) {
110
			this.delegate = reference;
111
		}
112
		public IType getType() throws DOMException {
113
			if (type == null) {
114
				return delegate.getType();
115
			}
116
			return type;
117
		}
118
		public boolean isSameType(IType type) {
119
			if( type instanceof ITypedef )
120
			    return type.isSameType(this);
121
			
122
			if( !( type instanceof ICPPReferenceType )) 
123
			    return false;
124
			
125
			ICPPReferenceType rhs = (ICPPReferenceType) type;
126
			try {
127
				IType type1= getType();
128
				if (type1 != null) {
129
					return type1.isSameType(rhs.getType());
130
				}
131
			} catch (DOMException e) {
132
			}
133
			return false;
134
		}
135
		public void setType(IType type) {
136
			this.type = type;
137
		}
138
		public Object clone() {
139
			return new PDOMCPPReferenceTypeClone(this);
106
		}
140
		}
107
	}
141
	}
108
}
142
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionInstance.java (-1 / +2 lines)
Lines 27-32 Link Here
27
import org.eclipse.cdt.internal.core.index.IIndexType;
27
import org.eclipse.cdt.internal.core.index.IIndexType;
28
import org.eclipse.cdt.internal.core.pdom.PDOM;
28
import org.eclipse.cdt.internal.core.pdom.PDOM;
29
import org.eclipse.cdt.internal.core.pdom.db.Database;
29
import org.eclipse.cdt.internal.core.pdom.db.Database;
30
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
30
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
31
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
31
import org.eclipse.core.runtime.CoreException;
32
import org.eclipse.core.runtime.CoreException;
32
33
Lines 60-66 Link Here
60
	 */
61
	 */
61
	protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 12;
62
	protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 12;
62
	
63
	
63
	public PDOMCPPFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMCPPFunctionTemplate instantiated)
64
	public PDOMCPPFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding instantiated)
64
			throws CoreException {
65
			throws CoreException {
65
		super(pdom, parent, (ICPPTemplateInstance) function, instantiated);
66
		super(pdom, parent, (ICPPTemplateInstance) function, instantiated);
66
		
67
		
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredClassInstance.java (-2 / +23 lines)
Lines 23-30 Link Here
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
26
import org.eclipse.cdt.core.parser.util.ObjectMap;
27
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
28
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeferredClassInstance;
29
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
26
import org.eclipse.cdt.internal.core.index.IIndexType;
30
import org.eclipse.cdt.internal.core.index.IIndexType;
27
import org.eclipse.cdt.internal.core.pdom.PDOM;
31
import org.eclipse.cdt.internal.core.pdom.PDOM;
32
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
28
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
33
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
29
import org.eclipse.core.runtime.CoreException;
34
import org.eclipse.core.runtime.CoreException;
30
35
Lines 33-46 Link Here
33
 * 
38
 * 
34
 */
39
 */
35
class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
40
class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
36
		ICPPClassType, IIndexType, ICPPDeferredTemplateInstance {
41
		ICPPClassType, IIndexType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
37
42
38
	/**
43
	/**
39
	 * The size in bytes of a PDOMCPPDeferredClassInstance record in the database.
44
	 * The size in bytes of a PDOMCPPDeferredClassInstance record in the database.
40
	 */
45
	 */
41
	protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 0;
46
	protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 0;
42
	
47
	
43
	public PDOMCPPDeferredClassInstance(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMCPPClassTemplate instantiated)
48
	public PDOMCPPDeferredClassInstance(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding instantiated)
44
			throws CoreException {
49
			throws CoreException {
45
		super(pdom, parent, (ICPPTemplateInstance) classType, instantiated);
50
		super(pdom, parent, (ICPPTemplateInstance) classType, instantiated);
46
	}
51
	}
Lines 105-108 Link Here
105
	public ICPPMethod[] getMethods() throws DOMException { fail(); return null; }
110
	public ICPPMethod[] getMethods() throws DOMException { fail(); return null; }
106
	public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
111
	public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
107
	public Object clone() {fail();return null;}
112
	public Object clone() {fail();return null;}
113
	
114
	/**
115
	 * @param argMap
116
	 * @return
117
	 */
118
	public IType instantiate(ObjectMap argMap) {
119
		IType[] arguments = getArguments();
120
		
121
		IType [] newArgs = new IType[ arguments.length ];
122
		int size = arguments.length;
123
		for( int i = 0; i < size; i++ ){
124
			newArgs[i] = CPPTemplates.instantiateType( arguments[i], argMap );
125
		}
126
		
127
		return (IType) ((ICPPInternalTemplateInstantiator)getTemplateDefinition()).instantiate( newArgs );
128
	}
108
}
129
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBase.java (+27 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.cdt.core.CCorePlugin;
14
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.dom.IName;
15
import org.eclipse.cdt.core.dom.IName;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.IBinding;
17
import org.eclipse.cdt.core.dom.ast.IBinding;
17
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
18
import org.eclipse.cdt.internal.core.pdom.PDOM;
19
import org.eclipse.cdt.internal.core.pdom.PDOM;
Lines 124-127 Link Here
124
	public void delete() throws CoreException {
125
	public void delete() throws CoreException {
125
		pdom.getDB().free(record);
126
		pdom.getDB().free(record);
126
	}
127
	}
128
	
129
	private static class PDOMCPPBaseSpecialization implements ICPPBase {
130
		private PDOMCPPBase base;
131
		private IBinding baseClass;
132
		
133
		public PDOMCPPBaseSpecialization(PDOMCPPBase base, IBinding baseClass) {
134
			this.base = base;
135
			this.baseClass = baseClass;
136
		}
137
		public IBinding getBaseClass() throws DOMException {
138
			return baseClass;
139
		}
140
		public IName getBaseClassSpecifierName() {
141
			return base.getBaseClassSpecifierName();
142
		}
143
		public int getVisibility() throws DOMException {
144
			return base.getVisibility();
145
		}
146
		public boolean isVirtual() throws DOMException {
147
			return base.isVirtual();
148
		}
149
	}
150
	
151
	public ICPPBase createSpecialization(IBinding baseClass) {
152
		return new PDOMCPPBaseSpecialization(this, baseClass);
153
	}
127
}
154
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPTypedef.java (-2 / +67 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 QNX Software Systems and others.
2
 * Copyright (c) 2006, 2007 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-20 Link Here
12
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
12
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
13
13
14
import org.eclipse.cdt.core.CCorePlugin;
14
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.dom.ILinkage;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.DOMException;
17
import org.eclipse.cdt.core.dom.ast.IScope;
16
import org.eclipse.cdt.core.dom.ast.IType;
18
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.ITypedef;
19
import org.eclipse.cdt.core.dom.ast.ITypedef;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
18
import org.eclipse.cdt.internal.core.Util;
21
import org.eclipse.cdt.internal.core.Util;
19
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
22
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
20
import org.eclipse.cdt.internal.core.index.IIndexType;
23
import org.eclipse.cdt.internal.core.index.IIndexType;
Lines 82-87 Link Here
82
		return false;
85
		return false;
83
	}
86
	}
84
87
85
	public Object clone() { fail(); return null; }
86
	public void setType(IType type) { fail(); }
88
	public void setType(IType type) { fail(); }
89
90
	public Object clone() {
91
		return new PDOMCPPTypedefClone(this);
92
	}
93
	
94
	private static class PDOMCPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, ICPPBinding {
95
		protected final ITypedef delegate;
96
		private IType type = null;
97
		
98
		public PDOMCPPTypedefClone(ITypedef typedef) {
99
			this.delegate = typedef;
100
		}
101
		public IType getType() throws DOMException {
102
			if (type == null) {
103
				return delegate.getType();
104
			}
105
			return type;
106
		}
107
		public ILinkage getLinkage() throws CoreException {
108
			return delegate.getLinkage();
109
		}
110
		public String getName() {
111
			return delegate.getName();
112
		}
113
		public char[] getNameCharArray() {
114
			return delegate.getNameCharArray();
115
		}
116
		public IScope getScope() throws DOMException {
117
			return delegate.getScope();
118
		}
119
		public Object getAdapter(Class adapter) {
120
			return delegate.getAdapter(adapter);
121
		}
122
		public boolean isSameType(IType type) {
123
			try {
124
				IType myrtype = getType();
125
				if (myrtype == null)
126
					return false;
127
				
128
				if (type instanceof ITypedef) {
129
					type= ((ITypedef)type).getType();
130
				}
131
				return myrtype.isSameType(type);
132
			} catch (DOMException e) {
133
			}
134
			return false;
135
		}
136
		public void setType(IType type) {
137
			this.type = type;
138
		}
139
		public String[] getQualifiedName() throws DOMException {
140
			return ((ICPPBinding)delegate).getQualifiedName();
141
		}
142
		public char[][] getQualifiedNameCharArray() throws DOMException {
143
			return ((ICPPBinding)delegate).getQualifiedNameCharArray();
144
		}
145
		public boolean isGloballyQualified() throws DOMException {
146
			return ((ICPPBinding)delegate).isGloballyQualified();
147
		}
148
		public Object clone() {
149
			return new PDOMCPPTypedefClone(this);
150
		}
151
	}
87
}
152
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionTemplate.java (-2 / +50 lines)
Lines 17-32 Link Here
17
import org.eclipse.cdt.core.dom.IPDOMNode;
17
import org.eclipse.cdt.core.dom.IPDOMNode;
18
import org.eclipse.cdt.core.dom.IPDOMVisitor;
18
import org.eclipse.cdt.core.dom.IPDOMVisitor;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
20
import org.eclipse.cdt.core.dom.ast.IASTName;
20
import org.eclipse.cdt.core.dom.ast.IBinding;
21
import org.eclipse.cdt.core.dom.ast.IBinding;
21
import org.eclipse.cdt.core.dom.ast.IType;
22
import org.eclipse.cdt.core.dom.ast.IType;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
28
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
29
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
30
import org.eclipse.cdt.core.index.IIndexBinding;
31
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
32
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
27
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
33
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
34
import org.eclipse.cdt.internal.core.index.IIndexScope;
28
import org.eclipse.cdt.internal.core.pdom.PDOM;
35
import org.eclipse.cdt.internal.core.pdom.PDOM;
29
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
36
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
37
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
30
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
38
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
31
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
39
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
32
import org.eclipse.core.runtime.CoreException;
40
import org.eclipse.core.runtime.CoreException;
Lines 37-43 Link Here
37
 */
45
 */
38
public class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
46
public class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
39
		ICPPFunctionTemplate, ICPPInternalTemplateInstantiator,
47
		ICPPFunctionTemplate, ICPPInternalTemplateInstantiator,
40
		IPDOMMemberOwner {
48
		IPDOMMemberOwner, ICPPTemplateScope, IIndexScope {
41
49
42
	private static final int TEMPLATE_PARAMS = PDOMCPPFunction.RECORD_SIZE + 0;
50
	private static final int TEMPLATE_PARAMS = PDOMCPPFunction.RECORD_SIZE + 0;
43
	private static final int INSTANCES = PDOMCPPFunction.RECORD_SIZE + 4;
51
	private static final int INSTANCES = PDOMCPPFunction.RECORD_SIZE + 4;
Lines 140-146 Link Here
140
	}
148
	}
141
149
142
	public IBinding instantiate(IType[] arguments) {
150
	public IBinding instantiate(IType[] arguments) {
143
		return getInstance(arguments);
151
		return CPPTemplates.instantiateTemplate(this, arguments, null);
144
	}
152
	}
145
153
146
	public void addChild(PDOMNode child) throws CoreException {
154
	public void addChild(PDOMNode child) throws CoreException {
Lines 167-170 Link Here
167
		list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
175
		list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
168
		list.accept(visitor);
176
		list.accept(visitor);
169
	}
177
	}
178
179
	public ICPPTemplateDefinition getTemplateDefinition() throws DOMException {
180
		return this;
181
	}
182
183
	public IBinding[] find(String name) throws DOMException {
184
		return find(name, false);
185
	}
186
187
	public IBinding[] find(String name, boolean prefixLookup)
188
			throws DOMException {
189
		try {
190
			BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
191
			PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TEMPLATE_PARAMS, getLinkageImpl());
192
			list.accept(visitor);
193
			
194
			return visitor.getBindings();
195
		} catch (CoreException e) {
196
			CCorePlugin.log(e);
197
		}
198
		return null;
199
	}
200
201
	public IBinding getBinding(IASTName name, boolean resolve)
202
			throws DOMException {
203
		try {
204
			BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
205
			PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TEMPLATE_PARAMS, getLinkageImpl());
206
			list.accept(visitor);
207
			
208
			return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
209
		} catch (CoreException e) {
210
			CCorePlugin.log(e);
211
		}
212
		return null;
213
	}
214
215
	public IIndexBinding getScopeBinding() {
216
		return this;
217
	}
170
}
218
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java (-8 / +42 lines)
Lines 21-33 Link Here
21
import org.eclipse.cdt.core.dom.ast.IType;
21
import org.eclipse.cdt.core.dom.ast.IType;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
25
import org.eclipse.cdt.core.parser.util.ObjectMap;
28
import org.eclipse.cdt.core.parser.util.ObjectMap;
26
import org.eclipse.cdt.internal.core.Util;
29
import org.eclipse.cdt.internal.core.Util;
30
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
27
import org.eclipse.cdt.internal.core.pdom.PDOM;
31
import org.eclipse.cdt.internal.core.pdom.PDOM;
28
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
32
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
29
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
33
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
30
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
31
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
34
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
32
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
35
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
33
import org.eclipse.core.runtime.CoreException;
36
import org.eclipse.core.runtime.CoreException;
Lines 50-63 Link Here
50
	protected static final int RECORD_SIZE = PDOMCPPClassTemplate.RECORD_SIZE + 16;
53
	protected static final int RECORD_SIZE = PDOMCPPClassTemplate.RECORD_SIZE + 16;
51
	
54
	
52
	public PDOMCPPClassTemplatePartialSpecialization(PDOM pdom,
55
	public PDOMCPPClassTemplatePartialSpecialization(PDOM pdom,
53
			PDOMNode parent, ICPPClassTemplatePartialSpecialization partial, PDOMBinding primary) throws CoreException {
56
			PDOMNode parent, ICPPClassTemplatePartialSpecialization partial, PDOMCPPClassTemplate primary) throws CoreException {
54
		super(pdom, parent, partial);
57
		super(pdom, parent, partial);
55
		pdom.getDB().putInt(record + PRIMARY, primary.getRecord());
58
		pdom.getDB().putInt(record + PRIMARY, primary.getRecord());
56
		if (primary instanceof PDOMCPPClassTemplate) {
59
		primary.addPartial(this);
57
			((PDOMCPPClassTemplate)primary).addPartial(this);
58
		} else if (primary instanceof PDOMCPPClassTemplateSpecialization) {
59
			((PDOMCPPClassTemplateSpecialization)primary).addPartial(this);
60
		}
61
		
60
		
62
		try {
61
		try {
63
			Integer memento = PDOMCPPOverloaderUtil.getSignatureMemento(partial);
62
			Integer memento = PDOMCPPOverloaderUtil.getSignatureMemento(partial);
Lines 161-167 Link Here
161
	}
160
	}
162
161
163
	public IBinding instantiate(IType[] args) {
162
	public IBinding instantiate(IType[] args) {
164
		return getInstance( args );
163
		ICPPSpecialization instance = getInstance( args );
164
		if( instance != null ){
165
			return instance;
166
		}
167
		
168
		IType [] specArgs = getArguments();
169
		if( specArgs.length != args.length ){
170
			return null;
171
		}
172
		
173
		ObjectMap argMap = new ObjectMap( specArgs.length );
174
		int numSpecArgs = specArgs.length;
175
		for( int i = 0; i < numSpecArgs; i++ ){
176
			IType spec = specArgs[i];
177
			IType arg = args[i];
178
			
179
			//If the argument is a template parameter, we can't instantiate yet, defer for later
180
			if( CPPTemplates.typeContainsTemplateParameter( arg ) ){
181
				return deferredInstance( args );
182
			}
183
			try {
184
				if( !CPPTemplates.deduceTemplateArgument( argMap,  spec, arg ) )
185
					return null;
186
			} catch (DOMException e) {
187
				return null;
188
			}
189
		}
190
		
191
		ICPPTemplateParameter [] params = getTemplateParameters();
192
		int numParams = params.length;
193
		for( int i = 0; i < numParams; i++ ){
194
			if( params[i] instanceof IType && !argMap.containsKey( params[i] ) )
195
				return null;
196
		}
197
		
198
		return (ICPPTemplateInstance) CPPTemplates.createInstance( (ICPPScope) getScope(), this, argMap, args );
165
	}
199
	}
166
200
167
	public ObjectMap getArgumentMap() {
201
	public ObjectMap getArgumentMap() {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFieldSpecialization.java (-1 / +2 lines)
Lines 19-24 Link Here
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
20
import org.eclipse.cdt.internal.core.Util;
20
import org.eclipse.cdt.internal.core.Util;
21
import org.eclipse.cdt.internal.core.pdom.PDOM;
21
import org.eclipse.cdt.internal.core.pdom.PDOM;
22
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
22
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
23
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
24
25
Lines 37-43 Link Here
37
	protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 4;
38
	protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 4;
38
	
39
	
39
	public PDOMCPPFieldSpecialization(PDOM pdom, PDOMNode parent,
40
	public PDOMCPPFieldSpecialization(PDOM pdom, PDOMNode parent,
40
			ICPPField field, PDOMCPPField specialized)
41
			ICPPField field, PDOMBinding specialized)
41
			throws CoreException {
42
			throws CoreException {
42
		super(pdom, parent, (ICPPSpecialization) field, specialized);
43
		super(pdom, parent, (ICPPSpecialization) field, specialized);
43
		
44
		
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPSpecialization.java (-6 / +19 lines)
Lines 20-25 Link Here
20
import org.eclipse.cdt.core.dom.ast.IBinding;
20
import org.eclipse.cdt.core.dom.ast.IBinding;
21
import org.eclipse.cdt.core.dom.ast.IType;
21
import org.eclipse.cdt.core.dom.ast.IType;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
23
import org.eclipse.cdt.core.parser.util.ObjectMap;
25
import org.eclipse.cdt.core.parser.util.ObjectMap;
24
import org.eclipse.cdt.internal.core.pdom.PDOM;
26
import org.eclipse.cdt.internal.core.pdom.PDOM;
25
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
27
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
Lines 135-150 Link Here
135
		return pdom.getDB().getInt(record + SIGNATURE_MEMENTO);
137
		return pdom.getDB().getInt(record + SIGNATURE_MEMENTO);
136
	}
138
	}
137
		
139
		
138
	private static IType[] getArguments(ObjectMap argMap) {
140
	private IType[] getArguments() {
139
		IType[] args = new IType[argMap.size()];
141
		if (!(this instanceof ICPPTemplateDefinition)
140
		for (int i = 0; i < argMap.size(); i++) {
142
				&& getSpecializedBinding() instanceof ICPPTemplateDefinition) {
141
			args[i] = (IType) argMap.getAt(i);
143
			ICPPTemplateDefinition template = (ICPPTemplateDefinition) getSpecializedBinding();
144
			try {
145
				ICPPTemplateParameter[] params = template.getTemplateParameters();
146
				ObjectMap argMap = getArgumentMap();
147
				IType[] args = new IType[argMap.size()];
148
				for (int i = 0; i < argMap.size(); i++) {
149
					args[i] = (IType) argMap.get(params[i]);
150
				}
151
				return args;
152
			} catch (DOMException e) {
153
			}
142
		}
154
		}
143
		return args;
155
156
		return IType.EMPTY_TYPE_ARRAY;
144
	}
157
	}
145
	
158
	
146
	public boolean matchesArguments(IType[] arguments) {
159
	public boolean matchesArguments(IType[] arguments) {
147
		IType [] args = getArguments(getArgumentMap());
160
		IType [] args = getArguments();
148
		if( args.length == arguments.length ){
161
		if( args.length == arguments.length ){
149
			int i = 0;
162
			int i = 0;
150
			for(; i < args.length; i++) {
163
			for(; i < args.length; i++) {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java (-56 / +79 lines)
Lines 46-51 Link Here
46
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
46
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
47
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
47
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
48
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
48
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
49
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
49
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
50
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
50
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
51
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
51
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
52
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
Lines 54-60 Link Here
54
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
55
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
55
import org.eclipse.cdt.internal.core.Util;
56
import org.eclipse.cdt.internal.core.Util;
56
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
57
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
57
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecializationScope;
58
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction;
58
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction;
59
import org.eclipse.cdt.internal.core.pdom.PDOM;
59
import org.eclipse.cdt.internal.core.pdom.PDOM;
60
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
60
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
Lines 124-129 Link Here
124
	public static final int CPP_CLASS_SPECIALIZATION= PDOMLinkage.LAST_NODE_TYPE + 30;
124
	public static final int CPP_CLASS_SPECIALIZATION= PDOMLinkage.LAST_NODE_TYPE + 30;
125
	public static final int CPP_CLASS_TEMPLATE_SPECIALIZATION= PDOMLinkage.LAST_NODE_TYPE + 31;
125
	public static final int CPP_CLASS_TEMPLATE_SPECIALIZATION= PDOMLinkage.LAST_NODE_TYPE + 31;
126
	
126
	
127
	private class ConfigureTemplate implements Runnable {
128
		PDOMBinding template;
129
		ICPPTemplateDefinition binding;
130
		
131
		public ConfigureTemplate(PDOMBinding template, ICPPTemplateDefinition binding) {
132
			this.template = template;
133
			this.binding = binding;
134
		}
135
		
136
		public void run() {
137
			try {
138
				ICPPTemplateParameter[] params = binding.getTemplateParameters();
139
				for (int i = 0; i < params.length; i++) {
140
					addBinding(params[i]);
141
				}
142
			} catch (CoreException e) {
143
			} catch (DOMException e) {
144
			} finally {
145
				template = null;
146
				binding = null;
147
			}
148
		}
149
	}
150
	
127
	private class ConfigurePartialSpecialization implements Runnable {
151
	private class ConfigurePartialSpecialization implements Runnable {
128
		PDOMCPPClassTemplatePartialSpecialization partial;
152
		PDOMCPPClassTemplatePartialSpecialization partial;
129
		ICPPClassTemplatePartialSpecialization binding;
153
		ICPPClassTemplatePartialSpecialization binding;
Lines 238-252 Link Here
238
	private boolean shouldAddParent(IBinding binding) throws CoreException {
262
	private boolean shouldAddParent(IBinding binding) throws CoreException {
239
		if (binding instanceof ICPPTemplateParameter) {
263
		if (binding instanceof ICPPTemplateParameter) {
240
			return true;
264
			return true;
241
		} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
242
			return true;
243
		} else if (binding instanceof ICPPSpecialization) {
265
		} else if (binding instanceof ICPPSpecialization) {
244
			try {
266
			return true;
245
				IScope scope = binding.getScope();
246
				if (scope instanceof CPPClassSpecializationScope)
247
					return true;
248
			} catch (DOMException e) {
249
			}
250
		}
267
		}
251
		return false;
268
		return false;
252
	}
269
	}
Lines 257-293 Link Here
257
		if (binding instanceof ICPPSpecialization) {
274
		if (binding instanceof ICPPSpecialization) {
258
			IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
275
			IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
259
			PDOMBinding pdomSpecialized = addBinding(specialized);
276
			PDOMBinding pdomSpecialized = addBinding(specialized);
277
			if (pdomSpecialized == null) return null;
260
			
278
			
261
			if (binding instanceof ICPPDeferredTemplateInstance) {
279
			if (binding instanceof ICPPDeferredTemplateInstance) {
262
				if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) {
280
				if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) {
263
					pdomBinding = new PDOMCPPDeferredFunctionInstance(pdom,
281
					pdomBinding = new PDOMCPPDeferredFunctionInstance(pdom,
264
							parent, (ICPPFunction) binding,
282
							parent, (ICPPFunction) binding, pdomSpecialized);	
265
							(PDOMCPPFunctionTemplate) pdomSpecialized);	
266
				} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassTemplate) {
283
				} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassTemplate) {
267
					pdomBinding = new PDOMCPPDeferredClassInstance(pdom,
284
					pdomBinding = new PDOMCPPDeferredClassInstance(pdom,
268
							parent, (ICPPClassType) binding,
285
							parent, (ICPPClassType) binding, pdomSpecialized);
269
							(PDOMCPPClassTemplate) pdomSpecialized);
270
				}
286
				}
271
			} else if (binding instanceof ICPPTemplateInstance) {
287
			} else if (binding instanceof ICPPTemplateInstance) {
272
				if (binding instanceof ICPPFunction && pdomSpecialized instanceof PDOMCPPFunctionTemplate) {
288
				if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunction) {
273
					pdomBinding = new PDOMCPPFunctionInstance(pdom, parent,
289
					pdomBinding = new PDOMCPPFunctionInstance(pdom, parent,
274
							(ICPPFunction) binding,
290
							(ICPPFunction) binding, pdomSpecialized);
275
							(PDOMCPPFunctionTemplate) pdomSpecialized);
291
				} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassType) {
276
				} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof PDOMCPPClassTemplate) {
277
					pdomBinding = new PDOMCPPClassInstance(pdom, parent,
278
							(ICPPClassType) binding, pdomSpecialized);
279
				} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof PDOMCPPClassTemplateSpecialization) {
280
					pdomBinding = new PDOMCPPClassInstance(pdom, parent,
292
					pdomBinding = new PDOMCPPClassInstance(pdom, parent,
281
							(ICPPClassType) binding, pdomSpecialized);
293
							(ICPPClassType) binding, pdomSpecialized);
282
				}
294
				}
283
			} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
295
			} else if (binding instanceof ICPPClassTemplatePartialSpecialization && pdomSpecialized instanceof PDOMCPPClassTemplate) {
284
				pdomBinding = new PDOMCPPClassTemplatePartialSpecialization(
296
				pdomBinding = new PDOMCPPClassTemplatePartialSpecialization(
285
						pdom, parent,
297
						pdom, parent, (ICPPClassTemplatePartialSpecialization) binding,
286
						(ICPPClassTemplatePartialSpecialization) binding,
298
						(PDOMCPPClassTemplate) pdomSpecialized);
287
						pdomSpecialized);
299
			} else if (binding instanceof ICPPField) {
288
			} else if (binding instanceof ICPPField && pdomSpecialized instanceof PDOMCPPField) {
289
				pdomBinding = new PDOMCPPFieldSpecialization(pdom, parent,
300
				pdomBinding = new PDOMCPPFieldSpecialization(pdom, parent,
290
						(ICPPField) binding, (PDOMCPPField) pdomSpecialized);
301
						(ICPPField) binding, pdomSpecialized);
291
			} else if (binding instanceof ICPPConstructor) {
302
			} else if (binding instanceof ICPPConstructor) {
292
				pdomBinding = new PDOMCPPConstructorSpecialization(pdom, parent,
303
				pdomBinding = new PDOMCPPConstructorSpecialization(pdom, parent,
293
						(ICPPConstructor) binding, pdomSpecialized);
304
						(ICPPConstructor) binding, pdomSpecialized);
Lines 368-378 Link Here
368
			PDOMCPPClassTemplatePartialSpecialization pdomSpec = (PDOMCPPClassTemplatePartialSpecialization) pdomBinding;
379
			PDOMCPPClassTemplatePartialSpecialization pdomSpec = (PDOMCPPClassTemplatePartialSpecialization) pdomBinding;
369
			ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) binding;
380
			ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) binding;
370
			postProcesses.add(postProcesses.size(), new ConfigurePartialSpecialization(pdomSpec, spec));
381
			postProcesses.add(postProcesses.size(), new ConfigurePartialSpecialization(pdomSpec, spec));
371
		} else if (pdomBinding instanceof PDOMCPPFunctionTemplate && binding instanceof ICPPFunction) {
382
		} 
383
		if (pdomBinding instanceof PDOMCPPFunctionTemplate && binding instanceof ICPPFunction) {
372
			PDOMCPPFunctionTemplate pdomTemplate = (PDOMCPPFunctionTemplate) pdomBinding;
384
			PDOMCPPFunctionTemplate pdomTemplate = (PDOMCPPFunctionTemplate) pdomBinding;
373
			ICPPFunction function = (ICPPFunction) binding;
385
			ICPPFunction function = (ICPPFunction) binding;
374
			postProcesses.add(postProcesses.size(), new ConfigureFunctionTemplate(pdomTemplate, function));
386
			postProcesses.add(postProcesses.size(), new ConfigureFunctionTemplate(pdomTemplate, function));
375
		}
387
		}
388
		if ((pdomBinding instanceof PDOMCPPClassTemplate || pdomBinding instanceof PDOMCPPFunctionTemplate) &&
389
				binding instanceof ICPPTemplateDefinition) {
390
			ICPPTemplateDefinition template = (ICPPTemplateDefinition) binding;
391
			postProcesses.add(postProcesses.size(), new ConfigureTemplate(pdomBinding, template));
392
		}
376
	}
393
	}
377
	
394
	
378
	private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
395
	private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
Lines 508-543 Link Here
508
	}
525
	}
509
526
510
	public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
527
	public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
511
		try {
528
		if (type instanceof IProblemBinding) {
512
			if (type instanceof IProblemBinding) {
529
			return null;
513
				return null;
514
			}
515
			if (type instanceof ICPPBasicType) {
516
				return new PDOMCPPBasicType(pdom, parent, (ICPPBasicType)type);
517
			}
518
			if (type instanceof ICPPClassType) {
519
				return addBinding((ICPPClassType) type);
520
			} 
521
			if (type instanceof IEnumeration) {
522
				return addBinding((IEnumeration) type);
523
			} 
524
			if (type instanceof ITypedef) {
525
				return addBinding((ITypedef) type);
526
			}
527
			if (type instanceof ICPPReferenceType) {
528
				return new PDOMCPPReferenceType(pdom, parent, (ICPPReferenceType)type);
529
			}
530
			if (type instanceof ICPPPointerToMemberType) {
531
				return new PDOMCPPPointerToMemberType(pdom, parent, (ICPPPointerToMemberType)type);
532
			}
533
			if (type instanceof ICPPTemplateTypeParameter) {
534
				return addBinding((ICPPTemplateTypeParameter) type);
535
			}
536
			
537
			return super.addType(parent, type); 
538
		} finally {
539
			handlePostProcesses();
540
		}
530
		}
531
		if (type instanceof ICPPBasicType) {
532
			return new PDOMCPPBasicType(pdom, parent, (ICPPBasicType) type);
533
		}
534
		if (type instanceof ICPPClassType) {
535
			return addBinding((ICPPClassType) type);
536
		}
537
		if (type instanceof IEnumeration) {
538
			return addBinding((IEnumeration) type);
539
		}
540
		if (type instanceof ITypedef) {
541
			return addBinding((ITypedef) type);
542
		}
543
		if (type instanceof ICPPReferenceType) {
544
			return new PDOMCPPReferenceType(pdom, parent,
545
					(ICPPReferenceType) type);
546
		}
547
		if (type instanceof ICPPPointerToMemberType) {
548
			return new PDOMCPPPointerToMemberType(pdom, parent,
549
					(ICPPPointerToMemberType) type);
550
		}
551
		if (type instanceof ICPPTemplateTypeParameter) {
552
			return addBinding((ICPPTemplateTypeParameter) type);
553
		}
554
555
		return super.addType(parent, type); 
541
	}
556
	}
542
557
543
	private void handlePostProcesses() {
558
	private void handlePostProcesses() {
Lines 636-641 Link Here
636
					PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility());
651
					PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility());
637
					ownerClass.addBase(pdomBase);
652
					ownerClass.addBase(pdomBase);
638
					pdomName.setIsBaseSpecifier(true);
653
					pdomName.setIsBaseSpecifier(true);
654
				} else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) {
655
					PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization)derivedClassBinding;
656
					PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility());
657
					ownerClass.addBase(pdomBase);
658
					pdomName.setIsBaseSpecifier(true);
639
				}
659
				}
640
			}
660
			}
641
		}
661
		}
Lines 651-656 Link Here
651
				if (derivedClassBinding instanceof PDOMCPPClassType) {
671
				if (derivedClassBinding instanceof PDOMCPPClassType) {
652
					PDOMCPPClassType ownerClass = (PDOMCPPClassType)derivedClassBinding;
672
					PDOMCPPClassType ownerClass = (PDOMCPPClassType)derivedClassBinding;
653
					ownerClass.removeBase(pdomName);
673
					ownerClass.removeBase(pdomName);
674
				} else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) {
675
					PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization)derivedClassBinding;
676
					ownerClass.removeBase(pdomName);
654
				}
677
				}
655
			}
678
			}
656
		}
679
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java (-5 / +9 lines)
Lines 11-17 Link Here
11
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
11
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
12
12
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.HashSet;
15
import java.util.List;
14
import java.util.List;
16
15
17
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.CCorePlugin;
Lines 36-41 Link Here
36
import org.eclipse.cdt.core.index.IIndexBinding;
35
import org.eclipse.cdt.core.index.IIndexBinding;
37
import org.eclipse.cdt.core.index.IndexFilter;
36
import org.eclipse.cdt.core.index.IndexFilter;
38
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
37
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
38
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
39
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
39
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
40
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
40
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
41
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
41
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
Lines 94-100 Link Here
94
		}
94
		}
95
	}
95
	}
96
	
96
	
97
	public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
97
	public ICPPTemplateParameter[] getTemplateParameters() {
98
		try {
98
		try {
99
			PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
99
			PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
100
			TemplateParameterCollector visitor = new TemplateParameterCollector();
100
			TemplateParameterCollector visitor = new TemplateParameterCollector();
Lines 186-192 Link Here
186
			};
186
			};
187
			
187
			
188
			BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter, prefixLookup, !prefixLookup);
188
			BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter, prefixLookup, !prefixLookup);
189
			acceptInHierarchy(new HashSet(), visitor);
189
			accept(visitor);
190
			return visitor.getBindings();
190
			return visitor.getBindings();
191
		} catch (CoreException e) {
191
		} catch (CoreException e) {
192
			CCorePlugin.log(e);
192
			CCorePlugin.log(e);
Lines 282-288 Link Here
282
	}
282
	}
283
283
284
	public ICPPSpecialization deferredInstance(IType[] arguments) {
284
	public ICPPSpecialization deferredInstance(IType[] arguments) {
285
		return getInstance( arguments );
285
		ICPPSpecialization instance = getInstance( arguments );
286
		if( instance == null ){
287
			instance = new CPPDeferredClassInstance( this, arguments );
288
		}
289
		return instance;
286
	}
290
	}
287
291
288
	private static class InstanceFinder implements IPDOMVisitor {
292
	private static class InstanceFinder implements IPDOMVisitor {
Lines 342-347 Link Here
342
			return ((PDOMCPPClassTemplate)template).instantiate( arguments );	
346
			return ((PDOMCPPClassTemplate)template).instantiate( arguments );	
343
		}
347
		}
344
		
348
		
345
		return getInstance(arguments);
349
		return CPPTemplates.instantiateTemplate(this, arguments, null);
346
	}
350
	}
347
}
351
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java (-35 / +10 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
11
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
12
12
13
import java.util.ArrayList;
14
15
import org.eclipse.cdt.core.CCorePlugin;
13
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.dom.IPDOMNode;
14
import org.eclipse.cdt.core.dom.IPDOMNode;
17
import org.eclipse.cdt.core.dom.IPDOMVisitor;
15
import org.eclipse.cdt.core.dom.IPDOMVisitor;
Lines 43-54 Link Here
43
41
44
	private static final int INSTANCES = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
42
	private static final int INSTANCES = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
45
	private static final int SPECIALIZATIONS = PDOMCPPClassSpecialization.RECORD_SIZE + 4;
43
	private static final int SPECIALIZATIONS = PDOMCPPClassSpecialization.RECORD_SIZE + 4;
46
	private static final int FIRST_PARTIAL = PDOMCPPClassSpecialization.RECORD_SIZE + 8;
47
	
44
	
48
	/**
45
	/**
49
	 * The size in bytes of a PDOMCPPClassTemplateSpecialization record in the database.
46
	 * The size in bytes of a PDOMCPPClassTemplateSpecialization record in the database.
50
	 */
47
	 */
51
	protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE + 12;
48
	protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE + 8;
52
	
49
	
53
	public PDOMCPPClassTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
50
	public PDOMCPPClassTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
54
			throws CoreException {
51
			throws CoreException {
Lines 66-99 Link Here
66
	public int getNodeType() {
63
	public int getNodeType() {
67
		return PDOMCPPLinkage.CPP_CLASS_TEMPLATE_SPECIALIZATION;
64
		return PDOMCPPLinkage.CPP_CLASS_TEMPLATE_SPECIALIZATION;
68
	}
65
	}
69
	
70
	private PDOMCPPClassTemplatePartialSpecialization getFirstPartial() throws CoreException {
71
		int value = pdom.getDB().getInt(record + FIRST_PARTIAL);
72
		return value != 0 ? new PDOMCPPClassTemplatePartialSpecialization(pdom, value) : null;
73
	}
74
	
75
	public void addPartial(PDOMCPPClassTemplatePartialSpecialization partial) throws CoreException {
76
		PDOMCPPClassTemplatePartialSpecialization first = getFirstPartial();
77
		partial.setNextPartial(first);
78
		pdom.getDB().putInt(record + FIRST_PARTIAL, partial.getRecord());
79
	}
80
		
66
		
81
	public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
67
	public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
82
		try {
68
		return ((ICPPClassTemplate)getSpecializedBinding()).getPartialSpecializations();
83
			ArrayList partials = new ArrayList();
84
			for (PDOMCPPClassTemplatePartialSpecialization partial = getFirstPartial();
85
					partial != null;
86
					partial = partial.getNextPartial()) {
87
				partials.add(partial);
88
			}
89
			
90
			return (ICPPClassTemplatePartialSpecialization[]) partials
91
					.toArray(new ICPPClassTemplatePartialSpecialization[partials
92
							.size()]);
93
		} catch (CoreException e) {
94
			CCorePlugin.log(e);
95
			return new ICPPClassTemplatePartialSpecialization[0];
96
		}
97
	}
69
	}
98
70
99
	public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
71
	public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
Lines 162-178 Link Here
162
			return ((PDOMCPPClassTemplate)template).instantiate( arguments );	
134
			return ((PDOMCPPClassTemplate)template).instantiate( arguments );	
163
		}
135
		}
164
		
136
		
165
		return getInstance(arguments);
137
		return CPPTemplates.instantiateTemplate(this, arguments, getArgumentMap());
166
	}
138
	}
167
	
139
	
168
	public void addMember(PDOMNode member) throws CoreException {
140
	public void addMember(PDOMNode member) throws CoreException {
169
		if (member instanceof ICPPTemplateInstance) {
141
		if (member instanceof ICPPTemplateInstance) {
170
			PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
142
			PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
171
			list.addMember(member);
143
			list.addMember(member);
172
		} else if (member instanceof ICPPSpecialization
144
		} else if (member instanceof ICPPSpecialization) {
173
				&& !(member instanceof ICPPClassTemplatePartialSpecialization)) {
145
			if (this.equals(((ICPPSpecialization)member).getSpecializedBinding())) {
174
			PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + SPECIALIZATIONS, getLinkageImpl());
146
				PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + SPECIALIZATIONS, getLinkageImpl());
175
			list.addMember(member);
147
				list.addMember(member);
148
			} else {
149
				super.addMember(member);
150
			}
176
		} else {
151
		} else {
177
			super.addMember(member);
152
			super.addMember(member);
178
		}
153
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPPointerToMemberType.java (-1 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Wind River Systems, Inc. and others.
2
 * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Markus Schorn - initial API and implementation
9
 *    Markus Schorn - initial API and implementation
10
 *    Bryan Wilkinson (QNX)
10
 *******************************************************************************/ 
11
 *******************************************************************************/ 
11
12
12
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
13
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
Lines 66-69 Link Here
66
		}
67
		}
67
		return null;
68
		return null;
68
	}
69
	}
70
	
71
	public Object clone() {
72
		return new PDOMCPPPointerToMemberTypeClone(this);
73
	}
74
	
75
	private static class PDOMCPPPointerToMemberTypeClone extends PDOMPointerType.PDOMPointerTypeClone implements ICPPPointerToMemberType {
76
		public PDOMCPPPointerToMemberTypeClone(ICPPPointerToMemberType pointer) {
77
			super(pointer);
78
		}
79
		public ICPPClassType getMemberOfClass() {
80
			return ((ICPPPointerToMemberType)delegate).getMemberOfClass();
81
		}
82
		public Object clone() {
83
			return new PDOMCPPPointerToMemberTypeClone(this);
84
		}
85
	}
69
}
86
}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPDeferredFunctionInstance.java (-1 / +2 lines)
Lines 13-18 Link Here
13
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
13
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
14
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
14
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
15
import org.eclipse.cdt.internal.core.pdom.PDOM;
15
import org.eclipse.cdt.internal.core.pdom.PDOM;
16
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
16
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
17
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
18
19
Lines 28-34 Link Here
28
	 */
29
	 */
29
	protected static final int RECORD_SIZE = PDOMCPPFunctionInstance.RECORD_SIZE + 0;
30
	protected static final int RECORD_SIZE = PDOMCPPFunctionInstance.RECORD_SIZE + 0;
30
	
31
	
31
	public PDOMCPPDeferredFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMCPPFunctionTemplate instantiated)
32
	public PDOMCPPDeferredFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding instantiated)
32
			throws CoreException {
33
			throws CoreException {
33
		super(pdom, parent, function, instantiated);
34
		super(pdom, parent, function, instantiated);
34
	}
35
	}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java (-15 / +76 lines)
Lines 30-45 Link Here
30
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
30
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
31
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
31
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
32
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
33
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
33
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
34
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
34
import org.eclipse.cdt.core.index.IIndexBinding;
35
import org.eclipse.cdt.core.index.IIndexBinding;
36
import org.eclipse.cdt.core.parser.util.ArrayUtil;
35
import org.eclipse.cdt.core.parser.util.ObjectMap;
37
import org.eclipse.cdt.core.parser.util.ObjectMap;
36
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
38
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
37
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
39
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
40
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
38
import org.eclipse.cdt.internal.core.index.IIndexScope;
41
import org.eclipse.cdt.internal.core.index.IIndexScope;
39
import org.eclipse.cdt.internal.core.index.IIndexType;
42
import org.eclipse.cdt.internal.core.index.IIndexType;
40
import org.eclipse.cdt.internal.core.pdom.PDOM;
43
import org.eclipse.cdt.internal.core.pdom.PDOM;
41
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
44
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
42
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
43
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
45
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
44
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
46
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
45
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
47
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
Lines 75-84 Link Here
75
	public int getNodeType() {
77
	public int getNodeType() {
76
		return PDOMCPPLinkage.CPP_CLASS_INSTANCE;
78
		return PDOMCPPLinkage.CPP_CLASS_INSTANCE;
77
	}
79
	}
80
	
81
	public ICPPBase[] getBases() throws DOMException {		
82
		ICPPBase[] pdomBases = ((ICPPClassType) getTemplateDefinition()).getBases();
78
83
79
	public ICPPBase[] getBases() throws DOMException {
84
		if (pdomBases != null) {
80
		//TODO Get bases
85
			ICPPBase[] result = new ICPPBase[pdomBases.length];
81
		return ICPPBase.EMPTY_BASE_ARRAY;
86
			
87
			for (int i = 0; i < pdomBases.length; i++) {
88
				PDOMCPPBase pdomBase = (PDOMCPPBase) pdomBases[i];
89
				IType type = (IType) pdomBase.getBaseClass();
90
				type = CPPTemplates.instantiateType(type, getArgumentMap());
91
				type = CPPSemantics.getUltimateType(type, false);
92
				if (type instanceof IBinding) {
93
					result[i] = pdomBase.createSpecialization((IBinding)type);
94
				}
95
			}
96
			
97
			return (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result);
98
		}
99
		
100
		return new ICPPBase[0];
82
	}
101
	}
83
	
102
	
84
	private static class ConstructorCollector implements IPDOMVisitor {
103
	private static class ConstructorCollector implements IPDOMVisitor {
Lines 159-194 Link Here
159
		return this;
178
		return this;
160
	}
179
	}
161
	
180
	
181
	private class SpecializationFinder implements IPDOMVisitor {
182
		private ObjectMap specMap;
183
		public SpecializationFinder(IBinding[] specialized) {
184
			specMap = new ObjectMap(specialized.length);
185
			for (int i = 0; i < specialized.length; i++) {
186
				specMap.put(specialized[i], null);
187
			}
188
		}
189
		public boolean visit(IPDOMNode node) throws CoreException {
190
			if (node instanceof ICPPSpecialization) {
191
				IBinding specialized = ((ICPPSpecialization)node).getSpecializedBinding();
192
				if (specMap.containsKey(specialized)) {
193
					ICPPSpecialization specialization = (ICPPSpecialization) specMap.get(node);
194
					if (specialization == null) {
195
						specMap.remove(specialized);
196
						specMap.put(specialized, node);
197
					}
198
				}
199
			}
200
			return false;
201
		}
202
		public void leave(IPDOMNode node) throws CoreException {
203
		}
204
		public ICPPSpecialization[] getSpecializations() {
205
			ICPPSpecialization[] result = new ICPPSpecialization[specMap.size()];
206
			for (int i = 0; i < specMap.size(); i++) {
207
				ICPPSpecialization specialization = (ICPPSpecialization) specMap.getAt(i);
208
				if (specialization != null) {
209
					result[i] = specialization;
210
				} else {
211
					result[i] = CPPTemplates.createSpecialization(
212
							PDOMCPPClassInstance.this, (IBinding) specMap
213
									.keyAt(i), getArgumentMap());
214
				}
215
			}
216
			return result;
217
		}
218
	}
219
	
162
	public IBinding[] find(String name) throws DOMException {
220
	public IBinding[] find(String name) throws DOMException {
163
		return find(name, false);
221
		return find(name, false);
164
	}
222
	}
165
223
166
	public IBinding[] find(String name, boolean prefixLookup)
224
	public IBinding[] find(String name, boolean prefixLookup)
167
			throws DOMException {
225
			throws DOMException {
168
		try {
226
		try {						
169
			BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
227
			IBinding[] specialized = ((ICPPClassType) getTemplateDefinition())
228
					.getCompositeScope().find(name.toString(), prefixLookup);			
229
			SpecializationFinder visitor = new SpecializationFinder(specialized);
170
			accept(visitor);
230
			accept(visitor);
171
			return visitor.getBindings();
231
			return visitor.getSpecializations();
172
		} catch (CoreException e) {
232
		} catch (CoreException e) {
173
			CCorePlugin.log(e);
233
			CCorePlugin.log(e);
174
		}
234
		}
175
		return null;
235
		return null;
176
	}
236
	}
177
237
	
178
	public IBinding getBinding(IASTName name, boolean resolve)
238
	public IBinding getBinding(IASTName name, boolean resolve)
179
			throws DOMException {
239
			throws DOMException {
180
		try {
240
		try {			
181
		    if (getDBName().equals(name.toCharArray())) {
241
		    if (getDBName().equals(name.toCharArray())) {
182
		        if (CPPClassScope.isConstructorReference(name)){
242
		        if (!CPPClassScope.isConstructorReference(name)){
183
		            return CPPSemantics.resolveAmbiguities(name, getConstructors());
243
		        	//9.2 ... The class-name is also inserted into the scope of the class itself
244
		        	return this;
184
		        }
245
		        }
185
	            //9.2 ... The class-name is also inserted into the scope of the class itself
186
	            return this;
187
		    }
246
		    }
188
			
247
			
189
		    BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
248
			IBinding[] specialized = ((ICPPClassType) getTemplateDefinition())
249
					.getCompositeScope().find(name.toString());			
250
			SpecializationFinder visitor = new SpecializationFinder(specialized);
190
			accept(visitor);
251
			accept(visitor);
191
			return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
252
			return CPPSemantics.resolveAmbiguities(name, visitor.getSpecializations());
192
		} catch (CoreException e) {
253
		} catch (CoreException e) {
193
			CCorePlugin.log(e);
254
			CCorePlugin.log(e);
194
		}
255
		}
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java (-2 / +2 lines)
Lines 187-193 Link Here
187
		}
187
		}
188
	}
188
	}
189
189
190
	protected void acceptInHierarchy(Set visited, IPDOMVisitor visitor) throws CoreException {
190
	private void acceptInHierarchy(Set visited, IPDOMVisitor visitor) throws CoreException {
191
		if (visited.contains(this))
191
		if (visited.contains(this))
192
			return;
192
			return;
193
		visited.add(this);
193
		visited.add(this);
Lines 391-397 Link Here
391
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
391
	public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
392
		try {
392
		try {
393
			BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
393
			BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
394
			acceptInHierarchy(new HashSet(), visitor);
394
			accept(visitor);
395
			return visitor.getBindings();
395
			return visitor.getBindings();
396
		} catch (CoreException e) {
396
		} catch (CoreException e) {
397
			CCorePlugin.log(e);
397
			CCorePlugin.log(e);
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPOverloaderUtil.java (-5 / +11 lines)
Lines 22-27 Link Here
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
22
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
23
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
24
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
25
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
26
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
27
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
27
import org.eclipse.cdt.core.parser.util.ObjectMap;
28
import org.eclipse.cdt.core.parser.util.ObjectMap;
Lines 56-67 Link Here
56
			buffer.append(getTemplateArgString(partial.getArguments(), false));
57
			buffer.append(getTemplateArgString(partial.getArguments(), false));
57
		} else if (binding instanceof ICPPSpecialization) {
58
		} else if (binding instanceof ICPPSpecialization) {
58
			ICPPSpecialization spec = (ICPPSpecialization) binding;
59
			ICPPSpecialization spec = (ICPPSpecialization) binding;
59
			ObjectMap argMap = spec.getArgumentMap();
60
			if (!(spec instanceof ICPPTemplateDefinition)
60
			IType[] args = new IType[argMap.size()];
61
					&& spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
61
			for (int i = 0; i < argMap.size(); i++) {
62
				ICPPTemplateDefinition template = (ICPPTemplateDefinition) spec.getSpecializedBinding();
62
				args[i] = (IType) argMap.getAt(i);
63
				ICPPTemplateParameter[] params = template.getTemplateParameters();
64
				ObjectMap argMap = spec.getArgumentMap();
65
				IType[] args = new IType[params.length];
66
				for (int i = 0; i < params.length; i++) {
67
					args[i] = (IType) argMap.get(params[i]);
68
				}
69
				buffer.append(getTemplateArgString(args, false));	
63
			}
70
			}
64
			buffer.append(getTemplateArgString(args, false));
65
		} 
71
		} 
66
		
72
		
67
		if (binding instanceof IFunction) {
73
		if (binding instanceof IFunction) {
(-)parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPBinding.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 Symbian Corporation and others.
2
 * Copyright (c) 2006, 2007 Symbian Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-23 Link Here
18
import org.eclipse.cdt.core.CCorePlugin;
18
import org.eclipse.cdt.core.CCorePlugin;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
19
import org.eclipse.cdt.core.dom.ast.DOMException;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
21
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
21
import org.eclipse.cdt.internal.core.pdom.PDOM;
22
import org.eclipse.cdt.internal.core.pdom.PDOM;
22
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
23
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
23
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
24
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
Lines 57-63 Link Here
57
		try {
58
		try {
58
			PDOMNode node = this;
59
			PDOMNode node = this;
59
			while (node != null) {
60
			while (node != null) {
60
				if (node instanceof PDOMBinding) {							
61
				if (node instanceof PDOMBinding && !(node instanceof ICPPTemplateInstance)) {							
61
					result.add(0, ((PDOMBinding)node).getName().toCharArray());
62
					result.add(0, ((PDOMBinding)node).getName().toCharArray());
62
				}
63
				}
63
				node = node.getParentNode();
64
				node = node.getParentNode();
(-)parser/org/eclipse/cdt/internal/core/index/composite/cpp/TemplateInstanceUtil.java (-3 / +5 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * Andrew Ferguson (Symbian) - Initial implementation
9
 * Andrew Ferguson (Symbian) - Initial implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.index.composite.cpp;
12
package org.eclipse.cdt.internal.core.index.composite.cpp;
12
13
Lines 17-23 Link Here
17
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
18
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
19
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
20
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
21
import org.eclipse.cdt.core.index.IIndexBinding;
21
import org.eclipse.cdt.core.index.IIndexBinding;
22
import org.eclipse.cdt.core.parser.util.ObjectMap;
22
import org.eclipse.cdt.core.parser.util.ObjectMap;
23
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
23
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
Lines 33-40 Link Here
33
		ObjectMap result= new ObjectMap(preresult.size());
33
		ObjectMap result= new ObjectMap(preresult.size());
34
		Object[] keys= preresult.keyArray();
34
		Object[] keys= preresult.keyArray();
35
		for(int i=0; i<keys.length; i++) {
35
		for(int i=0; i<keys.length; i++) {
36
			ICPPTemplateParameter param= (ICPPTemplateParameter) preresult.get(keys[i]);
36
			IType type= (IType) preresult.get(keys[i]);
37
			result.put(keys[i], cf.getCompositeBinding((IIndexFragmentBinding)param));
37
			result.put(
38
					cf.getCompositeBinding((IIndexFragmentBinding)keys[i]),
39
					cf.getCompositeBinding((IIndexFragmentBinding)type));
38
		}
40
		}
39
		return result;
41
		return result;
40
	}
42
	}
(-)parser/org/eclipse/cdt/internal/core/index/composite/cpp/InternalTemplateInstantiatorUtil.java (-1 / +7 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * Andrew Ferguson (Symbian) - Initial implementation
9
 * Andrew Ferguson (Symbian) - Initial implementation
10
 * Bryan Wilkinson (QNX)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.index.composite.cpp;
12
package org.eclipse.cdt.internal.core.index.composite.cpp;
12
13
Lines 31-36 Link Here
31
32
32
	public static IBinding instantiate(IType[] arguments, ICompositesFactory cf, IIndexBinding rbinding) {
33
	public static IBinding instantiate(IType[] arguments, ICompositesFactory cf, IIndexBinding rbinding) {
33
		IBinding ins= ((ICPPInternalTemplateInstantiator)rbinding).instantiate(arguments);
34
		IBinding ins= ((ICPPInternalTemplateInstantiator)rbinding).instantiate(arguments);
34
		return (IBinding) cf.getCompositeBinding((IIndexFragmentBinding)ins);
35
		if (ins instanceof IIndexFragmentBinding) {
36
			return (IBinding) cf.getCompositeBinding((IIndexFragmentBinding)ins);
37
		} else {
38
			//instantiation of an index template can result in a non-index binding
39
			return ins;
40
		}
35
	}
41
	}
36
}
42
}
(-)parser/org/eclipse/cdt/internal/core/index/composite/CompositeIndexBinding.java (+12 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * Andrew Ferguson (Symbian) - Initial implementation
9
 * Andrew Ferguson (Symbian) - Initial implementation
10
 * Markus Schorn (Wind River Systems)
10
 * Markus Schorn (Wind River Systems)
11
 * Bryan Wilkinson (QNX)
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.cdt.internal.core.index.composite;
13
package org.eclipse.cdt.internal.core.index.composite;
13
14
Lines 88-91 Link Here
88
	public boolean isFileLocal() throws CoreException {
89
	public boolean isFileLocal() throws CoreException {
89
		return rbinding instanceof IIndexBinding ? ((IIndexBinding)rbinding).isFileLocal() : true;
90
		return rbinding instanceof IIndexBinding ? ((IIndexBinding)rbinding).isFileLocal() : true;
90
	}
91
	}
92
	
93
	public boolean equals(Object obj) {
94
		if (obj == this)
95
			return true;
96
		if (obj instanceof IIndexFragmentBinding)
97
			return rbinding.equals(obj);
98
		if (obj instanceof CompositeIndexBinding)
99
			return rbinding.equals(((CompositeIndexBinding)obj).rbinding);
100
		
101
		return super.equals(obj);
102
	}
91
}
103
}
(-)parser/org/eclipse/cdt/internal/core/pdom/PDOM.java (-1 / +2 lines)
Lines 73-79 Link Here
73
public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
73
public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
74
	protected Database db;
74
	protected Database db;
75
75
76
	public static final int VERSION = 27;
76
	public static final int VERSION = 28;
77
	// 0 - the beginning of it all
77
	// 0 - the beginning of it all
78
	// 1 - first change to kick off upgrades
78
	// 1 - first change to kick off upgrades
79
	// 2 - added file inclusions
79
	// 2 - added file inclusions
Lines 102-107 Link Here
102
	// 25 - change ordering of bindings (175275)
102
	// 25 - change ordering of bindings (175275)
103
	// 26 - add properties storage
103
	// 26 - add properties storage
104
	// 27 - templates: classes, functions, limited nesting support, only template type parameters
104
	// 27 - templates: classes, functions, limited nesting support, only template type parameters
105
	// 28 - templates: class instance/specialization base classes
105
106
106
	public static final int LINKAGES = Database.DATA_AREA;
107
	public static final int LINKAGES = Database.DATA_AREA;
107
	public static final int FILE_INDEX = Database.DATA_AREA + 4;
108
	public static final int FILE_INDEX = Database.DATA_AREA + 4;
(-)parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalDeferredClassInstance.java (+27 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 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
 * QNX - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp;
12
13
import org.eclipse.cdt.core.dom.ast.IType;
14
import org.eclipse.cdt.core.parser.util.ObjectMap;
15
16
/**
17
 * @author Bryan Wilkinson
18
 * 
19
 */
20
public interface ICPPInternalDeferredClassInstance {
21
	
22
	/**
23
	 * instantiate the original template
24
	 * @return
25
	 */
26
	public IType instantiate(ObjectMap argMap);
27
}
(-)src/org/eclipse/cdt/internal/ui/IndexLabelProvider.java (-15 / +16 lines)
Lines 34-44 Link Here
34
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
34
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
35
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
35
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
36
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
36
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
37
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
38
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
37
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
39
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
38
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
40
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
39
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
41
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
40
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
41
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
42
import org.eclipse.cdt.core.model.ICContainer;
42
import org.eclipse.cdt.core.model.ICContainer;
43
import org.eclipse.cdt.core.model.ICProject;
43
import org.eclipse.cdt.core.model.ICProject;
44
import org.eclipse.cdt.core.model.ITranslationUnit;
44
import org.eclipse.cdt.core.model.ITranslationUnit;
Lines 97-122 Link Here
97
					buffer.append('>');
97
					buffer.append('>');
98
					result = buffer.toString();
98
					result = buffer.toString();
99
				} else if (element instanceof ICPPSpecialization) {
99
				} else if (element instanceof ICPPSpecialization) {
100
					PDOMNode parentOfSpec = ((PDOMNode)((ICPPSpecialization)element).getSpecializedBinding()).getParentNode();
100
					ICPPSpecialization spec = (ICPPSpecialization) element;
101
					PDOMNode parent = ((PDOMNode)element).getParentNode();
102
					PDOMNode grandParent = parent != null ? parent.getParentNode() : null;
103
					boolean showArgs = parentOfSpec == null || grandParent == null || !parentOfSpec.equals(grandParent);
104
					showArgs = showArgs && ((element instanceof ICPPClassType || element instanceof ICPPFunction)
105
							&& !(element instanceof ICPPTemplateDefinition)); 
106
					
101
					
107
					StringBuffer buffer = null;
102
					StringBuffer buffer = null;
108
					buffer = new StringBuffer("Spec: "); //$NON-NLS-1$
103
					buffer = new StringBuffer("Spec: "); //$NON-NLS-1$
109
					buffer.append(result);
104
					buffer.append(result);
110
					
105
					
111
					if (showArgs) {
106
					if (!(spec instanceof ICPPTemplateDefinition)
112
						buffer.append('<');
107
							&& spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
113
						ObjectMap argMap = ((ICPPSpecialization) element).getArgumentMap();
108
						ICPPTemplateDefinition template = (ICPPTemplateDefinition) spec.getSpecializedBinding();
114
						for (int i = 0; i < argMap.size(); i++) {
109
						try {
115
							if (i > 0)
110
							ICPPTemplateParameter[] params = template.getTemplateParameters();
116
								buffer.append(',');
111
							buffer.append('<');
117
							buffer.append(ASTTypeUtil.getType((IType) argMap.getAt(i)));
112
							ObjectMap argMap = ((ICPPSpecialization) element).getArgumentMap();
113
							for (int i = 0; i < params.length; i++) {
114
								if (i > 0)
115
									buffer.append(',');
116
								buffer.append(ASTTypeUtil.getType((IType) argMap.get(params[i])));
117
							}
118
							buffer.append('>');
119
						} catch (DOMException e) {
118
						}
120
						}
119
						buffer.append('>');
120
					}
121
					}
121
					
122
					
122
					result = buffer.toString();
123
					result = buffer.toString();

Return to bug 167098