mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Introduce ICPPFunctionSpecialization and ICPPConstructorSpecialization interfaces
This allows us to avoid some awkward uses of generics Change-Id: I054abe8c871bd2adbfa3212341a28c11ece6236c
This commit is contained in:
parent
ee3c2f0776
commit
0459a0ea4d
11 changed files with 60 additions and 18 deletions
|
@ -0,0 +1,17 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Nathan Ridge.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
/**
|
||||
* Binding for specializations of constructors.
|
||||
*
|
||||
* @since 6.2
|
||||
*/
|
||||
public interface ICPPConstructorSpecialization extends ICPPConstructor, ICPPSpecialization {
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 Nathan Ridge.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
/**
|
||||
* Binding for specializations of functions.
|
||||
*
|
||||
* @since 6.2
|
||||
*/
|
||||
public interface ICPPFunctionSpecialization extends ICPPFunction, ICPPSpecialization {
|
||||
}
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
@ -22,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|||
/**
|
||||
* Instantiation of a constructor template
|
||||
*/
|
||||
public class CPPConstructorInstance extends CPPMethodInstance implements ICPPConstructor {
|
||||
public class CPPConstructorInstance extends CPPMethodInstance implements ICPPConstructorSpecialization {
|
||||
|
||||
public CPPConstructorInstance(ICPPConstructor orig, ICPPClassType owner, ICPPTemplateParameterMap tpmap,
|
||||
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpec) {
|
||||
|
|
|
@ -15,22 +15,22 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
/**
|
||||
* Specialization of a constructor for a class-template or class-template specialization.
|
||||
*/
|
||||
public class CPPConstructorSpecialization extends CPPMethodSpecialization implements ICPPConstructor {
|
||||
public class CPPConstructorSpecialization extends CPPMethodSpecialization
|
||||
implements ICPPConstructorSpecialization {
|
||||
|
||||
public CPPConstructorSpecialization(ICPPConstructor orig, ICPPClassType owner,
|
||||
ICPPTemplateParameterMap argMap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||
super(orig, owner, argMap, type, exceptionSpecs);
|
||||
}
|
||||
|
||||
static <T extends ICPPConstructor & ICPPSpecialization & ICPPInternalBinding> ICPPExecution
|
||||
static <T extends ICPPConstructorSpecialization & ICPPInternalBinding> ICPPExecution
|
||||
getConstructorChainExecution(T functionSpec, IASTNode point) {
|
||||
if (!functionSpec.isConstexpr()) {
|
||||
return null;
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
||||
|
@ -22,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|||
* Specialization of a constructor template
|
||||
*/
|
||||
public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpecialization
|
||||
implements ICPPConstructor {
|
||||
implements ICPPConstructorSpecialization {
|
||||
|
||||
public CPPConstructorTemplateSpecialization(ICPPConstructor original,
|
||||
ICPPClassSpecialization owner, ICPPTemplateParameterMap tpmap, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
@ -42,7 +43,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
* The specialization of a friend function in the context of a class specialization,
|
||||
* also used as base class for function instances.
|
||||
*/
|
||||
public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunction, ICPPInternalFunction {
|
||||
public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunctionSpecialization,
|
||||
ICPPInternalFunction {
|
||||
private final ICPPFunctionType fType;
|
||||
private ICPPParameter[] fParams;
|
||||
private final IType[] fExceptionSpecs;
|
||||
|
|
|
@ -84,12 +84,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFieldTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
@ -3103,8 +3105,7 @@ public class CPPTemplates {
|
|||
* Returns the instantiated function body of the given function specialization.
|
||||
* @param point The point of instantiation for name lookups
|
||||
*/
|
||||
public static <T extends ICPPFunction & ICPPSpecialization> ICPPExecution instantiateFunctionBody(T f,
|
||||
IASTNode point) {
|
||||
public static ICPPExecution instantiateFunctionBody(ICPPFunctionSpecialization f, IASTNode point) {
|
||||
ICPPFunction spec = (ICPPFunction) f.getSpecializedBinding();
|
||||
ICPPExecution exec = null;
|
||||
if (spec instanceof ICPPComputableFunction) {
|
||||
|
@ -3117,9 +3118,8 @@ public class CPPTemplates {
|
|||
}
|
||||
return exec;
|
||||
}
|
||||
|
||||
private static <T extends ICPPFunction & ICPPSpecialization> void addInstantiatedParameters(
|
||||
InstantiationContext context, T spec) {
|
||||
private static void addInstantiatedParameters(InstantiationContext context,
|
||||
ICPPFunctionSpecialization spec) {
|
||||
ICPPFunction specialized = (ICPPFunction) spec.getSpecializedBinding();
|
||||
ICPPParameter paramSpecs[] = spec.getParameters();
|
||||
ICPPParameter specializedParams[] = specialized.getParameters();
|
||||
|
@ -3137,8 +3137,7 @@ public class CPPTemplates {
|
|||
* Returns the instantiated constructor chain of the given constructor specialization.
|
||||
* @param point The point of instantiation for name lookups
|
||||
*/
|
||||
public static <T extends ICPPConstructor & ICPPSpecialization> ICPPExecution instantiateConstructorChain(
|
||||
T f, IASTNode point) {
|
||||
public static ICPPExecution instantiateConstructorChain(ICPPConstructorSpecialization f, IASTNode point) {
|
||||
ICPPConstructor spec = (ICPPConstructor) f.getSpecializedBinding();
|
||||
ICPPExecution exec = null;
|
||||
if (spec != null) {
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPExecution;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
|
@ -25,7 +26,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public class PDOMCPPConstructorInstance extends PDOMCPPMethodInstance implements ICPPConstructor {
|
||||
public class PDOMCPPConstructorInstance extends PDOMCPPMethodInstance
|
||||
implements ICPPConstructorSpecialization {
|
||||
/** Offset of the constructor chain execution for constexpr constructors. */
|
||||
private static final int CONSTRUCTOR_CHAIN = PDOMCPPMethodInstance.RECORD_SIZE + 0; // Database.EXECUTION_SIZE
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPExecution;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
|
@ -25,7 +26,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
class PDOMCPPConstructorSpecialization extends PDOMCPPMethodSpecialization implements ICPPConstructor {
|
||||
class PDOMCPPConstructorSpecialization extends PDOMCPPMethodSpecialization
|
||||
implements ICPPConstructorSpecialization {
|
||||
/** Offset of the constructor chain execution for constexpr constructors. */
|
||||
private static final int CONSTRUCTOR_CHAIN = PDOMCPPMethodSpecialization.RECORD_SIZE + 0; // Database.EXECUTION_SIZE
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructorSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPExecution;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
|
@ -26,7 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Bryan Wilkinson
|
||||
*/
|
||||
class PDOMCPPConstructorTemplateSpecialization extends PDOMCPPMethodTemplateSpecialization
|
||||
implements ICPPConstructor {
|
||||
implements ICPPConstructorSpecialization {
|
||||
/** Offset of the constructor chain execution for constexpr constructors. */
|
||||
private static final int CONSTRUCTOR_CHAIN = PDOMCPPMethodTemplateSpecialization.RECORD_SIZE + 0; // Database.EXECUTION_SIZE
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
|
@ -40,7 +41,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* Binding for function specialization in the index.
|
||||
*/
|
||||
class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization
|
||||
implements ICPPFunction, ICPPComputableFunction {
|
||||
implements ICPPFunctionSpecialization, ICPPComputableFunction {
|
||||
/**
|
||||
* Offset of total number of function parameters (relative to the beginning of the record).
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue