1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 162217, by Andrew Ferguson, PDOM bindings constructed off bindings

This commit is contained in:
Markus Schorn 2006-10-27 10:08:08 +00:00
parent 1ee1c0cb84
commit de14fed9ad
28 changed files with 150 additions and 237 deletions

View file

@ -52,7 +52,7 @@ public class OverloadsWithinCommonHeaderTests extends PDOMTestBase {
public void testDummy() {} public void testDummy() {}
public void _testOverloadedInCommonHeader_ClassScope() throws CoreException { public void testOverloadedInCommonHeader_ClassScope() throws CoreException {
Pattern[] ManyOverloadedQuxPath = makePatternArray(new String[] {"ManyOverloaded","qux"}); Pattern[] ManyOverloadedQuxPath = makePatternArray(new String[] {"ManyOverloaded","qux"});
IBinding[] ManyOverloadedQux = pdom.findBindings(ManyOverloadedQuxPath, new NullProgressMonitor()); IBinding[] ManyOverloadedQux = pdom.findBindings(ManyOverloadedQuxPath, new NullProgressMonitor());
assertEquals(5,ManyOverloadedQux.length); assertEquals(5,ManyOverloadedQux.length);
@ -73,7 +73,7 @@ public class OverloadsWithinCommonHeaderTests extends PDOMTestBase {
assertFunctionRefCount(new Class[]{ICPPClassType.class}, ManyOverloadedQux, 10); assertFunctionRefCount(new Class[]{ICPPClassType.class}, ManyOverloadedQux, 10);
} }
public void _testOverloadedInCommonHeader_FileScope() throws CoreException { public void testOverloadedInCommonHeader_FileScope() throws CoreException {
Pattern[] QuuxPath = makePatternArray(new String[] {"quux"}); Pattern[] QuuxPath = makePatternArray(new String[] {"quux"});
IBinding[] Quux = pdom.findBindings(QuuxPath, false, IndexFilter.getFilter(Linkage.CPP_LINKAGE), new NullProgressMonitor()); IBinding[] Quux = pdom.findBindings(QuuxPath, false, IndexFilter.getFilter(Linkage.CPP_LINKAGE), new NullProgressMonitor());
@ -95,7 +95,7 @@ public class OverloadsWithinCommonHeaderTests extends PDOMTestBase {
assertFunctionRefCount(new Class[] {ICPPClassType.class}, Quux, 12); assertFunctionRefCount(new Class[] {ICPPClassType.class}, Quux, 12);
} }
public void _testOverloadedInCommonHeader_NamespaceScope() throws CoreException { public void testOverloadedInCommonHeader_NamespaceScope() throws CoreException {
Pattern[] GraultPath = makePatternArray(new String[] {"corge","grault"}); Pattern[] GraultPath = makePatternArray(new String[] {"corge","grault"});
IBinding[] Grault = pdom.findBindings(GraultPath, true, IndexFilter.getFilter(Linkage.CPP_LINKAGE), new NullProgressMonitor()); IBinding[] Grault = pdom.findBindings(GraultPath, true, IndexFilter.getFilter(Linkage.CPP_LINKAGE), new NullProgressMonitor());
assertEquals(5,Grault.length); assertEquals(5,Grault.length);

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragment; import org.eclipse.cdt.internal.core.index.IIndexFragment;
@ -35,10 +34,6 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 12; protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 12;
protected PDOMBinding(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
super(pdom, parent, name.toCharArray());
}
protected PDOMBinding(PDOM pdom, PDOMNode parent, char[] name) throws CoreException { protected PDOMBinding(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
super(pdom, parent, name); super(pdom, parent, name);
} }

View file

@ -177,8 +177,10 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IBindingIdent
/** /**
* *
* @param binding * @param binding
* @return null for filescope for non-pdom bindings, this for filescope for pdom bindings * @return <ul><li> null - skip this binding (don't add to pdom)
* or the parent binding in any other case * <li>this - for filescope
* <li>a PDOMBinding instance - parent adapted binding
* </ul>
* @throws CoreException * @throws CoreException
*/ */
public PDOMNode getAdaptedParent(IBinding binding) throws CoreException { public PDOMNode getAdaptedParent(IBinding binding) throws CoreException {

View file

@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
import org.eclipse.cdt.internal.core.pdom.db.IString; import org.eclipse.cdt.internal.core.pdom.db.IString;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -47,9 +46,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
name != null ? db.newString(name).getRecord() : 0); name != null ? db.newString(name).getRecord() : 0);
} }
protected int getRecordSize() { abstract protected int getRecordSize();
return RECORD_SIZE;
}
public IString getDBName() throws CoreException { public IString getDBName() throws CoreException {
Database db = pdom.getDB(); Database db = pdom.getDB();
@ -65,17 +62,6 @@ public abstract class PDOMNamedNode extends PDOMNode {
return getDBName().equals(name); return getDBName().equals(name);
} }
public IBTreeComparator getIndexComparator() {
return new IBTreeComparator() {
public int compare(int record1, int record2) throws CoreException {
Database db = pdom.getDB();
int string1 = db.getInt(record1 + NAME);
int string2 = db.getInt(record2 + NAME);
return db.getString(string1).compare(db.getString(string2));
}
};
}
/** /**
* Convenience method for fetching a byte from the database. * Convenience method for fetching a byte from the database.
* @param offset Location of the byte. * @param offset Location of the byte.

View file

@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
/** /**
* A utility class for packing various annotations into bit fields. This * A utility class for packing various annotations into bit fields. This
@ -67,14 +67,17 @@ public class PDOMCAnnotation {
/** /**
* Encodes CV qualifiers from a method declarator as a bit vector. * Encodes CV qualifiers from a method declarator as a bit vector.
* @param declarator Method declarator. * @param type the function type
* @return a bit vector of the CV qualifiers. * @return a bit vector of the CV qualifiers.
*/ */
public static byte encodeCVQualifiers(ICPPASTFunctionDeclarator declarator) { /*
* aftodo - will we put CV information in C pdom bindings or should we
* move this to PDOMCPPAnnotation?
*/
public static byte encodeCVQualifiers(ICPPFunctionType type) {
byte modifiers = 0; byte modifiers = 0;
modifiers |= (declarator.isConst() ? 1 : 0) << CONST_OFFSET; modifiers |= (type.isConst() ? 1 : 0) << CONST_OFFSET;
modifiers |= (declarator.isVolatile() ? 1 : 0) << VOLATILE_OFFSET; modifiers |= (type.isVolatile() ? 1 : 0) << VOLATILE_OFFSET;
return modifiers; return modifiers;
} }
} }

View file

@ -14,7 +14,6 @@ import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
@ -33,9 +32,9 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration {
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCEnumeration(PDOM pdom, PDOMNode parent, IASTName name) public PDOMCEnumeration(PDOM pdom, PDOMNode parent, IEnumeration enumeration)
throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, enumeration.getNameCharArray());
} }
public PDOMCEnumeration(PDOM pdom, int record) { public PDOMCEnumeration(PDOM pdom, int record) {

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -32,9 +31,9 @@ class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
public PDOMCEnumerator(PDOM pdom, PDOMNode parent, IASTName name, PDOMCEnumeration enumeration) public PDOMCEnumerator(PDOM pdom, PDOMNode parent, IEnumerator enumerator, PDOMCEnumeration enumeration)
throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, enumerator.getNameCharArray());
pdom.getDB().putInt(record + ENUMERATION, enumeration.getRecord()); pdom.getDB().putInt(record + ENUMERATION, enumeration.getRecord());
enumeration.addEnumerator(this); enumeration.addEnumerator(this);
} }

View file

@ -13,7 +13,6 @@
package org.eclipse.cdt.internal.core.pdom.dom.c; package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -28,8 +27,8 @@ import org.eclipse.core.runtime.CoreException;
*/ */
class PDOMCField extends PDOMBinding implements IField { class PDOMCField extends PDOMBinding implements IField {
public PDOMCField(PDOM pdom, IPDOMMemberOwner parent, IASTName name) throws CoreException { public PDOMCField(PDOM pdom, IPDOMMemberOwner parent, IField field) throws CoreException {
super(pdom, (PDOMNode) parent, name); super(pdom, (PDOMNode) parent, field.getNameCharArray());
} }
public PDOMCField(PDOM pdom, int record) { public PDOMCField(PDOM pdom, int record) {

View file

@ -15,17 +15,11 @@ package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -60,25 +54,16 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
*/ */
public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9; public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
public PDOMCFunction(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCFunction(PDOM pdom, PDOMNode parent, IFunction function) throws CoreException {
super(pdom, parent, name); super(pdom, parent, function.getNameCharArray());
try { try {
IASTNode parentNode = name.getParent(); IParameter[] params = function.getParameters();
if (parentNode instanceof IASTStandardFunctionDeclarator) { pdom.getDB().putInt(record + NUM_PARAMS, params.length);
IASTStandardFunctionDeclarator funcDecl = (IASTStandardFunctionDeclarator)parentNode; for (int i = 0; i < params.length; ++i) {
IASTParameterDeclaration[] params = funcDecl.getParameters(); setFirstParameter(new PDOMCParameter(pdom, this, params[i]));
pdom.getDB().putInt(record + NUM_PARAMS, params.length);
for (int i = 0; i < params.length; ++i) {
IASTParameterDeclaration param = params[i];
IASTName paramName = param.getDeclarator().getName();
IBinding binding = paramName.resolveBinding();
IParameter paramBinding = (IParameter)binding;
setFirstParameter(new PDOMCParameter(pdom, this, paramName, paramBinding));
}
} else if(parentNode instanceof ICASTKnRFunctionDeclarator) {
fail(); // aftodo
} }
pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(name.resolveBinding())); pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(function));
} catch(DOMException e) { } catch(DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }

View file

@ -102,7 +102,7 @@ class PDOMCLinkage extends PDOMLinkage {
if (binding instanceof IParameter) if (binding instanceof IParameter)
// skip parameters // skip parameters
return null; return null;
PDOMBinding pdomBinding = adaptBinding(binding); PDOMBinding pdomBinding = adaptBinding(binding);
try { try {
if (pdomBinding == null) { if (pdomBinding == null) {
@ -114,42 +114,38 @@ class PDOMCLinkage extends PDOMLinkage {
return null; // skip parameters return null; // skip parameters
else if (binding instanceof IField) { // must be before IVariable else if (binding instanceof IField) { // must be before IVariable
if (parent instanceof IPDOMMemberOwner) if (parent instanceof IPDOMMemberOwner)
pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, name); pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, (IField) binding);
} else if (binding instanceof IVariable) { } else if (binding instanceof IVariable) {
IVariable var= (IVariable) binding; IVariable var= (IVariable) binding;
if (!var.isStatic()) { // bug 161216 if (!var.isStatic()) { // bug 161216
pdomBinding = new PDOMCVariable(pdom, parent, name); pdomBinding = new PDOMCVariable(pdom, parent, var);
} }
} } else if (binding instanceof IFunction) {
else if (binding instanceof IFunction) {
IFunction func= (IFunction) binding; IFunction func= (IFunction) binding;
if (!func.isStatic()) { // bug 161216 if (!func.isStatic()) { // bug 161216
pdomBinding = new PDOMCFunction(pdom, parent, name); pdomBinding = new PDOMCFunction(pdom, parent, func);
} }
} } else if (binding instanceof ICompositeType)
else if (binding instanceof ICompositeType) pdomBinding = new PDOMCStructure(pdom, parent, (ICompositeType) binding);
pdomBinding = new PDOMCStructure(pdom, parent, name);
else if (binding instanceof IEnumeration) else if (binding instanceof IEnumeration)
pdomBinding = new PDOMCEnumeration(pdom, parent, name); pdomBinding = new PDOMCEnumeration(pdom, parent, (IEnumeration) binding);
else if (binding instanceof IEnumerator) { else if (binding instanceof IEnumerator) {
try { try {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType(); IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration); PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCEnumeration) if (pdomEnumeration instanceof PDOMCEnumeration)
pdomBinding = new PDOMCEnumerator(pdom, parent, name, pdomBinding = new PDOMCEnumerator(pdom, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
(PDOMCEnumeration)pdomEnumeration);
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }
} else if (binding instanceof ITypedef) } else if (binding instanceof ITypedef)
pdomBinding = new PDOMCTypedef(pdom, parent, name, (ITypedef)binding); pdomBinding = new PDOMCTypedef(pdom, parent, (ITypedef)binding);
if(pdomBinding!=null) { if(pdomBinding!=null) {
parent.addChild(pdomBinding); parent.addChild(pdomBinding);
} }
} }
} } catch (DOMException e) {
catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }

View file

@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
@ -44,9 +43,9 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter {
super(pdom, record); super(pdom, record);
} }
public PDOMCParameter(PDOM pdom, PDOMNode parent, IASTName name, IParameter param) public PDOMCParameter(PDOM pdom, PDOMNode parent, IParameter param)
throws CoreException { throws CoreException {
super(pdom, parent, name.toCharArray()); super(pdom, parent, param.getNameCharArray());
Database db = pdom.getDB(); Database db = pdom.getDB();

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode; import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
@ -42,8 +41,8 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, IPDOM
private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE; private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE;
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCStructure(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCStructure(PDOM pdom, PDOMNode parent, ICompositeType compType) throws CoreException {
super(pdom, parent, name); super(pdom, parent, compType.getNameCharArray());
// linked list is initialized by malloc zeroing allocated storage // linked list is initialized by malloc zeroing allocated storage
} }

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
@ -33,9 +32,9 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef {
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCTypedef(PDOM pdom, PDOMNode parent, IASTName name, ITypedef typedef) public PDOMCTypedef(PDOM pdom, PDOMNode parent, ITypedef typedef)
throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, typedef.getNameCharArray());
try { try {
IType type = typedef.getType(); IType type = typedef.getType();

View file

@ -13,7 +13,6 @@
package org.eclipse.cdt.internal.core.pdom.dom.c; package org.eclipse.cdt.internal.core.pdom.dom.c;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
@ -39,12 +38,11 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
*/ */
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1;
public PDOMCVariable(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCVariable(PDOM pdom, PDOMNode parent, IVariable variable) throws CoreException {
super(pdom, parent, name); super(pdom, parent, variable.getNameCharArray());
IVariable binding = (IVariable)name.getBinding();
try { try {
pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(binding)); pdom.getDB().putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(variable));
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }

View file

@ -102,7 +102,7 @@ public class CPPBindingIdentity extends AbstractCLocalBindingIdentity {
} }
public String toString() { public String toString() {
return name+" "+type+" "+mangledExtendedType; return name+" "+type+" "+mangledExtendedType; //$NON-NLS-1$ //$NON-NLS-2$
} }
public char[] getNameCharArray() throws CoreException { public char[] getNameCharArray() throws CoreException {

View file

@ -16,7 +16,6 @@ import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -31,7 +30,7 @@ abstract public class PDOMCPPBinding extends PDOMBinding implements ICPPBinding
public PDOMCPPBinding(PDOM pdom, int record) { public PDOMCPPBinding(PDOM pdom, int record) {
super(pdom, record); super(pdom, record);
} }
public PDOMCPPBinding(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCPPBinding(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
super(pdom, parent, name); super(pdom, parent, name);
} }

View file

@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor; import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
@ -61,16 +60,12 @@ class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12; protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12;
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, IASTName name) public PDOMCPPClassType(PDOM pdom, PDOMNode parent, ICPPClassType classType)
throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, classType.getName().toCharArray());
IBinding binding = name.resolveBinding();
try { try {
int key = 0; pdom.getDB().putByte(record + KEY, (byte) classType.getKey());
if (binding instanceof ICPPClassType) // not sure why it wouldn't
key = ((ICPPClassType) binding).getKey();
pdom.getDB().putByte(record + KEY, (byte) key);
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }

View file

@ -14,7 +14,6 @@ import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
@ -34,9 +33,9 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IEnumeration, ICPPBin
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCPPEnumeration(PDOM pdom, PDOMNode parent, IASTName name) public PDOMCPPEnumeration(PDOM pdom, PDOMNode parent, IEnumeration enumeration)
throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, enumeration.getNameCharArray());
} }
public PDOMCPPEnumeration(PDOM pdom, int record) { public PDOMCPPEnumeration(PDOM pdom, int record) {

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
@ -33,9 +32,9 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator, ICPPBindi
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
public PDOMCPPEnumerator(PDOM pdom, PDOMNode parent, IASTName name, PDOMCPPEnumeration enumeration) public PDOMCPPEnumerator(PDOM pdom, PDOMNode parent, IEnumerator enumerator, PDOMCPPEnumeration enumeration)
throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, enumerator.getNameCharArray());
pdom.getDB().putInt(record + ENUMERATION, enumeration.getRecord()); pdom.getDB().putInt(record + ENUMERATION, enumeration.getRecord());
enumeration.addEnumerator(this); enumeration.addEnumerator(this);
} }

View file

@ -14,8 +14,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; 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.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
@ -44,13 +42,12 @@ class PDOMCPPField extends PDOMCPPBinding implements ICPPField {
*/ */
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 1;
public PDOMCPPField(PDOM pdom, PDOMCPPClassType parent, IASTName name) public PDOMCPPField(PDOM pdom, PDOMCPPClassType parent, ICPPField field)
throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, field.getNameCharArray());
IBinding binding = name.resolveBinding();
try { try {
Database db = pdom.getDB(); Database db = pdom.getDB();
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding)); db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(field));
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }

View file

@ -14,19 +14,13 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -65,26 +59,18 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, ICPPFuncti
*/ */
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
public PDOMCPPFunction(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCPPFunction(PDOM pdom, PDOMNode parent, ICPPFunction function) throws CoreException {
super(pdom, parent, name); super(pdom, parent, function.getNameCharArray());
IASTNode parentNode = name.getParent();
Database db = pdom.getDB(); Database db = pdom.getDB();
if (parentNode instanceof ICPPASTFunctionDeclarator) { IBinding binding = function;
ICPPASTFunctionDeclarator funcDecl = (ICPPASTFunctionDeclarator)parentNode;
IASTParameterDeclaration[] params = funcDecl.getParameters();
db.putInt(record + NUM_PARAMS, params.length);
for (int i = 0; i < params.length; ++i) {
ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration)params[i];
IASTName paramName = param.getDeclarator().getName();
IBinding binding = paramName.resolveBinding();
if (!(binding instanceof ICPPParameter))
continue;
ICPPParameter paramBinding = (ICPPParameter)binding;
setFirstParameter(new PDOMCPPParameter(pdom, this, paramName, paramBinding));
}
}
IBinding binding = name.resolveBinding();
try { try {
IParameter[] params = function.getParameters();
db.putInt(record + NUM_PARAMS, params.length);
for (int i=0; i<params.length; ++i) {
setFirstParameter(new PDOMCPPParameter(pdom, this, params[i]));
}
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding)); db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding));
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));

View file

@ -119,7 +119,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
return null; return null;
IBinding binding = name.resolveBinding(); IBinding binding = name.resolveBinding();
if (binding == null || binding instanceof IProblemBinding) if (binding == null || binding instanceof IProblemBinding)
// Can't tell what it is // Can't tell what it is
return null; return null;
@ -132,50 +132,51 @@ class PDOMCPPLinkage extends PDOMLinkage {
try { try {
if (pdomBinding == null) { if (pdomBinding == null) {
PDOMNode parent = getAdaptedParent(binding); PDOMNode parent = getAdaptedParent(binding);
if (parent != null) { if (parent == null)
if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType) return null;
pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
else if (binding instanceof ICPPVariable) { if (binding instanceof ICPPField && parent instanceof PDOMCPPClassType)
if (!(binding.getScope() instanceof CPPBlockScope)) { pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, (ICPPField) binding);
ICPPVariable var= (ICPPVariable) binding; else if (binding instanceof ICPPVariable && !(binding.getScope() instanceof CPPBlockScope)) {
if (!var.isStatic()) { // bug 161216 if (!(binding.getScope() instanceof CPPBlockScope)) {
pdomBinding = new PDOMCPPVariable(pdom, parent, name); ICPPVariable var= (ICPPVariable) binding;
} if (!var.isStatic()) { // bug 161216
pdomBinding = new PDOMCPPVariable(pdom, parent, var);
} }
} else if (binding instanceof ICPPMethod && parent instanceof PDOMCPPClassType) {
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
if(!name.isReference()) {
//because we got the implicit method off of an IASTName that is not a reference,
//it is no longer completly implicit and it should be treated as a normal method.
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
}
} else if (binding instanceof ICPPFunction) {
ICPPFunction func= (ICPPFunction) binding;
if (!func.isStatic()) { // bug 161216
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
}
} else if (binding instanceof ICPPClassType) {
pdomBinding = new PDOMCPPClassType(pdom, parent, name);
} else if (binding instanceof ICPPNamespaceAlias) {
pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, name);
} else if (binding instanceof ICPPNamespace) {
pdomBinding = new PDOMCPPNamespace(pdom, parent, name);
} else if (binding instanceof IEnumeration) {
pdomBinding = new PDOMCPPEnumeration(pdom, parent, name);
} else if (binding instanceof IEnumerator) {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCPPEnumeration)
pdomBinding = new PDOMCPPEnumerator(pdom, parent, name,
(PDOMCPPEnumeration)pdomEnumeration);
} else if (binding instanceof ITypedef) {
pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
} }
} else if (parent instanceof PDOMCPPClassType && binding instanceof ICPPMethod) {
if(pdomBinding!=null) { pdomBinding = new PDOMCPPMethod(pdom, parent, (ICPPMethod)binding);
parent.addChild(pdomBinding); } else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
if(!name.isReference()) {
//because we got the implicit method off of an IASTName that is not a reference,
//it is no longer completly implicit and it should be treated as a normal method.
pdomBinding = new PDOMCPPMethod(pdom, parent, (ICPPMethod)binding);
} }
} else if (binding instanceof ICPPFunction) {
ICPPFunction func= (ICPPFunction) binding;
if (!func.isStatic()) { // bug 161216
pdomBinding = new PDOMCPPFunction(pdom, parent, func);
}
} else if (binding instanceof ICPPClassType) {
pdomBinding = new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding);
} else if (binding instanceof ICPPNamespaceAlias) {
pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, (ICPPNamespaceAlias) binding);
} else if (binding instanceof ICPPNamespace) {
pdomBinding = new PDOMCPPNamespace(pdom, parent, (ICPPNamespace) binding);
} else if (binding instanceof IEnumeration) {
pdomBinding = new PDOMCPPEnumeration(pdom, parent, (IEnumeration) binding);
} else if (binding instanceof IEnumerator) {
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
if (pdomEnumeration instanceof PDOMCPPEnumeration)
pdomBinding = new PDOMCPPEnumerator(pdom, parent, (IEnumerator) binding,
(PDOMCPPEnumeration)pdomEnumeration);
} else if (binding instanceof ITypedef) {
pdomBinding = new PDOMCPPTypedef(pdom, parent, name, (ITypedef)binding);
}
if(pdomBinding!=null) {
parent.addChild(pdomBinding);
} }
} }
} catch(DOMException e) { } catch(DOMException e) {

View file

@ -15,20 +15,13 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; 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.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -78,29 +71,24 @@ class PDOMCPPMethod extends PDOMCPPBinding implements ICPPMethod, ICPPFunctionTy
*/ */
private static final int CV_OFFSET = 2; private static final int CV_OFFSET = 2;
public PDOMCPPMethod(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCPPMethod(PDOM pdom, PDOMNode parent, ICPPMethod method) throws CoreException {
super(pdom, parent, name); super(pdom, parent, method.getNameCharArray());
IASTNode parentNode = name.getParent();
byte annotation = 0;
Database db = pdom.getDB(); Database db = pdom.getDB();
if (parentNode instanceof ICPPASTFunctionDeclarator) {
ICPPASTFunctionDeclarator funcDecl = (ICPPASTFunctionDeclarator)parentNode;
IASTParameterDeclaration[] params = funcDecl.getParameters();
db.putInt(record + NUM_PARAMS, params.length);
for (int i = 0; i < params.length; ++i) {
ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration)params[i];
IASTName paramName = param.getDeclarator().getName();
IBinding binding = paramName.resolveBinding();
ICPPParameter paramBinding = (ICPPParameter)binding;
setFirstParameter(new PDOMCPPParameter(pdom, this, paramName, paramBinding));
}
annotation |= PDOMCAnnotation.encodeCVQualifiers(funcDecl) << CV_OFFSET;
}
try { try {
IBinding binding = name.resolveBinding(); IParameter[] params = method.getParameters();
annotation |= PDOMCPPAnnotation.encodeExtraAnnotation(binding); db.putInt(record + NUM_PARAMS, params.length);
db.putByte(record + ANNOTATION0, PDOMCPPAnnotation.encodeAnnotation(binding));
db.putByte(record + ANNOTATION1, annotation); for (int i=0; i<params.length; ++i) {
setFirstParameter(new PDOMCPPParameter(pdom, this, params[i]));
}
ICPPFunctionType type = (ICPPFunctionType) method.getType();
byte annotation = 0;
annotation |= PDOMCAnnotation.encodeCVQualifiers(type) << CV_OFFSET;
annotation |= PDOMCPPAnnotation.encodeExtraAnnotation(method);
db.putByte(record + ANNOTATION0, PDOMCPPAnnotation.encodeAnnotation(method));
db.putByte(record + ANNOTATION1, annotation);
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }

View file

@ -49,8 +49,8 @@ class PDOMCPPNamespace extends PDOMCPPBinding
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCPPNamespace(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCPPNamespace(PDOM pdom, PDOMNode parent, ICPPNamespace namespace) throws CoreException {
super(pdom, parent, name); super(pdom, parent, namespace.getNameCharArray());
} }
public PDOMCPPNamespace(PDOM pdom, int record) throws CoreException { public PDOMCPPNamespace(PDOM pdom, int record) throws CoreException {

View file

@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
@ -28,9 +27,9 @@ import org.eclipse.core.runtime.CoreException;
class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements
ICPPNamespaceAlias { ICPPNamespaceAlias {
public PDOMCPPNamespaceAlias(PDOM pdom, PDOMNode parent, public PDOMCPPNamespaceAlias(PDOM pdom, PDOMNode parent, ICPPNamespaceAlias alias)
IASTName name) throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, alias.getNameCharArray());
} }
public PDOMCPPNamespaceAlias(PDOM pdom, int record) { public PDOMCPPNamespaceAlias(PDOM pdom, int record) {

View file

@ -16,10 +16,9 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.Database;
@ -33,7 +32,7 @@ import org.eclipse.core.runtime.CoreException;
* *
* @author Doug Schaefer * @author Doug Schaefer
*/ */
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter { class PDOMCPPParameter extends PDOMNamedNode implements IParameter {
/** /**
* Offset of pointer to the next parameter (relative to the * Offset of pointer to the next parameter (relative to the
@ -56,9 +55,9 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
super(pdom, record); super(pdom, record);
} }
public PDOMCPPParameter(PDOM pdom, PDOMNode parent, IASTName name, ICPPParameter param) public PDOMCPPParameter(PDOM pdom, PDOMNode parent, IParameter param)
throws CoreException { throws CoreException {
super(pdom, parent, name.toCharArray()); super(pdom, parent, param.getNameCharArray());
Database db = pdom.getDB(); Database db = pdom.getDB();

View file

@ -34,7 +34,7 @@ class PDOMCPPTypedef extends PDOMBinding implements ITypedef {
public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, IASTName name, ITypedef typedef) public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, IASTName name, ITypedef typedef)
throws CoreException { throws CoreException {
super(pdom, parent, name); super(pdom, parent, name.toCharArray());
try { try {
IType type = typedef.getType(); IType type = typedef.getType();
PDOMNode typeNode = parent.getLinkageImpl().addType(this, type); PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);

View file

@ -15,13 +15,9 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -52,21 +48,17 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
*/ */
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 5; protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 5;
public PDOMCPPVariable(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCPPVariable(PDOM pdom, PDOMNode parent, ICPPVariable variable) throws CoreException {
super(pdom, parent, name); super(pdom, parent, variable.getNameCharArray());
// Find the type record try {
IASTNode nameParent = name.getParent(); // Find the type record
Database db = pdom.getDB(); Database db = pdom.getDB();
if (nameParent instanceof IASTDeclarator) { PDOMNode typeNode = parent.getLinkageImpl().addType(this, variable.getType());
IASTDeclarator declarator = (IASTDeclarator)nameParent;
IType type = CPPVisitor.createType(declarator);
PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
if (typeNode != null) if (typeNode != null)
db.putInt(record + TYPE_OFFSET, typeNode.getRecord()); db.putInt(record + TYPE_OFFSET, typeNode.getRecord());
}
try { db.putByte(record + ANNOTATIONS, PDOMCPPAnnotation.encodeAnnotation(variable));
db.putByte(record + ANNOTATIONS, PDOMCPPAnnotation.encodeAnnotation(name.resolveBinding()));
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }