1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Specialization scope caches specialized bases.

This commit is contained in:
Markus Schorn 2009-02-02 08:57:25 +00:00
parent 0c70640ddc
commit 1110c15233

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2008 IBM Corporation and others. * Copyright (c) 2005, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -42,6 +42,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
*/ */
public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializationScope { public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializationScope {
final private ICPPClassSpecialization specialClass; final private ICPPClassSpecialization specialClass;
private ICPPBase[] fBases;
public AbstractCPPClassSpecializationScope(ICPPClassSpecialization specialization) { public AbstractCPPClassSpecializationScope(ICPPClassSpecialization specialization) {
this.specialClass= specialization; this.specialClass= specialization;
@ -128,22 +129,31 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
} }
public ICPPBase[] getBases() throws DOMException { public ICPPBase[] getBases() throws DOMException {
ICPPBase[] result = null; if (fBases == null) {
ICPPBase[] bases = specialClass.getSpecializedBinding().getBases(); ICPPBase[] result = null;
final ICPPTemplateParameterMap tpmap = specialClass.getTemplateParameterMap(); ICPPBase[] bases = specialClass.getSpecializedBinding().getBases();
for (ICPPBase base : bases) { if (bases.length == 0) {
ICPPBase specBase = base.clone(); fBases= bases;
IBinding origClass = base.getBaseClass(); } else {
if (origClass instanceof IType) { final ICPPTemplateParameterMap tpmap = specialClass.getTemplateParameterMap();
IType specClass= CPPTemplates.instantiateType((IType) origClass, tpmap, specialClass); for (ICPPBase base : bases) {
specClass = SemanticUtil.getUltimateType(specClass, false); ICPPBase specBase = base.clone();
if (specClass instanceof IBinding && !(specClass instanceof IProblemBinding)) { IBinding origClass = base.getBaseClass();
specBase.setBaseClass((IBinding) specClass); if (origClass instanceof IType) {
IType specClass= CPPTemplates.instantiateType((IType) origClass, tpmap, specialClass);
specClass = SemanticUtil.getUltimateType(specClass, false);
if (specClass instanceof IBinding && !(specClass instanceof IProblemBinding)) {
specBase.setBaseClass((IBinding) specClass);
}
result = (ICPPBase[]) ArrayUtil.append(ICPPBase.class, result, specBase);
}
} }
result = (ICPPBase[]) ArrayUtil.append(ICPPBase.class, result, specBase); result= (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result);
fBases= result;
return result;
} }
} }
return (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result); return fBases;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")