mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
207840: add PDOM non-type parameters
This commit is contained in:
parent
f0b43c8098
commit
b786f524dc
10 changed files with 201 additions and 14 deletions
|
@ -1182,7 +1182,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
|
||||
// const SI y= 99;
|
||||
// A<y> ay;
|
||||
public void _testNonTypeTemplateParameter_207840() {
|
||||
public void testNonTypeTemplateParameter_207840() {
|
||||
ICPPVariable b0= getBindingFromASTName("y>", 1, ICPPVariable.class);
|
||||
ICPPClassType b1= getBindingFromASTName("A<y>", 1, ICPPClassType.class, ICPPTemplateDefinition.class);
|
||||
ICPPTemplateInstance b2= getBindingFromASTName("A<y>", 4, ICPPTemplateInstance.class, ICPPClassType.class);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
|
||||
* 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
|
||||
|
@ -58,4 +58,5 @@ public interface IIndexCPPBindingConstants {
|
|||
int CPP_USING_DECLARATION= IIndexBindingConstants.LAST_CONSTANT + 41;
|
||||
int CPP_UNKNOWN_CLASS_TYPE= IIndexBindingConstants.LAST_CONSTANT + 42;
|
||||
int CPP_UNKNOWN_CLASS_INSTANCE= IIndexBindingConstants.LAST_CONSTANT + 43;
|
||||
int CPP_TEMPLATE_NON_TYPE_PARAMETER= IIndexBindingConstants.LAST_CONSTANT + 44;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
|
@ -273,6 +274,8 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
result = new CompositeCPPTypedef(this, (ICPPBinding) binding);
|
||||
} else if (binding instanceof ICPPTemplateTypeParameter) {
|
||||
result = new CompositeCPPTemplateTypeParameter(this, (ICPPTemplateTypeParameter) binding);
|
||||
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
result = new CompositeCPPTemplateNonTypeParameter(this, (ICPPTemplateNonTypeParameter) binding);
|
||||
} else if (binding instanceof IIndexMacroContainer) {
|
||||
result= new CompositeMacroContainer(this, binding);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
|
||||
* 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
|
||||
|
@ -14,13 +14,14 @@ import java.util.Arrays;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.CompositeIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
abstract class CompositeCPPBinding extends CompositeIndexBinding implements ICPPBinding {
|
||||
public CompositeCPPBinding(ICompositesFactory cf, ICPPBinding rbinding) {
|
||||
public CompositeCPPBinding(ICompositesFactory cf, IBinding rbinding) {
|
||||
super(cf, (IIndexFragmentBinding) rbinding);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Symbian Software Systems and others.
|
||||
* 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
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPTemplateNonTypeParameter extends CompositeCPPVariable implements ICPPTemplateNonTypeParameter {
|
||||
public CompositeCPPTemplateNonTypeParameter(ICompositesFactory cf, ICPPTemplateNonTypeParameter binding) {
|
||||
super(cf, binding);
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
return ((IType)rbinding).isSameType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
fail(); return null;
|
||||
}
|
||||
|
||||
public IASTExpression getDefault() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -13,13 +13,14 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCPPVariable extends CompositeCPPBinding implements ICPPVariable {
|
||||
|
||||
public CompositeCPPVariable(ICompositesFactory cf, ICPPVariable delegate) {
|
||||
public CompositeCPPVariable(ICompositesFactory cf, IVariable delegate) {
|
||||
super(cf, delegate);
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
private static int version(int major, int minor) {
|
||||
return major << 16 + minor;
|
||||
}
|
||||
public static final int MAJOR_VERSION = 57;
|
||||
public static final int MAJOR_VERSION = 58;
|
||||
public static final int MINOR_VERSION = 0; // minor versions must be compatible
|
||||
|
||||
public static final int CURRENT_VERSION= version(MAJOR_VERSION, MINOR_VERSION);
|
||||
|
@ -171,6 +171,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* 55 - generalization of local bindings (bug 215783)
|
||||
* 56 - using directives (bug 216527)
|
||||
* 57.0 - macro references (bug 156561)
|
||||
* 58.0 - non-type parameters (bug 207840)
|
||||
*/
|
||||
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
|
@ -323,13 +324,12 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
} else if (binding instanceof ICPPTemplateParameter) {
|
||||
if (binding instanceof ICPPTemplateTypeParameter) {
|
||||
pdomBinding = new PDOMCPPTemplateTypeParameter(pdom, parent, (ICPPTemplateTypeParameter)binding);
|
||||
}
|
||||
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
pdomBinding = new PDOMCPPTemplateNonTypeParameter(pdom, parent, (ICPPTemplateNonTypeParameter)binding);
|
||||
}
|
||||
// TODO other template parameter types
|
||||
// else if (binding instanceof ICPPTemplateTemplateParameter) {
|
||||
// pdomBinding = new PDOMCPPTemplateTemplateParameter(pdom, parent, (ICPPTemplateTemplateParameter)binding);
|
||||
// } else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
// pdomBinding = new PDOMCPPTemplateNonTypeParameter(pdom, parent, (ICPPTemplateNonTypeParameter)binding);
|
||||
// }
|
||||
} else if (binding instanceof ICPPField) {
|
||||
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) {
|
||||
pdomBinding = new PDOMCPPField(pdom, parent, (ICPPField) binding);
|
||||
|
@ -906,8 +906,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
// TODO other template parameter types
|
||||
// case CPP_TEMPLATE_TEMPLATE_PARAMETER:
|
||||
// return new PDOMCPPTemplateTemplateParameter(pdom, record);
|
||||
// case CPP_TEMPLATE_NON_TYPE_PARAMETER:
|
||||
// return new PDOMCPPTemplateNonTypeParameter(pdom, record);
|
||||
case CPP_TEMPLATE_NON_TYPE_PARAMETER:
|
||||
return new PDOMCPPTemplateNonTypeParameter(pdom, record);
|
||||
case CPP_FIELD_SPECIALIZATION:
|
||||
return new PDOMCPPFieldSpecialization(pdom, record);
|
||||
case CPP_FUNCTION_SPECIALIZATION:
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 QNX Software Systems and others.
|
||||
* 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
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
class PDOMCPPTemplateNonTypeParameter extends PDOMCPPVariable implements IPDOMMemberOwner,
|
||||
ICPPTemplateNonTypeParameter, ICPPInternalUnknown, IIndexType {
|
||||
|
||||
private static final int MEMBERLIST = PDOMCPPVariable.RECORD_SIZE + 4;
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPTemplateTypeParameter record in the database.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPVariable.RECORD_SIZE + 4;
|
||||
|
||||
public PDOMCPPTemplateNonTypeParameter(PDOM pdom, PDOMNode parent,
|
||||
ICPPTemplateNonTypeParameter param) throws CoreException {
|
||||
super(pdom, parent, param);
|
||||
}
|
||||
|
||||
public PDOMCPPTemplateNonTypeParameter(PDOM pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeType() {
|
||||
return IIndexCPPBindingConstants.CPP_TEMPLATE_TYPE_PARAMETER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChild(PDOMNode member) throws CoreException {
|
||||
addMember(member);
|
||||
}
|
||||
|
||||
public void addMember(PDOMNode member) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
|
||||
list.addMember(member);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
|
||||
list.accept(visitor);
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
if (type instanceof ITypedef) {
|
||||
return type.isSameType(this);
|
||||
}
|
||||
|
||||
if (type instanceof PDOMNode) {
|
||||
PDOMNode node= (PDOMNode) type;
|
||||
if (node.getPDOM() == getPDOM()) {
|
||||
return node.getRecord() == getRecord();
|
||||
}
|
||||
}
|
||||
|
||||
if (type instanceof ICPPTemplateNonTypeParameter && !(type instanceof ProblemBinding)) {
|
||||
ICPPTemplateNonTypeParameter ttp= (ICPPTemplateNonTypeParameter) type;
|
||||
try {
|
||||
char[][] ttpName= ttp.getQualifiedNameCharArray();
|
||||
return hasQualifiedName(ttpName, ttpName.length - 1);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICPPBinding getParameterOwner() throws CoreException {
|
||||
return (ICPPBinding) getParentBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() { fail(); return null; }
|
||||
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IBinding resolveUnknown(ObjectMap argMap) { fail(); return null; }
|
||||
|
||||
public void addDeclaration(IASTNode node) {
|
||||
}
|
||||
|
||||
public void addDefinition(IASTNode node) {
|
||||
}
|
||||
|
||||
public IASTNode[] getDeclarations() {
|
||||
return IASTNode.EMPTY_NODE_ARRAY;
|
||||
}
|
||||
|
||||
public IASTNode getDefinition() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removeDeclaration(IASTNode node) {
|
||||
}
|
||||
|
||||
public IASTExpression getDefault() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 5;
|
||||
|
||||
public PDOMCPPVariable(PDOM pdom, PDOMNode parent, ICPPVariable variable) throws CoreException {
|
||||
public PDOMCPPVariable(PDOM pdom, PDOMNode parent, IVariable variable) throws CoreException {
|
||||
super(pdom, parent, variable.getNameCharArray());
|
||||
|
||||
try {
|
||||
|
@ -92,7 +92,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
|||
pdom.getDB().putInt(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
|
||||
}
|
||||
|
||||
protected byte encodeFlags(ICPPVariable variable) throws DOMException {
|
||||
protected byte encodeFlags(IVariable variable) throws DOMException {
|
||||
return PDOMCPPAnnotation.encodeAnnotation(variable);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue