1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Store linkage rather than pdom in pdom nodes, bug 263022.

This commit is contained in:
Markus Schorn 2009-01-30 15:10:37 +00:00
parent 858e15d457
commit 16269eba9c
94 changed files with 1345 additions and 1428 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
@ -795,7 +795,7 @@ public class IndexUpdateTests extends IndexTestBase {
assertEquals(0, tpars[0].getParameterID());
assertEquals("T", tpars[0].getName());
assertNull(tpars[0].getDefaultValue());
pdomid= ((PDOMNode)((IAdaptable) tpars[0]).getAdapter(PDOMNode.class)).getId();
pdomid= ((PDOMNode)((IAdaptable) tpars[0]).getAdapter(PDOMNode.class)).getRecord();
} finally {
fIndex.releaseReadLock();
}
@ -895,7 +895,7 @@ public class IndexUpdateTests extends IndexTestBase {
assertTrue(tpars[0] instanceof ICPPTemplateTypeParameter);
assertEquals(0, tpars[0].getParameterID());
assertEquals("U", tpars[0].getName());
assertEquals(pdomid, ((PDOMNode)((IAdaptable) tpars[0]).getAdapter(PDOMNode.class)).getId());
assertEquals(pdomid, ((PDOMNode)((IAdaptable) tpars[0]).getAdapter(PDOMNode.class)).getBindingID());
} finally {
fIndex.releaseReadLock();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 Symbian Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -26,6 +26,7 @@ import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -76,29 +77,42 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
* @param index
* @param linkageID
*/
public static void dumpLinkage(IIndex index, final String linkageID) {
public static void dumpLinkage(IIndex index, final int linkageID) {
final IPDOMVisitor v= new PDOMPrettyPrinter();
IIndexFragment[] frg= ((CIndex)index).getPrimaryFragments();
for (IIndexFragment element : frg) {
final PDOM pdom = (PDOM) element;
try {
pdom.getLinkage(linkageID).getIndex().accept(
new IBTreeVisitor() {
public int compare(int record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
if(record==0) return false;
PDOMNode node= pdom.getLinkage(linkageID).getNode(record);
if(v.visit(node))
node.accept(v);
v.leave(node);
return true;
}
});
} catch(CoreException ce) {
CCorePlugin.log(ce);
dumpLinkage(pdom, linkageID, v);
}
}
public static void dumpLinkage(PDOM pdom, final int linkageID) {
final IPDOMVisitor v= new PDOMPrettyPrinter();
dumpLinkage(pdom, linkageID, v);
}
private static void dumpLinkage(final PDOM pdom, final int linkageID, final IPDOMVisitor v) {
try {
final PDOMLinkage linkage = pdom.getLinkage(linkageID);
if (linkage != null) {
linkage.getIndex().accept(new IBTreeVisitor() {
public int compare(int record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
if (record == 0)
return false;
PDOMNode node = linkage.getNode(record);
if (v.visit(node))
node.accept(v);
v.leave(node);
return true;
}
});
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
@ -62,5 +62,5 @@ public interface IIndexFragmentBinding extends IIndexBinding {
* Returns a unique id for the binding within the fragment
* @since 5.1
*/
int getId();
int getBindingID();
}

View file

@ -329,9 +329,9 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
}
public static Object createInstanceCacheKey(ICompositesFactory cf,IIndexFragmentBinding rbinding) {
return new Key(Thread.currentThread().getId(), cf.hashCode(), rbinding.getId());
return new Key(Thread.currentThread().getId(), cf.hashCode(), rbinding.getBindingID());
}
public static Object createSpecializationKey(ICompositesFactory cf,IIndexFragmentBinding rbinding) {
return new Key(Thread.currentThread().getId(), cf.hashCode(), rbinding.getId()+1);
return new Key(Thread.currentThread().getId(), cf.hashCode(), rbinding.getBindingID()+1);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -54,6 +54,7 @@ import org.eclipse.cdt.core.index.IIndexLocationConverter;
import org.eclipse.cdt.core.index.IIndexMacro;
import org.eclipse.cdt.core.index.IIndexMacroContainer;
import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
@ -221,7 +222,7 @@ public class PDOM extends PlatformObject implements IPDOM {
// Local caches
protected Database db;
private BTree fileIndex;
private Map<String, PDOMLinkage> fLinkageIDCache = new HashMap<String, PDOMLinkage>();
private Map<Integer, PDOMLinkage> fLinkageIDCache = new HashMap<Integer, PDOMLinkage>();
private File fPath;
private IIndexLocationConverter locationConverter;
private Map<String, IPDOMLinkageFactory> fPDOMLinkageFactoryCache;
@ -269,8 +270,41 @@ public class PDOM extends PlatformObject implements IPDOM {
return version >= MIN_SUPPORTED_VERSION && version <= MAX_SUPPORTED_VERSION;
}
private void readLinkages() throws CoreException {
int record= getFirstLinkageRecord();
while (record != 0) {
String linkageID= PDOMLinkage.getLinkageID(this, record).getString();
IPDOMLinkageFactory factory= fPDOMLinkageFactoryCache.get(linkageID);
if (factory != null) {
PDOMLinkage linkage= factory.getLinkage(this, record);
fLinkageIDCache.put(linkage.getLinkageID(), linkage);
}
record= PDOMLinkage.getNextLinkageRecord(this, record);
}
}
private PDOMLinkage createLinkage(int linkageID) throws CoreException {
PDOMLinkage pdomLinkage= fLinkageIDCache.get(linkageID);
if (pdomLinkage == null) {
final String linkageName= Linkage.getLinkageName(linkageID);
IPDOMLinkageFactory factory= fPDOMLinkageFactoryCache.get(linkageName);
if (factory != null) {
return factory.createLinkage(this);
}
}
return pdomLinkage;
}
public PDOMLinkage getLinkage(int linkageID) throws CoreException {
return fLinkageIDCache.get(linkageID);
}
private Collection<PDOMLinkage> getLinkageList() {
return fLinkageIDCache.values();
}
public void accept(IPDOMVisitor visitor) throws CoreException {
for (PDOMLinkage linkage : fLinkageIDCache.values()) {
for (PDOMLinkage linkage : getLinkageList()) {
linkage.accept(visitor);
}
}
@ -306,7 +340,14 @@ public class PDOM extends PlatformObject implements IPDOM {
}
public PDOMFile getFile(int linkageID, IIndexFileLocation location) throws CoreException {
return PDOMFile.findFile(this, getFileIndex(), location, linkageID, locationConverter);
PDOMLinkage linkage= getLinkage(linkageID);
if (linkage == null)
return null;
return PDOMFile.findFile(linkage, getFileIndex(), location, locationConverter);
}
public PDOMFile getFile(PDOMLinkage linkage, IIndexFileLocation location) throws CoreException {
return PDOMFile.findFile(linkage, getFileIndex(), location, locationConverter);
}
public IIndexFragmentFile[] getFiles(IIndexFileLocation location) throws CoreException {
@ -320,7 +361,7 @@ public class PDOM extends PlatformObject implements IPDOM {
return 0;
}
public boolean visit(int record) throws CoreException {
PDOMFile file = new PDOMFile(PDOM.this, record);
PDOMFile file = PDOMFile.recreateFile(PDOM.this, record);
locations.add(file);
return true;
}
@ -329,9 +370,10 @@ public class PDOM extends PlatformObject implements IPDOM {
}
protected IIndexFragmentFile addFile(int linkageID, IIndexFileLocation location) throws CoreException {
IIndexFragmentFile file = getFile(linkageID, location);
PDOMLinkage linkage= createLinkage(linkageID);
IIndexFragmentFile file = getFile(linkage, location);
if (file == null) {
PDOMFile pdomFile = new PDOMFile(this, location, linkageID);
PDOMFile pdomFile = new PDOMFile(linkage, location, linkageID);
getFileIndex().insert(pdomFile.getRecord());
file= pdomFile;
}
@ -472,7 +514,7 @@ public class PDOM extends PlatformObject implements IPDOM {
monitor= new NullProgressMonitor();
}
BindingFinder finder = new BindingFinder(pattern, isFullyQualified, filter, monitor);
for (PDOMLinkage linkage : fLinkageIDCache.values()) {
for (PDOMLinkage linkage : getLinkageList()) {
if (filter.acceptLinkage(linkage)) {
try {
linkage.accept(finder);
@ -491,11 +533,13 @@ public class PDOM extends PlatformObject implements IPDOM {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
MacroContainerPatternCollector finder = new MacroContainerPatternCollector(this, pattern, monitor);
for (PDOMLinkage linkage : fLinkageIDCache.values()) {
List<IIndexFragmentBinding> result= new ArrayList<IIndexFragmentBinding>();
for (PDOMLinkage linkage : getLinkageList()) {
if (filter.acceptLinkage(linkage)) {
try {
MacroContainerPatternCollector finder = new MacroContainerPatternCollector(linkage, pattern, monitor);
linkage.getMacroIndex().accept(finder);
result.addAll(Arrays.asList(finder.getMacroContainers()));
} catch (CoreException e) {
if (e.getStatus() != Status.OK_STATUS)
throw e;
@ -504,7 +548,7 @@ public class PDOM extends PlatformObject implements IPDOM {
}
}
}
return finder.getMacroContainers();
return result.toArray(new IIndexFragmentBinding[result.size()]);
}
public IIndexFragmentBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
@ -513,7 +557,7 @@ public class PDOM extends PlatformObject implements IPDOM {
}
ArrayList<PDOMBinding> result= new ArrayList<PDOMBinding>();
ArrayList<PDOMNamedNode> nodes= new ArrayList<PDOMNamedNode>();
for (PDOMLinkage linkage : fLinkageIDCache.values()) {
for (PDOMLinkage linkage : getLinkageList()) {
if (filter.acceptLinkage(linkage)) {
nodes.add(linkage);
for (int i=0; i < names.length-1; i++) {
@ -539,80 +583,25 @@ public class PDOM extends PlatformObject implements IPDOM {
return result.toArray(new IIndexFragmentBinding[result.size()]);
}
private void readLinkages() throws CoreException {
// populate the linkage cache
int record= getFirstLinkageRecord();
while (record != 0) {
String linkageID= PDOMLinkage.getId(this, record).getString();
IPDOMLinkageFactory factory= fPDOMLinkageFactoryCache.get(linkageID);
if (factory != null) {
PDOMLinkage linkage= factory.getLinkage(this, record);
fLinkageIDCache.put(linkageID, linkage);
}
record= PDOMLinkage.getNextLinkageRecord(this, record);
}
}
public PDOMLinkage getLinkage(String linkageID) {
return fLinkageIDCache.get(linkageID);
}
public PDOMLinkage createLinkage(String linkageID) throws CoreException {
PDOMLinkage pdomLinkage= fLinkageIDCache.get(linkageID);
if (pdomLinkage == null) {
// Need to create it
IPDOMLinkageFactory factory= fPDOMLinkageFactoryCache.get(linkageID);
if (factory != null) {
return factory.createLinkage(this);
}
}
return pdomLinkage;
}
public PDOMLinkage getLinkage(int record) throws CoreException {
if (record == 0)
return null;
// First check the cache. We do a linear search since there will be very few linkages
// in a given database.
Iterator<PDOMLinkage> i = fLinkageIDCache.values().iterator();
while (i.hasNext()) {
PDOMLinkage linkage = i.next();
if (linkage.getRecord() == record)
return linkage;
}
String id = PDOMLinkage.getId(this, record).getString();
return createLinkage(id);
}
private int getFirstLinkageRecord() throws CoreException {
return db.getInt(LINKAGES);
}
public IIndexLinkage[] getLinkages() {
Collection<PDOMLinkage> values = fLinkageIDCache.values();
Collection<PDOMLinkage> values = getLinkageList();
return values.toArray(new IIndexLinkage[values.size()]);
}
public PDOMLinkage[] getLinkageImpls() {
Collection<PDOMLinkage> values = fLinkageIDCache.values();
Collection<PDOMLinkage> values = getLinkageList();
return values.toArray(new PDOMLinkage[values.size()]);
}
public void insertLinkage(PDOMLinkage linkage) throws CoreException {
linkage.setNext(db.getInt(LINKAGES));
db.putInt(LINKAGES, linkage.getRecord());
fLinkageIDCache.put(linkage.getLinkageName(), linkage);
}
public PDOMBinding getBinding(int record) throws CoreException {
if (record == 0)
return null;
else {
PDOMNode node = PDOMNode.getLinkage(this, record).getNode(record);
return node instanceof PDOMBinding ? (PDOMBinding)node : null;
}
fLinkageIDCache.put(linkage.getLinkageID(), linkage);
}
// Read-write lock rules. Readers don't conflict with other readers,
@ -726,7 +715,7 @@ public class PDOM extends PlatformObject implements IPDOM {
}
protected PDOMLinkage adaptLinkage(ILinkage linkage) throws CoreException {
return fLinkageIDCache.get(linkage.getLinkageName());
return fLinkageIDCache.get(linkage.getLinkageID());
}
public IIndexFragmentBinding adaptBinding(IBinding binding) throws CoreException {
@ -849,7 +838,7 @@ public class PDOM extends PlatformObject implements IPDOM {
public IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
ArrayList<IIndexFragmentBinding> result= new ArrayList<IIndexFragmentBinding>();
for (PDOMLinkage linkage : fLinkageIDCache.values()) {
for (PDOMLinkage linkage : getLinkageList()) {
if (filter.acceptLinkage(linkage)) {
PDOMBinding[] bindings;
BindingCollector visitor = new BindingCollector(linkage, prefix, filter, true, false);
@ -874,7 +863,7 @@ public class PDOM extends PlatformObject implements IPDOM {
public IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
ArrayList<IIndexFragmentBinding> result= new ArrayList<IIndexFragmentBinding>();
for (PDOMLinkage linkage : fLinkageIDCache.values()) {
for (PDOMLinkage linkage : getLinkageList()) {
if (filter.acceptLinkage(linkage)) {
PDOMBinding[] bindings;
BindingCollector visitor = new BindingCollector(linkage, name, filter, false, true);
@ -899,17 +888,17 @@ public class PDOM extends PlatformObject implements IPDOM {
public IIndexMacro[] findMacros(char[] prefix, boolean isPrefix, boolean isCaseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
ArrayList<IIndexMacro> result= new ArrayList<IIndexMacro>();
MacroContainerCollector visitor = new MacroContainerCollector(this, prefix, isPrefix, isCaseSensitive);
visitor.setMonitor(monitor);
try {
for (PDOMLinkage linkage : fLinkageIDCache.values()) {
for (PDOMLinkage linkage : getLinkageList()) {
if (filter.acceptLinkage(linkage)) {
MacroContainerCollector visitor = new MacroContainerCollector(linkage, prefix, isPrefix, isCaseSensitive);
visitor.setMonitor(monitor);
linkage.getMacroIndex().accept(visitor);
for (PDOMMacroContainer mcont : visitor.getMacroList()) {
result.addAll(Arrays.asList(mcont.getDefinitions()));
}
}
}
for (PDOMMacroContainer mcont : visitor.getMacroList()) {
result.addAll(Arrays.asList(mcont.getDefinitions()));
}
}
catch (OperationCanceledException e) {
}
@ -1004,7 +993,7 @@ public class PDOM extends PlatformObject implements IPDOM {
final int inputLinkage= binding.getLinkage().getLinkageID();
if (inputLinkage == ILinkage.C_LINKAGE_ID || inputLinkage == ILinkage.CPP_LINKAGE_ID) {
final char[] name= binding.getNameCharArray();
for (PDOMLinkage linkage : fLinkageIDCache.values()) {
for (PDOMLinkage linkage : getLinkageList()) {
final int linkageID = linkage.getLinkageID();
if (linkageID != inputLinkage) {
if (linkageID == ILinkage.C_LINKAGE_ID || linkageID == ILinkage.CPP_LINKAGE_ID) {
@ -1021,7 +1010,7 @@ public class PDOM extends PlatformObject implements IPDOM {
private PDOMBinding[] getCBindingForCPP(IBinding binding) throws CoreException {
PDOMBinding result= null;
PDOMLinkage c= getLinkage(ILinkage.C_LINKAGE_NAME);
PDOMLinkage c= getLinkage(ILinkage.C_LINKAGE_ID);
if (c == null) {
return PDOMBinding.EMPTY_PDOMBINDING_ARRAY;
}
@ -1029,29 +1018,29 @@ public class PDOM extends PlatformObject implements IPDOM {
if (binding instanceof ICPPFunction) {
ICPPFunction func = (ICPPFunction) binding;
if (func.isExternC()) {
result = FindBinding.findBinding(c.getIndex(), this, func.getNameCharArray(),
new int[] { IIndexCBindingConstants.CFUNCTION }, 0);
result = FindBinding.findBinding(c.getIndex(), c,
func.getNameCharArray(), new int[] { IIndexCBindingConstants.CFUNCTION }, 0);
}
} else if (binding instanceof ICPPVariable) {
ICPPVariable var = (ICPPVariable) binding;
if (var.isExternC()) {
result = FindBinding.findBinding(c.getIndex(), this, var.getNameCharArray(),
new int[] { IIndexCBindingConstants.CVARIABLE }, 0);
result = FindBinding.findBinding(c.getIndex(), c,
var.getNameCharArray(), new int[] { IIndexCBindingConstants.CVARIABLE }, 0);
}
} else if (binding instanceof IEnumeration) {
result= FindBinding.findBinding(c.getIndex(), this, binding.getNameCharArray(),
new int[] {IIndexCBindingConstants.CENUMERATION }, 0);
result= FindBinding.findBinding(c.getIndex(), c,
binding.getNameCharArray(), new int[] {IIndexCBindingConstants.CENUMERATION }, 0);
} else if (binding instanceof IEnumerator) {
result= FindBinding.findBinding(c.getIndex(), this, binding.getNameCharArray(),
new int[] {IIndexCBindingConstants.CENUMERATOR }, 0);
result= FindBinding.findBinding(c.getIndex(), c,
binding.getNameCharArray(), new int[] {IIndexCBindingConstants.CENUMERATOR }, 0);
} else if (binding instanceof ITypedef) {
result= FindBinding.findBinding(c.getIndex(), this, binding.getNameCharArray(),
new int[] {IIndexCBindingConstants.CTYPEDEF }, 0);
result= FindBinding.findBinding(c.getIndex(), c,
binding.getNameCharArray(), new int[] {IIndexCBindingConstants.CTYPEDEF }, 0);
} else if (binding instanceof ICompositeType) {
final int key= ((ICompositeType) binding).getKey();
if (key == ICompositeType.k_struct || key == ICompositeType.k_union) {
result= FindBinding.findBinding(c.getIndex(), this, binding.getNameCharArray(),
new int[] {IIndexCBindingConstants.CSTRUCTURE }, 0);
result= FindBinding.findBinding(c.getIndex(), c,
binding.getNameCharArray(), new int[] {IIndexCBindingConstants.CSTRUCTURE }, 0);
if (result instanceof ICompositeType && ((ICompositeType) result).getKey() != key) {
result= null;
}
@ -1063,7 +1052,7 @@ public class PDOM extends PlatformObject implements IPDOM {
}
private PDOMBinding[] getCPPBindingForC(IBinding binding) throws CoreException {
PDOMLinkage cpp= getLinkage(ILinkage.CPP_LINKAGE_NAME);
PDOMLinkage cpp= getLinkage(ILinkage.CPP_LINKAGE_ID);
if (cpp == null) {
return PDOMBinding.EMPTY_PDOMBINDING_ARRAY;
}

View file

@ -1,70 +0,0 @@
/*******************************************************************************
* Copyright (c) 2005, 2006 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
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IString;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
*/
public class PDOMLanguage {
private PDOM pdom;
private int record;
private static final int NEXT = 0; // int
private static final int ID = 4; // char
private static final int NAME = 6; // string
private static int RECORD_SIZE = 10;
public PDOMLanguage(PDOM pdom, int record) {
this.pdom = pdom;
this.record = record;
}
public PDOMLanguage(PDOM pdom, String name, int id, int next) throws CoreException {
this.pdom = pdom;
Database db = pdom.getDB();
record = db.malloc(RECORD_SIZE);
db.putInt(record + NEXT, next);
db.putChar(record + ID, (char)id);
db.putInt(record + NAME, db.newString(name).getRecord());
}
public int getRecord() {
return record;
}
public int getId() throws CoreException {
return pdom.getDB().getChar(record + ID);
}
public IString getName() throws CoreException {
Database db = pdom.getDB();
int rec = db.getInt(record + NAME);
return db.getString(rec);
}
public PDOMLanguage getNext() throws CoreException {
int nextrec = pdom.getDB().getInt(record + NEXT);
return nextrec != 0 ? new PDOMLanguage(pdom, nextrec) : null;
}
public boolean equals(String id) throws CoreException {
return getName().equals(id);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
@ -121,7 +121,7 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
return 0;
}
public boolean visit(int record) throws CoreException {
PDOMFile file = new PDOMFile(WritablePDOM.this, record);
PDOMFile file = PDOMFile.recreateFile(WritablePDOM.this, record);
pdomfiles.add(file);
return true;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -14,7 +14,6 @@
package org.eclipse.cdt.internal.core.pdom.db;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -25,7 +24,6 @@ import org.eclipse.core.runtime.CoreException;
*
*/
public class PDOMNodeLinkedList {
private PDOM pdom;
private int offset;
private PDOMLinkage linkage;
private boolean allowsNull;
@ -33,8 +31,7 @@ public class PDOMNodeLinkedList {
private static final int FIRST_MEMBER = 0;
protected static final int RECORD_SIZE = 4;
public PDOMNodeLinkedList(PDOM pdom, int offset, PDOMLinkage linkage, boolean allowsNulls) {
this.pdom = pdom;
public PDOMNodeLinkedList(PDOMLinkage linkage, int offset, boolean allowsNulls) {
this.offset = offset;
this.linkage = linkage;
this.allowsNull = allowsNulls;
@ -43,12 +40,11 @@ public class PDOMNodeLinkedList {
/**
* Creates an object representing a linked list at the specified offset of the specified pdom.
* The linked list created may not hold null items
* @param pdom
* @param offset
* @param linkage
* @param offset
*/
public PDOMNodeLinkedList(PDOM pdom, int offset, PDOMLinkage linkage) {
this(pdom, offset, linkage, false);
public PDOMNodeLinkedList(PDOMLinkage linkage, int offset) {
this(linkage, offset, false);
}
protected int getRecordSize() {
@ -56,7 +52,7 @@ public class PDOMNodeLinkedList {
}
public void accept(IPDOMVisitor visitor) throws CoreException {
Database db = pdom.getDB();
Database db = linkage.getDB();
int firstItem = db.getInt(offset + FIRST_MEMBER);
if (firstItem == 0)
return;
@ -81,7 +77,7 @@ public class PDOMNodeLinkedList {
}
private ListItem getFirstMemberItem() throws CoreException {
Database db = pdom.getDB();
Database db = linkage.getDB();
int item = db.getInt(offset + FIRST_MEMBER);
return item != 0 ? new ListItem(db, item) : null;
}
@ -93,7 +89,7 @@ public class PDOMNodeLinkedList {
* @return The node at position {@code pos}, or {@code null} if no such node exists.
*/
public PDOMNode getNodeAt(int pos) throws CoreException {
Database db = pdom.getDB();
Database db = linkage.getDB();
int firstItem = db.getInt(offset + FIRST_MEMBER);
if (firstItem == 0) {
return null;
@ -120,7 +116,7 @@ public class PDOMNodeLinkedList {
}
protected void addMember(int record) throws CoreException {
Database db = pdom.getDB();
Database db = linkage.getDB();
ListItem firstMember = getFirstMemberItem();
if (firstMember == null) {
firstMember = new ListItem(db);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Symbian Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -13,8 +13,8 @@ package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
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.IBTreeVisitor;
import org.eclipse.cdt.internal.core.pdom.db.IString;
@ -26,22 +26,24 @@ import org.eclipse.core.runtime.OperationCanceledException;
*/
public class FindBinding {
public static class DefaultBindingBTreeComparator implements IBTreeComparator {
protected PDOM pdom;
protected final PDOMLinkage linkage;
protected final Database database;
public DefaultBindingBTreeComparator(PDOM pdom) {
this.pdom = pdom;
public DefaultBindingBTreeComparator(PDOMLinkage linkage) {
this.linkage = linkage;
this.database= linkage.getDB();
}
public int compare(int record1, int record2) throws CoreException {
IString nm1 = PDOMNamedNode.getDBName(pdom, record1);
IString nm2 = PDOMNamedNode.getDBName(pdom, record2);
IString nm1 = PDOMNamedNode.getDBName(database, record1);
IString nm2 = PDOMNamedNode.getDBName(database, record2);
int cmp= nm1.compareCompatibleWithIgnoreCase(nm2);
if (cmp == 0) {
int t1= PDOMBinding.getLocalToFileRec(pdom, record1);
int t2= PDOMBinding.getLocalToFileRec(pdom, record2);
int t1= PDOMBinding.getLocalToFileRec(database, record1);
int t2= PDOMBinding.getLocalToFileRec(database, record2);
if (t1 == t2) {
t1 = PDOMNode.getNodeType(pdom, record1);
t2 = PDOMNode.getNodeType(pdom, record2);
t1 = PDOMNode.getNodeType(database, record1);
t2 = PDOMNode.getNodeType(database, record2);
}
cmp= t1 < t2 ? -1 : (t1 > t2 ? 1 : 0);
}
@ -50,14 +52,14 @@ public class FindBinding {
}
public static class DefaultFindBindingVisitor implements IBTreeVisitor, IPDOMVisitor {
protected final PDOM fPdom;
protected final PDOMLinkage fLinkage;
private final char[] fName;
private final int[] fConstants;
private final int fLocalToFile;
protected PDOMBinding fResult;
protected DefaultFindBindingVisitor(PDOM pdom, char[] name, int[] constants, int localToFile) {
fPdom = pdom;
protected DefaultFindBindingVisitor(PDOMLinkage linkage, char[] name, int[] constants, int localToFile) {
fLinkage = linkage;
fName = name;
fConstants = constants;
fLocalToFile= localToFile;
@ -65,10 +67,11 @@ public class FindBinding {
// IBTreeVisitor
public int compare(int record) throws CoreException {
IString nm1 = PDOMNamedNode.getDBName(fPdom, record);
final Database db = fLinkage.getDB();
IString nm1 = PDOMNamedNode.getDBName(db, record);
int cmp= nm1.compareCompatibleWithIgnoreCase(fName);
if (cmp == 0) {
int t1= PDOMBinding.getLocalToFileRec(fPdom, record);
int t1= PDOMBinding.getLocalToFileRec(db, record);
int t2= fLocalToFile;
cmp= t1 < t2 ? -1 : (t1 > t2 ? 1 : 0);
}
@ -77,7 +80,7 @@ public class FindBinding {
// IBTreeVisitor
public boolean visit(int record) throws CoreException {
final PDOMNamedNode nnode = (PDOMNamedNode) PDOMNode.getLinkage(fPdom, record).getNode(record);
final PDOMNamedNode nnode = (PDOMNamedNode) fLinkage.getNode(record);
if (nnode instanceof PDOMBinding) {
final PDOMBinding binding = (PDOMBinding) nnode;
if (matches(binding)) {
@ -120,11 +123,8 @@ public class FindBinding {
}
public static class NestedBindingsBTreeComparator extends DefaultBindingBTreeComparator {
protected PDOMLinkage linkage;
public NestedBindingsBTreeComparator(PDOMLinkage linkage) {
super(linkage.pdom);
this.linkage= linkage;
super(linkage);
}
@Override
@ -142,30 +142,29 @@ public class FindBinding {
}
public static class MacroBTreeComparator implements IBTreeComparator {
final private PDOM fPDom;
final private Database db;
public MacroBTreeComparator(PDOM pdom) {
fPDom= pdom;
public MacroBTreeComparator(Database database) {
db= database;
}
public int compare(int record1, int record2) throws CoreException {
return compare(PDOMNamedNode.getDBName(fPDom, record1), PDOMNamedNode.getDBName(fPDom, record2)); // compare names
return compare(PDOMNamedNode.getDBName(db, record1), PDOMNamedNode.getDBName(db, record2)); // compare names
}
private int compare(IString nameInDB, IString nameInDB2) throws CoreException {
return nameInDB.compareCompatibleWithIgnoreCase(nameInDB2);
}
}
public static PDOMBinding findBinding(BTree btree, final PDOM pdom, final char[] name, final int[] constants,
final int localToFileRec) throws CoreException {
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(pdom, name, constants, localToFileRec);
public static PDOMBinding findBinding(BTree btree, final PDOMLinkage linkage, final char[] name,
final int[] constants, final int localToFileRec) throws CoreException {
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(linkage, name, constants, localToFileRec);
btree.accept(visitor);
return visitor.getResult();
}
public static PDOMBinding findBinding(IPDOMNode node, final PDOM pdom, final char[] name, final int[] constants,
public static PDOMBinding findBinding(IPDOMNode node, final PDOMLinkage linkage, final char[] name, final int[] constants,
int localToFileRec) throws CoreException {
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(pdom, name, constants, localToFileRec);
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(linkage, name, constants, localToFileRec);
try {
node.accept(visitor);
} catch (OperationCanceledException e) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.dom;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.cdt.internal.core.pdom.db.IString;
import org.eclipse.core.runtime.CoreException;
@ -25,7 +24,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
* @since 4.0.2
*/
public final class MacroContainerCollector implements IBTreeVisitor {
private final PDOM pdom;
private final PDOMLinkage linkage;
private final char[] name;
private final boolean prefixLookup;
private final boolean caseSensitive;
@ -39,9 +38,9 @@ public final class MacroContainerCollector implements IBTreeVisitor {
* Collects all nodes with given name, passing the filter. If prefixLookup is set to
* <code>true</code> a binding is considered if its name starts with the given prefix.
*/
public MacroContainerCollector(PDOM pdom, char[] name, boolean prefixLookup, boolean caseSensitive) {
public MacroContainerCollector(PDOMLinkage linkage, char[] name, boolean prefixLookup, boolean caseSensitive) {
this.name= name;
this.pdom= pdom;
this.linkage= linkage;
this.prefixLookup= prefixLookup;
this.caseSensitive= caseSensitive;
}
@ -57,7 +56,7 @@ public final class MacroContainerCollector implements IBTreeVisitor {
final public int compare(int record) throws CoreException {
if (monitor != null)
checkCancelled();
IString rhsName= PDOMNamedNode.getDBName(pdom, record);
IString rhsName= PDOMNamedNode.getDBName(linkage.getDB(), record);
return compare(rhsName);
}
@ -87,7 +86,7 @@ public final class MacroContainerCollector implements IBTreeVisitor {
if (record == 0)
return true;
macros.add(new PDOMMacroContainer(pdom, record));
macros.add(new PDOMMacroContainer(linkage, record));
return true; // look for more
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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
@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.cdt.internal.core.pdom.db.IString;
import org.eclipse.core.runtime.CoreException;
@ -19,7 +18,7 @@ import org.eclipse.core.runtime.CoreException;
* Visitor to find a macro container in a BTree.
*/
public final class MacroContainerFinder implements IBTreeVisitor {
private final PDOM fPdom;
private final PDOMLinkage fLinkage;
private final char[] fName;
private PDOMMacroContainer fMacroContainer;
@ -27,13 +26,13 @@ public final class MacroContainerFinder implements IBTreeVisitor {
* Collects all nodes with given name, passing the filter. If prefixLookup is set to
* <code>true</code> a binding is considered if its name starts with the given prefix.
*/
public MacroContainerFinder(PDOM pdom, char[] name) {
public MacroContainerFinder(PDOMLinkage linkage, char[] name) {
fName= name;
fPdom= pdom;
fLinkage= linkage;
}
final public int compare(int record) throws CoreException {
IString name= PDOMNamedNode.getDBName(fPdom, record);
IString name= PDOMNamedNode.getDBName(fLinkage.getDB(), record);
return compare(name);
}
@ -44,7 +43,7 @@ public final class MacroContainerFinder implements IBTreeVisitor {
final public boolean visit(int record) throws CoreException {
if (record == 0)
return true;
fMacroContainer= new PDOMMacroContainer(fPdom, record);
fMacroContainer= new PDOMMacroContainer(fLinkage, record);
return false; // we are done.
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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,7 +14,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@ -25,7 +24,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
* @since 4.0.2
*/
public final class MacroContainerPatternCollector implements IBTreeVisitor {
private final PDOM fPDOM;
private final PDOMLinkage fLinkage;
private final List<PDOMMacroContainer> macros = new ArrayList<PDOMMacroContainer>();
private final Pattern fPattern;
@ -33,8 +32,8 @@ public final class MacroContainerPatternCollector implements IBTreeVisitor {
private int fMonitorCheckCounter= 0;
public MacroContainerPatternCollector(PDOM pdom, Pattern pattern, IProgressMonitor monitor) {
fPDOM= pdom;
public MacroContainerPatternCollector(PDOMLinkage linkage, Pattern pattern, IProgressMonitor monitor) {
fLinkage= linkage;
fPattern= pattern;
fMonitor= monitor;
}
@ -50,9 +49,9 @@ public final class MacroContainerPatternCollector implements IBTreeVisitor {
if (record == 0)
return true;
String name= PDOMNamedNode.getDBName(fPDOM, record).getString();
String name= PDOMNamedNode.getDBName(fLinkage.getDB(), record).getString();
if (fPattern.matcher(name).matches()) {
macros.add(new PDOMMacroContainer(fPDOM, record));
macros.add(new PDOMMacroContainer(fLinkage, record));
}
return true; // look for more
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
@ -64,7 +64,7 @@ public class NamedNodeCollector implements IBTreeVisitor, IPDOMVisitor {
final public int compare(int record) throws CoreException {
if (monitor != null)
checkCancelled();
IString rhsName= PDOMNamedNode.getDBName(linkage.getPDOM(), record);
IString rhsName= PDOMNamedNode.getDBName(linkage.getDB(), record);
return compare(rhsName);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
@ -21,8 +21,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.ArrayTypeClone;
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, ITypeContainer {
@ -31,19 +29,17 @@ public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, I
@SuppressWarnings("hiding")
private static final int RECORD_SIZE= TYPE+4;
public PDOMArrayType(PDOM pdom, int record) {
super(pdom, record);
public PDOMArrayType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMArrayType(PDOM pdom, PDOMNode parent, IArrayType type) throws CoreException {
super(pdom, parent);
Database db = pdom.getDB();
public PDOMArrayType(PDOMLinkage linkage, PDOMNode parent, IArrayType type) throws CoreException {
super(linkage, parent);
try {
PDOMNode targetTypeNode = getLinkageImpl().addType(this, type.getType());
PDOMNode targetTypeNode = getLinkage().addType(this, type.getType());
if (targetTypeNode != null) {
int typeRec = targetTypeNode.getRecord();
db.putInt(record + TYPE, typeRec);
getDB().putInt(record + TYPE, typeRec);
}
} catch (DOMException e) {
CCorePlugin.log(e);
@ -66,7 +62,7 @@ public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, I
public IType getType() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -48,12 +48,12 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 16;
protected PDOMBinding(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
super(pdom, parent, name);
protected PDOMBinding(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
super(linkage, parent, name);
}
public PDOMBinding(PDOM pdom, int record) {
super(pdom, record);
public PDOMBinding(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@SuppressWarnings("unchecked")
@ -81,13 +81,8 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
&& db.getInt(record + FIRST_REF_OFFSET) == 0;
}
@Override
public int getRecord() {
return record;
}
public final boolean hasDeclaration() throws CoreException {
Database db = pdom.getDB();
Database db = getDB();
return db.getInt(record + FIRST_DECL_OFFSET) != 0
|| db.getInt(record + FIRST_DEF_OFFSET) != 0;
}
@ -120,50 +115,50 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
public PDOMName getFirstDeclaration() throws CoreException {
int namerec = pdom.getDB().getInt(record + FIRST_DECL_OFFSET);
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
int namerec = getDB().getInt(record + FIRST_DECL_OFFSET);
return namerec != 0 ? new PDOMName(getLinkage(), namerec) : null;
}
public void setFirstDeclaration(PDOMName name) throws CoreException {
int namerec = name != null ? name.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_DECL_OFFSET, namerec);
getDB().putInt(record + FIRST_DECL_OFFSET, namerec);
}
public PDOMName getFirstDefinition() throws CoreException {
int namerec = pdom.getDB().getInt(record + FIRST_DEF_OFFSET);
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
int namerec = getDB().getInt(record + FIRST_DEF_OFFSET);
return namerec != 0 ? new PDOMName(getLinkage(), namerec) : null;
}
public void setFirstDefinition(PDOMName name) throws CoreException {
int namerec = name != null ? name.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_DEF_OFFSET, namerec);
getDB().putInt(record + FIRST_DEF_OFFSET, namerec);
}
public PDOMName getFirstReference() throws CoreException {
int namerec = pdom.getDB().getInt(record + FIRST_REF_OFFSET);
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
int namerec = getDB().getInt(record + FIRST_REF_OFFSET);
return namerec != 0 ? new PDOMName(getLinkage(), namerec) : null;
}
public void setFirstReference(PDOMName name) throws CoreException {
int namerec = name != null ? name.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_REF_OFFSET, namerec);
getDB().putInt(record + FIRST_REF_OFFSET, namerec);
}
public final PDOMFile getLocalToFile() throws CoreException {
final int filerec = getLocalToFileRec(pdom, record);
return filerec == 0 ? null : new PDOMFile(pdom, filerec);
final int filerec = getLocalToFileRec(getDB(), record);
return filerec == 0 ? null : new PDOMFile(getLinkage(), filerec);
}
public final int getLocalToFileRec() throws CoreException {
return pdom.getDB().getInt(record + LOCAL_TO_FILE);
return getLocalToFileRec(getDB(), record);
}
public static int getLocalToFileRec(PDOM pdom, int record) throws CoreException {
return pdom.getDB().getInt(record + LOCAL_TO_FILE);
public static int getLocalToFileRec(Database db, int record) throws CoreException {
return db.getInt(record + LOCAL_TO_FILE);
}
public final void setLocalToFileRec(int rec) throws CoreException {
pdom.getDB().putInt(record + LOCAL_TO_FILE, rec);
getDB().putInt(record + LOCAL_TO_FILE, rec);
}
public String getName() {
@ -218,7 +213,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
public IIndexFragment getFragment() {
return pdom;
return getPDOM();
}
@Override
@ -230,7 +225,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
@Override
public String toString() {
try {
return getName() + " " + getConstantNameForValue(getLinkageImpl(), getNodeType()); //$NON-NLS-1$
return getName() + " " + getConstantNameForValue(getLinkage(), getNodeType()); //$NON-NLS-1$
} catch (CoreException ce) {
return getName() + " " + getNodeType(); //$NON-NLS-1$
}
@ -301,7 +296,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
final public boolean isFileLocal() throws CoreException {
return pdom.getDB().getInt(record + LOCAL_TO_FILE) != 0;
return getDB().getInt(record + LOCAL_TO_FILE) != 0;
}
public boolean hasDefinition() throws CoreException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -21,7 +21,6 @@ import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
@ -36,7 +35,6 @@ import org.eclipse.cdt.core.index.IIndexInclude;
import org.eclipse.cdt.core.index.IIndexLocationConverter;
import org.eclipse.cdt.core.index.IIndexMacro;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
@ -59,10 +57,9 @@ import org.eclipse.core.runtime.Status;
* @author Doug Schaefer
*/
public class PDOMFile implements IIndexFragmentFile {
private final PDOM pdom;
private final PDOMLinkage fLinkage;
private final int record;
private IIndexFileLocation location;
private PDOMLinkage fLinkage;
private static final int FIRST_NAME = 0;
private static final int FIRST_INCLUDE = 4;
@ -95,17 +92,17 @@ public class PDOMFile implements IIndexFragmentFile {
}
}
public PDOMFile(PDOM pdom, int record) {
this.pdom = pdom;
public PDOMFile(PDOMLinkage linkage, int record) {
fLinkage = linkage;
this.record = record;
}
public PDOMFile(PDOM pdom, IIndexFileLocation location, int linkageID) throws CoreException {
this.pdom = pdom;
public PDOMFile(PDOMLinkage linkage, IIndexFileLocation location, int linkageID) throws CoreException {
fLinkage = linkage;
this.location= location;
Database db = pdom.getDB();
Database db = fLinkage.getDB();
record = db.malloc(RECORD_SIZE);
String locationString = pdom.getLocationConverter().toInternalFormat(location);
String locationString = fLinkage.getPDOM().getLocationConverter().toInternalFormat(location);
if (locationString==null)
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem")+location.getURI())); //$NON-NLS-1$
IString locationDBString = db.newString(locationString);
@ -128,14 +125,14 @@ public class PDOMFile implements IIndexFragmentFile {
return true;
if (obj instanceof PDOMFile) {
PDOMFile other = (PDOMFile)obj;
return pdom.equals(other.pdom) && record == other.record;
return fLinkage.getPDOM().equals(other.getLinkage().getPDOM()) && record == other.record;
}
return false;
}
@Override
public final int hashCode() {
return System.identityHashCode(pdom) + 41*record;
return System.identityHashCode(fLinkage.getPDOM()) + 41*record;
}
/**
@ -146,7 +143,7 @@ public class PDOMFile implements IIndexFragmentFile {
* @throws CoreException
*/
public void setInternalLocation(String internalLocation) throws CoreException {
Database db = pdom.getDB();
Database db = fLinkage.getDB();
int oldRecord = db.getInt(record + LOCATION_REPRESENTATION);
db.free(oldRecord);
db.putInt(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord());
@ -154,63 +151,63 @@ public class PDOMFile implements IIndexFragmentFile {
}
public int getLinkageID() throws CoreException {
Database db = pdom.getDB();
Database db = fLinkage.getDB();
return db.getInt(record + LINKAGE_ID);
}
public long getTimestamp() throws CoreException {
Database db = pdom.getDB();
Database db = fLinkage.getDB();
return db.getLong(record + TIME_STAMP);
}
public void setTimestamp(long timestamp) throws CoreException {
Database db= pdom.getDB();
Database db= fLinkage.getDB();
db.putLong(record + TIME_STAMP, timestamp);
}
public int getScannerConfigurationHashcode() throws CoreException {
Database db = pdom.getDB();
Database db = fLinkage.getDB();
return db.getInt(record + SCANNER_CONFIG_HASH);
}
public void setScannerConfigurationHashcode(int hashcode) throws CoreException {
Database db= pdom.getDB();
Database db= fLinkage.getDB();
db.putInt(record + SCANNER_CONFIG_HASH, hashcode);
}
private PDOMName getFirstName() throws CoreException {
int namerec = pdom.getDB().getInt(record + FIRST_NAME);
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
int namerec = fLinkage.getDB().getInt(record + FIRST_NAME);
return namerec != 0 ? new PDOMName(fLinkage, namerec) : null;
}
private void setFirstName(PDOMName firstName) throws CoreException {
int namerec = firstName != null ? firstName.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_NAME, namerec);
fLinkage.getDB().putInt(record + FIRST_NAME, namerec);
}
private PDOMMacroReferenceName getFirstMacroReference() throws CoreException {
int namerec = pdom.getDB().getInt(record + FIRST_MACRO_REFERENCE);
return namerec != 0 ? new PDOMMacroReferenceName(pdom, namerec) : null;
int namerec = fLinkage.getDB().getInt(record + FIRST_MACRO_REFERENCE);
return namerec != 0 ? new PDOMMacroReferenceName(fLinkage, namerec) : null;
}
private void setFirstMacroReference(PDOMMacroReferenceName firstName) throws CoreException {
int namerec = firstName != null ? firstName.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_MACRO_REFERENCE, namerec);
fLinkage.getDB().putInt(record + FIRST_MACRO_REFERENCE, namerec);
}
public PDOMInclude getFirstInclude() throws CoreException {
int increc = pdom.getDB().getInt(record + FIRST_INCLUDE);
return increc != 0 ? new PDOMInclude(pdom, increc) : null;
int increc = fLinkage.getDB().getInt(record + FIRST_INCLUDE);
return increc != 0 ? new PDOMInclude(fLinkage, increc) : null;
}
public void setFirstInclude(PDOMInclude include) throws CoreException {
int rec = include != null ? include.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_INCLUDE, rec);
fLinkage.getDB().putInt(record + FIRST_INCLUDE, rec);
}
public PDOMInclude getFirstIncludedBy() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRST_INCLUDED_BY);
return rec != 0 ? new PDOMInclude(pdom, rec) : null;
int rec = fLinkage.getDB().getInt(record + FIRST_INCLUDED_BY);
return rec != 0 ? new PDOMInclude(fLinkage, rec) : null;
}
public IIndexInclude getParsedInContext() throws CoreException {
@ -219,17 +216,17 @@ public class PDOMFile implements IIndexFragmentFile {
public void setFirstIncludedBy(PDOMInclude includedBy) throws CoreException {
int rec = includedBy != null ? includedBy.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_INCLUDED_BY, rec);
fLinkage.getDB().putInt(record + FIRST_INCLUDED_BY, rec);
}
public PDOMMacro getFirstMacro() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRST_MACRO);
return rec != 0 ? new PDOMMacro(pdom, rec) : null;
int rec = fLinkage.getDB().getInt(record + FIRST_MACRO);
return rec != 0 ? new PDOMMacro(fLinkage, rec) : null;
}
public void setFirstMacro(PDOMMacro macro) throws CoreException {
int rec = macro != null ? macro.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_MACRO, rec);
fLinkage.getDB().putInt(record + FIRST_MACRO, rec);
}
public void addMacros(IASTPreprocessorStatement[] macros) throws CoreException {
@ -242,11 +239,11 @@ public class PDOMFile implements IIndexFragmentFile {
if (stmt instanceof IASTPreprocessorMacroDefinition) {
IASTPreprocessorMacroDefinition macro= (IASTPreprocessorMacroDefinition) stmt;
PDOMMacroContainer container= linkage.getMacroContainer(macro.getName().getSimpleID());
pdomMacro = new PDOMMacro(pdom, container, macro, this);
pdomMacro = new PDOMMacro(fLinkage, container, macro, this);
} else if (stmt instanceof IASTPreprocessorUndefStatement) {
IASTPreprocessorUndefStatement undef= (IASTPreprocessorUndefStatement) stmt;
PDOMMacroContainer container= linkage.getMacroContainer(undef.getMacroName().getSimpleID());
pdomMacro = new PDOMMacro(pdom, container, undef, this);
pdomMacro = new PDOMMacro(fLinkage, container, undef, this);
}
if (pdomMacro != null) {
if (lastMacro == null) {
@ -259,14 +256,7 @@ public class PDOMFile implements IIndexFragmentFile {
}
}
PDOMLinkage getLinkage() throws CoreException {
if (fLinkage == null) {
final String linkageName = Linkage.getLinkageName(getLinkageID());
fLinkage= pdom.createLinkage(linkageName);
if (fLinkage == null) {
throw new CoreException(createStatus("Unsupported linkage: " + linkageName)); //$NON-NLS-1$
}
}
final PDOMLinkage getLinkage() {
return fLinkage;
}
@ -315,7 +305,7 @@ public class PDOMFile implements IIndexFragmentFile {
}
PDOMBinding pdomBinding = linkage.addBinding(name);
if (pdomBinding != null) {
final PDOMName result= new PDOMName(pdom, name, this, pdomBinding, caller);
final PDOMName result= new PDOMName(fLinkage, name, this, pdomBinding, caller);
linkage.onCreateName(this, name, result);
return result;
}
@ -327,7 +317,7 @@ public class PDOMFile implements IIndexFragmentFile {
private IIndexFragmentName createPDOMMacroReferenceName(PDOMLinkage linkage, IASTName name) throws CoreException {
PDOMMacroContainer cont= linkage.getMacroContainer(name.getSimpleID());
return new PDOMMacroReferenceName(pdom, name, this, cont);
return new PDOMMacroReferenceName(fLinkage, name, this, cont);
}
public void clear(Collection<IIndexFileLocation> contextsRemoved) throws CoreException {
@ -397,7 +387,7 @@ public class PDOMFile implements IIndexFragmentFile {
for (final IncludeInformation info : includeInfos) {
final PDOMFile targetFile= (PDOMFile) info.fTargetFile;
PDOMInclude pdomInclude = new PDOMInclude(pdom, info.fStatement, this, targetFile);
PDOMInclude pdomInclude = new PDOMInclude(fLinkage, info.fStatement, this, targetFile);
if (targetFile != null) {
assert targetFile.getIndexFragment() instanceof IWritableIndexFragment;
targetFile.addIncludedBy(pdomInclude, info.fIsContext);
@ -453,7 +443,7 @@ public class PDOMFile implements IIndexFragmentFile {
}
public IIndexFragment getIndexFragment() {
return pdom;
return fLinkage.getPDOM();
}
public IIndexName[] findNames(int offset, int length) throws CoreException {
@ -497,16 +487,19 @@ public class PDOMFile implements IIndexFragmentFile {
return result.toArray(new IIndexName[result.size()]);
}
public static PDOMFile findFile(PDOM pdom, BTree btree, IIndexFileLocation location, int linkageID, IIndexLocationConverter strategy)
public static PDOMFile findFile(PDOMLinkage linkage, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
throws CoreException {
String internalRepresentation= strategy.toInternalFormat(location);
int record= 0;
if (internalRepresentation != null) {
Finder finder = new Finder(pdom.getDB(), internalRepresentation, linkageID);
Finder finder = new Finder(linkage.getDB(), internalRepresentation, linkage.getLinkageID());
btree.accept(finder);
record= finder.getRecord();
}
return record != 0 ? new PDOMFile(pdom, record) : null;
if (record != 0) {
return new PDOMFile(linkage, record);
}
return null;
}
public static IIndexFragmentFile[] findFiles(PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
@ -518,13 +511,23 @@ public class PDOMFile implements IIndexFragmentFile {
int[] records= finder.getRecords();
PDOMFile[] result= new PDOMFile[records.length];
for (int i = 0; i < result.length; i++) {
result[i]= new PDOMFile(pdom, records[i]);
result[i] = recreateFile(pdom, records[i]);
}
return result;
}
return new IIndexFragmentFile[0];
}
public static PDOMFile recreateFile(PDOM pdom, final int record) throws CoreException {
final Database db= pdom.getDB();
final int linkageID= db.getInt(record + PDOMFile.LINKAGE_ID);
PDOMLinkage linkage= pdom.getLinkage(linkageID);
if (linkage == null)
throw new CoreException(createStatus("Invalid linkage ID in database")); //$NON-NLS-1$
PDOMFile file= new PDOMFile(linkage, record);
return file;
}
private static class Finder implements IBTreeVisitor {
private static final int[] EMPTY = {};
private final Database db;
@ -586,9 +589,9 @@ public class PDOMFile implements IIndexFragmentFile {
public IIndexFileLocation getLocation() throws CoreException {
if (location == null) {
Database db = pdom.getDB();
Database db = fLinkage.getDB();
String raw = db.getString(db.getInt(record + LOCATION_REPRESENTATION)).getString();
location= pdom.getLocationConverter().fromInternalFormat(raw);
location= fLinkage.getPDOM().getLocationConverter().fromInternalFormat(raw);
if (location == null) {
URI uri;
try {
@ -621,26 +624,22 @@ public class PDOMFile implements IIndexFragmentFile {
}
public int getFirstUsingDirectiveRec() throws CoreException {
return pdom.getDB().getInt(record + FIRST_USING_DIRECTIVE);
return fLinkage.getDB().getInt(record + FIRST_USING_DIRECTIVE);
}
public void setFirstUsingDirectiveRec(int rec) throws CoreException {
pdom.getDB().putInt(record + FIRST_USING_DIRECTIVE, rec);
fLinkage.getDB().putInt(record + FIRST_USING_DIRECTIVE, rec);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.index.IIndexFile#getUsingDirectives()
*/
public ICPPUsingDirective[] getUsingDirectives() throws CoreException {
PDOMLinkage linkage= pdom.getLinkage(ILinkage.CPP_LINKAGE_NAME);
if (linkage != null) {
return linkage.getUsingDirectives(this);
}
return ICPPUsingDirective.EMPTY_ARRAY;
return fLinkage.getUsingDirectives(this);
}
// required because we cannot reference CCorePlugin in order for StandaloneIndexer to work
private IStatus createStatus(String msg) {
private static IStatus createStatus(String msg) {
return new Status(IStatus.ERROR, "org.eclipse.cdt.core", IStatus.ERROR, msg, null); //$NON-NLS-1$
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -20,7 +20,6 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.index.IIndexFragmentInclude;
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.IString;
import org.eclipse.core.runtime.CoreException;
@ -46,20 +45,20 @@ public class PDOMInclude implements IIndexFragmentInclude {
private static final int FLAG_UNRESOLVED_INCLUDE = 4;
private static final int FLAG_RESOLVED_BY_HEURISTICS= 8;
private final PDOM pdom;
private final PDOMLinkage linkage;
private final int record;
// cached fields
private String fName= null;
public PDOMInclude(PDOM pdom, int record) {
this.pdom = pdom;
public PDOMInclude(PDOMLinkage pdom, int record) {
this.linkage = pdom;
this.record = record;
}
public PDOMInclude(PDOM pdom, IASTPreprocessorIncludeStatement include, PDOMFile containerFile, PDOMFile targetFile) throws CoreException {
this.pdom = pdom;
this.record = pdom.getDB().malloc(RECORD_SIZE);
public PDOMInclude(PDOMLinkage linkage, IASTPreprocessorIncludeStatement include, PDOMFile containerFile, PDOMFile targetFile) throws CoreException {
this.linkage = linkage;
this.record = linkage.getDB().malloc(RECORD_SIZE);
IASTName name= include.getName();
IASTFileLocation loc= name.getFileLocation();
// includes generated by -include or -macro don't have a location
@ -102,7 +101,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
}
// Delete our record
pdom.getDB().free(record);
linkage.getDB().free(record);
}
private void removeThisFromIncludedByChain() throws CoreException {
@ -121,7 +120,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
if (isResolved()) {
return null;
}
final Database db = pdom.getDB();
final Database db = linkage.getDB();
return db.getString(db.getInt(record + INCLUDES_FILE_OR_NAME));
}
@ -129,63 +128,63 @@ public class PDOMInclude implements IIndexFragmentInclude {
if (!isResolved()) {
return null;
}
int rec = pdom.getDB().getInt(record + INCLUDES_FILE_OR_NAME);
return rec != 0 ? new PDOMFile(pdom, rec) : null;
int rec = linkage.getDB().getInt(record + INCLUDES_FILE_OR_NAME);
return rec != 0 ? new PDOMFile(linkage, rec) : null;
}
private void setIncludes(PDOMFile includes, char[] name) throws CoreException {
int rec= 0;
if (includes == null) {
rec= pdom.getDB().newString(name).getRecord();
rec= linkage.getDB().newString(name).getRecord();
}
else {
rec= includes.getRecord();
}
pdom.getDB().putInt(record + INCLUDES_FILE_OR_NAME, rec);
linkage.getDB().putInt(record + INCLUDES_FILE_OR_NAME, rec);
}
public IIndexFile getIncludedBy() throws CoreException {
int rec = pdom.getDB().getInt(record + INCLUDED_BY);
return rec != 0 ? new PDOMFile(pdom, rec) : null;
int rec = linkage.getDB().getInt(record + INCLUDED_BY);
return rec != 0 ? new PDOMFile(linkage, rec) : null;
}
private void setIncludedBy(PDOMFile includedBy) throws CoreException {
int rec = includedBy != null ? includedBy.getRecord() : 0;
pdom.getDB().putInt(record + INCLUDED_BY, rec);
linkage.getDB().putInt(record + INCLUDED_BY, rec);
}
public PDOMInclude getNextInIncludes() throws CoreException {
int rec = pdom.getDB().getInt(record + INCLUDES_NEXT);
return rec != 0 ? new PDOMInclude(pdom, rec) : null;
int rec = linkage.getDB().getInt(record + INCLUDES_NEXT);
return rec != 0 ? new PDOMInclude(linkage, rec) : null;
}
public void setNextInIncludes(PDOMInclude include) throws CoreException {
int rec = include != null ? include.getRecord() : 0;
pdom.getDB().putInt(record + INCLUDES_NEXT, rec);
linkage.getDB().putInt(record + INCLUDES_NEXT, rec);
}
public PDOMInclude getNextInIncludedBy() throws CoreException {
int rec = pdom.getDB().getInt(record + INCLUDED_BY_NEXT);
return rec != 0 ? new PDOMInclude(pdom, rec) : null;
int rec = linkage.getDB().getInt(record + INCLUDED_BY_NEXT);
return rec != 0 ? new PDOMInclude(linkage, rec) : null;
}
public void setNextInIncludedBy(PDOMInclude include) throws CoreException {
int rec = include != null ? include.getRecord() : 0;
pdom.getDB().putInt(record + INCLUDED_BY_NEXT, rec);
linkage.getDB().putInt(record + INCLUDED_BY_NEXT, rec);
}
public PDOMInclude getPrevInIncludedBy() throws CoreException {
int rec = getPrevInIncludedByRecord();
return rec != 0 ? new PDOMInclude(pdom, rec) : null;
return rec != 0 ? new PDOMInclude(linkage, rec) : null;
}
int getPrevInIncludedByRecord() throws CoreException {
return pdom.getDB().getInt(record + INCLUDED_BY_PREV);
return linkage.getDB().getInt(record + INCLUDED_BY_PREV);
}
public void setPrevInIncludedBy(PDOMInclude include) throws CoreException {
int rec = include != null ? include.getRecord() : 0;
pdom.getDB().putInt(record + INCLUDED_BY_PREV, rec);
linkage.getDB().putInt(record + INCLUDED_BY_PREV, rec);
}
public IIndexFileLocation getIncludedByLocation() throws CoreException {
@ -200,20 +199,20 @@ public class PDOMInclude implements IIndexFragmentInclude {
}
public IIndexFragment getFragment() {
return pdom;
return linkage.getPDOM();
}
private void setNameOffsetAndLength(int offset, short length) throws CoreException {
pdom.getDB().putInt(record + NODE_OFFSET_OFFSET, offset);
pdom.getDB().putShort(record + NODE_LENGTH_OFFSET, length);
linkage.getDB().putInt(record + NODE_OFFSET_OFFSET, offset);
linkage.getDB().putShort(record + NODE_LENGTH_OFFSET, length);
}
private void setFlag(byte flag) throws CoreException {
pdom.getDB().putByte(record + FLAG_OFFSET, flag);
linkage.getDB().putByte(record + FLAG_OFFSET, flag);
}
private int getFlag() throws CoreException {
return pdom.getDB().getByte(record + FLAG_OFFSET);
return linkage.getDB().getByte(record + FLAG_OFFSET);
}
public boolean isSystemInclude() throws CoreException {
@ -233,11 +232,11 @@ public class PDOMInclude implements IIndexFragmentInclude {
}
public int getNameOffset() throws CoreException {
return pdom.getDB().getInt(record + NODE_OFFSET_OFFSET);
return linkage.getDB().getInt(record + NODE_OFFSET_OFFSET);
}
public int getNameLength() throws CoreException {
return pdom.getDB().getShort(record + NODE_LENGTH_OFFSET) & 0xffff;
return linkage.getDB().getShort(record + NODE_LENGTH_OFFSET) & 0xffff;
}
public String getName() throws CoreException {

View file

@ -65,20 +65,39 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
protected static final int LINKAGE= 0; // special one for myself
private BTree fMacroIndex= null;
private final PDOM fPDOM;
private final Database fDatabase;
public PDOMLinkage(PDOM pdom, int record) {
super(pdom, record);
super(null, record);
fPDOM= pdom;
fDatabase= pdom.getDB();
}
protected PDOMLinkage(PDOM pdom, String languageId, char[] name) throws CoreException {
super(pdom, null, name);
Database db = pdom.getDB();
super(pdom.getDB(), name);
final Database db= pdom.getDB();
// id
fPDOM= pdom;
fDatabase= db;
db.putInt(record + ID_OFFSET, db.newString(languageId).getRecord());
pdom.insertLinkage(this);
}
@Override
public final PDOM getPDOM() {
return fPDOM;
}
@Override
public final PDOMLinkage getLinkage() throws CoreException {
return this;
}
@Override
public final Database getDB() {
return fDatabase;
}
@Override
protected int getRecordSize() {
@ -90,7 +109,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return LINKAGE;
}
public static IString getId(PDOM pdom, int record) throws CoreException {
public static IString getLinkageID(PDOM pdom, int record) throws CoreException {
Database db = pdom.getDB();
int namerec = db.getInt(record + ID_OFFSET);
return db.getString(namerec);
@ -101,11 +120,11 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
}
public void setNext(int nextrec) throws CoreException {
pdom.getDB().putInt(record + NEXT_OFFSET, nextrec);
getDB().putInt(record + NEXT_OFFSET, nextrec);
}
public BTree getIndex() throws CoreException {
return new BTree(pdom.getDB(), record + INDEX_OFFSET, getIndexComparator());
return new BTree(getDB(), record + INDEX_OFFSET, getIndexComparator());
}
/**
@ -113,7 +132,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
* @throws CoreException
*/
public BTree getNestedBindingsIndex() throws CoreException {
return new BTree(getPDOM().getDB(), record + NESTED_BINDINGS_INDEX, getNestedBindingsComparator());
return new BTree(fDatabase, record + NESTED_BINDINGS_INDEX, getNestedBindingsComparator());
}
@Override
@ -138,35 +157,38 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
}
}
@Override
public PDOMLinkage getLinkage() throws CoreException {
return this;
}
@Override
public final void addChild(PDOMNode child) throws CoreException {
getIndex().insert(child.getRecord());
}
public final PDOMBinding getBinding(int record) throws CoreException {
final PDOMNode node= getNode(record);
if (node instanceof PDOMBinding)
return (PDOMBinding) node;
return null;
}
public PDOMNode getNode(int record) throws CoreException {
switch (PDOMNode.getNodeType(pdom, record)) {
switch (PDOMNode.getNodeType(fDatabase, record)) {
case POINTER_TYPE:
return new PDOMPointerType(pdom, record);
return new PDOMPointerType(this, record);
case ARRAY_TYPE:
return new PDOMArrayType(pdom, record);
return new PDOMArrayType(this, record);
case QUALIFIER_TYPE:
return new PDOMQualifierType(pdom, record);
return new PDOMQualifierType(this, record);
}
return null;
}
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
if (type instanceof IPointerType)
return new PDOMPointerType(pdom, parent, (IPointerType)type);
return new PDOMPointerType(this, parent, (IPointerType)type);
else if (type instanceof IArrayType)
return new PDOMArrayType(pdom, parent, (IArrayType) type);
return new PDOMArrayType(this, parent, (IArrayType) type);
else if (type instanceof IQualifierType)
return new PDOMQualifierType(pdom, parent, (IQualifierType)type);
return new PDOMQualifierType(this, parent, (IQualifierType)type);
else
return null;
}
@ -198,7 +220,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return pdomBinding;
}
}
return (PDOMBinding) pdom.getCachedResult(binding);
return (PDOMBinding) fPDOM.getCachedResult(binding);
}
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
public abstract PDOMBinding addBinding(IASTName name) throws CoreException;
@ -218,8 +240,8 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
}
protected PDOMFile getLocalToFile(IBinding binding, PDOMBinding glob) throws CoreException {
if (pdom instanceof WritablePDOM) {
final WritablePDOM wpdom= (WritablePDOM) pdom;
if (fPDOM instanceof WritablePDOM) {
final WritablePDOM wpdom= (WritablePDOM) fPDOM;
try {
if (binding instanceof IField) {
return null;
@ -333,45 +355,45 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
public BTree getMacroIndex() {
if (fMacroIndex == null) {
fMacroIndex= new BTree(pdom.getDB(), record + MACRO_BTREE, new FindBinding.MacroBTreeComparator(pdom));
fMacroIndex= new BTree(getDB(), record + MACRO_BTREE, new FindBinding.MacroBTreeComparator(fDatabase));
}
return fMacroIndex;
}
public PDOMMacroContainer findMacroContainer(final char[] name) throws CoreException {
return findMacroContainer(name, pdom.createKeyForCache(record, name));
return findMacroContainer(name, fPDOM.createKeyForCache(record, name));
}
private PDOMMacroContainer findMacroContainer(final char[] name, final String key) throws CoreException {
Object result= pdom.getCachedResult(key);
Object result= fPDOM.getCachedResult(key);
if (result instanceof PDOMMacroContainer) {
return ((PDOMMacroContainer) result);
}
assert result==null;
MacroContainerFinder visitor = new MacroContainerFinder(pdom, name);
MacroContainerFinder visitor = new MacroContainerFinder(this, name);
getMacroIndex().accept(visitor);
PDOMMacroContainer container= visitor.getMacroContainer();
if (container != null) {
pdom.putCachedResult(key, container);
fPDOM.putCachedResult(key, container);
}
return container;
}
public PDOMMacroContainer getMacroContainer(char[] name) throws CoreException {
String key= pdom.createKeyForCache(record, name);
String key= fPDOM.createKeyForCache(record, name);
PDOMMacroContainer result= findMacroContainer(name, key);
if (result == null) {
result= new PDOMMacroContainer(pdom, this, name);
result= new PDOMMacroContainer(this, name);
getMacroIndex().insert(result.getRecord());
pdom.putCachedResult(key, result);
fPDOM.putCachedResult(key, result);
}
return result;
}
public void removeMacroContainer (PDOMMacroContainer container) throws CoreException {
String key= pdom.createKeyForCache(record, container.getNameCharArray());
pdom.putCachedResult(key, null);
String key= fPDOM.createKeyForCache(record, container.getNameCharArray());
fPDOM.putCachedResult(key, null);
getMacroIndex().delete(container.getRecord());
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -58,7 +58,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
private static final char[][] UNINITIALIZED= {};
private static final char[] UNINITIALIZED1= {};
private final PDOM fPDOM;
private final PDOMLinkage fLinkage;
private final int fRecord;
private char[][] fParameterList= UNINITIALIZED;
@ -66,20 +66,20 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
private PDOMMacroContainer fContainer;
private PDOMMacroDefinitionName fDefinition;
public PDOMMacro(PDOM pdom, int record) {
fPDOM = pdom;
public PDOMMacro(PDOMLinkage linkage, int record) {
fLinkage = linkage;
fRecord = record;
}
public PDOMMacro(PDOM pdom, PDOMMacroContainer container, IASTPreprocessorMacroDefinition macro,
public PDOMMacro(PDOMLinkage linkage, PDOMMacroContainer container, IASTPreprocessorMacroDefinition macro,
PDOMFile file) throws CoreException {
this(pdom, container, file, macro.getName());
this(linkage, container, file, macro.getName());
final IASTName name = macro.getName();
final IMacroBinding binding= (IMacroBinding) name.getBinding();
final char[][] params= binding.getParameterList();
final Database db= pdom.getDB();
final Database db= linkage.getDB();
db.putInt(fRecord + EXPANSION, db.newString(binding.getExpansionImage()).getRecord());
if (params != null) {
StringBuilder buf= new StringBuilder();
@ -91,15 +91,15 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
}
}
public PDOMMacro(PDOM pdom, PDOMMacroContainer container, IASTPreprocessorUndefStatement undef,
public PDOMMacro(PDOMLinkage linkage, PDOMMacroContainer container, IASTPreprocessorUndefStatement undef,
PDOMFile file) throws CoreException {
this(pdom, container, file, undef.getMacroName());
this(linkage, container, file, undef.getMacroName());
}
private PDOMMacro(PDOM pdom, PDOMMacroContainer container, PDOMFile file, IASTName name)
private PDOMMacro(PDOMLinkage linkage, PDOMMacroContainer container, PDOMFile file, IASTName name)
throws CoreException {
final Database db= pdom.getDB();
fPDOM = pdom;
final Database db= linkage.getDB();
fLinkage = linkage;
fRecord = db.malloc(RECORD_SIZE);
fContainer= container;
@ -113,7 +113,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
}
public PDOM getPDOM() {
return fPDOM;
return fLinkage.getPDOM();
}
public int getRecord() {
@ -149,26 +149,26 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
public PDOMMacroContainer getContainer() throws CoreException {
if (fContainer == null) {
fContainer= new PDOMMacroContainer(fPDOM, fPDOM.getDB().getInt(fRecord + CONTAINER));
fContainer= new PDOMMacroContainer(fLinkage, fLinkage.getDB().getInt(fRecord + CONTAINER));
}
return fContainer;
}
private IString getExpansionInDB() throws CoreException {
Database db = fPDOM.getDB();
Database db = fLinkage.getDB();
int rec = db.getInt(fRecord + EXPANSION);
return rec == 0 ? null : db.getString(rec);
}
private IString getParamListInDB() throws CoreException {
Database db = fPDOM.getDB();
Database db = fLinkage.getDB();
int rec = db.getInt(fRecord + PARAMETERS);
return rec == 0 ? null : db.getString(rec);
}
public PDOMMacro getNextMacro() throws CoreException {
int rec = fPDOM.getDB().getInt(fRecord + NEXT_IN_FILE);
return rec != 0 ? new PDOMMacro(fPDOM, rec) : null;
int rec = fLinkage.getDB().getInt(fRecord + NEXT_IN_FILE);
return rec != 0 ? new PDOMMacro(fLinkage, rec) : null;
}
public void setNextMacro(PDOMMacro macro) throws CoreException {
@ -176,7 +176,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
}
private void setNextMacro(int rec) throws CoreException {
fPDOM.getDB().putInt(fRecord + NEXT_IN_FILE, rec);
fLinkage.getDB().putInt(fRecord + NEXT_IN_FILE, rec);
}
private PDOMMacro getPrevInContainer() throws CoreException {
@ -197,12 +197,12 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
private void setMacroField(int offset, PDOMMacro macro) throws CoreException {
int namerec = macro != null ? macro.getRecord() : 0;
fPDOM.getDB().putInt(fRecord + offset, namerec);
fLinkage.getDB().putInt(fRecord + offset, namerec);
}
private PDOMMacro getMacroField(int offset) throws CoreException {
int namerec= fPDOM.getDB().getInt(fRecord + offset);
return namerec != 0 ? new PDOMMacro(fPDOM, namerec) : null;
int namerec= fLinkage.getDB().getInt(fRecord + offset);
return namerec != 0 ? new PDOMMacro(fLinkage, namerec) : null;
}
public char[][] getParameterList() {
@ -232,7 +232,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
public boolean isMacroDefinition() throws CoreException {
if (fExpansion == UNINITIALIZED1) {
return fPDOM.getDB().getInt(fRecord + EXPANSION) != 0;
return fLinkage.getDB().getInt(fRecord + EXPANSION) != 0;
}
return fExpansion != null;
}
@ -264,8 +264,8 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
}
public PDOMFile getFile() throws CoreException {
int filerec = fPDOM.getDB().getInt(fRecord + FILE);
return filerec != 0 ? new PDOMFile(fPDOM, filerec) : null;
int filerec = fLinkage.getDB().getInt(fRecord + FILE);
return filerec != 0 ? new PDOMFile(fLinkage, filerec) : null;
}
public int getEndingLineNumber() {
@ -303,7 +303,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
public int getNodeLength() {
try {
return fPDOM.getDB().getShort(fRecord + NAME_LENGTH);
return fLinkage.getDB().getShort(fRecord + NAME_LENGTH);
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
@ -312,7 +312,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
public int getNodeOffset() {
try {
return fPDOM.getDB().getInt(fRecord + NAME_OFFSET);
return fLinkage.getDB().getInt(fRecord + NAME_OFFSET);
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
@ -390,7 +390,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
}
public IIndexFragment getFragment() {
return fPDOM;
return fLinkage.getPDOM();
}
public boolean hasDeclaration() throws CoreException {
@ -408,7 +408,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
public void accept(IPDOMVisitor visitor) {
}
public int getId() {
public int getBindingID() {
return fRecord;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
@ -36,12 +35,12 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 8;
public PDOMMacroContainer(PDOM pdom, PDOMLinkage linkage, char[] name) throws CoreException {
super(pdom, linkage, name);
public PDOMMacroContainer(PDOMLinkage linkage, char[] name) throws CoreException {
super(linkage, linkage, name);
}
PDOMMacroContainer(PDOM pdom, int record) {
super(pdom, record);
PDOMMacroContainer(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -55,7 +54,7 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
}
public boolean isOrphaned() throws CoreException {
Database db = pdom.getDB();
Database db = getDB();
return db.getInt(record + FIRST_DEF_OFFSET) == 0
&& db.getInt(record + FIRST_REF_OFFSET) == 0;
}
@ -79,23 +78,23 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
}
public PDOMMacro getFirstDefinition() throws CoreException {
int namerec = pdom.getDB().getInt(record + FIRST_DEF_OFFSET);
return namerec != 0 ? new PDOMMacro(pdom, namerec) : null;
int namerec = getDB().getInt(record + FIRST_DEF_OFFSET);
return namerec != 0 ? new PDOMMacro(getLinkage(), namerec) : null;
}
void setFirstDefinition(PDOMMacro macro) throws CoreException {
int namerec = macro != null ? macro.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_DEF_OFFSET, namerec);
getDB().putInt(record + FIRST_DEF_OFFSET, namerec);
}
public PDOMMacroReferenceName getFirstReference() throws CoreException {
int namerec = pdom.getDB().getInt(record + FIRST_REF_OFFSET);
return namerec != 0 ? new PDOMMacroReferenceName(pdom, namerec) : null;
int namerec = getDB().getInt(record + FIRST_REF_OFFSET);
return namerec != 0 ? new PDOMMacroReferenceName(getLinkage(), namerec) : null;
}
void setFirstReference(PDOMMacroReferenceName nextName) throws CoreException {
int namerec = nextName != null ? nextName.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_REF_OFFSET, namerec);
getDB().putInt(record + FIRST_REF_OFFSET, namerec);
}
public IIndexMacro[] getDefinitions() throws CoreException {
@ -123,7 +122,7 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
* @see org.eclipse.cdt.internal.core.index.IIndexFragmentBinding#getFragment()
*/
public IIndexFragment getFragment() {
return pdom;
return getPDOM();
}
public IIndexScope getScope() {
@ -135,7 +134,7 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
}
public boolean hasDefinition() throws CoreException {
return pdom.getDB().getInt(record + FIRST_DEF_OFFSET) != 0;
return getDB().getInt(record + FIRST_DEF_OFFSET) != 0;
}
public IIndexFile getLocalToFile() throws CoreException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -30,7 +29,7 @@ import org.eclipse.core.runtime.IPath;
* Represents declarations, definitions and references to bindings, except for macros.
*/
public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFileLocation {
private final PDOM pdom;
private final PDOMLinkage linkage;
private final int record;
private static final int FILE_REC_OFFSET = 0;
@ -43,10 +42,10 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
private static final int RECORD_SIZE = 26;
public PDOMMacroReferenceName(PDOM pdom, IASTName name, PDOMFile file,
public PDOMMacroReferenceName(PDOMLinkage linkage, IASTName name, PDOMFile file,
PDOMMacroContainer container) throws CoreException {
this.pdom = pdom;
Database db = pdom.getDB();
this.linkage = linkage;
Database db = linkage.getDB();
record = db.malloc(RECORD_SIZE);
db.putInt(record + CONTAINER_REC_OFFSET, container.getRecord());
@ -59,8 +58,8 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
container.addReference(this);
}
public PDOMMacroReferenceName(PDOM pdom, int nameRecord) {
this.pdom = pdom;
public PDOMMacroReferenceName(PDOMLinkage linkage, int nameRecord) {
this.linkage = linkage;
this.record = nameRecord;
}
@ -69,21 +68,21 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
}
private int getRecField(int offset) throws CoreException {
return pdom.getDB().getInt(record + offset);
return linkage.getDB().getInt(record + offset);
}
private void setRecField(int offset, int fieldrec) throws CoreException {
pdom.getDB().putInt(record + offset, fieldrec);
linkage.getDB().putInt(record + offset, fieldrec);
}
public PDOMMacroContainer getContainer() throws CoreException {
int bindingrec = getRecField(CONTAINER_REC_OFFSET);
return new PDOMMacroContainer(pdom, bindingrec);
return new PDOMMacroContainer(linkage, bindingrec);
}
private PDOMMacroReferenceName getNameField(int offset) throws CoreException {
int namerec = getRecField(offset);
return namerec != 0 ? new PDOMMacroReferenceName(pdom, namerec) : null;
return namerec != 0 ? new PDOMMacroReferenceName(linkage, namerec) : null;
}
private void setNameField(int offset, PDOMMacroReferenceName name) throws CoreException {
@ -108,8 +107,8 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
}
public PDOMFile getFile() throws CoreException {
int filerec = pdom.getDB().getInt(record + FILE_REC_OFFSET);
return filerec != 0 ? new PDOMFile(pdom, filerec) : null;
int filerec = linkage.getDB().getInt(record + FILE_REC_OFFSET);
return filerec != 0 ? new PDOMFile(linkage, filerec) : null;
}
PDOMMacroReferenceName getNextInFile() throws CoreException {
@ -205,7 +204,7 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
public int getNodeLength() {
try {
return (pdom.getDB().getShort(record + NODE_LENGTH_OFFSET)) & 0xffff;
return (linkage.getDB().getShort(record + NODE_LENGTH_OFFSET)) & 0xffff;
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
@ -214,7 +213,7 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
public int getNodeOffset() {
try {
return pdom.getDB().getInt(record + NODE_OFFSET_OFFSET);
return linkage.getDB().getInt(record + NODE_OFFSET_OFFSET);
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
@ -235,11 +234,11 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
nextName.setPrevInContainer(prevName);
// Delete our record
pdom.getDB().free(record);
linkage.getDB().free(record);
}
public IIndexFragment getIndexFragment() {
return pdom;
return linkage.getPDOM();
}
public IIndexName[] getEnclosedNames() throws CoreException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -22,7 +22,6 @@ import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -31,7 +30,7 @@ import org.eclipse.core.runtime.IPath;
* @author Doug Schaefer
*/
public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
private final PDOM pdom;
private final PDOMLinkage linkage;
private final int record;
private static final int FILE_REC_OFFSET = 0;
@ -57,10 +56,10 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
public static final int WRITE_ACCESS = 0x40;
public PDOMName(PDOM pdom, IASTName name, PDOMFile file, PDOMBinding binding, PDOMName caller)
public PDOMName(PDOMLinkage linkage, IASTName name, PDOMFile file, PDOMBinding binding, PDOMName caller)
throws CoreException {
this.pdom = pdom;
Database db = pdom.getDB();
this.linkage = linkage;
Database db = linkage.getDB();
record = db.malloc(RECORD_SIZE);
// What kind of name are we
@ -105,8 +104,8 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
return IS_REFERENCE;
}
public PDOMName(PDOM pdom, int nameRecord) {
this.pdom = pdom;
public PDOMName(PDOMLinkage linkage, int nameRecord) {
this.linkage = linkage;
this.record = nameRecord;
}
@ -115,16 +114,16 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
}
private int getRecField(int offset) throws CoreException {
return pdom.getDB().getInt(record + offset);
return linkage.getDB().getInt(record + offset);
}
private void setRecField(int offset, int fieldrec) throws CoreException {
pdom.getDB().putInt(record + offset, fieldrec);
linkage.getDB().putInt(record + offset, fieldrec);
}
public PDOMBinding getBinding() throws CoreException {
int bindingrec = getRecField(BINDING_REC_OFFSET);
return pdom.getBinding(bindingrec);
return linkage.getBinding(bindingrec);
}
public void setBinding(PDOMBinding binding) throws CoreException {
@ -134,7 +133,7 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
private PDOMName getNameField(int offset) throws CoreException {
int namerec = getRecField(offset);
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
return namerec != 0 ? new PDOMName(linkage, namerec) : null;
}
private void setNameField(int offset, PDOMName name) throws CoreException {
@ -159,17 +158,17 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
}
public PDOMFile getFile() throws CoreException {
int filerec = pdom.getDB().getInt(record + FILE_REC_OFFSET);
return filerec != 0 ? new PDOMFile(pdom, filerec) : null;
int filerec = linkage.getDB().getInt(record + FILE_REC_OFFSET);
return filerec != 0 ? new PDOMFile(linkage, filerec) : null;
}
public IIndexName getEnclosingDefinition() throws CoreException {
int namerec = getEnclosingDefinitionRecord();
return namerec != 0 ? new PDOMName(pdom, namerec) : null;
return namerec != 0 ? new PDOMName(linkage, namerec) : null;
}
int getEnclosingDefinitionRecord() throws CoreException {
return pdom.getDB().getInt(record + CALLER_REC_OFFSET);
return linkage.getDB().getInt(record + CALLER_REC_OFFSET);
}
public PDOMName getNextInFile() throws CoreException {
@ -190,9 +189,9 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
public char[] getSimpleID() {
try {
Database db = pdom.getDB();
Database db = linkage.getDB();
int bindingRec = db.getInt(record + BINDING_REC_OFFSET);
PDOMBinding binding = pdom.getBinding(bindingRec);
PDOMBinding binding = linkage.getBinding(bindingRec);
return binding != null ? binding.getNameCharArray() : null;
} catch (CoreException e) {
CCorePlugin.log(e);
@ -206,25 +205,25 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
}
private int getFlags(int mask) throws CoreException {
return pdom.getDB().getByte(record + FLAGS) & mask;
return linkage.getDB().getByte(record + FLAGS) & mask;
}
public void setIsFriendSpecifier(boolean val) throws CoreException {
int flags= pdom.getDB().getByte(record + FLAGS) & 0xff;
int flags= linkage.getDB().getByte(record + FLAGS) & 0xff;
if (val)
flags |= IS_FRIEND_SPEC;
else
flags &= ~IS_FRIEND_SPEC;
pdom.getDB().putByte(record + FLAGS, (byte) flags);
linkage.getDB().putByte(record + FLAGS, (byte) flags);
}
public void setIsBaseSpecifier(boolean val) throws CoreException {
int flags= pdom.getDB().getByte(record + FLAGS) & 0xff;
int flags= linkage.getDB().getByte(record + FLAGS) & 0xff;
if (val)
flags |= IS_INHERITANCE_SPEC;
else
flags &= ~IS_INHERITANCE_SPEC;
pdom.getDB().putByte(record + FLAGS, (byte) flags);
linkage.getDB().putByte(record + FLAGS, (byte) flags);
}
public boolean isFriendSpecifier() throws CoreException {
@ -312,7 +311,7 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
public int getNodeLength() {
try {
return (pdom.getDB().getShort(record + NODE_LENGTH_OFFSET)) & 0xffff;
return (linkage.getDB().getShort(record + NODE_LENGTH_OFFSET)) & 0xffff;
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
@ -321,7 +320,7 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
public int getNodeOffset() {
try {
return pdom.getDB().get3ByteUnsignedInt(record + NODE_OFFSET_OFFSET);
return linkage.getDB().get3ByteUnsignedInt(record + NODE_OFFSET_OFFSET);
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
@ -352,11 +351,11 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
nextName.setPrevInBinding(prevName);
// Delete our record
pdom.getDB().free(record);
linkage.getDB().free(record);
}
public IIndexFragment getIndexFragment() {
return pdom;
return linkage.getPDOM();
}
public IIndexName[] getEnclosedNames() throws CoreException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -20,7 +20,6 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
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.IString;
import org.eclipse.core.runtime.CoreException;
@ -43,30 +42,35 @@ public abstract class PDOMNamedNode extends PDOMNode {
private char[] fName;
public PDOMNamedNode(PDOM pdom, int record) {
super(pdom, record);
public PDOMNamedNode(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMNamedNode(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
super(pdom, parent);
public PDOMNamedNode(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
super(linkage, parent);
fName= name;
Database db = pdom.getDB();
db.putInt(record + NAME,
name != null ? db.newString(name).getRecord() : 0);
final Database db = linkage.getDB();
db.putInt(record + NAME, name != null ? db.newString(name).getRecord() : 0);
}
/**
* For linkages, only.
*/
protected PDOMNamedNode(Database db, char[] name) throws CoreException {
super(db);
fName= name;
db.putInt(record + NAME, name != null ? db.newString(name).getRecord() : 0);
}
@Override
abstract protected int getRecordSize();
public IString getDBName() throws CoreException {
Database db = pdom.getDB();
int namerec = db.getInt(record + NAME);
return db.getString(namerec);
return getDBName(getDB(), record);
}
public static IString getDBName(PDOM pdom, int record) throws CoreException {
Database db = pdom.getDB();
public static IString getDBName(Database db, int record) throws CoreException {
int namerec = db.getInt(record + NAME);
return db.getString(namerec);
}
@ -96,7 +100,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
IString name= getDBName();
if (!name.equals(nameCharArray)) {
name.delete();
final Database db= pdom.getDB();
final Database db= getDB();
db.putInt(record + NAME, db.newString(nameCharArray).getRecord());
}
fName= nameCharArray;
@ -105,7 +109,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
@Override
public void delete(PDOMLinkage linkage) throws CoreException {
final Database db = pdom.getDB();
final Database db = getDB();
final int namerec= db.getInt(record + NAME);
if (namerec != 0) {
db.free(namerec);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -31,42 +31,58 @@ public abstract class PDOMNode implements IInternalPDOMNode {
protected static final int RECORD_SIZE = 8;
protected final PDOM pdom;
private final PDOMLinkage fLinkage;
protected final int record;
private int cachedParentRecord;
protected PDOMNode(PDOM pdom, int record) {
this.pdom = pdom;
protected PDOMNode(PDOMLinkage linkage, int record) {
fLinkage = linkage;
this.record = record;
}
protected PDOMNode(PDOM pdom, PDOMNode parent) throws CoreException {
this.pdom = pdom;
Database db = pdom.getDB();
record = db.malloc(getRecordSize());
// type
protected PDOMNode(PDOMLinkage linkage, PDOMNode parent) throws CoreException {
this(linkage.getDB(), linkage, parent == null ? 0 : parent.getRecord());
}
/**
* For linkages, only.
*/
protected PDOMNode(Database db) throws CoreException {
this(db, null, 0);
}
protected PDOMNode(Database db, PDOMLinkage linkage, int parentRec) throws CoreException {
this.fLinkage = linkage;
record = db.malloc(getRecordSize());
db.putInt(record + TYPE, getNodeType());
// parent
cachedParentRecord= parent != null ? parent.getRecord() : 0;
db.putInt(record + PARENT, cachedParentRecord);
cachedParentRecord= parentRec;
db.putInt(record + PARENT, parentRec);
}
protected Database getDB() {
return fLinkage.getDB();
}
public PDOM getPDOM() {
return fLinkage.getPDOM();
}
public PDOMLinkage getLinkage() throws CoreException {
return fLinkage;
}
protected abstract int getRecordSize();
public abstract int getNodeType();
public PDOM getPDOM() {
return pdom;
}
public int getRecord() {
public final int getRecord() {
return record;
}
public int getId() {
public final int getBindingID() {
return record;
}
@ -77,7 +93,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
*/
public boolean isChildOf(PDOMNode other) {
try {
return other.pdom == pdom && other.record == getParentNodeRec();
return other.fLinkage == fLinkage && other.record == getParentNodeRec();
} catch (CoreException e) {
return false;
}
@ -89,7 +105,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
return true;
if (obj instanceof PDOMNode) {
PDOMNode other = (PDOMNode)obj;
return pdom == other.pdom && record == other.record;
return getPDOM() == other.getPDOM() && record == other.record;
}
return super.equals(obj);
@ -97,53 +113,33 @@ public abstract class PDOMNode implements IInternalPDOMNode {
@Override
public final int hashCode() {
return System.identityHashCode(pdom) + 41*record;
return System.identityHashCode(getPDOM()) + 41*record;
}
public void accept(IPDOMVisitor visitor) throws CoreException {
// No children here.
}
public static int getNodeType(PDOM pdom, int record) throws CoreException {
return pdom.getDB().getInt(record + TYPE);
public static int getNodeType(Database db, int record) throws CoreException {
return db.getInt(record + TYPE);
}
public int getParentNodeRec() throws CoreException {
if (cachedParentRecord != 0) {
return cachedParentRecord;
}
return cachedParentRecord= pdom.getDB().getInt(record + PARENT);
return cachedParentRecord= getDB().getInt(record + PARENT);
}
public PDOMNode getParentNode() throws CoreException {
int parentrec = getParentNodeRec();
return parentrec != 0 ? getLinkageImpl().getNode(parentrec) : null;
return parentrec != 0 ? getLinkage().getNode(parentrec) : null;
}
public PDOMLinkage getLinkage() throws CoreException {
return getLinkage(pdom, record);
}
public final PDOMLinkage getLinkageImpl() throws CoreException {
return getLinkage();
}
public static PDOMLinkage getLinkage(PDOM pdom, int record) throws CoreException {
Database db = pdom.getDB();
int linkagerec = record;
int parentrec = db.getInt(linkagerec + PARENT);
while (parentrec != 0) {
linkagerec = parentrec;
parentrec = db.getInt(linkagerec + PARENT);
}
return pdom.getLinkage(linkagerec);
}
public void addChild(PDOMNode child) throws CoreException {
// nothing here
}
/**
* Convenience method for fetching a byte from the database.
* @param offset Location of the byte.
@ -151,17 +147,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
*/
protected byte getByte(int offset) {
try {
return pdom.getDB().getByte(offset);
}
catch (CoreException e) {
CCorePlugin.log(e);
return 0;
}
}
protected int getInt(int offset) {
try {
return pdom.getDB().getInt(offset);
return getDB().getByte(offset);
}
catch (CoreException e) {
CCorePlugin.log(e);
@ -187,6 +173,6 @@ public abstract class PDOMNode implements IInternalPDOMNode {
* @throws CoreException
*/
public void delete(PDOMLinkage linkage) throws CoreException {
pdom.getDB().free(record);
getDB().free(record);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.PointerTypeClone;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
@ -43,14 +42,14 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
private static final int CONST = 0x1;
private static final int VOLATILE = 0x2;
public PDOMPointerType(PDOM pdom, int record) {
super(pdom, record);
public PDOMPointerType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMPointerType(PDOM pdom, PDOMNode parent, IPointerType type) throws CoreException {
super(pdom, parent);
public PDOMPointerType(PDOMLinkage linkage, PDOMNode parent, IPointerType type) throws CoreException {
super(linkage, parent);
Database db = pdom.getDB();
Database db = getDB();
try {
// type
@ -58,7 +57,7 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
byte flags = 0;
if (type != null) {
IType targetType= type.getType();
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
PDOMNode targetTypeNode = getLinkage().addType(this, targetType);
if (targetTypeNode != null)
typeRec = targetTypeNode.getRecord();
if (type.isConst())
@ -84,12 +83,12 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
}
private byte getFlags() throws CoreException {
return pdom.getDB().getByte(record + FLAGS);
return getDB().getByte(record + FLAGS);
}
public IType getType() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.QualifierTypeClone;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
@ -44,20 +43,20 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
private static final int VOLATILE = 0x2;
private static final int RESTRICT = 0x4;
public PDOMQualifierType(PDOM pdom, int record) {
super(pdom, record);
public PDOMQualifierType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMQualifierType(PDOM pdom, PDOMNode parent, IQualifierType type) throws CoreException {
super(pdom, parent);
public PDOMQualifierType(PDOMLinkage linkage, PDOMNode parent, IQualifierType type) throws CoreException {
super(linkage, parent);
Database db = pdom.getDB();
Database db = getDB();
// type
try {
if (type != null) {
IType targetType = type.getType();
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
PDOMNode targetTypeNode = getLinkage().addType(this, targetType);
if (targetTypeNode != null) {
db.putInt(record + TYPE, targetTypeNode.getRecord());
}
@ -88,7 +87,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
public IType getType() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);
@ -97,7 +96,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
}
private byte getFlags() throws CoreException {
return pdom.getDB().getByte(record + FLAGS);
return getDB().getByte(record + FLAGS);
}
public boolean isConst() {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -21,8 +21,8 @@ import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -45,15 +45,15 @@ class PDOMCBasicType extends PDOMNode implements ICBasicType, IIndexType {
public static final int IS_IMAGINARY = 0x20;
public static final int IS_COMPLEX = 0x40;
public PDOMCBasicType(PDOM pdom, int record) {
super(pdom, record);
public PDOMCBasicType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCBasicType(PDOM pdom, PDOMNode parent, ICBasicType type) throws CoreException {
super(pdom, parent);
public PDOMCBasicType(PDOMLinkage linkage, PDOMNode parent, ICBasicType type) throws CoreException {
super(linkage, parent);
try {
Database db = pdom.getDB();
Database db = getDB();
db.putChar(record + TYPE_ID, (char)type.getType());
char flags = 0;
@ -84,7 +84,7 @@ class PDOMCBasicType extends PDOMNode implements ICBasicType, IIndexType {
public int getType() {
try {
return pdom.getDB().getChar(record + TYPE_ID);
return getDB().getChar(record + TYPE_ID);
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
@ -142,7 +142,7 @@ class PDOMCBasicType extends PDOMNode implements ICBasicType, IIndexType {
}
private char getFlags() throws CoreException {
return pdom.getDB().getChar(record + FLAGS);
return getDB().getChar(record + FLAGS);
}
private boolean flagSet(int flag) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -22,9 +22,9 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
@ -39,13 +39,13 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCEnumeration(PDOM pdom, PDOMNode parent, IEnumeration enumeration)
public PDOMCEnumeration(PDOMLinkage linkage, PDOMNode parent, IEnumeration enumeration)
throws CoreException {
super(pdom, parent, enumeration.getNameCharArray());
super(linkage, parent, enumeration.getNameCharArray());
}
public PDOMCEnumeration(PDOM pdom, int record) {
super(pdom, record);
public PDOMCEnumeration(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -77,14 +77,14 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
}
private PDOMCEnumerator getFirstEnumerator() throws CoreException {
int value = pdom.getDB().getInt(record + FIRST_ENUMERATOR);
return value != 0 ? new PDOMCEnumerator(pdom, value) : null;
int value = getDB().getInt(record + FIRST_ENUMERATOR);
return value != 0 ? new PDOMCEnumerator(getLinkage(), value) : null;
}
public void addEnumerator(PDOMCEnumerator enumerator) throws CoreException {
PDOMCEnumerator first = getFirstEnumerator();
enumerator.setNextEnumerator(first);
pdom.getDB().putInt(record + FIRST_ENUMERATOR, enumerator.getRecord());
getDB().putInt(record + FIRST_ENUMERATOR, enumerator.getRecord());
}
public boolean isSameType(IType type) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
@ -37,18 +36,18 @@ class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 12;
public PDOMCEnumerator(PDOM pdom, PDOMNode parent, IEnumerator enumerator, PDOMCEnumeration enumeration)
public PDOMCEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator, PDOMCEnumeration enumeration)
throws CoreException {
super(pdom, parent, enumerator.getNameCharArray());
super(linkage, parent, enumerator.getNameCharArray());
final Database db = pdom.getDB();
final Database db = getDB();
db.putInt(record + ENUMERATION, enumeration.getRecord());
storeValue(db, enumerator);
enumeration.addEnumerator(this);
}
public PDOMCEnumerator(PDOM pdom, int record) {
super(pdom, record);
public PDOMCEnumerator(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -72,23 +71,23 @@ class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof IEnumerator)
storeValue(pdom.getDB(), (IEnumerator) newBinding);
storeValue(getDB(), (IEnumerator) newBinding);
}
public PDOMCEnumerator getNextEnumerator() throws CoreException {
int value = pdom.getDB().getInt(record + NEXT_ENUMERATOR);
return value != 0 ? new PDOMCEnumerator(pdom, value) : null;
int value = getDB().getInt(record + NEXT_ENUMERATOR);
return value != 0 ? new PDOMCEnumerator(getLinkage(), value) : null;
}
public void setNextEnumerator(PDOMCEnumerator enumerator) throws CoreException {
int value = enumerator != null ? enumerator.getRecord() : 0;
pdom.getDB().putInt(record + NEXT_ENUMERATOR, value);
getDB().putInt(record + NEXT_ENUMERATOR, value);
}
public IType getType() throws DOMException {
try {
return new PDOMCEnumeration(pdom, pdom.getDB().getInt(record + ENUMERATION));
return new PDOMCEnumeration(getLinkage(), getDB().getInt(record + ENUMERATION));
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
@ -97,7 +96,7 @@ class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
public IValue getValue() {
try {
int val= pdom.getDB().getInt(record + VALUE);
int val= getDB().getInt(record + VALUE);
return Value.create(val);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -16,8 +16,8 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -27,12 +27,12 @@ import org.eclipse.core.runtime.CoreException;
*/
class PDOMCField extends PDOMCVariable implements IField {
public PDOMCField(PDOM pdom, IPDOMMemberOwner parent, IField field) throws CoreException {
super(pdom, (PDOMNode) parent, field);
public PDOMCField(PDOMLinkage linkage, IPDOMMemberOwner parent, IField field) throws CoreException {
super(linkage, (PDOMNode) parent, field);
}
public PDOMCField(PDOM pdom, int record) {
super(pdom, record);
public PDOMCField(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -64,8 +63,12 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
@SuppressWarnings("hiding")
public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 13;
public PDOMCFunction(PDOM pdom, PDOMNode parent, IFunction function) throws CoreException {
super(pdom, parent, function.getNameCharArray());
public PDOMCFunction(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCFunction(PDOMLinkage linkage, PDOMNode parent, IFunction function) throws CoreException {
super(linkage, parent, function.getNameCharArray());
IFunctionType type;
IParameter[] parameters;
@ -77,9 +80,9 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
} catch(DOMException e) {
throw new CoreException(Util.createStatus(e));
}
setType(getLinkageImpl(), type);
setType(getLinkage(), type);
setParameters(parameters);
pdom.getDB().putByte(record + ANNOTATIONS, annotations);
getDB().putByte(record + ANNOTATIONS, annotations);
}
@Override
@ -107,7 +110,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
if (oldParams != null) {
oldParams.delete(linkage);
}
pdom.getDB().putByte(record + ANNOTATIONS, newAnnotation);
getDB().putByte(record + ANNOTATIONS, newAnnotation);
}
}
@ -119,32 +122,29 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
rec= typeNode.getRecord();
}
}
pdom.getDB().putInt(record + FUNCTION_TYPE, rec);
getDB().putInt(record + FUNCTION_TYPE, rec);
}
private void setParameters(IParameter[] params) throws CoreException {
pdom.getDB().putInt(record + NUM_PARAMS, params.length);
pdom.getDB().putInt(record + FIRST_PARAM, 0);
getDB().putInt(record + NUM_PARAMS, params.length);
getDB().putInt(record + FIRST_PARAM, 0);
for (int i = 0; i < params.length; ++i) {
setFirstParameter(new PDOMCParameter(pdom, this, params[i]));
setFirstParameter(new PDOMCParameter(getLinkage(), this, params[i]));
}
}
public PDOMCParameter getFirstParameter() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRST_PARAM);
return rec != 0 ? new PDOMCParameter(pdom, rec) : null;
int rec = getDB().getInt(record + FIRST_PARAM);
return rec != 0 ? new PDOMCParameter(getLinkage(), rec) : null;
}
public void setFirstParameter(PDOMCParameter param) throws CoreException {
if (param != null)
param.setNextParameter(getFirstParameter());
int rec = param != null ? param.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_PARAM, rec);
getDB().putInt(record + FIRST_PARAM, rec);
}
public PDOMCFunction(PDOM pdom, int record) {
super(pdom, record);
}
@Override
protected int getRecordSize() {
@ -165,8 +165,8 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
* both the IType and IBinding interfaces.
*/
try {
int offset= pdom.getDB().getInt(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCFunctionType(pdom, offset);
int offset= getDB().getInt(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCFunctionType(getLinkage(), offset);
} catch(CoreException ce) {
CCorePlugin.log(ce);
return null;
@ -183,7 +183,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
public IParameter[] getParameters() throws DOMException {
try {
int n = pdom.getDB().getInt(record + NUM_PARAMS);
int n = getDB().getInt(record + NUM_PARAMS);
IParameter[] params = new IParameter[n];
PDOMCParameter param = getFirstParameter();
while (param != null) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -27,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -53,16 +52,15 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE= PDOMNode.RECORD_SIZE + 8;
public PDOMCFunctionType(PDOM pdom, int record) {
super(pdom, record);
public PDOMCFunctionType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCFunctionType(PDOM pdom, PDOMNode parent, IFunctionType type) throws CoreException {
super(pdom, parent);
public PDOMCFunctionType(PDOMLinkage linkage, PDOMNode parent, IFunctionType type) throws CoreException {
super(linkage, parent);
try {
PDOMLinkage linkage= parent.getLinkageImpl();
PDOMNodeLinkedList list= new PDOMNodeLinkedList(pdom, record + TYPELIST, parent.getLinkageImpl(), true);
PDOMNodeLinkedList list= new PDOMNodeLinkedList(parent.getLinkage(), record + TYPELIST, true);
setReturnType(type.getReturnType());
IType[] pt= type.getParameterTypes();
for (int i = 0; i < pt.length; i++) {
@ -81,7 +79,7 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
@Override
public void delete(final PDOMLinkage linkage) throws CoreException {
linkage.deleteType(getReturnType(), record);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TYPELIST, getLinkageImpl(), true);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + TYPELIST, true);
list.accept(new IPDOMVisitor() {
public void leave(IPDOMNode node) throws CoreException {
}
@ -152,7 +150,7 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
public IType[] getParameterTypes() {
final List<IType> result= new ArrayList<IType>();
try {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TYPELIST, getLinkageImpl(), true);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + TYPELIST, true);
list.accept(new IPDOMVisitor() {
public void leave(IPDOMNode node) throws CoreException {
result.add((IType)node);
@ -169,7 +167,7 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
public IType getReturnType() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + RETURN_TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + RETURN_TYPE));
if (node instanceof IType) {
return (IType) node;
}
@ -180,9 +178,9 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
}
public void setReturnType(IType type) throws CoreException {
PDOMNode typeNode = getLinkageImpl().addType(this, type);
PDOMNode typeNode = getLinkage().addType(this, type);
if (typeNode != null) {
pdom.getDB().putInt(record + RETURN_TYPE, typeNode.getRecord());
getDB().putInt(record + RETURN_TYPE, typeNode.getRecord());
}
}

View file

@ -90,12 +90,12 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
if (pdomBinding == null) {
pdomBinding = createBinding(parent, binding, localToFileHolder[0]);
if (pdomBinding != null) {
pdom.putCachedResult(inputBinding, pdomBinding);
getPDOM().putCachedResult(inputBinding, pdomBinding);
}
return pdomBinding;
}
pdom.putCachedResult(inputBinding, pdomBinding);
getPDOM().putCachedResult(inputBinding, pdomBinding);
}
if (shouldUpdate(pdomBinding, fromName)) {
@ -109,30 +109,30 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
if (binding instanceof IField) { // must be before IVariable
if (parent instanceof IPDOMMemberOwner)
pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, (IField) binding);
pdomBinding = new PDOMCField(this, (IPDOMMemberOwner)parent, (IField) binding);
} else if (binding instanceof IVariable) {
IVariable var= (IVariable) binding;
pdomBinding = new PDOMCVariable(pdom, parent, var);
pdomBinding = new PDOMCVariable(this, parent, var);
} else if (binding instanceof IFunction) {
IFunction func= (IFunction) binding;
pdomBinding = new PDOMCFunction(pdom, parent, func);
pdomBinding = new PDOMCFunction(this, parent, func);
} else if (binding instanceof ICompositeType) {
pdomBinding = new PDOMCStructure(pdom, parent, (ICompositeType) binding);
pdomBinding = new PDOMCStructure(this, parent, (ICompositeType) binding);
} else if (binding instanceof IEnumeration) {
pdomBinding = new PDOMCEnumeration(pdom, parent, (IEnumeration) binding);
pdomBinding = new PDOMCEnumeration(this, parent, (IEnumeration) binding);
} else if (binding instanceof IEnumerator) {
try {
IType enumeration= ((IEnumerator)binding).getType();
if (enumeration instanceof IEnumeration) {
PDOMBinding pdomEnumeration = adaptBinding((IEnumeration) enumeration);
if (pdomEnumeration instanceof PDOMCEnumeration)
pdomBinding = new PDOMCEnumerator(pdom, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
pdomBinding = new PDOMCEnumerator(this, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
}
} catch (DOMException e) {
CCorePlugin.log(e);
}
} else if (binding instanceof ITypedef) {
pdomBinding = new PDOMCTypedef(pdom, parent, (ITypedef)binding);
pdomBinding = new PDOMCTypedef(this, parent, (ITypedef)binding);
}
if (pdomBinding != null) {
@ -251,7 +251,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
result= doAdaptBinding(parent, binding, localToFileHolder);
if (result != null) {
pdom.putCachedResult(inputBinding, result);
getPDOM().putCachedResult(inputBinding, result);
}
return result;
}
@ -275,22 +275,22 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
if (parent == this) {
final int[] bindingTypes = new int[] {getBindingType(binding)};
final char[] nameChars = binding.getNameCharArray();
PDOMBinding nonLocal= FindBinding.findBinding(getIndex(), getPDOM(), nameChars, bindingTypes, 0);
PDOMBinding nonLocal= FindBinding.findBinding(getIndex(), this, nameChars, bindingTypes, 0);
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
if (localToFileRec == 0)
return nonLocal;
localToFileHolder[0]= localToFileRec;
return FindBinding.findBinding(getIndex(), getPDOM(), nameChars, bindingTypes, localToFileRec);
return FindBinding.findBinding(getIndex(), this, nameChars, bindingTypes, localToFileRec);
}
if (parent instanceof IPDOMMemberOwner) {
final int[] bindingTypes = new int[] {getBindingType(binding)};
final char[] nameChars = binding.getNameCharArray();
PDOMBinding nonLocal= FindBinding.findBinding(parent, getPDOM(), nameChars, bindingTypes, 0);
PDOMBinding nonLocal= FindBinding.findBinding(parent, this, nameChars, bindingTypes, 0);
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
if (localToFileRec == 0)
return nonLocal;
localToFileHolder[0]= localToFileRec;
return FindBinding.findBinding(parent, getPDOM(), nameChars, bindingTypes, localToFileRec);
return FindBinding.findBinding(parent, this, nameChars, bindingTypes, localToFileRec);
}
return null;
}
@ -300,27 +300,27 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
if (record == 0)
return null;
switch (PDOMNode.getNodeType(pdom, record)) {
switch (PDOMNode.getNodeType(getDB(), record)) {
case CVARIABLE:
return new PDOMCVariable(pdom, record);
return new PDOMCVariable(this, record);
case CFUNCTION:
return new PDOMCFunction(pdom, record);
return new PDOMCFunction(this, record);
case CSTRUCTURE:
return new PDOMCStructure(pdom, record);
return new PDOMCStructure(this, record);
case CFIELD:
return new PDOMCField(pdom, record);
return new PDOMCField(this, record);
case CENUMERATION:
return new PDOMCEnumeration(pdom, record);
return new PDOMCEnumeration(this, record);
case CENUMERATOR:
return new PDOMCEnumerator(pdom, record);
return new PDOMCEnumerator(this, record);
case CTYPEDEF:
return new PDOMCTypedef(pdom, record);
return new PDOMCTypedef(this, record);
case CPARAMETER:
return new PDOMCParameter(pdom, record);
return new PDOMCParameter(this, record);
case CBASICTYPE:
return new PDOMCBasicType(pdom, record);
return new PDOMCBasicType(this, record);
case CFUNCTIONTYPE:
return new PDOMCFunctionType(pdom, record);
return new PDOMCFunctionType(this, record);
}
return super.getNode(record);
@ -332,9 +332,9 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
return null;
if (type instanceof ICBasicType) {
return new PDOMCBasicType(pdom, parent, (ICBasicType)type);
return new PDOMCBasicType(this, parent, (ICBasicType)type);
} else if(type instanceof IFunctionType) {
return new PDOMCFunctionType(pdom, parent, (IFunctionType)type);
return new PDOMCFunctionType(this, parent, (IFunctionType)type);
} else if (type instanceof IBinding) {
return addBinding((IBinding)type, null);
}
@ -344,6 +344,6 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
@Override
public IBTreeComparator getIndexComparator() {
return new FindBinding.DefaultBindingBTreeComparator(getPDOM());
return new FindBinding.DefaultBindingBTreeComparator(this);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
@ -49,22 +48,22 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
assert RECORD_SIZE <= 22; // 23 would yield a 32-byte block
}
public PDOMCParameter(PDOM pdom, int record) {
super(pdom, record);
public PDOMCParameter(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCParameter(PDOM pdom, PDOMNode parent, IParameter param)
public PDOMCParameter(PDOMLinkage linkage, PDOMNode parent, IParameter param)
throws CoreException {
super(pdom, parent, param.getNameCharArray());
super(linkage, parent, param.getNameCharArray());
Database db = pdom.getDB();
Database db = getDB();
db.putInt(record + NEXT_PARAM, 0);
try {
if(!(param instanceof IProblemBinding)) {
IType type = param.getType();
if (type != null) {
PDOMNode typeNode = getLinkageImpl().addType(this, type);
PDOMNode typeNode = getLinkage().addType(this, type);
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
byte flags = encodeFlags(param);
@ -87,12 +86,12 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
public void setNextParameter(PDOMCParameter nextParam) throws CoreException {
int rec = nextParam != null ? nextParam.getRecord() : 0;
pdom.getDB().putInt(record + NEXT_PARAM, rec);
getDB().putInt(record + NEXT_PARAM, rec);
}
public PDOMCParameter getNextParameter() throws CoreException {
int rec = pdom.getDB().getInt(record + NEXT_PARAM);
return rec != 0 ? new PDOMCParameter(pdom, rec) : null;
int rec = getDB().getInt(record + NEXT_PARAM);
return rec != 0 ? new PDOMCParameter(getLinkage(), rec) : null;
}
public IASTInitializer getDefaultValue() {
@ -102,8 +101,8 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
public IType getType() {
try {
PDOMLinkage linkage = getLinkageImpl();
PDOMNode node = linkage.getNode(pdom.getDB().getInt(record + TYPE));
PDOMLinkage linkage = getLinkage();
PDOMNode node = linkage.getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);
@ -153,7 +152,7 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
}
public IIndexFragment getFragment() {
return pdom;
return getPDOM();
}
public boolean hasDefinition() throws CoreException {
@ -222,7 +221,7 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
protected boolean hasFlag(byte flag, boolean defValue) {
try {
byte myflags= pdom.getDB().getByte(record + FLAGS);
byte myflags= getDB().getByte(record + FLAGS);
return (myflags & flag) == flag;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -56,15 +56,15 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = MEMBERLIST + 6;
public PDOMCStructure(PDOM pdom, PDOMNode parent, ICompositeType compType) throws CoreException {
super(pdom, parent, compType.getNameCharArray());
public PDOMCStructure(PDOMLinkage linkage, PDOMNode parent, ICompositeType compType) throws CoreException {
super(linkage, parent, compType.getNameCharArray());
setKind(compType);
setAnonymous(compType);
// linked list is initialized by malloc zeroing allocated storage
}
public PDOMCStructure(PDOM pdom, int record) {
super(pdom, record);
public PDOMCStructure(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public EScopeKind getKind() {
@ -83,7 +83,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
private void setKind(ICompositeType ct) throws CoreException {
try {
pdom.getDB().putByte(record + KEY, (byte) ct.getKey());
getDB().putByte(record + KEY, (byte) ct.getKey());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@ -91,7 +91,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
private void setAnonymous(ICompositeType ct) throws CoreException {
try {
pdom.getDB().putByte(record + ANONYMOUS, (byte) (ct.isAnonymous() ? 1 : 0));
getDB().putByte(record + ANONYMOUS, (byte) (ct.isAnonymous() ? 1 : 0));
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@ -101,7 +101,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
@Override
public void accept(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor);
new PDOMNodeLinkedList(pdom, record+MEMBERLIST, getLinkageImpl()).accept(visitor);
new PDOMNodeLinkedList(getLinkage(), record+MEMBERLIST).accept(visitor);
}
@Override
@ -116,7 +116,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
public int getKey() throws DOMException {
try {
return pdom.getDB().getByte(record + KEY);
return getDB().getByte(record + KEY);
} catch (CoreException e) {
CCorePlugin.log(e);
return ICompositeType.k_struct; // or something
@ -125,7 +125,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
public boolean isAnonymous() throws DOMException {
try {
return pdom.getDB().getByte(record + ANONYMOUS) != 0;
return getDB().getByte(record + ANONYMOUS) != 0;
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
@ -198,6 +198,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
}
public IField findField(String name) throws DOMException {
final PDOM pdom = getPDOM();
final String key= pdom.createKeyForCache(record, name.toCharArray());
IField result= (IField) pdom.getCachedResult(key);
if (result != null) {
@ -259,7 +260,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
@Override
public void addChild(PDOMNode member) throws CoreException {
new PDOMNodeLinkedList(pdom, record+MEMBERLIST, getLinkageImpl()).addMember(member);
new PDOMNodeLinkedList(getLinkage(), record+MEMBERLIST).addMember(member);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -23,7 +23,6 @@ import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexType;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -39,20 +38,20 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCTypedef(PDOM pdom, PDOMNode parent, ITypedef typedef)
public PDOMCTypedef(PDOMLinkage linkage, PDOMNode parent, ITypedef typedef)
throws CoreException {
super(pdom, parent, typedef.getNameCharArray());
super(linkage, parent, typedef.getNameCharArray());
try {
IType type = typedef.getType();
setType(parent.getLinkageImpl(), type);
setType(parent.getLinkage(), type);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCTypedef(PDOM pdom, int record) {
super(pdom, record);
public PDOMCTypedef(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -78,7 +77,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
linkage.deleteType((IType) typeNode, record);
typeNode= null;
}
pdom.getDB().putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
getDB().putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
private boolean introducesRecursion(IType type, char[] tdname) throws DOMException {
@ -123,8 +122,8 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
public IType getType() {
try {
int typeRec = pdom.getDB().getInt(record + TYPE);
return (IType)getLinkageImpl().getNode(typeRec);
int typeRec = getDB().getInt(record + TYPE);
return (IType)getLinkage().getNode(typeRec);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.c.CVariableReadWriteFlags;
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
@ -60,12 +59,12 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
public PDOMCVariable(PDOM pdom, PDOMNode parent, IVariable variable) throws CoreException {
super(pdom, parent, variable.getNameCharArray());
public PDOMCVariable(PDOMLinkage linkage, PDOMNode parent, IVariable variable) throws CoreException {
super(linkage, parent, variable.getNameCharArray());
try {
final Database db = pdom.getDB();
setType(parent.getLinkageImpl(), variable.getType());
final Database db = getDB();
setType(parent.getLinkage(), variable.getType());
db.putByte(record + ANNOTATIONS, PDOMCAnnotation.encodeAnnotation(variable));
setValue(db, variable);
@ -83,7 +82,7 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof IVariable) {
final Database db = pdom.getDB();
final Database db = getDB();
IVariable var= (IVariable) newBinding;
IType mytype= getType();
int valueRec= db.getInt(record + VALUE_OFFSET);
@ -104,11 +103,11 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
private void setType(final PDOMLinkage linkage, final IType type) throws CoreException {
final PDOMNode typeNode = linkage.addType(this, type);
pdom.getDB().putInt(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
getDB().putInt(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
}
public PDOMCVariable(PDOM pdom, int record) {
super(pdom, record);
public PDOMCVariable(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -123,8 +122,8 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
public IType getType() {
try {
int typeRec = pdom.getDB().getInt(record + TYPE_OFFSET);
return (IType)getLinkageImpl().getNode(typeRec);
int typeRec = getDB().getInt(record + TYPE_OFFSET);
return (IType)getLinkage().getNode(typeRec);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
@ -133,7 +132,7 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
public IValue getInitialValue() {
try {
final Database db = pdom.getDB();
final Database db = getDB();
int valRec = db.getInt(record + VALUE_OFFSET);
return PDOMValue.restore(db, getLinkage(), valRec);
} catch (CoreException e) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Symbian Software Systems and others.
* Copyright (c) 2006, 2009 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,7 +14,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.dom.FindBinding;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
@ -32,15 +31,15 @@ import org.eclipse.core.runtime.OperationCanceledException;
public class CPPFindBinding extends FindBinding {
public static class CPPBindingBTreeComparator extends FindBinding.DefaultBindingBTreeComparator {
public CPPBindingBTreeComparator(PDOM pdom) {
super(pdom);
public CPPBindingBTreeComparator(PDOMLinkage linkage) {
super(linkage);
}
@Override
public int compare(int record1, int record2) throws CoreException {
int cmp = super.compare(record1, record2);
if (cmp == 0) {
PDOMBinding binding1 = pdom.getBinding(record1);
PDOMBinding binding2 = pdom.getBinding(record2);
PDOMBinding binding1 = linkage.getBinding(record1);
PDOMBinding binding2 = linkage.getBinding(record2);
if (binding1 instanceof IPDOMOverloader && binding2 instanceof IPDOMOverloader) {
int ty1 = ((IPDOMOverloader) binding1).getSignatureHash();
int ty2 = ((IPDOMOverloader) binding2).getSignatureHash();
@ -54,8 +53,8 @@ public class CPPFindBinding extends FindBinding {
public static class CPPFindBindingVisitor extends FindBinding.DefaultFindBindingVisitor {
private final int fConstant;
private final int fSigHash;
public CPPFindBindingVisitor(PDOM pdom, char[] name, int constant, int hash, int localToFile) {
super(pdom, name, new int[] {constant}, localToFile);
public CPPFindBindingVisitor(PDOMLinkage linkage, char[] name, int constant, int hash, int localToFile) {
super(linkage, name, new int[] {constant}, localToFile);
fConstant= constant;
fSigHash= hash;
}
@ -64,10 +63,10 @@ public class CPPFindBinding extends FindBinding {
public int compare(int record) throws CoreException {
int cmp= super.compare(record);
if (cmp == 0) {
int c1 = PDOMNode.getNodeType(fPdom, record);
int c1 = PDOMNode.getNodeType(fLinkage.getDB(), record);
int c2= fConstant;
if (c1 == c2) {
PDOMBinding binding = fPdom.getBinding(record);
PDOMBinding binding = fLinkage.getBinding(record);
if (binding instanceof IPDOMOverloader) {
c1 = ((IPDOMOverloader) binding).getSignatureHash();
c2= fSigHash;
@ -80,7 +79,7 @@ public class CPPFindBinding extends FindBinding {
@Override
public boolean visit(int record) throws CoreException {
fResult= fPdom.getBinding(record);
fResult= fLinkage.getBinding(record);
return false;
}
@ -96,16 +95,16 @@ public class CPPFindBinding extends FindBinding {
}
}
public static PDOMBinding findBinding(BTree btree, final PDOM pdom, final char[] name,
public static PDOMBinding findBinding(BTree btree, final PDOMLinkage linkage, final char[] name,
final int c2, final int ty2, int localToFileRec) throws CoreException {
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(pdom, name, c2, ty2, localToFileRec);
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(linkage, name, c2, ty2, localToFileRec);
btree.accept(visitor);
return visitor.getResult();
}
public static PDOMBinding findBinding(PDOMNode node, PDOM pdom, char[] name, int constant,
public static PDOMBinding findBinding(PDOMNode node, PDOMLinkage linkage, char[] name, int constant,
int sigHash, int localToFileRec) throws CoreException {
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(pdom, name, constant, sigHash,
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(linkage, name, constant, sigHash,
localToFileRec);
try {
node.accept(visitor);
@ -122,10 +121,10 @@ public class CPPFindBinding extends FindBinding {
} catch (DOMException e) {
}
if (hash != null) {
return findBinding(btree, linkage.getPDOM(), binding.getNameCharArray(),
return findBinding(btree, linkage, binding.getNameCharArray(),
linkage.getBindingType(binding), hash.intValue(), localToFileRec);
}
return findBinding(btree, linkage.getPDOM(), binding.getNameCharArray(),
return findBinding(btree, linkage, binding.getNameCharArray(),
new int[] {linkage.getBindingType(binding)}, localToFileRec);
}
@ -137,10 +136,10 @@ public class CPPFindBinding extends FindBinding {
} catch (DOMException e) {
}
if (hash != null) {
return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(),
return findBinding(node, linkage, binding.getNameCharArray(),
linkage.getBindingType(binding), hash.intValue(), localToFileRec);
}
return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(),
return findBinding(node, linkage, binding.getNameCharArray(),
new int[] {linkage.getBindingType(binding)}, localToFileRec);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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
@ -32,7 +32,7 @@ public class PDOMCPPArgumentList {
*/
public static int putArguments(PDOMNode parent, ICPPTemplateArgument[] templateArguments) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len= (short) Math.min(templateArguments.length, (Database.MAX_MALLOC_SIZE-2)/8);
final int block= db.malloc(2+8*len);
int p= block;
@ -62,7 +62,7 @@ public class PDOMCPPArgumentList {
*/
public static void clearArguments(PDOMNode parent, final int record) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len= db.getShort(record);
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/8);
@ -85,7 +85,7 @@ public class PDOMCPPArgumentList {
*/
public static ICPPTemplateArgument[] getArguments(PDOMNode parent, int rec) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len= db.getShort(rec);
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/8);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -17,9 +17,9 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBase;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
@ -35,19 +35,19 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
protected static final int RECORD_SIZE = 9;
protected final PDOM pdom;
protected final int record;
private final PDOMLinkage linkage;
private final int record;
private PDOMBinding fCachedBaseClass;
public PDOMCPPBase(PDOM pdom, int record) {
this.pdom = pdom;
public PDOMCPPBase(PDOMLinkage linkage, int record) {
this.linkage = linkage;
this.record = record;
}
public PDOMCPPBase(PDOM pdom, PDOMName baseClassSpec, boolean isVirtual, int visibility) throws CoreException {
this.pdom = pdom;
Database db = pdom.getDB();
public PDOMCPPBase(PDOMLinkage linkage, PDOMName baseClassSpec, boolean isVirtual, int visibility) throws CoreException {
this.linkage = linkage;
Database db = getDB();
this.record = db.malloc(RECORD_SIZE);
int baserec = baseClassSpec != null ? baseClassSpec.getRecord() : 0;
@ -57,29 +57,33 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
db.putByte(record + FLAGS, flags);
}
private Database getDB() {
return linkage.getDB();
}
public int getRecord() {
return record;
}
public void setNextBase(PDOMCPPBase nextBase) throws CoreException {
int rec = nextBase != null ? nextBase.getRecord() : 0;
pdom.getDB().putInt(record + NEXTBASE, rec);
getDB().putInt(record + NEXTBASE, rec);
}
public PDOMCPPBase getNextBase() throws CoreException {
int rec = pdom.getDB().getInt(record + NEXTBASE);
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
int rec = getDB().getInt(record + NEXTBASE);
return rec != 0 ? new PDOMCPPBase(linkage, rec) : null;
}
private int getFlags() throws CoreException {
return pdom.getDB().getByte(record + FLAGS);
return getDB().getByte(record + FLAGS);
}
public PDOMName getBaseClassSpecifierName() {
try {
int rec = pdom.getDB().getInt(record + BASECLASS_SPECIFIER);
int rec = getDB().getInt(record + BASECLASS_SPECIFIER);
if (rec != 0) {
return new PDOMName(pdom, rec);
return new PDOMName(linkage, rec);
}
} catch (CoreException e) {
CCorePlugin.log(e);
@ -126,7 +130,7 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
}
public void delete() throws CoreException {
pdom.getDB().free(record);
getDB().free(record);
}
public void setBaseClass(IBinding binding) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -22,8 +22,8 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
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.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -40,19 +40,19 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
protected short fFlags= -1;
public PDOMCPPBasicType(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPBasicType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCPPBasicType(PDOM pdom, PDOMNode parent, ICPPBasicType type) throws CoreException {
this(pdom, parent, type, encodeFlags(type));
public PDOMCPPBasicType(PDOMLinkage linkage, PDOMNode parent, ICPPBasicType type) throws CoreException {
this(linkage, parent, type, encodeFlags(type));
}
protected PDOMCPPBasicType(PDOM pdom, PDOMNode parent, ICPPBasicType type, final short flags) throws CoreException {
super(pdom, parent);
protected PDOMCPPBasicType(PDOMLinkage linkage, PDOMNode parent, ICPPBasicType type, final short flags) throws CoreException {
super(linkage, parent);
fFlags= flags;
Database db = pdom.getDB();
Database db = getDB();
db.putShort(record + TYPE_ID, getTypeCode(type));
db.putShort(record + QUALIFIER_FLAGS, flags);
}
@ -94,7 +94,7 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
public int getType() {
try {
return pdom.getDB().getShort(record + TYPE_ID);
return getDB().getShort(record + TYPE_ID);
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
@ -109,7 +109,7 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
public int getQualifierBits() {
if (fFlags == -1) {
try {
fFlags= pdom.getDB().getShort(record + QUALIFIER_FLAGS);
fFlags= getDB().getShort(record + QUALIFIER_FLAGS);
}
catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 Symbian Corporation and others.
* Copyright (c) 2006, 2009 Symbian Corporation 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
@ -23,8 +23,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -36,11 +36,11 @@ abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE= PDOMBinding.RECORD_SIZE + 0;
public PDOMCPPBinding(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPBinding(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCPPBinding(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
super(pdom, parent, name);
public PDOMCPPBinding(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
super(linkage, parent, name);
}
protected boolean isSameOwner(IBinding owner1, IBinding owner2) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -23,8 +23,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -41,16 +41,16 @@ class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTem
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE + 4;
public PDOMCPPClassInstance(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding orig)
public PDOMCPPClassInstance(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding orig)
throws CoreException {
super(pdom, parent, classType, orig);
super(linkage, parent, classType, orig);
final ICPPTemplateInstance asInstance= (ICPPTemplateInstance) classType;
final int argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
pdom.getDB().putInt(record + ARGUMENTS, argListRec);
getDB().putInt(record + ARGUMENTS, argListRec);
}
public PDOMCPPClassInstance(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPClassInstance(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -42,10 +42,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
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.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -68,13 +68,13 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
private ICPPClassScope fScope;
private ObjectMap specializationMap= null;
public PDOMCPPClassSpecialization(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized)
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized)
throws CoreException {
super(pdom, parent, (ICPPSpecialization) classType, specialized);
super(linkage, parent, (ICPPSpecialization) classType, specialized);
}
public PDOMCPPClassSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPClassSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -95,7 +95,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
public IBinding specializeMember(IBinding original) {
if (specializationMap == null) {
final Integer key= record+PDOMCPPLinkage.CACHE_INSTANCE_SCOPE;
Object cached= pdom.getCachedResult(key);
Object cached= getPDOM().getCachedResult(key);
if (cached != null) {
specializationMap= (ObjectMap) cached;
} else {
@ -112,7 +112,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
} catch (CoreException e) {
CCorePlugin.log(e);
}
specializationMap= (ObjectMap) pdom.putCachedResult(key, newMap, false);
specializationMap= (ObjectMap) getPDOM().putCachedResult(key, newMap, false);
}
}
synchronized (specializationMap) {
@ -148,13 +148,13 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
public PDOMCPPBase getFirstBase() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
int rec = getDB().getInt(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(getLinkage(), rec) : null;
}
private void setFirstBase(PDOMCPPBase base) throws CoreException {
int rec = base != null ? base.getRecord() : 0;
pdom.getDB().putInt(record + FIRSTBASE, rec);
getDB().putInt(record + FIRSTBASE, rec);
}
public void addBase(PDOMCPPBase base) throws CoreException {
@ -195,7 +195,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
// this is an explicit specialization
Integer key= record + PDOMCPPLinkage.CACHE_BASES;
ICPPBase[] bases= (ICPPBase[]) pdom.getCachedResult(key);
ICPPBase[] bases= (ICPPBase[]) getPDOM().getCachedResult(key);
if (bases != null)
return bases;
@ -205,7 +205,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
list.add(base);
Collections.reverse(list);
bases = list.toArray(new ICPPBase[list.size()]);
pdom.putCachedResult(key, bases);
getPDOM().putCachedResult(key, bases);
return bases;
} catch (CoreException e) {
CCorePlugin.log(e);
@ -355,13 +355,13 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
@Override
public void addChild(PDOMNode member) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.addMember(member);
}
public void acceptUncached(IPDOMVisitor visitor) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.accept(visitor);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -35,7 +35,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -58,20 +57,20 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
private ICPPTemplateParameter[] params; // Cached template parameters.
public PDOMCPPClassTemplate(PDOM pdom, PDOMCPPLinkage linkage, PDOMNode parent, ICPPClassTemplate template) throws CoreException, DOMException {
super(pdom, parent, template);
public PDOMCPPClassTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPClassTemplate template) throws CoreException, DOMException {
super(linkage, parent, template);
final Database db = pdom.getDB();
final Database db = getDB();
final ICPPTemplateParameter[] origParams= template.getTemplateParameters();
final IPDOMCPPTemplateParameter[] params = PDOMTemplateParameterArray.createPDOMTemplateParameters(pdom, this, origParams);
final IPDOMCPPTemplateParameter[] params = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
int rec= PDOMTemplateParameterArray.putArray(db, params);
db.putInt(record + PARAMETERS, rec);
db.putShort(record + RELEVANT_PARAMETERS, (short) params.length);
linkage.new ConfigureTemplateParameters(origParams, params);
}
public PDOMCPPClassTemplate(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPClassTemplate(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -87,7 +86,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
public ICPPTemplateParameter[] getTemplateParameters() {
if (params == null) {
try {
final Database db = pdom.getDB();
final Database db = getDB();
int rec= db.getInt(record + PARAMETERS);
int count= Math.max(0, db.getShort(record + RELEVANT_PARAMETERS));
if (rec == 0 || count == 0) {
@ -124,7 +123,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
}
private void updateTemplateParameters(PDOMLinkage linkage, ICPPTemplateParameter[] newParams) throws CoreException, DOMException {
final Database db = pdom.getDB();
final Database db = getDB();
int rec= db.getInt(record + PARAMETERS);
IPDOMCPPTemplateParameter[] allParams;
if (rec == 0) {
@ -170,7 +169,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
newAllParams[j]= allParams[idx];
allParams[idx]= null;
} else {
newAllParams[j]= PDOMTemplateParameterArray.createPDOMTemplateParameter(pdom, this, newParams[j]);
newAllParams[j]= PDOMTemplateParameterArray.createPDOMTemplateParameter(getLinkage(), this, newParams[j]);
}
}
int pos= newParamLength;
@ -197,14 +196,14 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
}
private PDOMCPPClassTemplatePartialSpecialization getFirstPartial() throws CoreException {
int value = pdom.getDB().getInt(record + FIRST_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecialization(pdom, value) : null;
int value = getDB().getInt(record + FIRST_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecialization(getLinkage(), value) : null;
}
public void addPartial(PDOMCPPClassTemplatePartialSpecialization partial) throws CoreException {
PDOMCPPClassTemplatePartialSpecialization first = getFirstPartial();
partial.setNextPartial(first);
pdom.getDB().putInt(record + FIRST_PARTIAL, partial.getRecord());
getDB().putInt(record + FIRST_PARTIAL, partial.getRecord());
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -28,10 +28,10 @@ import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
@ -53,29 +53,29 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPClassTemplate.RECORD_SIZE + 16;
public PDOMCPPClassTemplatePartialSpecialization(PDOM pdom, PDOMCPPLinkage linkage,
PDOMNode parent, ICPPClassTemplatePartialSpecialization partial, PDOMCPPClassTemplate primary)
public PDOMCPPClassTemplatePartialSpecialization(PDOMCPPLinkage linkage, PDOMNode parent,
ICPPClassTemplatePartialSpecialization partial, PDOMCPPClassTemplate primary)
throws CoreException, DOMException {
super(pdom, linkage, parent, partial);
pdom.getDB().putInt(record + PRIMARY, primary.getRecord());
super(linkage, parent, partial);
getDB().putInt(record + PRIMARY, primary.getRecord());
primary.addPartial(this);
try {
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(partial);
pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
linkage.new ConfigurePartialSpecialization(this, partial);
}
public PDOMCPPClassTemplatePartialSpecialization(PDOM pdom,
public PDOMCPPClassTemplatePartialSpecialization(PDOMLinkage linkage,
int bindingRecord) {
super(pdom, bindingRecord);
super(linkage, bindingRecord);
}
public int getSignatureHash() throws CoreException {
return pdom.getDB().getInt(record + SIGNATURE_HASH);
return getDB().getInt(record + SIGNATURE_HASH);
}
@Override
@ -89,18 +89,18 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
}
public PDOMCPPClassTemplatePartialSpecialization getNextPartial() throws CoreException {
int value = pdom.getDB().getInt(record + NEXT_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecialization(pdom, value) : null;
int value = getDB().getInt(record + NEXT_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecialization(getLinkage(), value) : null;
}
public void setNextPartial(PDOMCPPClassTemplatePartialSpecialization partial) throws CoreException {
int value = partial != null ? partial.getRecord() : 0;
pdom.getDB().putInt(record + NEXT_PARTIAL, value);
getDB().putInt(record + NEXT_PARTIAL, value);
}
public ICPPClassTemplate getPrimaryClassTemplate() {
try {
return new PDOMCPPClassTemplate(pdom, pdom.getDB().getInt(record + PRIMARY));
return new PDOMCPPClassTemplate(getLinkage(), getDB().getInt(record + PRIMARY));
} catch (CoreException e) {
CCorePlugin.log(e);
return null;

View file

@ -21,9 +21,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -41,20 +41,20 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
private ICPPClassTemplate fPrimaryTemplate;
public PDOMCPPClassTemplatePartialSpecializationSpecialization(PDOM pdom,
PDOMCPPLinkage linkage, PDOMNode parent, PDOMBinding specialized,
ICPPClassTemplatePartialSpecialization partial, PDOMCPPClassTemplateSpecialization primary) throws CoreException {
super(pdom, parent, partial, specialized);
public PDOMCPPClassTemplatePartialSpecializationSpecialization(PDOMCPPLinkage linkage,
PDOMNode parent, PDOMBinding specialized, ICPPClassTemplatePartialSpecialization partial,
PDOMCPPClassTemplateSpecialization primary) throws CoreException {
super(linkage, parent, partial, specialized);
pdom.getDB().putInt(record + PRIMARY_TEMPLATE, primary.getRecord());
getDB().putInt(record + PRIMARY_TEMPLATE, primary.getRecord());
primary.addPartial(this);
linkage.new ConfigurePartialSpecialization(this, partial);
}
public PDOMCPPClassTemplatePartialSpecializationSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPClassTemplatePartialSpecializationSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -73,13 +73,13 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
}
public PDOMCPPClassTemplatePartialSpecializationSpecialization getNextPartial() throws CoreException {
int value = pdom.getDB().getInt(record + NEXT_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecializationSpecialization(pdom, value) : null;
int value = getDB().getInt(record + NEXT_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecializationSpecialization(getLinkage(), value) : null;
}
public void setNextPartial(PDOMCPPClassTemplatePartialSpecializationSpecialization partial) throws CoreException {
int value = partial != null ? partial.getRecord() : 0;
pdom.getDB().putInt(record + NEXT_PARTIAL, value);
getDB().putInt(record + NEXT_PARTIAL, value);
}
@Override
@ -124,8 +124,8 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
public ICPPClassTemplate getPrimaryClassTemplate() {
if (fPrimaryTemplate == null) {
try {
int specializedRec = pdom.getDB().getInt(record + PRIMARY_TEMPLATE);
fPrimaryTemplate= (ICPPClassTemplate) getLinkageImpl().getNode(specializedRec);
int specializedRec = getDB().getInt(record + PRIMARY_TEMPLATE);
fPrimaryTemplate= (ICPPClassTemplate) getLinkage().getNode(specializedRec);
} catch (CoreException e) {
CCorePlugin.log(e);
}

View file

@ -31,8 +31,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -46,13 +46,13 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE+4;
public PDOMCPPClassTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
public PDOMCPPClassTemplateSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
throws CoreException {
super(pdom, parent, template, specialized);
super(linkage, parent, template, specialized);
}
public PDOMCPPClassTemplateSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPClassTemplateSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -159,14 +159,14 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
}
private PDOMCPPClassTemplatePartialSpecializationSpecialization getFirstPartial() throws CoreException {
int value = pdom.getDB().getInt(record + FIRST_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecializationSpecialization(pdom, value) : null;
int value = getDB().getInt(record + FIRST_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecializationSpecialization(getLinkage(), value) : null;
}
public void addPartial(PDOMCPPClassTemplatePartialSpecializationSpecialization pspecspec) throws CoreException {
PDOMCPPClassTemplatePartialSpecializationSpecialization first = getFirstPartial();
pspecspec.setNextPartial(first);
pdom.getDB().putInt(record + FIRST_PARTIAL, pspecspec.getRecord());
getDB().putInt(record + FIRST_PARTIAL, pspecspec.getRecord());
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -38,7 +38,6 @@ import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
@ -66,16 +65,16 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
private ICPPClassScope fScope;
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, ICPPClassType classType) throws CoreException {
super(pdom, parent, classType.getNameCharArray());
public PDOMCPPClassType(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType) throws CoreException {
super(linkage, parent, classType.getNameCharArray());
setKind(classType);
setAnonymous(classType);
// linked list is initialized by storage being zero'd by malloc
}
public PDOMCPPClassType(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPClassType(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -100,7 +99,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
private void setKind(ICPPClassType ct) throws CoreException {
try {
pdom.getDB().putByte(record + KEY, (byte) ct.getKey());
getDB().putByte(record + KEY, (byte) ct.getKey());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@ -108,7 +107,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
private void setAnonymous(ICPPClassType ct) throws CoreException {
try {
pdom.getDB().putByte(record + ANONYMOUS, (byte) (ct.isAnonymous() ? 1 : 0));
getDB().putByte(record + ANONYMOUS, (byte) (ct.isAnonymous() ? 1 : 0));
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@ -121,8 +120,8 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
@Override
public void addChild(PDOMNode member) throws CoreException {
pdom.removeCachedResult(record + PDOMCPPLinkage.CACHE_MEMBERS);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
getPDOM().removeCachedResult(record + PDOMCPPLinkage.CACHE_MEMBERS);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.addMember(member);
}
@ -136,29 +135,29 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
*/
public void acceptUncached(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.accept(visitor);
}
private PDOMCPPBase getFirstBase() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
int rec = getDB().getInt(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(getLinkage(), rec) : null;
}
private void setFirstBase(PDOMCPPBase base) throws CoreException {
int rec = base != null ? base.getRecord() : 0;
pdom.getDB().putInt(record + FIRSTBASE, rec);
getDB().putInt(record + FIRSTBASE, rec);
}
public void addBase(PDOMCPPBase base) throws CoreException {
pdom.removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
PDOMCPPBase firstBase = getFirstBase();
base.setNextBase(firstBase);
setFirstBase(base);
}
public void removeBase(PDOMName pdomName) throws CoreException {
pdom.removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
getPDOM().removeCachedResult(record+PDOMCPPLinkage.CACHE_BASES);
PDOMCPPBase base= getFirstBase();
PDOMCPPBase predecessor= null;
@ -189,13 +188,13 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
}
private PDOMCPPFriend getFirstFriend() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRSTFRIEND);
return rec != 0 ? new PDOMCPPFriend(pdom, rec) : null;
int rec = getDB().getInt(record + FIRSTFRIEND);
return rec != 0 ? new PDOMCPPFriend(getLinkage(), rec) : null;
}
private void setFirstFriend(PDOMCPPFriend friend) throws CoreException {
int rec = friend != null ? friend.getRecord() : 0;
pdom.getDB().putInt(record + FIRSTFRIEND, rec);
getDB().putInt(record + FIRSTFRIEND, rec);
}
public void removeFriend(PDOMName pdomName) throws CoreException {
@ -230,7 +229,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
public int getKey() throws DOMException {
try {
return pdom.getDB().getByte(record + KEY);
return getDB().getByte(record + KEY);
} catch (CoreException e) {
CCorePlugin.log(e);
return ICPPClassType.k_class; // or something
@ -239,7 +238,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
public boolean isAnonymous() throws DOMException {
try {
return pdom.getDB().getByte(record + ANONYMOUS) != 0;
return getDB().getByte(record + ANONYMOUS) != 0;
} catch (CoreException e) {
CCorePlugin.log(e);
return false;
@ -280,7 +279,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
public ICPPBase[] getBases() throws DOMException {
Integer key= record + PDOMCPPLinkage.CACHE_BASES;
ICPPBase[] bases= (ICPPBase[]) pdom.getCachedResult(key);
ICPPBase[] bases= (ICPPBase[]) getPDOM().getCachedResult(key);
if (bases != null)
return bases;
@ -290,7 +289,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
list.add(base);
Collections.reverse(list);
bases = list.toArray(new ICPPBase[list.size()]);
pdom.putCachedResult(key, bases);
getPDOM().putCachedResult(key, bases);
return bases;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
@ -15,18 +15,18 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor {
public PDOMCPPConstructor(PDOM pdom, PDOMNode parent, ICPPConstructor method) throws CoreException, DOMException {
super(pdom, parent, method);
public PDOMCPPConstructor(PDOMLinkage linkage, PDOMNode parent, ICPPConstructor method) throws CoreException, DOMException {
super(linkage, parent, method);
}
public PDOMCPPConstructor(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPConstructor(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public boolean isExplicit() throws DOMException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -14,8 +14,8 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -32,13 +32,13 @@ public class PDOMCPPConstructorInstance extends PDOMCPPMethodInstance implements
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPMethodInstance.RECORD_SIZE + 0;
public PDOMCPPConstructorInstance(PDOM pdom, PDOMNode parent, ICPPMethod method, PDOMBinding instantiated)
public PDOMCPPConstructorInstance(PDOMLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding instantiated)
throws CoreException {
super(pdom, parent, method, instantiated);
super(linkage, parent, method, instantiated);
}
public PDOMCPPConstructorInstance(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPConstructorInstance(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -13,8 +13,8 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -31,12 +31,12 @@ class PDOMCPPConstructorSpecialization extends
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPMethodSpecialization.RECORD_SIZE + 0;
public PDOMCPPConstructorSpecialization(PDOM pdom, PDOMNode parent, ICPPConstructor constructor, PDOMBinding specialized) throws CoreException {
super(pdom, parent, constructor, specialized);
public PDOMCPPConstructorSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPConstructor constructor, PDOMBinding specialized) throws CoreException {
super(linkage, parent, constructor, specialized);
}
public PDOMCPPConstructorSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPConstructorSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -24,13 +24,13 @@ import org.eclipse.core.runtime.CoreException;
class PDOMCPPConstructorTemplate extends PDOMCPPMethodTemplate implements
ICPPConstructor {
public PDOMCPPConstructorTemplate(PDOM pdom, PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor method)
public PDOMCPPConstructorTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor method)
throws CoreException, DOMException {
super(pdom, linkage, parent, method);
super(linkage, parent, method);
}
public PDOMCPPConstructorTemplate(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPConstructorTemplate(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public boolean isExplicit() throws DOMException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -13,8 +13,8 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -29,15 +29,15 @@ class PDOMCPPConstructorTemplateSpecialization extends
* The size in bytes of a PDOMCPPConstructorTemplateSpecialization record in the database.
*/
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPMethodTemplateSpecialization.RECORD_SIZE + 0;
protected static final int RECORD_SIZE = PDOMCPPFunctionSpecialization.RECORD_SIZE + 0;
public PDOMCPPConstructorTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPConstructor constructor, PDOMBinding specialized)
public PDOMCPPConstructorTemplateSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPConstructor constructor, PDOMBinding specialized)
throws CoreException {
super(pdom, parent, constructor, specialized);
super(linkage, parent, constructor, specialized);
}
public PDOMCPPConstructorTemplateSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPConstructorTemplateSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -36,10 +36,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
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.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -59,16 +59,16 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
private ICPPScope unknownScope;
public PDOMCPPDeferredClassInstance(PDOM pdom, PDOMNode parent, ICPPDeferredClassInstance classType, PDOMBinding instantiated)
public PDOMCPPDeferredClassInstance(PDOMLinkage linkage, PDOMNode parent, ICPPDeferredClassInstance classType, PDOMBinding instantiated)
throws CoreException {
super(pdom, parent, classType, instantiated);
super(linkage, parent, classType, instantiated);
final int argListRec= PDOMCPPArgumentList.putArguments(this, classType.getTemplateArguments());
pdom.getDB().putInt(record+ARGUMENTS, argListRec);
getDB().putInt(record+ARGUMENTS, argListRec);
}
public PDOMCPPDeferredClassInstance(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPDeferredClassInstance(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -114,14 +114,14 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
@Override
public void addChild(PDOMNode member) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.addMember(member);
}
@Override
public void accept(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.accept(visitor);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -24,8 +24,8 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
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.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
@ -40,13 +40,13 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IEnumeration, IIndexT
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCPPEnumeration(PDOM pdom, PDOMNode parent, IEnumeration enumeration)
public PDOMCPPEnumeration(PDOMLinkage linkage, PDOMNode parent, IEnumeration enumeration)
throws CoreException {
super(pdom, parent, enumeration.getNameCharArray());
super(linkage, parent, enumeration.getNameCharArray());
}
public PDOMCPPEnumeration(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPEnumeration(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -86,14 +86,14 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IEnumeration, IIndexT
}
private PDOMCPPEnumerator getFirstEnumerator() throws CoreException {
int value = pdom.getDB().getInt(record + FIRST_ENUMERATOR);
return value != 0 ? new PDOMCPPEnumerator(pdom, value) : null;
int value = getDB().getInt(record + FIRST_ENUMERATOR);
return value != 0 ? new PDOMCPPEnumerator(getLinkage(), value) : null;
}
public void addEnumerator(PDOMCPPEnumerator enumerator) throws CoreException {
PDOMCPPEnumerator first = getFirstEnumerator();
enumerator.setNextEnumerator(first);
pdom.getDB().putInt(record + FIRST_ENUMERATOR, enumerator.getRecord());
getDB().putInt(record + FIRST_ENUMERATOR, enumerator.getRecord());
}
public boolean isSameType(IType type) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
@ -39,18 +38,18 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 12;
public PDOMCPPEnumerator(PDOM pdom, PDOMNode parent, IEnumerator enumerator, PDOMCPPEnumeration enumeration)
public PDOMCPPEnumerator(PDOMLinkage linkage, PDOMNode parent, IEnumerator enumerator, PDOMCPPEnumeration enumeration)
throws CoreException {
super(pdom, parent, enumerator.getNameCharArray());
super(linkage, parent, enumerator.getNameCharArray());
final Database db = pdom.getDB();
final Database db = getDB();
db.putInt(record + ENUMERATION, enumeration.getRecord());
storeValue(db, enumerator);
enumeration.addEnumerator(this);
}
public PDOMCPPEnumerator(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPEnumerator(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -74,22 +73,22 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof IEnumerator)
storeValue(pdom.getDB(), (IEnumerator) newBinding);
storeValue(getDB(), (IEnumerator) newBinding);
}
public PDOMCPPEnumerator getNextEnumerator() throws CoreException {
int value = pdom.getDB().getInt(record + NEXT_ENUMERATOR);
return value != 0 ? new PDOMCPPEnumerator(pdom, value) : null;
int value = getDB().getInt(record + NEXT_ENUMERATOR);
return value != 0 ? new PDOMCPPEnumerator(getLinkage(), value) : null;
}
public void setNextEnumerator(PDOMCPPEnumerator enumerator) throws CoreException {
int value = enumerator != null ? enumerator.getRecord() : 0;
pdom.getDB().putInt(record + NEXT_ENUMERATOR, value);
getDB().putInt(record + NEXT_ENUMERATOR, value);
}
public IType getType() throws DOMException {
try {
return new PDOMCPPEnumeration(pdom, pdom.getDB().getInt(record + ENUMERATION));
return new PDOMCPPEnumeration(getLinkage(), getDB().getInt(record + ENUMERATION));
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
@ -98,7 +97,7 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
public IValue getValue() {
try {
int val= pdom.getDB().getInt(record + VALUE);
int val= getDB().getInt(record + VALUE);
return Value.create(val);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -26,13 +26,13 @@ import org.eclipse.core.runtime.CoreException;
*/
class PDOMCPPField extends PDOMCPPVariable implements ICPPField {
public PDOMCPPField(PDOM pdom, PDOMNode parent, ICPPField field)
public PDOMCPPField(PDOMLinkage linkage, PDOMNode parent, ICPPField field)
throws CoreException {
super(pdom, parent, field);
super(linkage, parent, field);
}
public PDOMCPPField(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPField(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
// @Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
@ -49,15 +48,14 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 8;
public PDOMCPPFieldSpecialization(PDOM pdom, PDOMNode parent,
public PDOMCPPFieldSpecialization(PDOMLinkage linkage, PDOMNode parent,
ICPPField field, PDOMBinding specialized)
throws CoreException {
super(pdom, parent, (ICPPSpecialization) field, specialized);
super(linkage, parent, (ICPPSpecialization) field, specialized);
try {
final Database db = pdom.getDB();
final Database db = getDB();
IType type = field.getType();
final PDOMLinkage linkage = getLinkage();
PDOMNode typeNode = linkage.addType(this, type);
if (typeNode != null) {
db.putInt(record + TYPE, typeNode.getRecord());
@ -70,8 +68,8 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
}
}
public PDOMCPPFieldSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPFieldSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -94,7 +92,7 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
public IType getType() throws DOMException {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
if (node instanceof IType) {
return (IType) node;
}
@ -106,7 +104,7 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
public IValue getInitialValue() {
try {
final Database db = pdom.getDB();
final Database db = getDB();
int valRec = db.getInt(record + VALUE_OFFSET);
return PDOMValue.restore(db, getLinkage(), valRec);
} catch (CoreException e) {

View file

@ -1,10 +1,19 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -17,16 +26,15 @@ class PDOMCPPFriend extends PDOMNode {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 8;
public PDOMCPPFriend(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPFriend(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCPPFriend(PDOM pdom, PDOMName friendSpec) throws CoreException {
super(pdom, null);
Database db = pdom.getDB();
public PDOMCPPFriend(PDOMLinkage linkage, PDOMName friendSpec) throws CoreException {
super(linkage, null);
int friendrec = friendSpec != null ? friendSpec.getRecord() : 0;
db.putInt(record + FRIEND_SPECIFIER, friendrec);
linkage.getDB().putInt(record + FRIEND_SPECIFIER, friendrec);
}
@Override
@ -40,8 +48,8 @@ class PDOMCPPFriend extends PDOMNode {
}
public PDOMName getSpecifierName() throws CoreException {
int rec = pdom.getDB().getInt(record + FRIEND_SPECIFIER);
if (rec != 0) return new PDOMName(pdom, rec);
int rec = getDB().getInt(record + FRIEND_SPECIFIER);
if (rec != 0) return new PDOMName(getLinkage(), rec);
return null;
}
@ -60,16 +68,16 @@ class PDOMCPPFriend extends PDOMNode {
public void setNextFriend(PDOMCPPFriend nextFriend) throws CoreException {
int rec = nextFriend != null ? nextFriend.getRecord() : 0;
pdom.getDB().putInt(record + NEXT_FRIEND, rec);
getDB().putInt(record + NEXT_FRIEND, rec);
}
public PDOMCPPFriend getNextFriend() throws CoreException {
int rec = pdom.getDB().getInt(record + NEXT_FRIEND);
return rec != 0 ? new PDOMCPPFriend(pdom, rec) : null;
int rec = getDB().getInt(record + NEXT_FRIEND);
return rec != 0 ? new PDOMCPPFriend(getLinkage(), rec) : null;
}
public void delete() throws CoreException {
pdom.getDB().free(record);
getDB().free(record);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -81,11 +80,11 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 21;
public PDOMCPPFunction(PDOM pdom, PDOMNode parent, ICPPFunction function, boolean setTypes) throws CoreException, DOMException {
super(pdom, parent, function.getNameCharArray());
Database db = pdom.getDB();
public PDOMCPPFunction(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, boolean setTypes) throws CoreException, DOMException {
super(linkage, parent, function.getNameCharArray());
Database db = getDB();
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
if (setTypes) {
initData(function.getType(), function.getParameters());
@ -129,7 +128,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
if (oldParams != null) {
oldParams.delete(linkage);
}
final Database db = pdom.getDB();
final Database db = getDB();
db.putByte(record + ANNOTATION, newAnnotation);
int oldRec = db.getInt(record+EXCEPTION_SPEC);
@ -155,32 +154,32 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
private void setParameters(PDOMCPPFunctionType pft, IParameter[] params) throws CoreException {
final Database db= pdom.getDB();
final Database db= getDB();
db.putInt(record + NUM_PARAMS, params.length);
db.putInt(record + FIRST_PARAM, 0);
IType[] paramTypes= pft.getParameterTypes();
for (int i= 0; i < params.length; ++i) {
int ptRecord= i < paramTypes.length && paramTypes[i] != null ? ((PDOMNode) paramTypes[i]).getRecord() : 0;
setFirstParameter(new PDOMCPPParameter(pdom, this, params[i], ptRecord));
setFirstParameter(new PDOMCPPParameter(getLinkage(), this, params[i], ptRecord));
}
}
private PDOMCPPFunctionType setType(ICPPFunctionType ft) throws CoreException {
PDOMCPPFunctionType pft = (PDOMCPPFunctionType) getLinkageImpl().addType(this, ft);
pdom.getDB().putInt(record + FUNCTION_TYPE, pft.getRecord());
PDOMCPPFunctionType pft = (PDOMCPPFunctionType) getLinkage().addType(this, ft);
getDB().putInt(record + FUNCTION_TYPE, pft.getRecord());
return pft;
}
public int getSignatureHash() throws CoreException {
return pdom.getDB().getInt(record + SIGNATURE_HASH);
return getDB().getInt(record + SIGNATURE_HASH);
}
public static int getSignatureHash(PDOM pdom, int record) throws CoreException {
return pdom.getDB().getInt(record + SIGNATURE_HASH);
public static int getSignatureHash(PDOMLinkage linkage, int record) throws CoreException {
return linkage.getDB().getInt(record + SIGNATURE_HASH);
}
public PDOMCPPFunction(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPFunction(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -194,15 +193,15 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
private PDOMCPPParameter getFirstParameter() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRST_PARAM);
return rec != 0 ? new PDOMCPPParameter(pdom, rec) : null;
int rec = getDB().getInt(record + FIRST_PARAM);
return rec != 0 ? new PDOMCPPParameter(getLinkage(), rec) : null;
}
private void setFirstParameter(PDOMCPPParameter param) throws CoreException {
if (param != null)
param.setNextParameter(getFirstParameter());
int rec = param != null ? param.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_PARAM, rec);
getDB().putInt(record + FIRST_PARAM, rec);
}
public boolean isInline() throws DOMException {
@ -223,7 +222,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
public IParameter[] getParameters() throws DOMException {
try {
int n = pdom.getDB().getInt(record + NUM_PARAMS);
int n = getDB().getInt(record + NUM_PARAMS);
IParameter[] params = new IParameter[n];
PDOMCPPParameter param = getFirstParameter();
while (param != null) {
@ -239,8 +238,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
public ICPPFunctionType getType() {
try {
int offset= pdom.getDB().getInt(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCPPFunctionType(pdom, offset);
int offset= getDB().getInt(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCPPFunctionType(getLinkage(), offset);
} catch(CoreException ce) {
CCorePlugin.log(ce);
return null;
@ -287,7 +286,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
IFunctionType t = getType();
result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
try {
result.append(" " + getConstantNameForValue(getLinkageImpl(), getNodeType())); //$NON-NLS-1$
result.append(" " + getConstantNameForValue(getLinkage(), getNodeType())); //$NON-NLS-1$
} catch (CoreException e) {
result.append(" " + getNodeType()); //$NON-NLS-1$
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -22,9 +22,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -40,13 +40,13 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPFunctionSpecialization.RECORD_SIZE + 8;
public PDOMCPPFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding orig)
public PDOMCPPFunctionInstance(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, PDOMBinding orig)
throws CoreException {
super(pdom, parent, function, orig);
super(linkage, parent, function, orig);
final ICPPTemplateInstance asInstance= (ICPPTemplateInstance) function;
final int argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
final Database db = pdom.getDB();
final Database db = getDB();
db.putInt(record+ARGUMENTS, argListRec);
try {
@ -57,8 +57,8 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
}
}
public PDOMCPPFunctionInstance(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPFunctionInstance(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -118,7 +118,7 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
}
result.append("} ");
try {
result.append(getConstantNameForValue(getLinkageImpl(), getNodeType()));
result.append(getConstantNameForValue(getLinkage(), getNodeType()));
} catch (CoreException ce) {
result.append(getNodeType());
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -24,9 +24,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
@ -71,14 +71,14 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 17;
public PDOMCPPFunctionSpecialization(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding specialized) throws CoreException {
super(pdom, parent, (ICPPSpecialization) function, specialized);
public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPFunction function, PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPSpecialization) function, specialized);
Database db = pdom.getDB();
Database db = getDB();
try {
IFunctionType ft= function.getType();
if (ft != null) {
PDOMNode typeNode = getLinkageImpl().addType(this, ft);
PDOMNode typeNode = getLinkage().addType(this, ft);
if (typeNode != null) {
db.putInt(record + FUNCTION_TYPE, typeNode.getRecord());
}
@ -98,8 +98,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
int typeRecord= i<paramTypes.length && paramTypes[i]!=null ? ((PDOMNode)paramTypes[i]).getRecord() : 0;
//TODO shouldn't need to make new parameter (find old one)
final IType type= i<sParamTypes.length ? sParamTypes[i] : null;
PDOMCPPParameter sParam = new PDOMCPPParameter(pdom, this, sParams[i], type);
setFirstParameter(new PDOMCPPParameterSpecialization(pdom, this, (ICPPParameter) params[i], sParam, typeRecord));
PDOMCPPParameter sParam = new PDOMCPPParameter(getLinkage(), this, sParams[i], type);
setFirstParameter(new PDOMCPPParameterSpecialization(getLinkage(), this, (ICPPParameter) params[i], sParam, typeRecord));
}
db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(function));
} catch (DOMException e) {
@ -119,8 +119,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
public PDOMCPPFunctionSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -134,15 +134,15 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
public PDOMCPPParameterSpecialization getFirstParameter() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRST_PARAM);
return rec != 0 ? new PDOMCPPParameterSpecialization(pdom, rec) : null;
int rec = getDB().getInt(record + FIRST_PARAM);
return rec != 0 ? new PDOMCPPParameterSpecialization(getLinkage(), rec) : null;
}
public void setFirstParameter(PDOMCPPParameterSpecialization param) throws CoreException {
if (param != null)
param.setNextParameter(getFirstParameter());
int rec = param != null ? param.getRecord() : 0;
pdom.getDB().putInt(record + FIRST_PARAM, rec);
getDB().putInt(record + FIRST_PARAM, rec);
}
public boolean isInline() throws DOMException {
@ -159,7 +159,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
public IParameter[] getParameters() throws DOMException {
try {
int n = pdom.getDB().getInt(record + NUM_PARAMS);
int n = getDB().getInt(record + NUM_PARAMS);
IParameter[] params = new IParameter[n];
PDOMCPPParameterSpecialization param = getFirstParameter();
while (param != null) {
@ -175,8 +175,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
public ICPPFunctionType getType() throws DOMException {
try {
int offset= pdom.getDB().getInt(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCPPFunctionType(pdom, offset);
int offset= getDB().getInt(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCPPFunctionType(getLinkage(), offset);
} catch(CoreException ce) {
CCorePlugin.log(ce);
return null;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
@ -47,19 +46,19 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
private IPDOMCPPTemplateParameter[] params; // Cached template parameters.
public PDOMCPPFunctionTemplate(PDOM pdom, PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunctionTemplate template)
public PDOMCPPFunctionTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPFunctionTemplate template)
throws CoreException, DOMException {
super(pdom, parent, template, false);
super(linkage, parent, template, false);
final ICPPTemplateParameter[] origParams= template.getTemplateParameters();
params = PDOMTemplateParameterArray.createPDOMTemplateParameters(pdom, this, origParams);
final Database db = pdom.getDB();
params = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
final Database db = getDB();
int rec= PDOMTemplateParameterArray.putArray(db, params);
db.putInt(record + TEMPLATE_PARAMS, rec);
linkage.new ConfigureFunctionTemplate(template, this);
}
public PDOMCPPFunctionTemplate(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPFunctionTemplate(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -80,7 +79,7 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
public IPDOMCPPTemplateParameter[] getTemplateParameters() {
if (params == null) {
try {
int rec= pdom.getDB().getInt(record + TEMPLATE_PARAMS);
int rec= getDB().getInt(record + TEMPLATE_PARAMS);
if (rec == 0) {
params= IPDOMCPPTemplateParameter.EMPTY_ARRAY;
} else {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -18,9 +18,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -31,13 +31,13 @@ import org.eclipse.core.runtime.CoreException;
class PDOMCPPFunctionTemplateSpecialization extends PDOMCPPFunctionSpecialization
implements ICPPFunctionTemplate, ICPPInstanceCache, IPDOMMemberOwner {
public PDOMCPPFunctionTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPFunctionTemplate template, PDOMBinding specialized)
public PDOMCPPFunctionTemplateSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPFunctionTemplate template, PDOMBinding specialized)
throws CoreException {
super(pdom, parent, template, specialized);
super(linkage, parent, template, specialized);
}
public PDOMCPPFunctionTemplateSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPFunctionTemplateSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCFunctionType;
import org.eclipse.core.runtime.CoreException;
@ -66,27 +66,27 @@ public class PDOMCPPFunctionType extends PDOMCFunctionType implements ICPPFuncti
IPointerType thisType; // Cached value
protected PDOMCPPFunctionType(PDOM pdom, int offset) {
super(pdom, offset);
protected PDOMCPPFunctionType(PDOMLinkage linkage, int offset) {
super(linkage, offset);
}
protected PDOMCPPFunctionType(PDOM pdom, PDOMNode parent, ICPPFunctionType type)
protected PDOMCPPFunctionType(PDOMLinkage linkage, PDOMNode parent, ICPPFunctionType type)
throws CoreException {
super(pdom, parent, type);
super(linkage, parent, type);
setThisType(type.getThisType());
}
private void setThisType(IPointerType type) throws CoreException {
PDOMNode typeNode = getLinkageImpl().addType(this, type);
PDOMNode typeNode = getLinkage().addType(this, type);
if (typeNode != null) {
pdom.getDB().putInt(record + THIS_TYPE, typeNode.getRecord());
getDB().putInt(record + THIS_TYPE, typeNode.getRecord());
}
}
public IPointerType getThisType() {
if (thisType == null) {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + THIS_TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + THIS_TYPE));
if (node instanceof IPointerType) {
thisType = (IPointerType) node;
}

View file

@ -250,12 +250,12 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
int fileLocalRec[]= {0};
pdomBinding = adaptBinding(parent, binding, fileLocalRec);
if (pdomBinding != null) {
pdom.putCachedResult(inputBinding, pdomBinding);
getPDOM().putCachedResult(inputBinding, pdomBinding);
} else {
try {
pdomBinding = createBinding(parent, binding, fileLocalRec[0]);
if (pdomBinding != null) {
pdom.putCachedResult(inputBinding, pdomBinding);
getPDOM().putCachedResult(inputBinding, pdomBinding);
}
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
@ -311,58 +311,58 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
pdomBinding = createSpecialization(parent, pdomSpecialized, binding);
} else if (binding instanceof ICPPField) {
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) {
pdomBinding = new PDOMCPPField(pdom, parent, (ICPPField) binding);
pdomBinding = new PDOMCPPField(this, parent, (ICPPField) binding);
}
} else if (binding instanceof ICPPVariable) {
ICPPVariable var= (ICPPVariable) binding;
pdomBinding = new PDOMCPPVariable(pdom, parent, var);
pdomBinding = new PDOMCPPVariable(this, parent, var);
} else if (binding instanceof ICPPFunctionTemplate) {
if (binding instanceof ICPPConstructor) {
pdomBinding= new PDOMCPPConstructorTemplate(pdom, this, parent, (ICPPConstructor) binding);
pdomBinding= new PDOMCPPConstructorTemplate(this, parent, (ICPPConstructor) binding);
} else if (binding instanceof ICPPMethod) {
pdomBinding= new PDOMCPPMethodTemplate(pdom, this, parent, (ICPPMethod) binding);
pdomBinding= new PDOMCPPMethodTemplate(this, parent, (ICPPMethod) binding);
} else if (binding instanceof ICPPFunction) {
pdomBinding= new PDOMCPPFunctionTemplate(pdom, this, parent, (ICPPFunctionTemplate) binding);
pdomBinding= new PDOMCPPFunctionTemplate(this, parent, (ICPPFunctionTemplate) binding);
}
} else if (binding instanceof ICPPConstructor) {
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) {
pdomBinding = new PDOMCPPConstructor(pdom, parent, (ICPPConstructor)binding);
pdomBinding = new PDOMCPPConstructor(this, parent, (ICPPConstructor)binding);
}
} else if (binding instanceof ICPPMethod) {
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) {
pdomBinding = new PDOMCPPMethod(pdom, parent, (ICPPMethod)binding);
pdomBinding = new PDOMCPPMethod(this, parent, (ICPPMethod)binding);
}
} else if (binding instanceof ICPPFunction) {
pdomBinding = new PDOMCPPFunction(pdom, parent, (ICPPFunction) binding, true);
pdomBinding = new PDOMCPPFunction(this, parent, (ICPPFunction) binding, true);
} else if (binding instanceof ICPPClassTemplate) {
pdomBinding= new PDOMCPPClassTemplate(pdom, this, parent, (ICPPClassTemplate) binding);
pdomBinding= new PDOMCPPClassTemplate(this, parent, (ICPPClassTemplate) binding);
} else if (binding instanceof ICPPClassType) {
if (binding instanceof ICPPUnknownClassInstance) {
pdomBinding= new PDOMCPPUnknownClassInstance(pdom, parent, (ICPPUnknownClassInstance) binding);
pdomBinding= new PDOMCPPUnknownClassInstance(this, parent, (ICPPUnknownClassInstance) binding);
} else if (binding instanceof ICPPUnknownClassType) {
pdomBinding= new PDOMCPPUnknownClassType(pdom, parent, (ICPPUnknownClassType) binding);
pdomBinding= new PDOMCPPUnknownClassType(this, parent, (ICPPUnknownClassType) binding);
} else {
pdomBinding= new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding);
pdomBinding= new PDOMCPPClassType(this, parent, (ICPPClassType) binding);
}
} else if (binding instanceof ICPPNamespaceAlias) {
pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, (ICPPNamespaceAlias) binding);
pdomBinding = new PDOMCPPNamespaceAlias(this, parent, (ICPPNamespaceAlias) binding);
} else if (binding instanceof ICPPNamespace) {
pdomBinding = new PDOMCPPNamespace(pdom, parent, (ICPPNamespace) binding);
pdomBinding = new PDOMCPPNamespace(this, parent, (ICPPNamespace) binding);
} else if (binding instanceof ICPPUsingDeclaration) {
pdomBinding = new PDOMCPPUsingDeclaration(pdom, parent, (ICPPUsingDeclaration) binding);
pdomBinding = new PDOMCPPUsingDeclaration(this, parent, (ICPPUsingDeclaration) binding);
} else if (binding instanceof IEnumeration) {
pdomBinding = new PDOMCPPEnumeration(pdom, parent, (IEnumeration) binding);
pdomBinding = new PDOMCPPEnumeration(this, parent, (IEnumeration) binding);
} else if (binding instanceof IEnumerator) {
final IEnumerator etor = (IEnumerator) binding;
IType enumeration= etor.getType();
if (enumeration instanceof IEnumeration) {
PDOMBinding pdomEnumeration = adaptBinding((IEnumeration) enumeration);
if (pdomEnumeration instanceof PDOMCPPEnumeration) {
pdomBinding = new PDOMCPPEnumerator(pdom, parent, etor, (PDOMCPPEnumeration)pdomEnumeration);
pdomBinding = new PDOMCPPEnumerator(this, parent, etor, (PDOMCPPEnumeration)pdomEnumeration);
}
}
} else if (binding instanceof ITypedef) {
pdomBinding = new PDOMCPPTypedef(pdom, parent, (ITypedef)binding);
pdomBinding = new PDOMCPPTypedef(this, parent, (ITypedef)binding);
}
if (pdomBinding != null) {
@ -379,46 +379,45 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMBinding result= null;
if (special instanceof ICPPDeferredClassInstance) {
if (orig instanceof ICPPClassTemplate) {
result= new PDOMCPPDeferredClassInstance(pdom, parent, (ICPPDeferredClassInstance) special, orig);
result= new PDOMCPPDeferredClassInstance(this, parent, (ICPPDeferredClassInstance) special, orig);
}
} else if (special instanceof ICPPTemplateInstance) {
if (special instanceof ICPPConstructor && orig instanceof ICPPConstructor) {
result= new PDOMCPPConstructorInstance(pdom, parent, (ICPPConstructor) special, orig);
result= new PDOMCPPConstructorInstance(this, parent, (ICPPConstructor) special, orig);
} else if (special instanceof ICPPMethod && orig instanceof ICPPMethod) {
result= new PDOMCPPMethodInstance(pdom, parent, (ICPPMethod) special, orig);
result= new PDOMCPPMethodInstance(this, parent, (ICPPMethod) special, orig);
} else if (special instanceof ICPPFunction && orig instanceof ICPPFunction) {
result= new PDOMCPPFunctionInstance(pdom, parent, (ICPPFunction) special, orig);
result= new PDOMCPPFunctionInstance(this, parent, (ICPPFunction) special, orig);
} else if (special instanceof ICPPClassType && orig instanceof ICPPClassType) {
result= new PDOMCPPClassInstance(pdom, parent, (ICPPClassType) special, orig);
result= new PDOMCPPClassInstance(this, parent, (ICPPClassType) special, orig);
}
} else if (special instanceof ICPPClassTemplatePartialSpecialization) {
if (orig instanceof PDOMCPPClassTemplate) {
result= new PDOMCPPClassTemplatePartialSpecialization(
pdom, this, parent, (ICPPClassTemplatePartialSpecialization) special,
(PDOMCPPClassTemplate) orig);
this, parent, (ICPPClassTemplatePartialSpecialization) special, (PDOMCPPClassTemplate) orig);
}
} else if (special instanceof ICPPField) {
result= new PDOMCPPFieldSpecialization(pdom, parent, (ICPPField) special, orig);
result= new PDOMCPPFieldSpecialization(this, parent, (ICPPField) special, orig);
} else if (special instanceof ICPPFunctionTemplate) {
if (special instanceof ICPPConstructor) {
result= new PDOMCPPConstructorTemplateSpecialization( pdom, parent, (ICPPConstructor) special, orig);
result= new PDOMCPPConstructorTemplateSpecialization( this, parent, (ICPPConstructor) special, orig);
} else if (special instanceof ICPPMethod) {
result= new PDOMCPPMethodTemplateSpecialization( pdom, parent, (ICPPMethod) special, orig);
result= new PDOMCPPMethodTemplateSpecialization( this, parent, (ICPPMethod) special, orig);
} else if (special instanceof ICPPFunction) {
result= new PDOMCPPFunctionTemplateSpecialization( pdom, parent, (ICPPFunctionTemplate) special, orig);
result= new PDOMCPPFunctionTemplateSpecialization( this, parent, (ICPPFunctionTemplate) special, orig);
}
} else if (special instanceof ICPPConstructor) {
result= new PDOMCPPConstructorSpecialization(pdom, parent, (ICPPConstructor) special, orig);
result= new PDOMCPPConstructorSpecialization(this, parent, (ICPPConstructor) special, orig);
} else if (special instanceof ICPPMethod) {
result= new PDOMCPPMethodSpecialization(pdom, parent, (ICPPMethod) special, orig);
result= new PDOMCPPMethodSpecialization(this, parent, (ICPPMethod) special, orig);
} else if (special instanceof ICPPFunction) {
result= new PDOMCPPFunctionSpecialization(pdom, parent, (ICPPFunction) special, orig);
result= new PDOMCPPFunctionSpecialization(this, parent, (ICPPFunction) special, orig);
} else if (special instanceof ICPPClassTemplate) {
result= new PDOMCPPClassTemplateSpecialization(pdom, parent, (ICPPClassTemplate) special, orig);
result= new PDOMCPPClassTemplateSpecialization(this, parent, (ICPPClassTemplate) special, orig);
} else if (special instanceof ICPPClassType) {
result= new PDOMCPPClassSpecialization(pdom, parent, (ICPPClassType) special, orig);
result= new PDOMCPPClassSpecialization(this, parent, (ICPPClassType) special, orig);
} else if (special instanceof ITypedef) {
result= new PDOMCPPTypedefSpecialization(pdom, parent, (ITypedef) special, orig);
result= new PDOMCPPTypedefSpecialization(this, parent, (ITypedef) special, orig);
}
return result;
@ -572,7 +571,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
result= doAdaptBinding(parent, binding, fileLocalRecHolder);
if (result != null) {
pdom.putCachedResult(inputBinding, result);
getPDOM().putCachedResult(inputBinding, result);
}
return result;
}
@ -695,13 +694,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
} catch (DOMException e) {
}
return new PDOMGPPBasicType(pdom, parent, gbt);
return new PDOMGPPBasicType(this, parent, gbt);
}
if (type instanceof ICPPBasicType) {
return new PDOMCPPBasicType(pdom, parent, (ICPPBasicType) type);
return new PDOMCPPBasicType(this, parent, (ICPPBasicType) type);
}
if (type instanceof ICPPFunctionType) {
return new PDOMCPPFunctionType(pdom, parent, (ICPPFunctionType) type);
return new PDOMCPPFunctionType(this, parent, (ICPPFunctionType) type);
}
if (type instanceof ICPPClassType) {
return addBinding((ICPPClassType) type, null);
@ -713,10 +712,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return addBinding((ITypedef) type, null);
}
if (type instanceof ICPPReferenceType) {
return new PDOMCPPReferenceType(pdom, parent, (ICPPReferenceType) type);
return new PDOMCPPReferenceType(this, parent, (ICPPReferenceType) type);
}
if (type instanceof ICPPPointerToMemberType) {
return new PDOMCPPPointerToMemberType(pdom, parent, (ICPPPointerToMemberType) type);
return new PDOMCPPPointerToMemberType(this, parent, (ICPPPointerToMemberType) type);
}
if (type instanceof ICPPTemplateTypeParameter) {
return addBinding((ICPPTemplateTypeParameter) type, null);
@ -736,97 +735,97 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (record == 0)
return null;
switch (PDOMNode.getNodeType(pdom, record)) {
switch (PDOMNode.getNodeType(getDB(), record)) {
case CPPVARIABLE:
return new PDOMCPPVariable(pdom, record);
return new PDOMCPPVariable(this, record);
case CPPFUNCTION:
return new PDOMCPPFunction(pdom, record);
return new PDOMCPPFunction(this, record);
case CPPCLASSTYPE:
return new PDOMCPPClassType(pdom, record);
return new PDOMCPPClassType(this, record);
case CPPFIELD:
return new PDOMCPPField(pdom, record);
return new PDOMCPPField(this, record);
case CPP_CONSTRUCTOR:
return new PDOMCPPConstructor(pdom, record);
return new PDOMCPPConstructor(this, record);
case CPPMETHOD:
return new PDOMCPPMethod(pdom, record);
return new PDOMCPPMethod(this, record);
case CPPNAMESPACE:
return new PDOMCPPNamespace(pdom, record);
return new PDOMCPPNamespace(this, record);
case CPPNAMESPACEALIAS:
return new PDOMCPPNamespaceAlias(pdom, record);
return new PDOMCPPNamespaceAlias(this, record);
case CPP_USING_DECLARATION:
return new PDOMCPPUsingDeclaration(pdom, record);
return new PDOMCPPUsingDeclaration(this, record);
case GPPBASICTYPE:
return new PDOMGPPBasicType(pdom, record);
return new PDOMGPPBasicType(this, record);
case CPPBASICTYPE:
return new PDOMCPPBasicType(pdom, record);
return new PDOMCPPBasicType(this, record);
case CPPPARAMETER:
return new PDOMCPPParameter(pdom, record);
return new PDOMCPPParameter(this, record);
case CPPENUMERATION:
return new PDOMCPPEnumeration(pdom, record);
return new PDOMCPPEnumeration(this, record);
case CPPENUMERATOR:
return new PDOMCPPEnumerator(pdom, record);
return new PDOMCPPEnumerator(this, record);
case CPPTYPEDEF:
return new PDOMCPPTypedef(pdom, record);
return new PDOMCPPTypedef(this, record);
case CPP_POINTER_TO_MEMBER_TYPE:
return new PDOMCPPPointerToMemberType(pdom, record);
return new PDOMCPPPointerToMemberType(this, record);
case CPP_REFERENCE_TYPE:
return new PDOMCPPReferenceType(pdom, record);
return new PDOMCPPReferenceType(this, record);
case CPP_FUNCTION_TEMPLATE:
return new PDOMCPPFunctionTemplate(pdom, record);
return new PDOMCPPFunctionTemplate(this, record);
case CPP_METHOD_TEMPLATE:
return new PDOMCPPMethodTemplate(pdom, record);
return new PDOMCPPMethodTemplate(this, record);
case CPP_CONSTRUCTOR_TEMPLATE:
return new PDOMCPPConstructorTemplate(pdom, record);
return new PDOMCPPConstructorTemplate(this, record);
case CPP_CLASS_TEMPLATE:
return new PDOMCPPClassTemplate(pdom, record);
return new PDOMCPPClassTemplate(this, record);
case CPP_CLASS_TEMPLATE_PARTIAL_SPEC:
return new PDOMCPPClassTemplatePartialSpecialization(pdom, record);
return new PDOMCPPClassTemplatePartialSpecialization(this, record);
case CPP_CLASS_TEMPLATE_PARTIAL_SPEC_SPEC:
return new PDOMCPPClassTemplatePartialSpecializationSpecialization(pdom, record);
return new PDOMCPPClassTemplatePartialSpecializationSpecialization(this, record);
case CPP_FUNCTION_INSTANCE:
return new PDOMCPPFunctionInstance(pdom, record);
return new PDOMCPPFunctionInstance(this, record);
case CPP_METHOD_INSTANCE:
return new PDOMCPPMethodInstance(pdom, record);
return new PDOMCPPMethodInstance(this, record);
case CPP_CONSTRUCTOR_INSTANCE:
return new PDOMCPPConstructorInstance(pdom, record);
return new PDOMCPPConstructorInstance(this, record);
case CPP_CLASS_INSTANCE:
return new PDOMCPPClassInstance(pdom, record);
return new PDOMCPPClassInstance(this, record);
case CPP_DEFERRED_CLASS_INSTANCE:
return new PDOMCPPDeferredClassInstance(pdom, record);
return new PDOMCPPDeferredClassInstance(this, record);
case CPP_UNKNOWN_CLASS_TYPE:
return new PDOMCPPUnknownClassType(pdom, record);
return new PDOMCPPUnknownClassType(this, record);
case CPP_UNKNOWN_CLASS_INSTANCE:
return new PDOMCPPUnknownClassInstance(pdom, record);
return new PDOMCPPUnknownClassInstance(this, record);
case CPP_TEMPLATE_TYPE_PARAMETER:
return new PDOMCPPTemplateTypeParameter(pdom, record);
return new PDOMCPPTemplateTypeParameter(this, record);
case CPP_TEMPLATE_TEMPLATE_PARAMETER:
return new PDOMCPPTemplateTemplateParameter(pdom, record);
return new PDOMCPPTemplateTemplateParameter(this, record);
case CPP_TEMPLATE_NON_TYPE_PARAMETER:
return new PDOMCPPTemplateNonTypeParameter(pdom, record);
return new PDOMCPPTemplateNonTypeParameter(this, record);
case CPP_FIELD_SPECIALIZATION:
return new PDOMCPPFieldSpecialization(pdom, record);
return new PDOMCPPFieldSpecialization(this, record);
case CPP_FUNCTION_SPECIALIZATION:
return new PDOMCPPFunctionSpecialization(pdom, record);
return new PDOMCPPFunctionSpecialization(this, record);
case CPP_METHOD_SPECIALIZATION:
return new PDOMCPPMethodSpecialization(pdom, record);
return new PDOMCPPMethodSpecialization(this, record);
case CPP_CONSTRUCTOR_SPECIALIZATION:
return new PDOMCPPConstructorSpecialization(pdom, record);
return new PDOMCPPConstructorSpecialization(this, record);
case CPP_CLASS_SPECIALIZATION:
return new PDOMCPPClassSpecialization(pdom, record);
return new PDOMCPPClassSpecialization(this, record);
case CPP_FUNCTION_TEMPLATE_SPECIALIZATION:
return new PDOMCPPFunctionTemplateSpecialization(pdom, record);
return new PDOMCPPFunctionTemplateSpecialization(this, record);
case CPP_METHOD_TEMPLATE_SPECIALIZATION:
return new PDOMCPPMethodTemplateSpecialization(pdom, record);
return new PDOMCPPMethodTemplateSpecialization(this, record);
case CPP_CONSTRUCTOR_TEMPLATE_SPECIALIZATION:
return new PDOMCPPConstructorTemplateSpecialization(pdom, record);
return new PDOMCPPConstructorTemplateSpecialization(this, record);
case CPP_CLASS_TEMPLATE_SPECIALIZATION:
return new PDOMCPPClassTemplateSpecialization(pdom, record);
return new PDOMCPPClassTemplateSpecialization(this, record);
case CPP_TYPEDEF_SPECIALIZATION:
return new PDOMCPPTypedefSpecialization(pdom, record);
return new PDOMCPPTypedefSpecialization(this, record);
case CPP_FUNCTION_TYPE:
return new PDOMCPPFunctionType(pdom, record);
return new PDOMCPPFunctionType(this, record);
case CPP_PARAMETER_SPECIALIZATION:
return new PDOMCPPParameterSpecialization(pdom, record);
return new PDOMCPPParameterSpecialization(this, record);
default:
return super.getNode(record);
}
@ -834,7 +833,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
@Override
public IBTreeComparator getIndexComparator() {
return new CPPFindBinding.CPPBindingBTreeComparator(pdom);
return new CPPFindBinding.CPPBindingBTreeComparator(this);
}
@Override
@ -854,13 +853,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMBinding derivedClassBinding= derivedClassName.getBinding();
if (derivedClassBinding instanceof PDOMCPPClassType) {
PDOMCPPClassType ownerClass = (PDOMCPPClassType) derivedClassBinding;
PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(),
PDOMCPPBase pdomBase = new PDOMCPPBase(this, pdomName, baseNode.isVirtual(),
baseNode.getVisibility());
ownerClass.addBase(pdomBase);
pdomName.setIsBaseSpecifier(true);
} else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) {
PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization) derivedClassBinding;
PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(),
PDOMCPPBase pdomBase = new PDOMCPPBase(this, pdomName, baseNode.isVirtual(),
baseNode.getVisibility());
ownerClass.addBase(pdomBase);
pdomName.setIsBaseSpecifier(true);
@ -903,7 +902,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMName enclClassName= (PDOMName) pdomName.getEnclosingDefinition();
PDOMBinding enclClassBinding= enclClassName.getBinding();
if (enclClassBinding instanceof PDOMCPPClassType) {
((PDOMCPPClassType)enclClassBinding).addFriend(new PDOMCPPFriend(pdom, pdomName));
((PDOMCPPClassType)enclClassBinding).addFriend(new PDOMCPPFriend(this, pdomName));
}
}
} else if (parentNode instanceof ICPPASTFunctionDeclarator) {
@ -915,7 +914,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
PDOMName enclClassName= (PDOMName) pdomName.getEnclosingDefinition();
PDOMBinding enclClassBinding= enclClassName.getBinding();
if (enclClassBinding instanceof PDOMCPPClassType) {
((PDOMCPPClassType)enclClassBinding).addFriend(new PDOMCPPFriend(pdom, pdomName));
((PDOMCPPClassType)enclClassBinding).addFriend(new PDOMCPPFriend(this, pdomName));
}
}
}
@ -971,6 +970,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
@Override
protected PDOMFile getLocalToFile(IBinding binding, PDOMBinding glob) throws CoreException {
PDOM pdom = getPDOM();
if (pdom instanceof WritablePDOM) {
final WritablePDOM wpdom= (WritablePDOM) pdom;
PDOMFile file= null;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -28,7 +28,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
@ -60,10 +59,10 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
*/
private static final int CV_OFFSET = PDOMCPPAnnotation.MAX_EXTRA_OFFSET + 1;
public PDOMCPPMethod(PDOM pdom, PDOMNode parent, ICPPMethod method) throws CoreException, DOMException {
super(pdom, parent, method, true);
public PDOMCPPMethod(PDOMLinkage linkage, PDOMNode parent, ICPPMethod method) throws CoreException, DOMException {
super(linkage, parent, method, true);
Database db = pdom.getDB();
Database db = getDB();
try {
byte annotation= PDOMCPPAnnotation.encodeExtraAnnotation(method);
@ -73,8 +72,8 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
}
public PDOMCPPMethod(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPMethod(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -83,7 +82,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
ICPPMethod method= (ICPPMethod) newBinding;
super.update(linkage, newBinding);
try {
pdom.getDB().putByte(record + ANNOTATION1, PDOMCPPAnnotation.encodeExtraAnnotation(method));
getDB().putByte(record + ANNOTATION1, PDOMCPPAnnotation.encodeExtraAnnotation(method));
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -15,8 +15,8 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -32,13 +32,13 @@ class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements ICPPMetho
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPFunctionInstance.RECORD_SIZE + 0;
public PDOMCPPMethodInstance(PDOM pdom, PDOMNode parent, ICPPMethod method, PDOMBinding instantiated)
public PDOMCPPMethodInstance(PDOMLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding instantiated)
throws CoreException {
super(pdom, parent, method, instantiated);
super(linkage, parent, method, instantiated);
}
public PDOMCPPMethodInstance(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPMethodInstance(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -19,9 +19,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
@ -50,9 +50,9 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
*/
private static final int CV_OFFSET = PDOMCPPAnnotation.MAX_EXTRA_OFFSET + 1;
public PDOMCPPMethodSpecialization(PDOM pdom, PDOMNode parent, ICPPMethod method, PDOMBinding specialized) throws CoreException {
super(pdom, parent, method, specialized);
Database db = pdom.getDB();
public PDOMCPPMethodSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding specialized) throws CoreException {
super(linkage, parent, method, specialized);
Database db = getDB();
try {
ICPPFunctionType type = method.getType();
@ -65,8 +65,8 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
}
}
public PDOMCPPMethodSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPMethodSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
import org.eclipse.core.runtime.CoreException;
@ -47,11 +47,11 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
*/
private static final int CV_OFFSET = PDOMCPPAnnotation.MAX_EXTRA_OFFSET + 1;
public PDOMCPPMethodTemplate(PDOM pdom, PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method)
public PDOMCPPMethodTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method)
throws CoreException, DOMException {
super(pdom, linkage, parent, (ICPPFunctionTemplate) method);
super(linkage, parent, (ICPPFunctionTemplate) method);
Database db = pdom.getDB();
Database db = getDB();
try {
ICPPFunctionType type = method.getType();
@ -64,8 +64,8 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
}
}
public PDOMCPPMethodTemplate(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPMethodTemplate(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -17,8 +17,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -29,13 +29,13 @@ import org.eclipse.core.runtime.CoreException;
class PDOMCPPMethodTemplateSpecialization extends
PDOMCPPFunctionTemplateSpecialization implements ICPPMethod {
public PDOMCPPMethodTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPMethod method, PDOMBinding specialized)
public PDOMCPPMethodTemplateSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding specialized)
throws CoreException {
super(pdom, parent, (ICPPFunctionTemplate) method, specialized);
super(linkage, parent, (ICPPFunctionTemplate) method, specialized);
}
public PDOMCPPMethodTemplateSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPMethodTemplateSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -39,6 +39,7 @@ import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -53,12 +54,12 @@ class PDOMCPPNamespace extends PDOMCPPBinding
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCPPNamespace(PDOM pdom, PDOMNode parent, ICPPNamespace namespace) throws CoreException {
super(pdom, parent, namespace.getNameCharArray());
public PDOMCPPNamespace(PDOMLinkage linkage, PDOMNode parent, ICPPNamespace namespace) throws CoreException {
super(linkage, parent, namespace.getNameCharArray());
}
public PDOMCPPNamespace(PDOM pdom, int record) throws CoreException {
super(pdom, record);
public PDOMCPPNamespace(PDOMLinkage linkage, int record) throws CoreException {
super(linkage, record);
}
public EScopeKind getKind() {
@ -76,7 +77,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
}
public BTree getIndex() throws CoreException {
return new BTree(pdom.getDB(), record + INDEX_OFFSET, getLinkageImpl().getIndexComparator());
return new BTree(getDB(), record + INDEX_OFFSET, getLinkage().getIndexComparator());
}
@Override
@ -89,7 +90,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
return 0;
}
public boolean visit(int record) throws CoreException {
PDOMBinding binding = pdom.getBinding(record);
PDOMBinding binding = getLinkage().getBinding(record);
if (binding != null) {
if (visitor.visit(binding))
binding.accept(visitor);
@ -116,7 +117,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
public IBinding[] find(String name) {
try {
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(),
BindingCollector visitor = new BindingCollector(getLinkage(), name.toCharArray(),
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, false, true);
getIndex().accept(visitor);
return visitor.getBindings();
@ -148,7 +149,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
if (!prefixLookup) {
return getBindingsViaCache(name.getLookupKey());
}
BindingCollector visitor= new BindingCollector(getLinkageImpl(), name.getLookupKey(),
BindingCollector visitor= new BindingCollector(getLinkage(), name.getLookupKey(),
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, prefixLookup, !prefixLookup);
getIndex().accept(visitor);
IBinding[] bindings = visitor.getBindings();
@ -163,12 +164,13 @@ class PDOMCPPNamespace extends PDOMCPPBinding
}
private IBinding[] getBindingsViaCache(final char[] name) throws CoreException {
final PDOM pdom = getPDOM();
final String key= pdom.createKeyForCache(record, name);
IBinding[] result= (IBinding[]) pdom.getCachedResult(key);
if (result != null) {
return result;
}
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name,
BindingCollector visitor = new BindingCollector(getLinkage(), name,
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, false, true);
getIndex().accept(visitor);
result = visitor.getBindings();
@ -190,7 +192,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
return 0;
}
public boolean visit(int record) throws CoreException {
preresult.add(getLinkageImpl().getNode(record));
preresult.add(getLinkage().getNode(record));
return true;
}
});

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -18,7 +18,6 @@ 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.ICPPNamespaceScope;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -35,14 +34,14 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 4;
public PDOMCPPNamespaceAlias(PDOM pdom, PDOMNode parent, ICPPNamespaceAlias alias)
public PDOMCPPNamespaceAlias(PDOMLinkage linkage, PDOMNode parent, ICPPNamespaceAlias alias)
throws CoreException {
super(pdom, parent, alias.getNameCharArray());
setTargetBinding(parent.getLinkageImpl(), alias.getBinding());
super(linkage, parent, alias.getNameCharArray());
setTargetBinding(parent.getLinkage(), alias.getBinding());
}
public PDOMCPPNamespaceAlias(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPNamespaceAlias(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -59,8 +58,8 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias
}
private void setTargetBinding(PDOMLinkage linkage, IBinding target) throws CoreException {
PDOMBinding namespace = getLinkageImpl().adaptBinding(target);
pdom.getDB().putInt(record + NAMESPACE_BINDING,
PDOMBinding namespace = getLinkage().adaptBinding(target);
getDB().putInt(record + NAMESPACE_BINDING,
namespace != null ? namespace.getRecord() : 0);
}
@ -99,7 +98,7 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias
public IBinding getBinding() {
try {
return (IBinding) getLinkageImpl().getNode(getPDOM().getDB().getInt(record + NAMESPACE_BINDING));
return (IBinding) getLinkage().getNode(getPDOM().getDB().getInt(record + NAMESPACE_BINDING));
} catch(CoreException ce) {
CCorePlugin.log(ce);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -23,7 +23,6 @@ import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
@ -74,15 +73,15 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
private static final byte FLAG_DEFAULT_VALUE = 0x1;
public PDOMCPPParameter(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPParameter(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCPPParameter(PDOM pdom, PDOMNode parent, IParameter param, IType type)
public PDOMCPPParameter(PDOMLinkage linkage, PDOMNode parent, IParameter param, IType type)
throws CoreException {
super(pdom, parent, param.getNameCharArray());
super(linkage, parent, param.getNameCharArray());
Database db = pdom.getDB();
Database db = getDB();
db.putInt(record + NEXT_PARAM, 0);
byte flags= encodeFlags(param);
@ -92,7 +91,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
if (type == null)
type= param.getType();
if (type != null) {
PDOMNode typeNode = getLinkageImpl().addType(this, type);
PDOMNode typeNode = getLinkage().addType(this, type);
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
byte annotations = PDOMCPPAnnotation.encodeAnnotation(param);
@ -102,11 +101,11 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
}
}
public PDOMCPPParameter(PDOM pdom, PDOMNode parent, IParameter param, int typeRecord)
public PDOMCPPParameter(PDOMLinkage linkage, PDOMNode parent, IParameter param, int typeRecord)
throws CoreException {
super(pdom, parent, param.getNameCharArray());
super(linkage, parent, param.getNameCharArray());
Database db = pdom.getDB();
Database db = getDB();
db.putInt(record + NEXT_PARAM, 0);
byte flags= encodeFlags(param);
@ -144,12 +143,12 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
public void setNextParameter(PDOMCPPParameter nextParam) throws CoreException {
int rec = nextParam != null ? nextParam.getRecord() : 0;
pdom.getDB().putInt(record + NEXT_PARAM, rec);
getDB().putInt(record + NEXT_PARAM, rec);
}
public PDOMCPPParameter getNextParameter() throws CoreException {
int rec = pdom.getDB().getInt(record + NEXT_PARAM);
return rec != 0 ? new PDOMCPPParameter(pdom, rec) : null;
int rec = getDB().getInt(record + NEXT_PARAM);
return rec != 0 ? new PDOMCPPParameter(getLinkage(), rec) : null;
}
public String[] getQualifiedName() {
@ -171,7 +170,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
public IType getType() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);
@ -234,7 +233,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
private boolean hasFlag(byte flag, boolean defValue, int offset) {
try {
byte myflags= pdom.getDB().getByte(record + offset);
byte myflags= getDB().getByte(record + offset);
return (myflags & flag) == flag;
} catch (CoreException e) {
CCorePlugin.log(e);
@ -243,7 +242,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
}
public IIndexFragment getFragment() {
return pdom;
return getPDOM();
}
public boolean hasDefinition() throws CoreException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -46,19 +46,19 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 8;
public PDOMCPPParameterSpecialization(PDOM pdom, PDOMNode parent, ICPPParameter param, PDOMCPPParameter specialized, int typeRecord)
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPParameter param, PDOMCPPParameter specialized, int typeRecord)
throws CoreException {
super(pdom, parent, (ICPPSpecialization) param, specialized);
Database db = pdom.getDB();
super(linkage, parent, (ICPPSpecialization) param, specialized);
Database db = getDB();
db.putInt(record + NEXT_PARAM, 0);
db.putInt(record + TYPE, typeRecord);
}
public PDOMCPPParameterSpecialization(PDOM pdom, PDOMNode parent, ICPPParameter param, PDOMCPPParameter specialized, IType type)
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPParameter param, PDOMCPPParameter specialized, IType type)
throws CoreException {
super(pdom, parent, (ICPPSpecialization) param, specialized);
super(linkage, parent, (ICPPSpecialization) param, specialized);
Database db = pdom.getDB();
Database db = getDB();
db.putInt(record + NEXT_PARAM, 0);
@ -66,7 +66,7 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
if (type == null)
type= param.getType();
if (type != null) {
PDOMNode typeNode = getLinkageImpl().addType(this, type);
PDOMNode typeNode = getLinkage().addType(this, type);
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
} catch (DOMException e) {
@ -74,8 +74,8 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
}
}
public PDOMCPPParameterSpecialization(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPParameterSpecialization(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -90,17 +90,17 @@ class PDOMCPPParameterSpecialization extends PDOMCPPSpecialization implements IC
public void setNextParameter(PDOMCPPParameterSpecialization nextParam) throws CoreException {
int rec = nextParam != null ? nextParam.getRecord() : 0;
pdom.getDB().putInt(record + NEXT_PARAM, rec);
getDB().putInt(record + NEXT_PARAM, rec);
}
public PDOMCPPParameterSpecialization getNextParameter() throws CoreException {
int rec = pdom.getDB().getInt(record + NEXT_PARAM);
return rec != 0 ? new PDOMCPPParameterSpecialization(pdom, rec) : null;
int rec = getDB().getInt(record + NEXT_PARAM);
return rec != 0 ? new PDOMCPPParameterSpecialization(getLinkage(), rec) : null;
}
public IType getType() throws DOMException {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.PointerTypeClone;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -30,19 +29,19 @@ class PDOMCPPPointerToMemberType extends PDOMPointerType implements ICPPPointerT
@SuppressWarnings("hiding")
private static final int RECORD_SIZE= TYPE + 4;
public PDOMCPPPointerToMemberType(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPPointerToMemberType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCPPPointerToMemberType(PDOM pdom, PDOMNode parent, ICPPPointerToMemberType type) throws CoreException {
super(pdom, parent, type);
Database db = pdom.getDB();
public PDOMCPPPointerToMemberType(PDOMLinkage linkage, PDOMNode parent, ICPPPointerToMemberType type) throws CoreException {
super(linkage, parent, type);
Database db = getDB();
// type
IType ct = type.getMemberOfClass();
int typeRec = 0;
if (ct != null) {
PDOMNode targetTypeNode = getLinkageImpl().addType(this, ct);
PDOMNode targetTypeNode = getLinkage().addType(this, ct);
if (targetTypeNode != null)
typeRec = targetTypeNode.getRecord();
}
@ -61,7 +60,7 @@ class PDOMCPPPointerToMemberType extends PDOMPointerType implements ICPPPointerT
public IType getMemberOfClass() {
try {
int rec = pdom.getDB().getInt(record + TYPE);
int rec = getDB().getInt(record + TYPE);
return (IType) getLinkage().getNode(rec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2009 Wind River Systems, Inc. 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
@ -23,7 +23,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.CPPReferenceTypeClone;
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.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -37,21 +36,21 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType, ITypeC
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 4;
public PDOMCPPReferenceType(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPReferenceType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMCPPReferenceType(PDOM pdom, PDOMNode parent, ICPPReferenceType type) throws CoreException {
super(pdom, parent);
public PDOMCPPReferenceType(PDOMLinkage linkage, PDOMNode parent, ICPPReferenceType type) throws CoreException {
super(linkage, parent);
Database db = pdom.getDB();
Database db = getDB();
try {
// type
int typeRec = 0;
if (type != null) {
IType targetType = type.getType();
PDOMNode targetTypeNode = getLinkageImpl().addType(this, targetType);
PDOMNode targetTypeNode = getLinkage().addType(this, targetType);
if (targetTypeNode != null)
typeRec = targetTypeNode.getRecord();
}
@ -73,7 +72,7 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType, ITypeC
public IType getType() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 QNX Software Systems and others.
* Copyright (c) 2008, 2009 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
@ -21,9 +21,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -44,32 +44,32 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements ICPPSpeci
private IBinding fSpecializedCache= null;
private ICPPTemplateParameterMap fArgMap;
public PDOMCPPSpecialization(PDOM pdom, PDOMNode parent, ICPPSpecialization spec, IPDOMBinding specialized)
public PDOMCPPSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPSpecialization spec, IPDOMBinding specialized)
throws CoreException {
super(pdom, parent, spec.getNameCharArray());
pdom.getDB().putInt(record + SPECIALIZED, specialized.getRecord());
super(linkage, parent, spec.getNameCharArray());
getDB().putInt(record + SPECIALIZED, specialized.getRecord());
// specializations that are not instances have the same map as their owner.
if (this instanceof ICPPTemplateInstance) {
int rec= PDOMCPPTemplateParameterMap.putMap(this, spec.getTemplateParameterMap());
pdom.getDB().putInt(record + ARGMAP, rec);
getDB().putInt(record + ARGMAP, rec);
}
try {
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(spec);
pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
} catch (DOMException e) {
}
}
public PDOMCPPSpecialization(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPSpecialization(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
public IBinding getSpecializedBinding() {
if (fSpecializedCache == null) {
try {
int specializedRec = pdom.getDB().getInt(record + SPECIALIZED);
fSpecializedCache= (IPDOMBinding) getLinkageImpl().getNode(specializedRec);
int specializedRec = getDB().getInt(record + SPECIALIZED);
fSpecializedCache= (IPDOMBinding) getLinkage().getNode(specializedRec);
} catch (CoreException e) {
CCorePlugin.log(e);
}
@ -86,7 +86,7 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements ICPPSpeci
if (fArgMap == null) {
try {
if (this instanceof ICPPTemplateInstance) {
fArgMap= PDOMCPPTemplateParameterMap.getMap(this, getInt(record + ARGMAP));
fArgMap= PDOMCPPTemplateParameterMap.getMap(this, getDB().getInt(record + ARGMAP));
} else {
// specializations that are no instances have the same argmap as their owner.
IBinding owner= getOwner();
@ -102,7 +102,7 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements ICPPSpeci
}
public int getSignatureHash() throws CoreException {
return pdom.getDB().getInt(record + SIGNATURE_HASH);
return getDB().getInt(record + SIGNATURE_HASH);
}
/*
@ -116,7 +116,7 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements ICPPSpeci
result.append(getArgumentMap().toString());
result.append(' ');
try {
result.append(getConstantNameForValue(getLinkageImpl(), getNodeType()));
result.append(getConstantNameForValue(getLinkage(), getNodeType()));
} catch (CoreException ce) {
result.append(getNodeType());
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
@ -51,15 +50,15 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPVariable.RECORD_SIZE + 12;
public PDOMCPPTemplateNonTypeParameter(PDOM pdom, PDOMNode parent,
public PDOMCPPTemplateNonTypeParameter(PDOMLinkage linkage, PDOMNode parent,
ICPPTemplateNonTypeParameter param) throws CoreException {
super(pdom, parent, param.getNameCharArray());
final Database db = pdom.getDB();
super(linkage, parent, param.getNameCharArray());
final Database db = getDB();
db.putInt(record + PARAMETERID, param.getParameterID());
}
public PDOMCPPTemplateNonTypeParameter(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPTemplateNonTypeParameter(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -74,7 +73,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
public ICPPTemplateArgument getDefaultValue() {
try {
final Database db = pdom.getDB();
final Database db = getDB();
int rec= db.getInt(record + DEFAULTVAL);
IValue val= PDOMValue.restore(db, getLinkage(), rec);
if (val == null)
@ -91,7 +90,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
if (newBinding instanceof ICPPTemplateNonTypeParameter) {
ICPPTemplateNonTypeParameter ntp= (ICPPTemplateNonTypeParameter) newBinding;
updateName(newBinding.getNameCharArray());
final Database db = pdom.getDB();
final Database db = getDB();
IType mytype= getType();
int valueRec= db.getInt(record + DEFAULTVAL);
try {
@ -114,7 +113,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
if (type instanceof PDOMNode) {
((PDOMNode) type).delete(linkage);
}
Database db= pdom.getDB();
Database db= getDB();
int valueRec= db.getInt(record + DEFAULTVAL);
PDOMValue.delete(db, valueRec);
}
@ -137,7 +136,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
private void readParamID() {
if (fCachedParamID == -1) {
try {
final Database db = pdom.getDB();
final Database db = getDB();
fCachedParamID= db.getInt(record + PARAMETERID);
} catch (CoreException e) {
CCorePlugin.log(e);
@ -148,7 +147,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
private void setType(final PDOMLinkage linkage, IType newType) throws CoreException, DOMException {
PDOMNode typeNode = linkage.addType(this, newType);
pdom.getDB().putInt(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
getDB().putInt(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
}
public void configure(ICPPTemplateParameter param) {
@ -156,7 +155,7 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
if (param instanceof ICPPTemplateNonTypeParameter) {
ICPPTemplateNonTypeParameter nonTypeParm= (ICPPTemplateNonTypeParameter) param;
setType(getLinkage(), nonTypeParm.getType());
final Database db= pdom.getDB();
final Database db= getDB();
setDefaultValue(db, nonTypeParm);
}
} catch (CoreException e) {
@ -181,8 +180,8 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPBinding implements IPDOMMem
public IType getType() {
try {
int typeRec = pdom.getDB().getInt(record + TYPE_OFFSET);
return (IType)getLinkageImpl().getNode(typeRec);
int typeRec = getDB().getInt(record + TYPE_OFFSET);
return (IType)getLinkage().getNode(typeRec);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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
@ -34,7 +34,7 @@ public class PDOMCPPTemplateParameterMap {
*/
public static int putMap(PDOMNode parent, ICPPTemplateParameterMap map) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
Integer[] keys= map.getAllParameterPositions();
final short len= (short) Math.min(keys.length, (Database.MAX_MALLOC_SIZE-2)/12);
final int block= db.malloc(2+12*len);
@ -68,7 +68,7 @@ public class PDOMCPPTemplateParameterMap {
*/
public static void clearMap(PDOMNode parent, int rec) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len= db.getShort(rec);
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/12);
@ -92,7 +92,7 @@ public class PDOMCPPTemplateParameterMap {
*/
public static CPPTemplateParameterMap getMap(PDOMNode parent, int rec) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len= db.getShort(rec);
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/12);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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
@ -37,7 +37,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
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.Database;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
@ -66,20 +65,20 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
private int fCachedParamID= -1;
private IPDOMCPPTemplateParameter[] params;
public PDOMCPPTemplateTemplateParameter(PDOM pdom, PDOMNode parent, ICPPTemplateTemplateParameter param)
public PDOMCPPTemplateTemplateParameter(PDOMLinkage linkage, PDOMNode parent, ICPPTemplateTemplateParameter param)
throws CoreException, DOMException {
super(pdom, parent, param.getNameCharArray());
super(linkage, parent, param.getNameCharArray());
final Database db = pdom.getDB();
final Database db = getDB();
db.putInt(record + PARAMETERID, param.getParameterID());
final ICPPTemplateParameter[] origParams= param.getTemplateParameters();
final IPDOMCPPTemplateParameter[] params = PDOMTemplateParameterArray.createPDOMTemplateParameters(pdom, this, origParams);
final IPDOMCPPTemplateParameter[] params = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
int rec= PDOMTemplateParameterArray.putArray(db, params);
pdom.getDB().putInt(record + PARAMETERS, rec);
getDB().putInt(record + PARAMETERS, rec);
}
public PDOMCPPTemplateTemplateParameter(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPTemplateTemplateParameter(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -110,7 +109,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
private void readParamID() {
if (fCachedParamID == -1) {
try {
final Database db = pdom.getDB();
final Database db = getDB();
fCachedParamID= db.getInt(record + PARAMETERID);
} catch (CoreException e) {
CCorePlugin.log(e);
@ -121,13 +120,13 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
@Override
public void addChild(PDOMNode member) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.addMember(member);
}
@Override
public void accept(IPDOMVisitor visitor) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.accept(visitor);
}
@ -144,7 +143,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
public IType getDefault() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + DEFAULT_TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + DEFAULT_TYPE));
if (node instanceof IType) {
return (IType) node;
}
@ -184,7 +183,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
IType dflt= val.getTypeValue();
if (dflt != null) {
final Database db= getPDOM().getDB();
PDOMNode typeNode = getLinkageImpl().addType(this, dflt);
PDOMNode typeNode = getLinkage().addType(this, dflt);
if (typeNode != null) {
db.putInt(record + DEFAULT_TYPE, typeNode.getRecord());
}
@ -198,7 +197,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof ICPPTemplateTemplateParameter) {
final Database db = pdom.getDB();
final Database db = getDB();
ICPPTemplateTemplateParameter ttp= (ICPPTemplateTemplateParameter) newBinding;
updateName(newBinding.getNameCharArray());
IType newDefault= null;
@ -209,7 +208,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
}
if (newDefault != null) {
IType mytype= getDefault();
PDOMNode typeNode = getLinkageImpl().addType(this, newDefault);
PDOMNode typeNode = getLinkage().addType(this, newDefault);
if (typeNode != null) {
db.putInt(record + DEFAULT_TYPE, typeNode.getRecord());
if (mytype != null)
@ -219,7 +218,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
int oldRec= db.getInt(record + PARAMETERS);
IPDOMCPPTemplateParameter[] oldParams= getTemplateParameters();
try {
params= PDOMTemplateParameterArray.createPDOMTemplateParameters(pdom, this, ttp.getTemplateParameters());
params= PDOMTemplateParameterArray.createPDOMTemplateParameters(getLinkage(), this, ttp.getTemplateParameters());
int newRec= PDOMTemplateParameterArray.putArray(db, params);
db.putInt(record + PARAMETERS, newRec);
if (oldRec != 0)
@ -238,7 +237,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
if (type instanceof PDOMNode) {
((PDOMNode) type).delete(linkage);
}
Database db= pdom.getDB();
Database db= getDB();
int valueRec= db.getInt(record + DEFAULT_TYPE);
if (valueRec != 0)
db.getString(valueRec).delete();
@ -255,7 +254,7 @@ public class PDOMCPPTemplateTemplateParameter extends PDOMCPPBinding
public IPDOMCPPTemplateParameter[] getTemplateParameters() {
if (params == null) {
try {
int rec= pdom.getDB().getInt(record + PARAMETERS);
int rec= getDB().getInt(record + PARAMETERS);
if (rec == 0) {
params= IPDOMCPPTemplateParameter.EMPTY_ARRAY;
} else {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -29,7 +29,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
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.Database;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
@ -57,16 +56,16 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
private ICPPScope fUnknownScope;
private int fCachedParamID= -1;
public PDOMCPPTemplateTypeParameter(PDOM pdom, PDOMNode parent, ICPPTemplateTypeParameter param)
public PDOMCPPTemplateTypeParameter(PDOMLinkage linkage, PDOMNode parent, ICPPTemplateTypeParameter param)
throws CoreException {
super(pdom, parent, param.getNameCharArray());
super(linkage, parent, param.getNameCharArray());
final Database db = pdom.getDB();
final Database db = getDB();
db.putInt(record + PARAMETERID, param.getParameterID());
}
public PDOMCPPTemplateTypeParameter(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPTemplateTypeParameter(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override
@ -97,7 +96,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
private void readParamID() {
if (fCachedParamID == -1) {
try {
final Database db = pdom.getDB();
final Database db = getDB();
fCachedParamID= db.getInt(record + PARAMETERID);
} catch (CoreException e) {
CCorePlugin.log(e);
@ -108,13 +107,13 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
@Override
public void addChild(PDOMNode member) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.addMember(member);
}
@Override
public void accept(IPDOMVisitor visitor) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.accept(visitor);
}
@ -131,7 +130,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
public IType getDefault() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + DEFAULT_TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + DEFAULT_TYPE));
if (node instanceof IType) {
return (IType) node;
}
@ -171,7 +170,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
IType dflt= val.getTypeValue();
if (dflt != null) {
final Database db= getPDOM().getDB();
PDOMNode typeNode = getLinkageImpl().addType(this, dflt);
PDOMNode typeNode = getLinkage().addType(this, dflt);
if (typeNode != null) {
db.putInt(record + DEFAULT_TYPE, typeNode.getRecord());
}
@ -194,9 +193,9 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
// ignore
}
if (newDefault != null) {
final Database db = pdom.getDB();
final Database db = getDB();
IType mytype= getDefault();
PDOMNode typeNode = getLinkageImpl().addType(this, newDefault);
PDOMNode typeNode = getLinkage().addType(this, newDefault);
if (typeNode != null) {
db.putInt(record + DEFAULT_TYPE, typeNode.getRecord());
if (mytype != null)

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.IType;
@ -8,11 +18,9 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
/**
* Stores a typelist
* TODO could refactor to have common base shared by {@link PDOMCPPArgumentList} using generics
* Stores a list of types
*/
class PDOMCPPTypeList {
protected static final int NODE_SIZE = 4;
/**
@ -24,7 +32,7 @@ class PDOMCPPTypeList {
return 0;
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len = (short)Math.min(types.length, (Database.MAX_MALLOC_SIZE-2)/NODE_SIZE);
final int block = db.malloc(2+ NODE_SIZE*len);
int p = block;
@ -47,7 +55,7 @@ class PDOMCPPTypeList {
return null;
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len = db.getShort(rec);
if (len == 0)
@ -72,7 +80,7 @@ class PDOMCPPTypeList {
return;
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len= db.getShort(record);
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/NODE_SIZE);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 QNX Software Systems and others.
* Copyright (c) 2006, 2009 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
@ -23,7 +23,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.index.CPPTypedefClone;
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.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -39,17 +38,17 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, ITypedef typedef) throws CoreException {
super(pdom, parent, typedef.getNameCharArray());
public PDOMCPPTypedef(PDOMLinkage linkage, PDOMNode parent, ITypedef typedef) throws CoreException {
super(linkage, parent, typedef.getNameCharArray());
try {
setType(parent.getLinkageImpl(), typedef.getType());
setType(parent.getLinkage(), typedef.getType());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCPPTypedef(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPTypedef(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -75,7 +74,7 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
linkage.deleteType((IType) typeNode, record);
typeNode= null;
}
pdom.getDB().putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
getDB().putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
private boolean introducesRecursion(IType type, int parentRec, char[] tdname) throws DOMException {
@ -128,7 +127,7 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
public IType getType() {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 QNX Software Systems and others.
* Copyright (c) 2007, 2009 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
@ -22,8 +22,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTypedefSpecialization;
import org.eclipse.cdt.internal.core.index.CPPTypedefClone;
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.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -38,9 +38,9 @@ class PDOMCPPTypedefSpecialization extends PDOMCPPSpecialization
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 4;
public PDOMCPPTypedefSpecialization(PDOM pdom, PDOMNode parent, ITypedef typedef, PDOMBinding specialized)
public PDOMCPPTypedefSpecialization(PDOMLinkage linkage, PDOMNode parent, ITypedef typedef, PDOMBinding specialized)
throws CoreException {
super(pdom, parent, (ICPPSpecialization) typedef, specialized);
super(linkage, parent, (ICPPSpecialization) typedef, specialized);
try {
if (typedef instanceof CPPTypedefSpecialization) {
@ -52,9 +52,9 @@ class PDOMCPPTypedefSpecialization extends PDOMCPPSpecialization
IType type = typedef.getType();
// The following may try to add the same typedef specialization to the index again.
// We protect against infinite recursion using a counter inside typedef.
PDOMNode typeNode = parent.getLinkageImpl().addType(this, type);
PDOMNode typeNode = parent.getLinkage().addType(this, type);
if (typeNode != null)
pdom.getDB().putInt(record + TYPE, typeNode.getRecord());
getDB().putInt(record + TYPE, typeNode.getRecord());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
} finally {
@ -64,8 +64,8 @@ class PDOMCPPTypedefSpecialization extends PDOMCPPSpecialization
}
}
public PDOMCPPTypedefSpecialization(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPTypedefSpecialization(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -80,7 +80,7 @@ class PDOMCPPTypedefSpecialization extends PDOMCPPSpecialization
public IType getType() throws DOMException {
try {
PDOMNode node = getLinkageImpl().getNode(pdom.getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* Copyright (c) 2008, 2009 Google, Inc 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
@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
@ -38,15 +38,15 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
// Cached values.
ICPPTemplateArgument[] arguments;
public PDOMCPPUnknownClassInstance(PDOM pdom, PDOMNode parent, ICPPUnknownClassInstance classInstance) throws CoreException {
super(pdom, parent, classInstance);
public PDOMCPPUnknownClassInstance(PDOMLinkage linkage, PDOMNode parent, ICPPUnknownClassInstance classInstance) throws CoreException {
super(linkage, parent, classInstance);
int rec= PDOMCPPArgumentList.putArguments(this, classInstance.getArguments());
pdom.getDB().putInt(record + ARGUMENTS, rec);
getDB().putInt(record + ARGUMENTS, rec);
}
public PDOMCPPUnknownClassInstance(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPUnknownClassInstance(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* Copyright (c) 2008, 2009 Google, Inc 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
@ -39,7 +39,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexScope;
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.PDOMLinkage;
@ -59,15 +58,15 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
private ICPPScope unknownScope;
public PDOMCPPUnknownClassType(PDOM pdom, PDOMNode parent, ICPPUnknownClassType classType) throws CoreException {
super(pdom, parent, classType.getNameCharArray());
public PDOMCPPUnknownClassType(PDOMLinkage linkage, PDOMNode parent, ICPPUnknownClassType classType) throws CoreException {
super(linkage, parent, classType.getNameCharArray());
setKind(classType);
// linked list is initialized by storage being zero'd by malloc
}
public PDOMCPPUnknownClassType(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
public PDOMCPPUnknownClassType(PDOMLinkage linkage, int bindingRecord) {
super(linkage, bindingRecord);
}
public EScopeKind getKind() {
@ -85,7 +84,7 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
private void setKind(ICPPClassType ct) throws CoreException {
try {
pdom.getDB().putByte(record + KEY, (byte) ct.getKey());
getDB().putByte(record + KEY, (byte) ct.getKey());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
@ -93,7 +92,7 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
@Override
public void addChild(PDOMNode member) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.addMember(member);
}
@ -110,7 +109,7 @@ class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope,
@Override
public void accept(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
PDOMNodeLinkedList list = new PDOMNodeLinkedList(getLinkage(), record + MEMBERLIST);
list.accept(visitor);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* Copyright (c) 2008, 2009 Google, Inc 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
@ -15,7 +15,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
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.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -41,31 +40,31 @@ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclara
private IBinding[] delegates;
public PDOMCPPUsingDeclaration(PDOM pdom, PDOMNode parent, ICPPUsingDeclaration using)
public PDOMCPPUsingDeclaration(PDOMLinkage linkage, PDOMNode parent, ICPPUsingDeclaration using)
throws CoreException {
super(pdom, parent, using.getNameCharArray());
super(linkage, parent, using.getNameCharArray());
IBinding[] delegates= using.getDelegates();
int nextRecord = 0;
for (int i = delegates.length; --i >= 0;) {
PDOMCPPUsingDeclaration simpleUsing = i > 0 ?
new PDOMCPPUsingDeclaration(pdom, parent, getNameCharArray()) : this;
simpleUsing.setTargetBinding(parent.getLinkageImpl(), delegates[i]);
pdom.getDB().putInt(record + NEXT_DELEGATE, nextRecord);
new PDOMCPPUsingDeclaration(linkage, parent, getNameCharArray()) : this;
simpleUsing.setTargetBinding(parent.getLinkage(), delegates[i]);
getDB().putInt(record + NEXT_DELEGATE, nextRecord);
nextRecord = simpleUsing.getRecord();
}
}
public PDOMCPPUsingDeclaration(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPUsingDeclaration(PDOMLinkage linkage, int record) {
super(linkage, record);
}
private PDOMCPPUsingDeclaration(PDOM pdom, PDOMNode parent, char[] name) throws CoreException {
super(pdom, parent, name);
private PDOMCPPUsingDeclaration(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {
super(linkage, parent, name);
}
private void setTargetBinding(PDOMLinkage linkage, IBinding delegate) throws CoreException {
PDOMBinding target = getLinkageImpl().adaptBinding(delegate);
pdom.getDB().putInt(record + TARGET_BINDING, target != null ? target.getRecord() : 0);
PDOMBinding target = getLinkage().adaptBinding(delegate);
getDB().putInt(record + TARGET_BINDING, target != null ? target.getRecord() : 0);
}
@Override
@ -99,13 +98,13 @@ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclara
}
private PDOMCPPUsingDeclaration getNext() throws CoreException {
int nextRecord = pdom.getDB().getInt(record + NEXT_DELEGATE);
return nextRecord != 0 ? new PDOMCPPUsingDeclaration(pdom, nextRecord) : null;
int nextRecord = getDB().getInt(record + NEXT_DELEGATE);
return nextRecord != 0 ? new PDOMCPPUsingDeclaration(getLinkage(), nextRecord) : null;
}
private IBinding getBinding() {
try {
return (IBinding) getLinkageImpl().getNode(
return (IBinding) getLinkage().getNode(
getPDOM().getDB().getInt(record + TARGET_BINDING));
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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
@ -46,7 +46,7 @@ public class PDOMCPPUsingDirective implements ICPPUsingDirective, IPDOMNode {
}
public PDOMCPPUsingDirective(PDOMCPPLinkage linkage, int prevRecInFile, PDOMCPPNamespace containerNS, PDOMBinding nominated) throws CoreException {
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final int containerRec= containerNS == null ? 0 : containerNS.getRecord();
final int nominatedRec= nominated.getRecord();
@ -62,7 +62,7 @@ public class PDOMCPPUsingDirective implements ICPPUsingDirective, IPDOMNode {
*/
public ICPPNamespaceScope getNominatedScope() {
try {
int rec = fLinkage.getPDOM().getDB().getInt(fRecord + NOMINATED_NAMESPACE);
int rec = fLinkage.getDB().getInt(fRecord + NOMINATED_NAMESPACE);
PDOMNode node= fLinkage.getNode(rec);
if (node instanceof ICPPNamespace) {
return ((ICPPNamespace) node).getNamespaceScope();
@ -80,7 +80,7 @@ public class PDOMCPPUsingDirective implements ICPPUsingDirective, IPDOMNode {
*/
public IScope getContainingScope() {
try {
int rec = fLinkage.getPDOM().getDB().getInt(fRecord + CONTAINER_NAMESPACE);
int rec = fLinkage.getDB().getInt(fRecord + CONTAINER_NAMESPACE);
if (rec != 0) {
PDOMNode node= fLinkage.getNode(rec);
if (node instanceof PDOMCPPNamespace) {
@ -105,7 +105,7 @@ public class PDOMCPPUsingDirective implements ICPPUsingDirective, IPDOMNode {
}
public int getPreviousRec() throws CoreException {
final Database db= fLinkage.getPDOM().getDB();
final Database db= fLinkage.getDB();
return db.getInt(fRecord + PREV_DIRECTIVE_OF_FILE);
}
@ -116,6 +116,6 @@ public class PDOMCPPUsingDirective implements ICPPUsingDirective, IPDOMNode {
}
public void delete(PDOMLinkage linkage) throws CoreException {
fLinkage.getPDOM().getDB().free(fRecord);
fLinkage.getDB().free(fRecord);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2008 QNX Software Systems and others.
* Copyright (c) 2005, 2009 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
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
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.PDOMLinkage;
@ -62,13 +61,13 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9;
public PDOMCPPVariable(PDOM pdom, PDOMNode parent, IVariable variable) throws CoreException {
super(pdom, parent, variable.getNameCharArray());
public PDOMCPPVariable(PDOMLinkage linkage, PDOMNode parent, IVariable variable) throws CoreException {
super(linkage, parent, variable.getNameCharArray());
try {
// Find the type record
Database db = pdom.getDB();
setType(parent.getLinkageImpl(), variable.getType());
Database db = getDB();
setType(parent.getLinkage(), variable.getType());
db.putByte(record + ANNOTATIONS, encodeFlags(variable));
setValue(db, variable);
} catch (DOMException e) {
@ -85,7 +84,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
@Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof IVariable) {
final Database db = pdom.getDB();
final Database db = getDB();
IVariable var= (IVariable) newBinding;
IType mytype= getType();
int valueRec= db.getInt(record + VALUE_OFFSET);
@ -107,15 +106,15 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
private void setType(final PDOMLinkage linkage, IType newType) throws CoreException, DOMException {
PDOMNode typeNode = linkage.addType(this, newType);
pdom.getDB().putInt(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
getDB().putInt(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
}
protected byte encodeFlags(IVariable variable) throws DOMException {
return PDOMCPPAnnotation.encodeAnnotation(variable);
}
public PDOMCPPVariable(PDOM pdom, int record) {
super(pdom, record);
public PDOMCPPVariable(PDOMLinkage linkage, int record) {
super(linkage, record);
}
@Override
@ -135,8 +134,8 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
public IType getType() {
try {
int typeRec = pdom.getDB().getInt(record + TYPE_OFFSET);
return (IType)getLinkageImpl().getNode(typeRec);
int typeRec = getDB().getInt(record + TYPE_OFFSET);
return (IType)getLinkage().getNode(typeRec);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
@ -145,7 +144,7 @@ class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
public IValue getInitialValue() {
try {
final Database db = pdom.getDB();
final Database db = getDB();
int valRec = db.getInt(record + VALUE_OFFSET);
return PDOMValue.restore(db, getLinkage(), valRec);
} catch (CoreException e) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2009 Wind River Systems, Inc. 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
@ -15,18 +15,18 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPBasicType;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
class PDOMGPPBasicType extends PDOMCPPBasicType implements IGPPBasicType {
public PDOMGPPBasicType(PDOM pdom, int record) {
super(pdom, record);
public PDOMGPPBasicType(PDOMLinkage linkage, int record) {
super(linkage, record);
}
public PDOMGPPBasicType(PDOM pdom, PDOMNode parent, IGPPBasicType type) throws CoreException {
super(pdom, parent, type, encodeGPPFlags(type));
public PDOMGPPBasicType(PDOMLinkage linkage, PDOMNode parent, IGPPBasicType type) throws CoreException {
super(linkage, parent, type, encodeGPPFlags(type));
}
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2009 Wind River Systems, Inc. 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
@ -15,7 +15,6 @@ 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.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -48,7 +47,7 @@ public class PDOMTemplateParameterArray {
*/
public static IPDOMCPPTemplateParameter[] getArray(PDOMNode parent, int rec) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getPDOM().getDB();
final Database db= linkage.getDB();
final short len= db.getShort(rec);
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/8);
@ -68,10 +67,10 @@ public class PDOMTemplateParameterArray {
/**
* Creates template parameters in the pdom
*/
public static IPDOMCPPTemplateParameter[] createPDOMTemplateParameters(PDOM pdom, PDOMNode parent, ICPPTemplateParameter[] origParams) throws CoreException, DOMException {
public static IPDOMCPPTemplateParameter[] createPDOMTemplateParameters(PDOMLinkage linkage, PDOMNode parent, ICPPTemplateParameter[] origParams) throws CoreException, DOMException {
IPDOMCPPTemplateParameter[] params= new IPDOMCPPTemplateParameter[origParams.length];
for (int i = 0; i < origParams.length; i++) {
params[i]= createPDOMTemplateParameter(pdom, parent, origParams[i]);
params[i]= createPDOMTemplateParameter(linkage, parent, origParams[i]);
}
return params;
}
@ -79,14 +78,14 @@ public class PDOMTemplateParameterArray {
/**
* Creates a template parameter in the pdom
*/
public static IPDOMCPPTemplateParameter createPDOMTemplateParameter(PDOM pdom, PDOMNode parent, ICPPTemplateParameter origParam) throws CoreException, DOMException {
public static IPDOMCPPTemplateParameter createPDOMTemplateParameter(PDOMLinkage linkage, PDOMNode parent, ICPPTemplateParameter origParam) throws CoreException, DOMException {
IPDOMCPPTemplateParameter param= null;
if (origParam instanceof ICPPTemplateNonTypeParameter) {
param= new PDOMCPPTemplateNonTypeParameter(pdom, parent, (ICPPTemplateNonTypeParameter) origParam);
param= new PDOMCPPTemplateNonTypeParameter(linkage, parent, (ICPPTemplateNonTypeParameter) origParam);
} else if (origParam instanceof ICPPTemplateTypeParameter) {
param= new PDOMCPPTemplateTypeParameter(pdom, parent, (ICPPTemplateTypeParameter) origParam);
param= new PDOMCPPTemplateTypeParameter(linkage, parent, (ICPPTemplateTypeParameter) origParam);
} else if (origParam instanceof ICPPTemplateTemplateParameter) {
param= new PDOMCPPTemplateTemplateParameter(pdom, parent, (ICPPTemplateTemplateParameter) origParam);
param= new PDOMCPPTemplateTemplateParameter(linkage, parent, (ICPPTemplateTemplateParameter) origParam);
}
return param;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 QNX Software Systems
* Copyright (c) 2005, 2009 QNX Software Systems
* 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
@ -91,7 +91,7 @@ public class CountNodeAction extends IndexAction {
public boolean visit(int record) throws CoreException {
if (record != 0) {
PDOMFile file = new PDOMFile(pdom, record);
PDOMFile file = PDOMFile.recreateFile(pdom, record);
++count[FILES];
PDOMMacro macro = file.getFirstMacro();
while (macro != null) {