1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Support for PDOMs larger than 2GB, bug 279620.

This commit is contained in:
Markus Schorn 2009-07-02 08:57:39 +00:00
parent be997b5279
commit 8c5f3483fa
126 changed files with 1175 additions and 954 deletions

View file

@ -528,7 +528,7 @@ class MockStateIndexFragmentProvider extends MockStateIndexProvider implements I
fragments = new IIndexFragment[MockState.states.size()];
for(int i=0; i<MockState.states.size(); i++) {
fragments[i] = new MockPDOM("mock.test.index."+System.identityHashCode(this)+"."+i, PDOM.versionString(PDOM.CURRENT_VERSION));
fragments[i] = new MockPDOM("mock.test.index."+System.identityHashCode(this)+"."+i, PDOM.versionString(PDOM.getDefaultVersion()));
}
}

View file

@ -785,7 +785,7 @@ public class IndexUpdateTests extends IndexTestBase {
ICPPClassTemplate binding;
ICompositeType ct;
fIndex.acquireReadLock();
int pdomid;
long pdomid;
try {
binding = (ICPPClassTemplate) findBinding("CT");
assertEquals(ICPPClassType.k_class , binding.getKey());

View file

@ -174,10 +174,10 @@ public class BTreeTests extends BaseTestCase {
final Iterator i = expected.iterator();
btree.accept(new IBTreeVisitor(){
int k;
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
if(record!=0) {
BTMockRecord btValue = new BTMockRecord(record, db);
if(i.hasNext()) {
@ -197,7 +197,7 @@ public class BTreeTests extends BaseTestCase {
private static class BTMockRecord {
public static final int VALUE_PTR = 0;
public static final int RECORD_SIZE = Database.INT_SIZE;
int record;
long record;
Database db;
/**
@ -212,7 +212,7 @@ public class BTreeTests extends BaseTestCase {
/**
* Get an existing record
*/
public BTMockRecord(int record, Database db) {
public BTMockRecord(long record, Database db) {
this.db = db;
this.record = record;
}
@ -221,13 +221,13 @@ public class BTreeTests extends BaseTestCase {
return db.getInt(record);
}
public int getRecord() {
public long getRecord() {
return record;
}
}
private class BTMockRecordComparator implements IBTreeComparator {
public int compare(int record1, int record2) throws CoreException {
public int compare(long record1, long record2) throws CoreException {
return db.getInt(record1) - db.getInt(record2);
}
}

View file

@ -68,12 +68,12 @@ public class DBTest extends BaseTestCase {
final int blocksize = deltas * Database.BLOCK_SIZE_DELTA;
final int freeDeltas= Database.CHUNK_SIZE/Database.BLOCK_SIZE_DELTA-deltas;
int mem = db.malloc(realsize);
long mem = db.malloc(realsize);
assertEquals(-blocksize, db.getShort(mem - Database.BLOCK_HEADER_SIZE));
db.free(mem);
assertEquals(blocksize, db.getShort(mem - Database.BLOCK_HEADER_SIZE));
assertEquals(mem - Database.BLOCK_HEADER_SIZE, db.getInt((deltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE));
assertEquals(mem - Database.BLOCK_HEADER_SIZE + blocksize, db.getInt((freeDeltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE));
assertEquals(mem - Database.BLOCK_HEADER_SIZE, db.getRecPtr((deltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE));
assertEquals(mem - Database.BLOCK_HEADER_SIZE + blocksize, db.getRecPtr((freeDeltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE));
}
public void testBug192437() throws IOException {
@ -106,44 +106,44 @@ public class DBTest extends BaseTestCase {
final int blocksize = deltas * Database.BLOCK_SIZE_DELTA;
final int freeDeltas= Database.MIN_BLOCK_DELTAS-deltas;
int mem1 = db.malloc(realsize);
int mem2 = db.malloc(realsize);
long mem1 = db.malloc(realsize);
long mem2 = db.malloc(realsize);
db.free(mem1);
db.free(mem2);
assertEquals(mem2 - Database.BLOCK_HEADER_SIZE, db.getInt((deltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE));
assertEquals(0, db.getInt(mem2));
assertEquals(mem1 - Database.BLOCK_HEADER_SIZE, db.getInt(mem2 + Database.INT_SIZE));
assertEquals(mem2 - Database.BLOCK_HEADER_SIZE, db.getInt(mem1));
assertEquals(0, db.getInt(mem1 + Database.INT_SIZE));
assertEquals(mem2 - Database.BLOCK_HEADER_SIZE, db.getRecPtr((deltas-Database.MIN_BLOCK_DELTAS+1) * Database.INT_SIZE));
assertEquals(0, db.getRecPtr(mem2));
assertEquals(mem1 - Database.BLOCK_HEADER_SIZE, db.getRecPtr(mem2 + Database.INT_SIZE));
assertEquals(mem2 - Database.BLOCK_HEADER_SIZE, db.getRecPtr(mem1));
assertEquals(0, db.getRecPtr(mem1 + Database.INT_SIZE));
}
public void testSimpleAllocationLifecycle() throws Exception {
int mem1 = db.malloc(42);
long mem1 = db.malloc(42);
db.free(mem1);
int mem2 = db.malloc(42);
long mem2 = db.malloc(42);
assertEquals(mem2, mem1);
}
private static class FindVisitor implements IBTreeVisitor {
private Database db;
private String key;
private int record;
private long record;
public FindVisitor(Database db, String key) {
this.db = db;
this.key = key;
}
public int compare(int record) throws CoreException {
return db.getString(db.getInt(record + 4)).compare(key, true);
public int compare(long record) throws CoreException {
return db.getString(db.getRecPtr(record + 4)).compare(key, true);
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
this.record = record;
return false;
}
public int getRecord() {
public long getRecord() {
return record;
}
@ -183,19 +183,19 @@ public class DBTest extends BaseTestCase {
};
IBTreeComparator comparator = new IBTreeComparator() {
public int compare(int record1, int record2) throws CoreException {
IString string1 = db.getString(db.getInt(record1 + 4));
IString string2 = db.getString(db.getInt(record2 + 4));
public int compare(long record1, long record2) throws CoreException {
IString string1 = db.getString(db.getRecPtr(record1 + 4));
IString string2 = db.getString(db.getRecPtr(record2 + 4));
return string1.compare(string2, true);
}
};
BTree btree = new BTree(db, Database.DATA_AREA, comparator);
for (int i = 0; i < names.length; ++i) {
String name = names[i];
int record = db.malloc(8);
long record = db.malloc(8);
db.putInt(record + 0, i);
IString string = db.newString(name);
db.putInt(record + 4, string.getRecord());
db.putRecPtr(record + 4, string.getRecord());
btree.insert(record);
}
@ -203,10 +203,10 @@ public class DBTest extends BaseTestCase {
String name = names[i];
FindVisitor finder = new FindVisitor(db, name);
btree.accept(finder);
int record = finder.getRecord();
long record = finder.getRecord();
assertTrue(record != 0);
assertEquals(i, db.getInt(record));
IString rname = db.getString(db.getInt(record + 4));
IString rname = db.getString(db.getRecPtr(record + 4));
assertTrue(rname.equals(name));
}
}

View file

@ -96,11 +96,11 @@ public class PDOMPrettyPrinter implements IPDOMVisitor {
final PDOMLinkage linkage = pdom.getLinkage(linkageID);
if (linkage != null) {
linkage.getIndex().accept(new IBTreeVisitor() {
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
if (record == 0)
return false;
PDOMNode node = linkage.getNode(record);

View file

@ -170,6 +170,7 @@ public class BaseTestCase extends TestCase {
}
}
}
cause= (cause==null) ? testThrowable : cause;
AssertionFailedError afe= new AssertionFailedError(msg.toString());
afe.initCause(cause);
throw afe;

View file

@ -62,5 +62,5 @@ public interface IIndexFragmentBinding extends IIndexBinding {
* Returns a unique id for the binding within the fragment
* @since 5.1
*/
int getBindingID();
long getBindingID();
}

View file

@ -303,8 +303,8 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
private static class Key {
final long i;
final int j;
final int k;
public Key(long id1, int id2, int id3) {
final long k;
public Key(long id1, int id2, long id3) {
i= id1;
j= id2;
k= id3;
@ -315,7 +315,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
int result = 1;
result = prime * result + (int) (i ^ (i >>> 32));
result = prime * result + j;
result = prime * result + k;
result = prime * result + (int)k;
return result;
}
@Override

View file

@ -80,7 +80,9 @@ public final class IndexProviderManager implements IElementChangedListener {
* <b>Note: This method should not be called by clients for purposes other than testing</b>
*/
public void reset() {
reset(new VersionRange(new Version(PDOM.MAJOR_VERSION,0, 0), true, new Version(PDOM.MAJOR_VERSION+1, 0, 0), false));
Version minVersion= Version.parseVersion(PDOM.versionString(PDOM.getMinSupportedVersion()));
Version maxVersion= Version.parseVersion(PDOM.versionString(PDOM.getMaxSupportedVersion()));
reset(new VersionRange(minVersion, true, maxVersion, true));
}
/**

View file

@ -784,6 +784,16 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
private void swallowError(IPath file, Throwable e) throws CoreException {
IStatus s;
/*
* If the thrown CoreException is for a STATUS_PDOM_TOO_LARGE, we don't want to
* swallow this one.
*/
if (e instanceof CoreException) {
s=((CoreException)e).getStatus();
if( s != null && s.getCode() == CCorePlugin.STATUS_PDOM_TOO_LARGE ) {
throw (CoreException)e;
}
}
if (e instanceof CoreException) {
s= ((CoreException) e).getStatus();
if (s.getException() == null) {

View file

@ -95,11 +95,7 @@ import org.eclipse.core.runtime.Status;
* Database for storing semantic information for one project.
*/
public class PDOM extends PlatformObject implements IPDOM {
/**
* mstodo
*/
private static final int BLOCKED_WRITELOCK_OUTPUT_INTERVAL = 30000;
static boolean sDEBUG_LOCKS= "true".equals(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/locks")); //$NON-NLS-1$//$NON-NLS-2$
/**
@ -167,6 +163,7 @@ public class PDOM extends PlatformObject implements IPDOM {
* 60.0 - store integral values with basic types (bug 207871)
* #61.0# - properly insert macro undef statements into macro-containers (bug 234591) - <<CDT 5.0>>
*
* CDT 6.0 development
* 70.0 - cleaned up templates, fixes bug 236197
* 71.0 - proper support for anonymous unions, bug 206450
* 72.0 - store project-relative paths for resources that belong to the project, bug 239472
@ -181,18 +178,43 @@ public class PDOM extends PlatformObject implements IPDOM {
* 80.0 - support for specializations of partial specializations, bug 259872
* 81.0 - change to c++ function types, bug 264479
* 82.0 - offsets for using directives, bug 270806
* 83.0 - unconditionally store name in PROMInclude, bug 272815
* #83.0# - unconditionally store name in PDOMInclude, bug 272815 - <<CDT 6.0>>
* 84.0 - storing free record pointers as (ptr>>3) and allocated pointers as (ptr-2)>>3 RECPTR_DENSE_VERSION
*
* CDT 7.0 development (versions not supported on the 6.0.x branch)
* next: 90.0
*/
private static int version(int major, int minor) {
return major << 16 + minor;
private static final int MIN_SUPPORTED_VERSION= version(83, 0);
private static final int MAX_SUPPORTED_VERSION= version(84, Short.MAX_VALUE);
private static int DEFAULT_VERSION = version(84, 0);
public static final int DENSE_RECPTR_VERSION = version(84, 0);
static {
if (System.getProperty("org.eclipse.cdt.core.parser.pdom.useDensePointers", "false").equals("true")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DEFAULT_VERSION= DENSE_RECPTR_VERSION;
}
}
public static final int MAJOR_VERSION = 83;
public static final int MINOR_VERSION = 0; // minor versions must be compatible
public static final int CURRENT_VERSION= version(MAJOR_VERSION, MINOR_VERSION);
public static final int MIN_SUPPORTED_VERSION= version(MAJOR_VERSION, 0);
public static final int MAX_SUPPORTED_VERSION= version(MAJOR_VERSION+1, 0)-1;
private static int version(int major, int minor) {
return (major << 16) + minor;
}
/**
* Returns the version that shall be used when creating new databases
*/
public static int getDefaultVersion() {
return DEFAULT_VERSION;
}
public static boolean isSupportedVersion(int vers) {
return vers >= MIN_SUPPORTED_VERSION && vers <= MAX_SUPPORTED_VERSION;
}
public static int getMinSupportedVersion() {
return MIN_SUPPORTED_VERSION;
}
public static int getMaxSupportedVersion() {
return MAX_SUPPORTED_VERSION;
}
public static String versionString(int version) {
final int major= version >> 16;
final int minor= version & 0xffff;
@ -268,7 +290,7 @@ public class PDOM extends PlatformObject implements IPDOM {
final boolean lockDB= db == null || lockCount != 0;
clearCaches();
db = new Database(fPath, cache, CURRENT_VERSION, isPermanentlyReadOnly());
db = new Database(fPath, cache, getDefaultVersion(), isPermanentlyReadOnly());
db.setLocked(lockDB);
if (isSupportedVersion()) {
@ -287,7 +309,7 @@ public class PDOM extends PlatformObject implements IPDOM {
}
private void readLinkages() throws CoreException {
int record= getFirstLinkageRecord();
long record= getFirstLinkageRecord();
while (record != 0) {
String linkageID= PDOMLinkage.getLinkageID(this, record).getString();
IPDOMLinkageFactory factory= fPDOMLinkageFactoryCache.get(linkageID);
@ -373,10 +395,10 @@ public class PDOM extends PlatformObject implements IPDOM {
public IIndexFragmentFile[] getAllFiles() throws CoreException {
final List<PDOMFile> locations = new ArrayList<PDOMFile>();
getFileIndex().accept(new IBTreeVisitor(){
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
PDOMFile file = PDOMFile.recreateFile(PDOM.this, record);
locations.add(file);
return true;
@ -397,7 +419,7 @@ public class PDOM extends PlatformObject implements IPDOM {
}
protected void clearFileIndex() throws CoreException {
db.putInt(FILE_INDEX, 0);
db.putRecPtr(FILE_INDEX, 0);
fileIndex = null;
}
@ -405,7 +427,8 @@ public class PDOM extends PlatformObject implements IPDOM {
assert lockCount < 0; // needs write-lock.
// Clear out the database, everything is set to zero.
db.clear(CURRENT_VERSION);
int vers = getDefaultVersion();
db.clear(vers);
clearCaches();
fEvent.setCleared();
}
@ -647,8 +670,8 @@ public class PDOM extends PlatformObject implements IPDOM {
}
private int getFirstLinkageRecord() throws CoreException {
return db.getInt(LINKAGES);
private long getFirstLinkageRecord() throws CoreException {
return db.getRecPtr(LINKAGES);
}
public IIndexLinkage[] getLinkages() {
@ -662,8 +685,8 @@ public class PDOM extends PlatformObject implements IPDOM {
}
public void insertLinkage(PDOMLinkage linkage) throws CoreException {
linkage.setNext(db.getInt(LINKAGES));
db.putInt(LINKAGES, linkage.getRecord());
linkage.setNext(db.getRecPtr(LINKAGES));
db.putRecPtr(LINKAGES, linkage.getRecord());
fLinkageIDCache.put(linkage.getLinkageID(), linkage);
}
@ -996,10 +1019,18 @@ public class PDOM extends PlatformObject implements IPDOM {
if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_ID.equals(propertyName)) {
return FRAGMENT_PROPERTY_VALUE_FORMAT_ID;
}
int version = db.getVersion();
if(IIndexFragment.PROPERTY_FRAGMENT_FORMAT_VERSION.equals(propertyName)) {
return PDOM.versionString(db.getVersion());
return PDOM.versionString(version);
}
return new DBProperties(db, PROPERTIES).getProperty(propertyName);
// play it safe, properties are accessed before version checks.
if (PDOM.isSupportedVersion(version)) {
return new DBProperties(db, PROPERTIES).getProperty(propertyName);
}
if (IIndexFragment.PROPERTY_FRAGMENT_ID.equals(propertyName)) {
return "Unknown"; //$NON-NLS-1$
}
return null;
}
public void close() throws CoreException {
@ -1062,7 +1093,7 @@ public class PDOM extends PlatformObject implements IPDOM {
}
}
public String createKeyForCache(int record, char[] name) {
public String createKeyForCache(long record, char[] name) {
return new StringBuilder(name.length+2).append((char) (record >> 16)).append((char) record).append(name).toString();
}

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,7 @@ import org.eclipse.core.runtime.CoreException;
public class PDOMFileSet implements IIndexFragmentFileSet {
private HashSet<Integer> fFileIDs= new HashSet<Integer>();
private HashSet<Long> fFileIDs= new HashSet<Long>();
public void add(IIndexFragmentFile fragFile) {
PDOMFile pdomFile= (PDOMFile) fragFile;

View file

@ -1199,7 +1199,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
version= (version << 8) + (b & 0xff);
out.write(b);
}
if (version < PDOM.MIN_SUPPORTED_VERSION || version > PDOM.MAX_SUPPORTED_VERSION) {
if ( !PDOM.isSupportedVersion( version ) ) {
final IStatus status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, 0, CCorePlugin.getResourceString("PDOMManager.unsupportedVersion"), null); //$NON-NLS-1$
throw new CoreException(status);
}

View file

@ -117,10 +117,10 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
public void rewriteLocations(final IIndexLocationConverter newConverter) throws CoreException {
final List<PDOMFile> pdomfiles = new ArrayList<PDOMFile>();
getFileIndex().accept(new IBTreeVisitor(){
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
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
@ -31,7 +31,7 @@ public class BTree {
private static final int DELMODE_DELETE_MAXIMUM = 2;
protected final Database db;
protected final int rootPointer;
protected final long rootPointer;
protected final int DEGREE;
protected final int MAX_RECORDS;
@ -42,7 +42,7 @@ public class BTree {
protected final IBTreeComparator cmp;
public BTree(Database db, int rootPointer, IBTreeComparator cmp) {
public BTree(Database db, long rootPointer, IBTreeComparator cmp) {
this(db, rootPointer, 8, cmp);
}
@ -52,7 +52,7 @@ public class BTree {
* @param db the database containing the btree
* @param rootPointer offset into database of the pointer to the root node
*/
public BTree(Database db, int rootPointer, int degree, IBTreeComparator cmp) {
public BTree(Database db, long rootPointer, int degree, IBTreeComparator cmp) {
if(degree<2)
throw new IllegalArgumentException(Messages.getString("BTree.IllegalDegree")); //$NON-NLS-1$
@ -68,24 +68,24 @@ public class BTree {
this.MEDIAN_RECORD = DEGREE - 1;
}
protected int getRoot() throws CoreException {
return db.getInt(rootPointer);
protected long getRoot() throws CoreException {
return db.getRecPtr(rootPointer);
}
protected final void putRecord(Chunk chunk, int node, int index, int record) {
chunk.putInt(node + index * Database.INT_SIZE, record);
protected final void putRecord(Chunk chunk, long node, int index, long record) {
chunk.putRecPtr(node + index * Database.INT_SIZE, record);
}
protected final int getRecord(Chunk chunk, int node, int index) {
return chunk.getInt(node + index * Database.INT_SIZE);
protected final long getRecord(Chunk chunk, long node, int index) {
return chunk.getRecPtr(node + index * Database.INT_SIZE);
}
protected final void putChild(Chunk chunk, int node, int index, int child) {
chunk.putInt(node + OFFSET_CHILDREN + index * Database.INT_SIZE, child);
protected final void putChild(Chunk chunk, long node, int index, long child) {
chunk.putRecPtr(node + OFFSET_CHILDREN + index * Database.INT_SIZE, child);
}
protected final int getChild(Chunk chunk, int node, int index) {
return chunk.getInt(node + OFFSET_CHILDREN + index * Database.INT_SIZE);
protected final long getChild(Chunk chunk, long node, int index) {
return chunk.getRecPtr(node + OFFSET_CHILDREN + index * Database.INT_SIZE);
}
/**
@ -95,8 +95,8 @@ public class BTree {
*
* @param record offset of the record
*/
public int insert(int record) throws CoreException {
int root = getRoot();
public long insert(long record) throws CoreException {
long root = getRoot();
// is this our first time in
if (root == 0) {
@ -107,19 +107,19 @@ public class BTree {
return insert(null, 0, 0, root, record);
}
private int insert(Chunk pChunk, int parent, int iParent, int node, int record) throws CoreException {
private long insert(Chunk pChunk, long parent, int iParent, long node, long record) throws CoreException {
Chunk chunk = db.getChunk(node);
// if this node is full (last record isn't null), split it
if (getRecord(chunk, node, MAX_RECORDS - 1) != 0) {
int median = getRecord(chunk, node, MEDIAN_RECORD);
long median = getRecord(chunk, node, MEDIAN_RECORD);
if (median == record)
// found it, never mind
return median;
else {
// split it
// create the new node and move the larger records over
int newnode = allocateNode();
long newnode = allocateNode();
Chunk newchunk = db.getChunk(newnode);
for (int i = 0; i < MEDIAN_RECORD; ++i) {
putRecord(newchunk, newnode, i, getRecord(chunk, node, MEDIAN_RECORD + 1 + i));
@ -134,12 +134,12 @@ public class BTree {
// create a new root
parent = allocateNode();
pChunk = db.getChunk(parent);
db.putInt(rootPointer, parent);
db.putRecPtr(rootPointer, parent);
putChild(pChunk, parent, 0, node);
} else {
// insert the median into the parent
for (int i = MAX_RECORDS - 2; i >= iParent; --i) {
int r = getRecord(pChunk, parent, i);
long r = getRecord(pChunk, parent, i);
if (r != 0) {
putRecord(pChunk, parent, i + 1, r);
putChild(pChunk, parent, i + 2, getChild(pChunk, parent, i + 1));
@ -168,7 +168,7 @@ public class BTree {
while (lower < upper) {
int middle= (lower+upper)/2;
int checkRec= getRecord(chunk, node, middle);
long checkRec= getRecord(chunk, node, middle);
if (checkRec == 0) {
upper= middle;
}
@ -187,7 +187,7 @@ public class BTree {
}
}
final int i= lower;
int child = getChild(chunk, node, i);
long child = getChild(chunk, node, i);
if (child != 0) {
// visit the children
return insert(chunk, node, i, child, record);
@ -195,7 +195,7 @@ public class BTree {
// were at the leaf, add us in.
// first copy everything after over one
for (int j = MAX_RECORDS - 2; j >= i; --j) {
int r = getRecord(chunk, node, j);
long r = getRecord(chunk, node, j);
if (r != 0)
putRecord(chunk, node, j + 1, r);
}
@ -204,15 +204,15 @@ public class BTree {
}
}
private void firstInsert(int record) throws CoreException {
private void firstInsert(long record) throws CoreException {
// create the node and save it as root
int root = allocateNode();
db.putInt(rootPointer, root);
long root = allocateNode();
db.putRecPtr(rootPointer, root);
// put the record in the first slot of the node
putRecord(db.getChunk(root), root, 0, record);
}
private int allocateNode() throws CoreException {
private long allocateNode() throws CoreException {
return db.malloc((2 * MAX_RECORDS + 1) * Database.INT_SIZE);
}
@ -230,7 +230,7 @@ public class BTree {
* @param record the record to delete
* @throws CoreException
*/
public void delete(int record) throws CoreException {
public void delete(long record) throws CoreException {
try {
deleteImp(record, getRoot(), DELMODE_NORMAL);
} catch(BTreeKeyNotFoundException e) {
@ -249,11 +249,11 @@ public class BTree {
* Used in implementation of delete routines
*/
private class BTNode {
final int node;
final long node;
final int keyCount;
final Chunk chunk;
BTNode(int node) throws CoreException {
BTNode(long node) throws CoreException {
this.node = node;
this.chunk = db.getChunk(node);
int i=0;
@ -264,7 +264,7 @@ public class BTree {
private BTNode getChild(int index) throws CoreException {
if(0<=index && index<MAX_CHILDREN) {
int child = BTree.this.getChild(chunk, node, index);
long child = BTree.this.getChild(chunk, node, index);
if(child!=0)
return new BTNode(child);
}
@ -289,7 +289,7 @@ public class BTree {
* @return the address of the record removed from the B-tree
* @throws CoreException
*/
private int deleteImp(int key, int nodeRecord, int mode)
private long deleteImp(long key, long nodeRecord, int mode)
throws CoreException, BTreeKeyNotFoundException {
BTNode node = new BTNode(nodeRecord);
@ -309,17 +309,17 @@ public class BTree {
return key;
} else {
if(mode==DELMODE_DELETE_MINIMUM) {
int subst = getRecord(node.chunk, node.node, 0);
long subst = getRecord(node.chunk, node.node, 0);
nodeContentDelete(node, 0, 1);
return subst;
} else if(mode==DELMODE_DELETE_MAXIMUM) {
int subst = getRecord(node.chunk, node.node, node.keyCount-1);
long subst = getRecord(node.chunk, node.node, node.keyCount-1);
nodeContentDelete(node, node.keyCount-1, 1);
return subst;
}
throw new BTreeKeyNotFoundException(
MessageFormat.format(Messages.getString("BTree.DeletionOnAbsentKey"), //$NON-NLS-1$
new Object[]{new Integer(key), new Integer(mode)}));
new Object[]{new Long(key), new Integer(mode)}));
}
} else {
if(keyIndexInNode != -1) {
@ -328,7 +328,7 @@ public class BTree {
BTNode succ = node.getChild(keyIndexInNode+1);
if(succ!=null && succ.keyCount > MIN_RECORDS) {
/* Case 2a: Delete key by overwriting it with its successor (which occurs in a leaf node) */
int subst = deleteImp(-1, succ.node, DELMODE_DELETE_MINIMUM);
long subst = deleteImp(-1, succ.node, DELMODE_DELETE_MINIMUM);
putRecord(node.chunk, node.node, keyIndexInNode, subst);
return key;
}
@ -336,7 +336,7 @@ public class BTree {
BTNode pred = node.getChild(keyIndexInNode);
if(pred!=null && pred.keyCount > MIN_RECORDS) {
/* Case 2b: Delete key by overwriting it with its predecessor (which occurs in a leaf node) */
int subst = deleteImp(-1, pred.node, DELMODE_DELETE_MAXIMUM);
long subst = deleteImp(-1, pred.node, DELMODE_DELETE_MAXIMUM);
putRecord(node.chunk, node.node, keyIndexInNode, subst);
return key;
}
@ -378,8 +378,8 @@ public class BTree {
BTNode sibR = node.getChild(subtreeIndex+1);
if(sibR!=null && sibR.keyCount > MIN_RECORDS) {
/* Case 3a (i): child will underflow upon deletion, take a key from rightSibling */
int rightKey = getRecord(node.chunk, node.node, subtreeIndex);
int leftmostRightSiblingKey = getRecord(sibR.chunk, sibR.node, 0);
long rightKey = getRecord(node.chunk, node.node, subtreeIndex);
long leftmostRightSiblingKey = getRecord(sibR.chunk, sibR.node, 0);
append(child, rightKey, getChild(sibR.chunk, sibR.node, 0));
nodeContentDelete(sibR, 0, 1);
putRecord(node.chunk, node.node, subtreeIndex, leftmostRightSiblingKey);
@ -389,9 +389,9 @@ public class BTree {
BTNode sibL = node.getChild(subtreeIndex-1);
if(sibL!=null && sibL.keyCount > MIN_RECORDS) {
/* Case 3a (ii): child will underflow upon deletion, take a key from leftSibling */
int leftKey = getRecord(node.chunk, node.node, subtreeIndex-1);
long leftKey = getRecord(node.chunk, node.node, subtreeIndex-1);
prepend(child, leftKey, getChild(sibL.chunk, sibL.node, sibL.keyCount));
int rightmostLeftSiblingKey = getRecord(sibL.chunk, sibL.node, sibL.keyCount-1);
long rightmostLeftSiblingKey = getRecord(sibL.chunk, sibL.node, sibL.keyCount-1);
putRecord(sibL.chunk, sibL.node, sibL.keyCount-1, 0);
putChild(sibL.chunk, sibL.node, sibL.keyCount, 0);
putRecord(node.chunk, node.node, subtreeIndex-1, rightmostLeftSiblingKey);
@ -412,7 +412,7 @@ public class BTree {
throw new BTreeKeyNotFoundException(
MessageFormat.format(Messages.getString("BTree.DeletionOnAbsentKey"), //$NON-NLS-1$
new Object[]{new Integer(key), new Integer(mode)}));
new Object[]{new Long(key), new Integer(mode)}));
}
}
}
@ -430,9 +430,9 @@ public class BTree {
public void mergeNodes(BTNode src, BTNode keyProvider, int kIndex, BTNode dst)
throws CoreException {
nodeContentCopy(src, 0, dst, dst.keyCount+1, src.keyCount+1);
int midKey = getRecord(keyProvider.chunk, keyProvider.node, kIndex);
long midKey = getRecord(keyProvider.chunk, keyProvider.node, kIndex);
putRecord(dst.chunk, dst.node, dst.keyCount, midKey);
int keySucc = kIndex+1 == MAX_RECORDS ? 0 : getRecord(keyProvider.chunk, keyProvider.node, kIndex+1);
long keySucc = kIndex+1 == MAX_RECORDS ? 0 : getRecord(keyProvider.chunk, keyProvider.node, kIndex+1);
db.free(getChild(keyProvider.chunk, keyProvider.node, kIndex+1));
nodeContentDelete(keyProvider, kIndex+1, 1);
putRecord(keyProvider.chunk, keyProvider.node, kIndex, keySucc);
@ -442,9 +442,9 @@ public class BTree {
* This means we must special case it at the point when its had all of its keys deleted
* entirely during merge operations (which push one of its keys down as a pivot)
*/
int rootNode = getRoot();
long rootNode = getRoot();
if(rootNode == keyProvider.node) {
db.putInt(rootPointer, dst.node);
db.putRecPtr(rootPointer, dst.node);
db.free(rootNode);
}
}
@ -457,7 +457,7 @@ public class BTree {
* @param key the new leftmost (least) key
* @param child the new leftmost (least) subtree root
*/
private void prepend(BTNode node, int key, int child) {
private void prepend(BTNode node, long key, long child) {
nodeContentCopy(node, 0, node, 1, node.keyCount+1);
putRecord(node.chunk, node.node, 0, key);
putChild(node.chunk, node.node, 0, child);
@ -470,7 +470,7 @@ public class BTree {
* @param key
* @param child
*/
private void append(BTNode node, int key, int child) {
private void append(BTNode node, long key, long child) {
putRecord(node.chunk, node.node, node.keyCount, key);
putChild(node.chunk, node.node, node.keyCount + 1, child);
}
@ -492,11 +492,11 @@ public class BTree {
int dstIndex = dstPos + i;
if(srcIndex<src.keyCount+1) {
int srcChild = getChild(src.chunk, src.node, srcIndex);
long srcChild = getChild(src.chunk, src.node, srcIndex);
putChild(dst.chunk, dst.node, dstIndex, srcChild);
if(srcIndex<src.keyCount) {
int srcKey = getRecord(src.chunk, src.node, srcIndex);
long srcKey = getRecord(src.chunk, src.node, srcIndex);
putRecord(dst.chunk, dst.node, dstIndex, srcKey);
}
}
@ -514,8 +514,8 @@ public class BTree {
*/
private void nodeContentDelete(BTNode node, int i, int length) {
for(int index=i; index<=MAX_RECORDS; index++) {
int newKey = (index+length) < node.keyCount ? getRecord(node.chunk, node.node, index+length) : 0;
int newChild = (index+length) < node.keyCount+1 ? getChild(node.chunk, node.node, index+length) : 0;
long newKey = (index+length) < node.keyCount ? getRecord(node.chunk, node.node, index+length) : 0;
long newChild = (index+length) < node.keyCount+1 ? getChild(node.chunk, node.node, index+length) : 0;
if(index<MAX_RECORDS) {
putRecord(node.chunk, node.node, index, newKey);
}
@ -532,10 +532,10 @@ public class BTree {
* @param visitor
*/
public void accept(IBTreeVisitor visitor) throws CoreException {
accept(db.getInt(rootPointer), visitor);
accept(db.getRecPtr(rootPointer), visitor);
}
private boolean accept(int node, IBTreeVisitor visitor) throws CoreException {
private boolean accept(long node, IBTreeVisitor visitor) throws CoreException {
// if found is false, we are still in search mode
// once found is true visit everything
// return false when ready to quit
@ -558,7 +558,7 @@ public class BTree {
}
while (lower < upper) {
int middle= (lower+upper)/2;
int checkRec= getRecord(chunk, node, middle);
long checkRec = getRecord(chunk, node, middle);
if (checkRec == 0) {
upper= middle;
}
@ -576,7 +576,7 @@ public class BTree {
// start with first record greater or equal, reuse comparison results.
int i= lower;
for (; i < MAX_RECORDS; ++i) {
int record = getRecord(chunk, node, i);
long record = getRecord(chunk, node, i);
if (record == 0)
break;
@ -605,8 +605,8 @@ public class BTree {
* IBTreeVisitor2 if this is acceptable.
*/
private interface IBTreeVisitor2 extends IBTreeVisitor {
void preNode(int node) throws CoreException;
void postNode(int node) throws CoreException;
void preNode(long node) throws CoreException;
void postNode(long node) throws CoreException;
}
/**
@ -633,11 +633,11 @@ public class BTree {
public String getMsg() { return msg; }
public boolean isValid() { return valid; }
public void postNode(int node) throws CoreException { depth--; }
public int compare(int record) throws CoreException { return 0; }
public boolean visit(int record) throws CoreException { return true; }
public void postNode(long node) throws CoreException { depth--; }
public int compare(long record) throws CoreException { return 0; }
public boolean visit(long record) throws CoreException { return true; }
public void preNode(int node) throws CoreException {
public void preNode(long node) throws CoreException {
depth++;
// collect information for checking
@ -667,25 +667,25 @@ public class BTree {
if(!full && !empty){
valid = false;
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorA"), //$NON-NLS-1$
new Object[]{new Integer(node), new Integer(indexFirstBlankKey), new Integer(indexLastNonBlankKey)});
new Object[]{new Long(node), new Integer(indexFirstBlankKey), new Integer(indexLastNonBlankKey)});
}
}
// Check: Key number constrains child numbers
if(childCount!=0 && childCount!=keyCount+1) {
valid = false;
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorB"), new Object[]{new Integer(node)}); //$NON-NLS-1$
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorB"), new Object[]{new Long(node)}); //$NON-NLS-1$
}
// the root node is excused from the remaining node constraints
if(node == db.getInt(rootPointer)) {
if(node == db.getRecPtr(rootPointer)) {
return;
}
// Check: Non-root nodes must have a keyCount within a certain range
if(keyCount < MIN_RECORDS || keyCount > MAX_RECORDS) {
valid = false;
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorC"), new Object[]{new Integer(node)}); //$NON-NLS-1$
msg += MessageFormat.format(Messages.getString("BTree.IntegrityErrorC"), new Object[]{new Long(node)}); //$NON-NLS-1$
}
// Check: All leaf nodes are at the same depth

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
@ -39,7 +39,7 @@ final class Chunk {
void read() throws CoreException {
try {
final ByteBuffer buf= ByteBuffer.wrap(fBuffer);
fDatabase.read(buf, fSequenceNumber*Database.CHUNK_SIZE);
fDatabase.read(buf, (long)fSequenceNumber*Database.CHUNK_SIZE);
} catch (IOException e) {
throw new CoreException(new DBStatus(e));
}
@ -48,84 +48,141 @@ final class Chunk {
void flush() throws CoreException {
try {
final ByteBuffer buf= ByteBuffer.wrap(fBuffer);
fDatabase.write(buf, fSequenceNumber*Database.CHUNK_SIZE);
fDatabase.write(buf, (long)fSequenceNumber*Database.CHUNK_SIZE);
} catch (IOException e) {
throw new CoreException(new DBStatus(e));
}
fDirty= false;
}
private static int recPtrToIndex( final long offset ) {
return (int)(offset & Database.OFFSET_IN_CHUNK_MASK );
}
public void putByte(final int offset, final byte value) {
public void putByte(final long offset, final byte value) {
assert fLocked;
fDirty= true;
fBuffer[offset & Database.OFFSET_IN_CHUNK_MASK]= value;
fBuffer[recPtrToIndex( offset )]= value;
}
public byte getByte(final int offset) {
return fBuffer[offset & Database.OFFSET_IN_CHUNK_MASK];
public byte getByte(final long offset) {
return fBuffer[recPtrToIndex( offset )];
}
public byte[] getBytes(final int offset, final int length) {
public byte[] getBytes(final long offset, final int length) {
final byte[] bytes = new byte[length];
System.arraycopy(fBuffer, offset & Database.OFFSET_IN_CHUNK_MASK, bytes, 0, length);
System.arraycopy(fBuffer, recPtrToIndex( offset ), bytes, 0, length);
return bytes;
}
public void putBytes(final int offset, final byte[] bytes) {
public void putBytes(final long offset, final byte[] bytes) {
assert fLocked;
fDirty= true;
System.arraycopy(bytes, 0, fBuffer, offset & Database.OFFSET_IN_CHUNK_MASK, bytes.length);
System.arraycopy(bytes, 0, fBuffer, recPtrToIndex( offset ), bytes.length);
}
public void putInt(final int offset, final int value) {
public void putInt(final long offset, final int value) {
assert fLocked;
fDirty= true;
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
int idx= recPtrToIndex( offset );
fBuffer[idx]= (byte)(value >> 24);
fBuffer[++idx]= (byte)(value >> 16);
fBuffer[++idx]= (byte)(value >> 8);
fBuffer[++idx]= (byte)(value);
}
public int getInt(final int offset) {
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
public int getInt(final long offset) {
int idx= recPtrToIndex( offset );
return ((fBuffer[idx] & 0xff) << 24) |
((fBuffer[++idx] & 0xff) << 16) |
((fBuffer[++idx] & 0xff) << 8) |
((fBuffer[++idx] & 0xff) << 0);
}
public void put3ByteUnsignedInt(final int offset, final int value) {
/*
* A Record Pointer is a pointer as returned by Database.malloc().
* This is a pointer to a block + BLOCK_HEADER_SIZE.
*
* A free Record Pointer is a pointer to a raw block, i.e. the
* pointer is not moved past the BLOCK_HEADER_SIZE.
*/
public void putRecPtr(final long offset, final long value) {
if (!fDatabase.usesDensePointers()) {
putFreeRecPtr(offset, value);
} else {
putFreeRecPtr(offset, value == 0 ? value : value - Database.BLOCK_HEADER_SIZE);
}
return;
}
public void putFreeRecPtr(final long offset, final long value) {
if (!fDatabase.usesDensePointers()) {
putInt(offset, (int) value);
return;
}
/*
* This assert verifies the alignment. We expect the low bits to be clear.
*/
assert (value & (Database.BLOCK_SIZE_DELTA - 1)) == 0;
putInt(offset, (int) (value >> Database.BLOCK_SIZE_DELTA_BITS));
}
public long getRecPtr(final long offset) {
if (!fDatabase.usesDensePointers()) {
return getInt(offset);
}
long address = getFreeRecPtr(offset);
return address != 0 ? (address + Database.BLOCK_HEADER_SIZE) : address;
}
public long getFreeRecPtr(final long offset) {
int value = getInt(offset);
if (!fDatabase.usesDensePointers()) {
return value;
}
/*
* We need to properly manage the integer that was read. The value will be sign-extended
* so if the most significant bit is set, the resulting long will look negative. By
* masking it with ((long)1 << 32) - 1 we remove all the sign-extended bits and just
* have an unsigned 32-bit value as a long. This gives us one more useful bit in the
* stored record pointers.
*/
long address = value & (((long) 1 << Integer.SIZE) - 1);
return address << Database.BLOCK_SIZE_DELTA_BITS;
}
public void put3ByteUnsignedInt(final long offset, final int value) {
assert fLocked;
fDirty= true;
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
int idx= recPtrToIndex( offset );
fBuffer[idx]= (byte)(value >> 16);
fBuffer[++idx]= (byte)(value >> 8);
fBuffer[++idx]= (byte)(value);
}
public int get3ByteUnsignedInt(final int offset) {
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
public int get3ByteUnsignedInt(final long offset) {
int idx= recPtrToIndex( offset );
return ((fBuffer[idx] & 0xff) << 16) |
((fBuffer[++idx] & 0xff) << 8) |
((fBuffer[++idx] & 0xff) << 0);
}
public void putShort(final int offset, final short value) {
public void putShort(final long offset, final short value) {
assert fLocked;
fDirty= true;
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
int idx= recPtrToIndex( offset );
fBuffer[idx]= (byte)(value >> 8);
fBuffer[++idx]= (byte)(value);
}
public short getShort(final int offset) {
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
public short getShort(final long offset) {
int idx= recPtrToIndex( offset );
return (short) (((fBuffer[idx] << 8) | (fBuffer[++idx] & 0xff)));
}
public long getLong(final int offset) {
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
public long getLong(final long offset) {
int idx= recPtrToIndex( offset );
return ((((long)fBuffer[idx] & 0xff) << 56) |
(((long)fBuffer[++idx] & 0xff) << 48) |
(((long)fBuffer[++idx] & 0xff) << 40) |
@ -136,10 +193,10 @@ final class Chunk {
(((long)fBuffer[++idx] & 0xff) << 0));
}
public void putLong(final int offset, final long value) {
public void putLong(final long offset, final long value) {
assert fLocked;
fDirty= true;
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
int idx= recPtrToIndex( offset );
fBuffer[idx]= (byte)(value >> 56);
fBuffer[++idx]= (byte)(value >> 48);
@ -151,29 +208,29 @@ final class Chunk {
fBuffer[++idx]= (byte)(value);
}
public void putChar(final int offset, final char value) {
public void putChar(final long offset, final char value) {
assert fLocked;
fDirty= true;
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
int idx= recPtrToIndex( offset );
fBuffer[idx]= (byte)(value >> 8);
fBuffer[++idx]= (byte)(value);
}
public char getChar(final int offset) {
int idx= offset & Database.OFFSET_IN_CHUNK_MASK;
public char getChar(final long offset) {
int idx= recPtrToIndex( offset );
return (char) (((fBuffer[idx] << 8) | (fBuffer[++idx] & 0xff)));
}
public void getCharArray(final int offset, final char[] result) {
public void getCharArray(final long offset, final char[] result) {
final ByteBuffer buf= ByteBuffer.wrap(fBuffer);
buf.position(offset & Database.OFFSET_IN_CHUNK_MASK);
buf.position(recPtrToIndex( offset ));
buf.asCharBuffer().get(result);
}
void clear(final int offset, final int length) {
void clear(final long offset, final int length) {
assert fLocked;
fDirty= true;
int idx= (offset & Database.OFFSET_IN_CHUNK_MASK);
int idx= recPtrToIndex( offset );
final int end= idx + length;
for (; idx < end; idx++) {
fBuffer[idx]= 0;

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
@ -25,7 +25,7 @@ public class DBProperties {
protected BTree index;
protected Database db;
protected int record;
protected long record;
/**
* Allocate storage for a new DBProperties record in the specified database
@ -44,7 +44,7 @@ public class DBProperties {
* @param record
* @throws CoreException
*/
public DBProperties(Database db, int record) throws CoreException {
public DBProperties(Database db, long record) throws CoreException {
this.record= record;
this.index= new BTree(db, record + PROP_INDEX, DBProperty.getComparator(db));
this.db= db;
@ -127,10 +127,10 @@ public class DBProperties {
*/
public void clear() throws CoreException {
index.accept(new IBTreeVisitor(){
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
new DBProperty(db, record).delete();
return false; // there should never be duplicates
}
@ -148,7 +148,7 @@ public class DBProperties {
db.free(record);
}
public int getRecord() {
public long getRecord() {
return record;
}
@ -159,9 +159,9 @@ public class DBProperties {
static final int RECORD_SIZE = 8;
Database db;
int record;
long record;
public int getRecord() {
public long getRecord() {
return record;
}
@ -178,8 +178,8 @@ public class DBProperties {
IString dbkey= db.newString(key);
IString dbvalue= db.newString(value);
this.record= db.malloc(RECORD_SIZE);
db.putInt(record + KEY, dbkey.getRecord());
db.putInt(record + VALUE, dbvalue.getRecord());
db.putRecPtr(record + KEY, dbkey.getRecord());
db.putRecPtr(record + VALUE, dbvalue.getRecord());
this.db= db;
}
@ -189,24 +189,24 @@ public class DBProperties {
* @param db
* @param record
*/
DBProperty(Database db, int record) {
DBProperty(Database db, long record) {
this.record= record;
this.db= db;
}
public IString getKey() throws CoreException {
return db.getString(db.getInt(record + KEY));
return db.getString(db.getRecPtr(record + KEY));
}
public IString getValue() throws CoreException {
return db.getString(db.getInt(record + VALUE));
return db.getString(db.getRecPtr(record + VALUE));
}
public static IBTreeComparator getComparator(final Database db) {
return new IBTreeComparator() {
public int compare(int record1, int record2) throws CoreException {
IString left= db.getString(db.getInt(record1 + KEY));
IString right= db.getString(db.getInt(record2 + KEY));
public int compare(long record1, long record2) throws CoreException {
IString left= db.getString(db.getRecPtr(record1 + KEY));
IString right= db.getString(db.getRecPtr(record2 + KEY));
return left.compare(right, true);
}
};
@ -215,10 +215,10 @@ public class DBProperties {
public static DBProperty search(final Database db, final BTree index, final String key) throws CoreException {
final DBProperty[] result= new DBProperty[1];
index.accept(new IBTreeVisitor(){
public int compare(int record) throws CoreException {
return db.getString(db.getInt(record + KEY)).compare(key, true);
public int compare(long record) throws CoreException {
return db.getString(db.getRecPtr(record + KEY)).compare(key, true);
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
result[0] = new DBProperty(db, record);
return false; // there should never be duplicates
}
@ -229,10 +229,10 @@ public class DBProperties {
public static Set<String> getKeySet(final Database db, final BTree index) throws CoreException {
final Set<String> result= new HashSet<String>();
index.accept(new IBTreeVisitor(){
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
result.add(new DBProperty(db, record).getKey().getString());
return true; // there should never be duplicates
}
@ -241,8 +241,8 @@ public class DBProperties {
}
public void delete() throws CoreException {
db.getString(db.getInt(record + KEY)).delete();
db.getString(db.getInt(record + VALUE)).delete();
db.getString(db.getRecPtr(record + KEY)).delete();
db.getString(db.getRecPtr(record + VALUE)).delete();
db.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
@ -24,9 +24,11 @@ import java.nio.channels.FileChannel;
import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
/**
@ -38,7 +40,7 @@ import org.eclipse.core.runtime.Status;
/*
* The file encapsulated is divided into Chunks of size CHUNK_SIZE, and a table of contents
* mapping chunk index to chunk address is maintained. Chunk structure exists only conceptually -
* its not a structure that appears in the file.
* it is not a structure that appears in the file.
*
* ===== The first chunk is used by Database itself for house-keeping purposes and has structure
*
@ -56,9 +58,9 @@ import org.eclipse.core.runtime.Status;
*
* offset content
* _____________________________
* 0 | size of block (negative indicates in use, positive unused)
* PREV_OFFSET | pointer to prev block (of same size)
* NEXT_OFFSET | pointer to next block (of same size)
* 0 | size of block (negative indicates in use, positive unused) (2 bytes)
* PREV_OFFSET | pointer to prev block (of same size) (only in free blocks)
* NEXT_OFFSET | pointer to next block (of same size) (only in free blocks)
*
*/
public class Database {
@ -67,7 +69,8 @@ public class Database {
public static final int CHUNK_SIZE = 1024 * 4;
public static final int OFFSET_IN_CHUNK_MASK= CHUNK_SIZE-1;
public static final int BLOCK_HEADER_SIZE= 2;
public static final int BLOCK_SIZE_DELTA= 8;
public static final int BLOCK_SIZE_DELTA_BITS = 3;
public static final int BLOCK_SIZE_DELTA= 1 << BLOCK_SIZE_DELTA_BITS;
public static final int MIN_BLOCK_DELTAS = 2; // a block must at least be 2 + 2*4 bytes to link the free blocks.
public static final int MAX_BLOCK_DELTAS = CHUNK_SIZE/BLOCK_SIZE_DELTA;
public static final int MAX_MALLOC_SIZE = MAX_BLOCK_DELTAS*BLOCK_SIZE_DELTA - BLOCK_HEADER_SIZE;
@ -88,6 +91,8 @@ public class Database {
private int fVersion;
private final Chunk fHeaderChunk;
private Chunk[] fChunks;
private int fChunksUsed;
private int fChunksAllocated;
private ChunkCache fCache;
private long malloced;
@ -116,11 +121,13 @@ public class Database {
if (nChunksOnDisk <= 0) {
fVersion= version;
fChunks= new Chunk[1];
fChunksUsed = fChunksAllocated = fChunks.length;
}
else {
fHeaderChunk.read();
fVersion= fHeaderChunk.getInt(VERSION_OFFSET);
fChunks = new Chunk[nChunksOnDisk]; // chunk[0] is unused.
fChunksUsed = fChunksAllocated = nChunksOnDisk;
}
} catch (IOException e) {
throw new CoreException(new DBStatus(e));
@ -131,11 +138,11 @@ public class Database {
fFile = new RandomAccessFile(fLocation, fReadOnly ? "r" : "rw"); //$NON-NLS-1$ //$NON-NLS-2$
}
void read(ByteBuffer buf, int i) throws IOException {
void read(ByteBuffer buf, long position) throws IOException {
int retries= 0;
do {
try {
fFile.getChannel().read(buf, i);
fFile.getChannel().read(buf, position);
return;
}
catch (ClosedChannelException e) {
@ -145,11 +152,11 @@ public class Database {
} while (true);
}
void write(ByteBuffer buf, int i) throws IOException {
void write(ByteBuffer buf, long position) throws IOException {
int retries= 0;
do {
try {
fFile.getChannel().write(buf, i);
fFile.getChannel().write(buf, position);
return;
}
catch (ClosedChannelException e) {
@ -184,7 +191,7 @@ public class Database {
}
}
public int getVersion() throws CoreException {
public int getVersion() {
return fVersion;
}
@ -207,6 +214,7 @@ public class Database {
fHeaderChunk.clear(0, CHUNK_SIZE);
// chunks have been removed from the cache, so we may just reset the array of chunks.
fChunks = new Chunk[] {null};
fChunksUsed = fChunksAllocated = fChunks.length;
try {
fHeaderChunk.flush(); // zero out header chunk
fFile.getChannel().truncate(CHUNK_SIZE); // truncate database
@ -215,6 +223,21 @@ public class Database {
CCorePlugin.log(e);
}
malloced = freed = 0;
/*
* This is for debugging purposes in order to simulate having a very large PDOM database.
* This will set aside the specified number of chunks.
* Nothing uses these chunks so subsequent allocations come after these fillers.
* The special function createNewChunks allocates all of these chunks at once.
* 524288 for a file starting at 2G
* 8388608 for a file starting at 32G
*
*/
long setasideChunks = Long.getLong("org.eclipse.cdt.core.parser.pdom.dense.recptr.setaside.chunks", 0 ); //$NON-NLS-1$
if( setasideChunks != 0 ) {
setVersion( getVersion() );
createNewChunks( (int) setasideChunks );
flush();
}
}
private void removeChunksFromCache() {
@ -234,13 +257,16 @@ public class Database {
* Return the Chunk that contains the given offset.
* @throws CoreException
*/
public Chunk getChunk(int offset) throws CoreException {
public Chunk getChunk(long offset) throws CoreException {
if (offset < CHUNK_SIZE) {
return fHeaderChunk;
}
long long_index = offset / CHUNK_SIZE;
assert long_index < Integer.MAX_VALUE;
synchronized(fCache) {
assert fLocked;
final int index = offset / CHUNK_SIZE;
final int index = (int)long_index;
Chunk chunk= fChunks[index];
if (chunk == null) {
cacheMisses++;
@ -258,12 +284,9 @@ public class Database {
/**
* Allocate a block out of the database.
*/
public int malloc(final int datasize) throws CoreException {
public long malloc(final int datasize) throws CoreException {
assert fExclusiveLock;
if (datasize < 0 || datasize > MAX_MALLOC_SIZE)
// Too Big
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0,
CCorePlugin.getResourceString("pdom.requestTooLarge"), new IllegalArgumentException())); //$NON-NLS-1$
assert datasize >=0 && datasize <= MAX_MALLOC_SIZE;
int needDeltas= (datasize + BLOCK_HEADER_SIZE + BLOCK_SIZE_DELTA - 1) / BLOCK_SIZE_DELTA;
if (needDeltas < MIN_BLOCK_DELTAS) {
@ -271,7 +294,7 @@ public class Database {
}
// Which block size
int freeblock = 0;
long freeblock = 0;
int useDeltas;
for (useDeltas= needDeltas; useDeltas <= MAX_BLOCK_DELTAS; useDeltas++) {
freeblock = getFirstBlock(useDeltas*BLOCK_SIZE_DELTA);
@ -309,56 +332,114 @@ public class Database {
return freeblock + BLOCK_HEADER_SIZE;
}
private int createNewChunk() throws CoreException {
private long createNewChunk() throws CoreException {
assert fExclusiveLock;
synchronized (fCache) {
final int oldLen= fChunks.length;
final Chunk chunk= new Chunk(this, oldLen);
chunk.fDirty= true;
final int newChunkIndex = fChunksUsed; // fChunks.length;
final Chunk chunk = new Chunk(this, newChunkIndex);
chunk.fDirty = true;
if (newChunkIndex >= fChunksAllocated) {
int increment = Math.max(1024, fChunksAllocated/20);
Chunk[] newchunks = new Chunk[fChunksAllocated + increment];
System.arraycopy(fChunks, 0, newchunks, 0, fChunksAllocated);
fChunks = newchunks;
fChunksAllocated += increment;
}
fChunksUsed += 1;
fChunks[newChunkIndex] = chunk;
Chunk[] newchunks = new Chunk[oldLen+1];
System.arraycopy(fChunks, 0, newchunks, 0, oldLen);
newchunks[oldLen]= chunk;
fChunks= newchunks;
fCache.add(chunk, true);
return oldLen * CHUNK_SIZE;
long address = (long) newChunkIndex * CHUNK_SIZE;
/*
* non-dense pointers are at most 31 bits dense pointers are at most 35 bits Check the sizes here
* and throw an exception if the address is too large. By throwing the CoreException with the
* special status, the indexing operation should be stopped. This is desired since generally, once
* the max size is exceeded, there are lots of errors.
*/
long max_size;
if (usesDensePointers()) {
max_size = ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS));
} else {
max_size = ((long) 1 << (Integer.SIZE - 1));
}
if (address >= max_size) {
Object bindings[] = { this.getLocation().getAbsolutePath(), max_size };
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID,
CCorePlugin.STATUS_PDOM_TOO_LARGE, NLS.bind(CCorePlugin
.getResourceString("pdom.DatabaseTooLarge"), bindings), null)); //$NON-NLS-1$
}
return address;
}
}
private int getFirstBlock(int blocksize) throws CoreException {
/**
* Returns whether this database uses dense pointers.
*/
boolean usesDensePointers() {
return getVersion() >= PDOM.DENSE_RECPTR_VERSION;
}
/**
* for testing purposes, only.
*/
private long createNewChunks(int numChunks) throws CoreException {
assert fExclusiveLock;
synchronized (fCache) {
final int oldLen= fChunks.length;
Chunk[] newchunks = new Chunk[oldLen+numChunks];
System.arraycopy(fChunks, 0, newchunks, 0, oldLen);
for( int i = oldLen; i < oldLen + numChunks; i++ ) {
newchunks[i]= null;
}
final Chunk chunk= new Chunk(this, oldLen + numChunks - 1);
chunk.fDirty= true;
newchunks[ oldLen + numChunks - 1 ] = chunk;
fChunks= newchunks;
fCache.add(chunk, true);
fChunksAllocated=oldLen+numChunks;
fChunksUsed=oldLen+numChunks;
return (long)(oldLen + numChunks - 1) * CHUNK_SIZE;
}
}
private long getFirstBlock(int blocksize) throws CoreException {
assert fLocked;
return fHeaderChunk.getInt((blocksize/BLOCK_SIZE_DELTA - MIN_BLOCK_DELTAS + 1) * INT_SIZE);
return fHeaderChunk.getFreeRecPtr((blocksize/BLOCK_SIZE_DELTA - MIN_BLOCK_DELTAS + 1) * INT_SIZE);
}
private void setFirstBlock(int blocksize, int block) throws CoreException {
private void setFirstBlock(int blocksize, long block) throws CoreException {
assert fExclusiveLock;
fHeaderChunk.putInt((blocksize/BLOCK_SIZE_DELTA - MIN_BLOCK_DELTAS + 1) * INT_SIZE, block);
fHeaderChunk.putFreeRecPtr((blocksize/BLOCK_SIZE_DELTA - MIN_BLOCK_DELTAS + 1) * INT_SIZE, block);
}
private void removeBlock(Chunk chunk, int blocksize, int block) throws CoreException {
private void removeBlock(Chunk chunk, int blocksize, long block) throws CoreException {
assert fExclusiveLock;
int prevblock = chunk.getInt(block + BLOCK_PREV_OFFSET);
int nextblock = chunk.getInt(block + BLOCK_NEXT_OFFSET);
long prevblock = chunk.getFreeRecPtr(block + BLOCK_PREV_OFFSET);
long nextblock = chunk.getFreeRecPtr(block + BLOCK_NEXT_OFFSET);
if (prevblock != 0)
putInt(prevblock + BLOCK_NEXT_OFFSET, nextblock);
putFreeRecPtr(prevblock + BLOCK_NEXT_OFFSET, nextblock);
else // we were the head
setFirstBlock(blocksize, nextblock);
if (nextblock != 0)
putInt(nextblock + BLOCK_PREV_OFFSET, prevblock);
putFreeRecPtr(nextblock + BLOCK_PREV_OFFSET, prevblock);
}
private void addBlock(Chunk chunk, int blocksize, int block) throws CoreException {
private void addBlock(Chunk chunk, int blocksize, long block) throws CoreException {
assert fExclusiveLock;
// Mark our size
chunk.putShort(block, (short) blocksize);
// Add us to the head of the list
int prevfirst = getFirstBlock(blocksize);
chunk.putInt(block + BLOCK_PREV_OFFSET, 0);
chunk.putInt(block + BLOCK_NEXT_OFFSET, prevfirst);
long prevfirst = getFirstBlock(blocksize);
chunk.putFreeRecPtr(block + BLOCK_PREV_OFFSET, 0);
chunk.putFreeRecPtr(block + BLOCK_NEXT_OFFSET, prevfirst);
if (prevfirst != 0)
putInt(prevfirst + BLOCK_PREV_OFFSET, block);
putFreeRecPtr(prevfirst + BLOCK_PREV_OFFSET, block);
setFirstBlock(blocksize, block);
}
@ -367,10 +448,10 @@ public class Database {
*
* @param offset
*/
public void free(int offset) throws CoreException {
public void free(long offset) throws CoreException {
assert fExclusiveLock;
// TODO - look for opportunities to merge blocks
int block = offset - BLOCK_HEADER_SIZE;
long block = offset - BLOCK_HEADER_SIZE;
Chunk chunk = getChunk(block);
int blocksize = - chunk.getShort(block);
if (blocksize < 0)
@ -380,51 +461,67 @@ public class Database {
freed += blocksize;
}
public void putByte(int offset, byte value) throws CoreException {
public void putByte(long offset, byte value) throws CoreException {
getChunk(offset).putByte(offset, value);
}
public byte getByte(int offset) throws CoreException {
public byte getByte(long offset) throws CoreException {
return getChunk(offset).getByte(offset);
}
public void putInt(int offset, int value) throws CoreException {
public void putInt(long offset, int value) throws CoreException {
getChunk(offset).putInt(offset, value);
}
public int getInt(int offset) throws CoreException {
public int getInt(long offset) throws CoreException {
return getChunk(offset).getInt(offset);
}
public void put3ByteUnsignedInt(int offset, int value) throws CoreException {
public void putRecPtr(long offset, long value) throws CoreException {
getChunk(offset).putRecPtr(offset, value);
}
public long getRecPtr(long offset) throws CoreException {
return getChunk(offset).getRecPtr(offset);
}
private void putFreeRecPtr(long offset, long value) throws CoreException {
getChunk(offset).putFreeRecPtr(offset, value);
}
private long getFreeRecPtr(long offset) throws CoreException {
return getChunk(offset).getFreeRecPtr(offset);
}
public void put3ByteUnsignedInt(long offset, int value) throws CoreException {
getChunk(offset).put3ByteUnsignedInt(offset, value);
}
public int get3ByteUnsignedInt(int offset) throws CoreException {
public int get3ByteUnsignedInt(long offset) throws CoreException {
return getChunk(offset).get3ByteUnsignedInt(offset);
}
public void putShort(int offset, short value) throws CoreException {
public void putShort(long offset, short value) throws CoreException {
getChunk(offset).putShort(offset, value);
}
public short getShort(int offset) throws CoreException {
public short getShort(long offset) throws CoreException {
return getChunk(offset).getShort(offset);
}
public void putLong(int offset, long value) throws CoreException {
public void putLong(long offset, long value) throws CoreException {
getChunk(offset).putLong(offset, value);
}
public long getLong(int offset) throws CoreException {
public long getLong(long offset) throws CoreException {
return getChunk(offset).getLong(offset);
}
public void putChar(int offset, char value) throws CoreException {
public void putChar(long offset, char value) throws CoreException {
getChunk(offset).putChar(offset, value);
}
public char getChar(int offset) throws CoreException {
public char getChar(long offset) throws CoreException {
return getChunk(offset).getChar(offset);
}
@ -442,7 +539,7 @@ public class Database {
return new ShortString(this, chars);
}
public IString getString(int offset) throws CoreException {
public IString getString(long offset) throws CoreException {
int length = getInt(offset);
if (length > ShortString.MAX_LENGTH)
return new LongString(this, offset);
@ -454,17 +551,17 @@ public class Database {
* For debugging purposes, only.
*/
public void reportFreeBlocks() throws CoreException {
System.out.println("Allocated size: " + fChunks.length * CHUNK_SIZE); //$NON-NLS-1$
System.out.println("Allocated size: " + fChunksUsed * CHUNK_SIZE); //$NON-NLS-1$
System.out.println("malloc'ed: " + malloced); //$NON-NLS-1$
System.out.println("free'd: " + freed); //$NON-NLS-1$
System.out.println("wasted: " + (fChunks.length * CHUNK_SIZE - (malloced - freed))); //$NON-NLS-1$
System.out.println("wasted: " + (fChunksUsed * CHUNK_SIZE - (malloced - freed))); //$NON-NLS-1$
System.out.println("Free blocks"); //$NON-NLS-1$
for (int bs = MIN_BLOCK_DELTAS*BLOCK_SIZE_DELTA; bs <= CHUNK_SIZE; bs += BLOCK_SIZE_DELTA) {
int count = 0;
int block = getFirstBlock(bs);
long block = getFirstBlock(bs);
while (block != 0) {
++count;
block = getInt(block + BLOCK_NEXT_OFFSET);
block = getFreeRecPtr(block + BLOCK_NEXT_OFFSET);
}
if (count != 0)
System.out.println("Block size: " + bs + "=" + count); //$NON-NLS-1$ //$NON-NLS-2$
@ -486,6 +583,7 @@ public class Database {
fHeaderChunk.clear(0, CHUNK_SIZE);
fHeaderChunk.fDirty= false;
fChunks= new Chunk[] {null};
fChunksUsed = fChunksAllocated = fChunks.length;
try {
fFile.close();
} catch (IOException e) {
@ -535,7 +633,7 @@ public class Database {
try {
ArrayList<Chunk> dirtyChunks= new ArrayList<Chunk>();
synchronized (fCache) {
for (int i= 1; i < fChunks.length; i++) {
for (int i= 1; i < fChunksUsed; i++) {
Chunk chunk= fChunks[i];
if (chunk != null) {
if (chunk.fCacheIndex < 0) {
@ -589,7 +687,7 @@ public class Database {
// be careful as other readers may access chunks concurrently
ArrayList<Chunk> dirtyChunks= new ArrayList<Chunk>();
synchronized (fCache) {
for (int i= 1; i < fChunks.length ; i++) {
for (int i= 1; i < fChunksUsed ; i++) {
Chunk chunk= fChunks[i];
if (chunk != null && chunk.fDirty) {
dirtyChunks.add(chunk);
@ -667,4 +765,5 @@ public class Database {
}
return 0;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 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,6 +21,6 @@ public interface IBTreeComparator {
/**
* Compare two records. Used for insert.
*/
public abstract int compare(int record1, int record2) throws CoreException;
public abstract int compare(long record1, long record2) throws CoreException;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2006 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
@ -29,7 +29,7 @@ public interface IBTreeVisitor {
* @return -1 if record < key, 0 if record == key, 1 if record > key
* @throws CoreException
*/
public abstract int compare(int record) throws CoreException;
public abstract int compare(long record) throws CoreException;
/**
* Visit a given record and return whether to continue or not.
@ -37,6 +37,6 @@ public interface IBTreeVisitor {
* @return <code>true</code> to continue the visit, <code>false</code> to abort it.
* @throws CoreException
*/
public abstract boolean visit(int record) throws CoreException;
public abstract boolean visit(long record) throws CoreException;
}

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
@ -25,7 +25,7 @@ public interface IString {
/**
* Get the offset of this IString record in the PDOM
*/
public int getRecord();
public long getRecord();
// strcmp equivalents
/**

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
@ -22,7 +22,7 @@ import org.eclipse.core.runtime.CoreException;
*/
public class ListItem {
protected final Database db;
protected final int record;
protected final long record;
protected static final int NEXT = 0;
protected static final int PREV = 4;
@ -30,7 +30,7 @@ public class ListItem {
protected static final int RECORD_SIZE = 12;
public ListItem(Database db, int record) {
public ListItem(Database db, long record) {
this.db = db;
this.record = record;
}
@ -40,7 +40,7 @@ public class ListItem {
this.record = db.malloc(RECORD_SIZE);
}
public int getRecord() {
public long getRecord() {
return record;
}
@ -54,29 +54,29 @@ public class ListItem {
return false;
}
public void setItem(int item) throws CoreException {
db.putInt(record + ITEM, item);
public void setItem(long item) throws CoreException {
db.putRecPtr(record + ITEM, item);
}
public int getItem() throws CoreException {
return db.getInt(record + ITEM);
public long getItem() throws CoreException {
return db.getRecPtr(record + ITEM);
}
public void setNext(ListItem next) throws CoreException {
db.putInt(record + NEXT, next.getRecord());
db.putRecPtr(record + NEXT, next.getRecord());
}
public ListItem getNext() throws CoreException {
int next = db.getInt(record + NEXT);
long next = db.getRecPtr(record + NEXT);
return next != 0 ? new ListItem(db, next) : null;
}
public void setPrev(ListItem prev) throws CoreException {
db.putInt(record + PREV, prev.getRecord());
db.putRecPtr(record + PREV, prev.getRecord());
}
public ListItem getPrev() throws CoreException {
int prev = db.getInt(record + PREV);
long prev = db.getRecPtr(record + PREV);
return prev != 0 ? new ListItem(db, prev) : null;
}

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
@ -28,7 +28,7 @@ import org.eclipse.core.runtime.CoreException;
public class LongString implements IString {
private final Database db;
private final int record;
private final long record;
private int hash;
// Additional fields of first record
@ -44,28 +44,28 @@ public class LongString implements IString {
private static final int NUM_CHARSN = (Database.MAX_MALLOC_SIZE - CHARSN) / 2;
public LongString(Database db, int record) {
public LongString(Database db, long record) {
this.db = db;
this.record = record;
}
private interface IWriter {
public void writeChars(int start, int length, int p) throws CoreException;
public void writeChars(int start, int length, long p) throws CoreException;
}
private int createString(int length, IWriter writer) throws CoreException {
private long createString(int length, IWriter writer) throws CoreException {
// write the first record
int firstRecord = db.malloc(Database.MAX_MALLOC_SIZE);
long firstRecord = db.malloc(Database.MAX_MALLOC_SIZE);
int start = 0;
db.putInt(firstRecord, length);
writer.writeChars(start, NUM_CHARS1, firstRecord + CHARS1);
// write the subsequent records
int lastNext = firstRecord + NEXT1;
long lastNext = firstRecord + NEXT1;
start += NUM_CHARS1;
while (length - start > NUM_CHARSN) {
int nextRecord = db.malloc(Database.MAX_MALLOC_SIZE);
db.putInt(lastNext, nextRecord);
long nextRecord = db.malloc(Database.MAX_MALLOC_SIZE);
db.putRecPtr(lastNext, nextRecord);
writer.writeChars(start, NUM_CHARSN, nextRecord + CHARSN);
start += NUM_CHARSN;
lastNext = nextRecord + NEXTN;
@ -73,8 +73,8 @@ public class LongString implements IString {
// Write the final record
length -= start;
int finalRecord = db.malloc(CHARSN + (length) * 2);
db.putInt(lastNext, finalRecord);
long finalRecord = db.malloc(CHARSN + (length) * 2);
db.putRecPtr(lastNext, finalRecord);
writer.writeChars(start, length, finalRecord + CHARSN);
return firstRecord;
@ -83,7 +83,7 @@ public class LongString implements IString {
public LongString(Database db, final String string) throws CoreException {
this.db = db;
this.record = createString(string.length(), new IWriter() {
public void writeChars(int start, int length, int p) throws CoreException {
public void writeChars(int start, int length, long p) throws CoreException {
for (int i = start; i < start + length; ++i) {
LongString.this.db.putChar(p, string.charAt(i));
p += 2;
@ -95,7 +95,7 @@ public class LongString implements IString {
public LongString(Database db, final char[] chars) throws CoreException {
this.db = db;
this.record = createString(chars.length, new IWriter() {
public void writeChars(int start, int length, int p) throws CoreException {
public void writeChars(int start, int length, long p) throws CoreException {
for (int i = start; i < start + length; ++i) {
LongString.this.db.putChar(p, chars[i]);
p += 2;
@ -104,19 +104,19 @@ public class LongString implements IString {
});
}
public int getRecord() {
public long getRecord() {
return record;
}
public void delete() throws CoreException {
int length = db.getInt(record + LENGTH) - NUM_CHARS1;
int nextRecord = db.getInt(record + NEXT1);
long nextRecord = db.getRecPtr(record + NEXT1);
db.free(record);
// Middle records
while (length > NUM_CHARSN) {
length -= NUM_CHARSN;
int nextnext = db.getInt(nextRecord + NEXTN);
long nextnext = db.getRecPtr(nextRecord + NEXTN);
db.free(nextRecord);
nextRecord = nextnext;
}
@ -295,13 +295,13 @@ public class LongString implements IString {
private void readChars(int length, IReader reader) throws CoreException {
// First record
int p = record + CHARS1;
long p = record + CHARS1;
for (int i = 0; i < NUM_CHARS1; ++i) {
reader.appendChar(db.getChar(p));
p += 2;
}
length -= NUM_CHARS1;
int nextRecord = db.getInt(record + NEXT1);
long nextRecord = db.getRecPtr(record + NEXT1);
// Middle records
while (length > NUM_CHARSN) {
@ -311,7 +311,7 @@ public class LongString implements IString {
p += 2;
}
length -= NUM_CHARSN;
nextRecord = db.getInt(nextRecord + NEXTN);
nextRecord = db.getRecPtr(nextRecord + NEXTN);
}
// Last record
@ -326,7 +326,7 @@ public class LongString implements IString {
* Convenience class for sequential access to LongString characters
*/
private class CharIterator {
int p;
long p;
int count;
int length;
@ -343,10 +343,10 @@ public class LongString implements IString {
throw new NoSuchElementException();
}
if(count == NUM_CHARS1) {
p = db.getInt(record + NEXT1) + CHARSN;
p = db.getRecPtr(record + NEXT1) + CHARSN;
}
if(count > NUM_CHARS1 && ((count-NUM_CHARS1) % NUM_CHARSN)==0) {
p = db.getInt(p-(NUM_CHARSN*2)-4) + CHARSN;
p = db.getRecPtr(p-(NUM_CHARSN*2)-4) + CHARSN;
}
return result;
}

View file

@ -24,14 +24,14 @@ import org.eclipse.core.runtime.CoreException;
*
*/
public class PDOMNodeLinkedList {
private int offset;
private long offset;
private PDOMLinkage linkage;
private boolean allowsNull;
private static final int FIRST_MEMBER = 0;
protected static final int RECORD_SIZE = 4;
public PDOMNodeLinkedList(PDOMLinkage linkage, int offset, boolean allowsNulls) {
public PDOMNodeLinkedList(PDOMLinkage linkage, long offset, boolean allowsNulls) {
this.offset = offset;
this.linkage = linkage;
this.allowsNull = allowsNulls;
@ -43,7 +43,7 @@ public class PDOMNodeLinkedList {
* @param linkage
* @param offset
*/
public PDOMNodeLinkedList(PDOMLinkage linkage, int offset) {
public PDOMNodeLinkedList(PDOMLinkage linkage, long offset) {
this(linkage, offset, false);
}
@ -53,14 +53,14 @@ public class PDOMNodeLinkedList {
public void accept(IPDOMVisitor visitor) throws CoreException {
Database db = linkage.getDB();
int firstItem = db.getInt(offset + FIRST_MEMBER);
long firstItem = db.getRecPtr(offset + FIRST_MEMBER);
if (firstItem == 0)
return;
int item = firstItem;
long item = firstItem;
do {
PDOMNode node;
final int record= db.getInt(item + ListItem.ITEM);
final long record= db.getRecPtr(item + ListItem.ITEM);
if (record == 0) {
if (!allowsNull) {
throw new NullPointerException();
@ -73,12 +73,12 @@ public class PDOMNodeLinkedList {
node.accept(visitor);
}
visitor.leave(node);
} while ((item = db.getInt(item + ListItem.NEXT)) != firstItem);
} while ((item = db.getRecPtr(item + ListItem.NEXT)) != firstItem);
}
private ListItem getFirstMemberItem() throws CoreException {
Database db = linkage.getDB();
int item = db.getInt(offset + FIRST_MEMBER);
long item = db.getRecPtr(offset + FIRST_MEMBER);
return item != 0 ? new ListItem(db, item) : null;
}
@ -90,14 +90,14 @@ public class PDOMNodeLinkedList {
*/
public PDOMNode getNodeAt(int pos) throws CoreException {
Database db = linkage.getDB();
int firstItem = db.getInt(offset + FIRST_MEMBER);
long firstItem = db.getRecPtr(offset + FIRST_MEMBER);
if (firstItem == 0) {
return null;
}
int item = firstItem;
long item = firstItem;
do {
if (--pos < 0) {
int record = db.getInt(item + ListItem.ITEM);
long record = db.getRecPtr(item + ListItem.ITEM);
if (record == 0) {
if (!allowsNull) {
throw new NullPointerException();
@ -107,7 +107,7 @@ public class PDOMNodeLinkedList {
return linkage.getNode(record);
}
}
} while ((item = db.getInt(item + ListItem.NEXT)) != firstItem);
} while ((item = db.getRecPtr(item + ListItem.NEXT)) != firstItem);
return null;
}
@ -115,7 +115,7 @@ public class PDOMNodeLinkedList {
addMember(allowsNull && member==null ? 0 : member.getRecord());
}
protected void addMember(int record) throws CoreException {
protected void addMember(long record) throws CoreException {
Database db = linkage.getDB();
ListItem firstMember = getFirstMemberItem();
if (firstMember == null) {
@ -123,7 +123,7 @@ public class PDOMNodeLinkedList {
firstMember.setItem(record);
firstMember.setNext(firstMember);
firstMember.setPrev(firstMember);
db.putInt(offset + FIRST_MEMBER, firstMember.getRecord());
db.putRecPtr(offset + FIRST_MEMBER, firstMember.getRecord());
} else {
ListItem newMember = new ListItem(db);
newMember.setItem(record);
@ -138,7 +138,7 @@ public class PDOMNodeLinkedList {
public void deleteListItems() throws CoreException {
ListItem item = getFirstMemberItem();
if (item != null) {
int firstRec= item.record;
long firstRec= item.record;
do {
ListItem nextItem= item.getNext();

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
@ -24,7 +24,7 @@ import org.eclipse.core.runtime.CoreException;
public class ShortString implements IString {
private final Database db;
private final int record;
private final long record;
private int hash;
private static final int LENGTH = 0;
@ -32,7 +32,7 @@ public class ShortString implements IString {
public static final int MAX_LENGTH = (Database.MAX_MALLOC_SIZE - CHARS) / 2;
public ShortString(Database db, int offset) {
public ShortString(Database db, long offset) {
this.db = db;
this.record = offset;
}
@ -44,7 +44,7 @@ public class ShortString implements IString {
Chunk chunk = db.getChunk(record);
chunk.putInt(record + LENGTH, (char)chars.length);
int n = chars.length;
int p = record + CHARS;
long p = record + CHARS;
for (int i = 0; i < n; ++i) {
chunk.putChar(p, chars[i]);
p += 2;
@ -58,14 +58,14 @@ public class ShortString implements IString {
Chunk chunk = db.getChunk(record);
chunk.putInt(record + LENGTH, string.length());
int n = string.length();
int p = record + CHARS;
long p = record + CHARS;
for (int i = 0; i < n; ++i) {
chunk.putChar(p, string.charAt(i));
p += 2;
}
}
public int getRecord() {
public long getRecord() {
return record;
}
@ -104,8 +104,8 @@ public class ShortString implements IString {
if (n1 != n2)
return false;
int p1 = record + CHARS;
int p2 = string.record + CHARS;
long p1 = record + CHARS;
long p2 = string.record + CHARS;
for (int i = 0; i < n1; ++i) {
if (chunk1.getChar(p1) != chunk2.getChar(p2))
return false;
@ -123,7 +123,7 @@ public class ShortString implements IString {
return false;
// Check each character
int p = record + CHARS;
long p = record + CHARS;
for (int i = 0; i < n; ++i) {
if (chunk.getChar(p) != chars[i])
return false;
@ -140,7 +140,7 @@ public class ShortString implements IString {
return false;
// Check each character
int p = record + CHARS;
long p = record + CHARS;
for (int i = 0; i < n; ++i) {
if (chunk.getChar(p) != string.charAt(i))
return false;
@ -178,9 +178,9 @@ public class ShortString implements IString {
public int compare(char[] other, boolean caseSensitive) throws CoreException {
Chunk chunk = db.getChunk(record);
int i1 = record + CHARS;
long i1 = record + CHARS;
int i2 = 0;
int n1 = i1 + chunk.getInt(record + LENGTH) * 2;
long n1 = i1 + chunk.getInt(record + LENGTH) * 2;
int n2 = other.length;
while (i1 < n1 && i2 < n2) {
@ -213,10 +213,10 @@ public class ShortString implements IString {
Chunk chunk1 = db.getChunk(record);
Chunk chunk2 = other.db.getChunk(other.record);
int i1 = record + CHARS;
int i2 = other.record + CHARS;
int n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
int n2 = i2 + chunk2.getInt(other.record + LENGTH) * 2;
long i1 = record + CHARS;
long i2 = other.record + CHARS;
long n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
long n2 = i2 + chunk2.getInt(other.record + LENGTH) * 2;
while (i1 < n1 && i2 < n2) {
int cmp= compareChars(chunk1.getChar(i1), chunk2.getChar(i2), caseSensitive);
@ -238,9 +238,9 @@ public class ShortString implements IString {
public int compare(String other, boolean caseSensitive) throws CoreException {
Chunk chunk = db.getChunk(record);
int i1 = record + CHARS;
long i1 = record + CHARS;
int i2 = 0;
int n1 = i1 + chunk.getInt(record + LENGTH) * 2;
long n1 = i1 + chunk.getInt(record + LENGTH) * 2;
int n2 = other.length();
while (i1 < n1 && i2 < n2) {
@ -275,10 +275,10 @@ public class ShortString implements IString {
Chunk chunk1 = db.getChunk(record);
Chunk chunk2 = other.db.getChunk(other.record);
int i1 = record + CHARS;
int i2 = other.record + CHARS;
int n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
int n2 = i2 + chunk2.getInt(other.record + LENGTH) * 2;
long i1 = record + CHARS;
long i2 = other.record + CHARS;
long n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
long n2 = i2 + chunk2.getInt(other.record + LENGTH) * 2;
int sensitiveCmp= 0;
while (i1 < n1 && i2 < n2) {
final char c1= chunk1.getChar(i1);
@ -313,9 +313,9 @@ public class ShortString implements IString {
public int compareCompatibleWithIgnoreCase(char[] chars) throws CoreException {
Chunk chunk1 = db.getChunk(record);
int i1 = record + CHARS;
long i1 = record + CHARS;
int i2 = 0;
int n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
long n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
int n2 = chars.length;
int sensitiveCmp= 0;
while (i1 < n1 && i2 < n2) {
@ -351,9 +351,9 @@ public class ShortString implements IString {
public int comparePrefix(char[] other, boolean caseSensitive) throws CoreException {
Chunk chunk = db.getChunk(record);
int i1 = record + CHARS;
long i1 = record + CHARS;
int i2 = 0;
int n1 = i1 + chunk.getInt(record + LENGTH) * 2;
long n1 = i1 + chunk.getInt(record + LENGTH) * 2;
int n2 = other.length;
while (i1 < n1 && i2 < n2) {
@ -372,7 +372,7 @@ public class ShortString implements IString {
}
public char charAt(int i) throws CoreException {
int ptr = record + CHARS + (i*2);
long ptr = record + CHARS + (i*2);
return db.getChar(ptr);
}

View file

@ -28,7 +28,7 @@ public class ApplyVisitor implements IBTreeVisitor, IPDOMVisitor {
this.visitor= visitor;
}
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0; // visit all nodes in a b-tree
}
@ -40,7 +40,7 @@ public class ApplyVisitor implements IBTreeVisitor, IPDOMVisitor {
return false; // don't visit children of the node
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
if (record == 0)
return true;
PDOMNode node= linkage.getNode(record);

View file

@ -34,13 +34,13 @@ public class FindBinding {
this.database= linkage.getDB();
}
public int compare(int record1, int record2) throws CoreException {
public int compare(long record1, long record2) throws CoreException {
IString nm1 = PDOMNamedNode.getDBName(database, record1);
IString nm2 = PDOMNamedNode.getDBName(database, record2);
int cmp= nm1.compareCompatibleWithIgnoreCase(nm2);
if (cmp == 0) {
int t1= PDOMBinding.getLocalToFileRec(database, record1);
int t2= PDOMBinding.getLocalToFileRec(database, record2);
long t1= PDOMBinding.getLocalToFileRec(database, record1);
long t2= PDOMBinding.getLocalToFileRec(database, record2);
if (t1 == t2) {
t1 = PDOMNode.getNodeType(database, record1);
t2 = PDOMNode.getNodeType(database, record2);
@ -55,10 +55,10 @@ public class FindBinding {
protected final PDOMLinkage fLinkage;
private final char[] fName;
private final int[] fConstants;
private final int fLocalToFile;
private final long fLocalToFile;
protected PDOMBinding fResult;
protected DefaultFindBindingVisitor(PDOMLinkage linkage, char[] name, int[] constants, int localToFile) {
protected DefaultFindBindingVisitor(PDOMLinkage linkage, char[] name, int[] constants, long localToFile) {
fLinkage = linkage;
fName = name;
fConstants = constants;
@ -66,20 +66,20 @@ public class FindBinding {
}
// IBTreeVisitor
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
final Database db = fLinkage.getDB();
IString nm1 = PDOMNamedNode.getDBName(db, record);
int cmp= nm1.compareCompatibleWithIgnoreCase(fName);
if (cmp == 0) {
int t1= PDOMBinding.getLocalToFileRec(db, record);
int t2= fLocalToFile;
long t1= PDOMBinding.getLocalToFileRec(db, record);
long t2= fLocalToFile;
cmp= t1 < t2 ? -1 : (t1 > t2 ? 1 : 0);
}
return cmp;
}
// IBTreeVisitor
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
final PDOMNamedNode nnode = (PDOMNamedNode) fLinkage.getNode(record);
if (nnode instanceof PDOMBinding) {
final PDOMBinding binding = (PDOMBinding) nnode;
@ -128,7 +128,7 @@ public class FindBinding {
}
@Override
public int compare(int record1, int record2) throws CoreException {
public int compare(long record1, long record2) throws CoreException {
int cmp= super.compare(record1, record2); // compare names
if (cmp == 0) { // any order will do.
if (record1 < record2) {
@ -147,7 +147,7 @@ public class FindBinding {
public MacroBTreeComparator(Database database) {
db= database;
}
public int compare(int record1, int record2) throws CoreException {
public int compare(long record1, long record2) throws CoreException {
return compare(PDOMNamedNode.getDBName(db, record1), PDOMNamedNode.getDBName(db, record2)); // compare names
}
private int compare(IString nameInDB, IString nameInDB2) throws CoreException {
@ -156,14 +156,14 @@ public class FindBinding {
}
public static PDOMBinding findBinding(BTree btree, final PDOMLinkage linkage, final char[] name,
final int[] constants, final int localToFileRec) throws CoreException {
final int[] constants, final long 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 PDOMLinkage linkage, final char[] name, final int[] constants,
int localToFileRec) throws CoreException {
long localToFileRec) throws CoreException {
final DefaultFindBindingVisitor visitor = new DefaultFindBindingVisitor(linkage, name, constants, localToFileRec);
try {
node.accept(visitor);

View file

@ -16,5 +16,5 @@ import org.eclipse.cdt.core.dom.IPDOMNode;
* Common, but internal methods for all pdom nodes.
*/
public interface IInternalPDOMNode extends IPDOMNode {
public int getRecord();
public long getRecord();
}

View file

@ -28,7 +28,7 @@ public interface IPDOMBinding extends IPDOMNode, IIndexFragmentBinding {
/**
* Returns the database record for this binding.
*/
int getRecord();
long getRecord();
/**
* Returns the linkage of the binding.

View file

@ -20,7 +20,7 @@ import org.eclipse.core.runtime.CoreException;
*/
public interface IPDOMLinkageFactory {
public PDOMLinkage getLinkage(PDOM pdom, int record);
public PDOMLinkage getLinkage(PDOM pdom, long record);
public PDOMLinkage createLinkage(PDOM pdom) throws CoreException;

View file

@ -53,7 +53,7 @@ public final class MacroContainerCollector implements IBTreeVisitor {
monitor= pm;
}
final public int compare(int record) throws CoreException {
final public int compare(long record) throws CoreException {
if (monitor != null)
checkCancelled();
IString rhsName= PDOMNamedNode.getDBName(linkage.getDB(), record);
@ -79,7 +79,7 @@ public final class MacroContainerCollector implements IBTreeVisitor {
return cmp;
}
final public boolean visit(int record) throws CoreException {
final public boolean visit(long record) throws CoreException {
if (monitor != null)
checkCancelled();

View file

@ -31,7 +31,7 @@ public final class MacroContainerFinder implements IBTreeVisitor {
fLinkage= linkage;
}
final public int compare(int record) throws CoreException {
final public int compare(long record) throws CoreException {
IString name= PDOMNamedNode.getDBName(fLinkage.getDB(), record);
return compare(name);
}
@ -40,7 +40,7 @@ public final class MacroContainerFinder implements IBTreeVisitor {
return rhsName.compareCompatibleWithIgnoreCase(fName);
}
final public boolean visit(int record) throws CoreException {
final public boolean visit(long record) throws CoreException {
if (record == 0)
return true;
fMacroContainer= new PDOMMacroContainer(fLinkage, record);

View file

@ -39,13 +39,13 @@ public final class MacroContainerPatternCollector implements IBTreeVisitor {
}
final public int compare(int record) throws CoreException {
final public int compare(long record) throws CoreException {
if (fMonitor != null)
checkCancelled();
return 0;
}
final public boolean visit(int record) throws CoreException {
final public boolean visit(long record) throws CoreException {
if (record == 0)
return true;

View file

@ -61,7 +61,7 @@ public class NamedNodeCollector implements IBTreeVisitor, IPDOMVisitor {
monitor= pm;
}
final public int compare(int record) throws CoreException {
final public int compare(long record) throws CoreException {
if (monitor != null)
checkCancelled();
IString rhsName= PDOMNamedNode.getDBName(linkage.getDB(), record);
@ -87,7 +87,7 @@ public class NamedNodeCollector implements IBTreeVisitor, IPDOMVisitor {
return cmp;
}
final public boolean visit(int record) throws CoreException {
final public boolean visit(long record) throws CoreException {
if (monitor != null)
checkCancelled();

View file

@ -29,7 +29,7 @@ public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, I
@SuppressWarnings("hiding")
private static final int RECORD_SIZE= TYPE+4;
public PDOMArrayType(PDOMLinkage linkage, int record) {
public PDOMArrayType(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -38,8 +38,8 @@ public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, I
try {
PDOMNode targetTypeNode = getLinkage().addType(this, type.getType());
if (targetTypeNode != null) {
int typeRec = targetTypeNode.getRecord();
getDB().putInt(record + TYPE, typeRec);
long typeRec = targetTypeNode.getRecord();
getDB().putRecPtr(record + TYPE, typeRec);
}
} catch (DOMException e) {
CCorePlugin.log(e);
@ -62,7 +62,7 @@ public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, I
public IType getType() {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -57,7 +57,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
super(linkage, parent, name);
}
public PDOMBinding(PDOMLinkage linkage, int record) {
public PDOMBinding(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -79,18 +79,18 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
* @return <code>true</code> if the binding is orphaned.
* @throws CoreException
*/
public static boolean isOrphaned(PDOM pdom, int record) throws CoreException {
public static boolean isOrphaned(PDOM pdom, long record) throws CoreException {
Database db = pdom.getDB();
return db.getInt(record + FIRST_DECL_OFFSET) == 0
&& db.getInt(record + FIRST_DEF_OFFSET) == 0
&& db.getInt(record + FIRST_REF_OFFSET) == 0;
return db.getRecPtr(record + FIRST_DECL_OFFSET) == 0
&& db.getRecPtr(record + FIRST_DEF_OFFSET) == 0
&& db.getRecPtr(record + FIRST_REF_OFFSET) == 0;
}
public final boolean hasDeclaration() throws CoreException {
if (hasDeclaration == -1) {
final Database db = getDB();
if (db.getInt(record + FIRST_DECL_OFFSET) != 0
|| db.getInt(record + FIRST_DEF_OFFSET) != 0) {
if (db.getRecPtr(record + FIRST_DECL_OFFSET) != 0
|| db.getRecPtr(record + FIRST_DEF_OFFSET) != 0) {
hasDeclaration= 1;
return true;
}
@ -128,50 +128,50 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
public PDOMName getFirstDeclaration() throws CoreException {
int namerec = getDB().getInt(record + FIRST_DECL_OFFSET);
long namerec = getDB().getRecPtr(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;
getDB().putInt(record + FIRST_DECL_OFFSET, namerec);
long namerec = name != null ? name.getRecord() : 0;
getDB().putRecPtr(record + FIRST_DECL_OFFSET, namerec);
}
public PDOMName getFirstDefinition() throws CoreException {
int namerec = getDB().getInt(record + FIRST_DEF_OFFSET);
long namerec = getDB().getRecPtr(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;
getDB().putInt(record + FIRST_DEF_OFFSET, namerec);
long namerec = name != null ? name.getRecord() : 0;
getDB().putRecPtr(record + FIRST_DEF_OFFSET, namerec);
}
public PDOMName getFirstReference() throws CoreException {
int namerec = getDB().getInt(record + FIRST_REF_OFFSET);
long namerec = getDB().getRecPtr(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;
getDB().putInt(record + FIRST_REF_OFFSET, namerec);
long namerec = name != null ? name.getRecord() : 0;
getDB().putRecPtr(record + FIRST_REF_OFFSET, namerec);
}
public final PDOMFile getLocalToFile() throws CoreException {
final int filerec = getLocalToFileRec(getDB(), record);
final long filerec = getLocalToFileRec(getDB(), record);
return filerec == 0 ? null : new PDOMFile(getLinkage(), filerec);
}
public final int getLocalToFileRec() throws CoreException {
public final long getLocalToFileRec() throws CoreException {
return getLocalToFileRec(getDB(), record);
}
public static int getLocalToFileRec(Database db, int record) throws CoreException {
return db.getInt(record + LOCAL_TO_FILE);
public static long getLocalToFileRec(Database db, long record) throws CoreException {
return db.getRecPtr(record + LOCAL_TO_FILE);
}
public final void setLocalToFileRec(int rec) throws CoreException {
getDB().putInt(record + LOCAL_TO_FILE, rec);
public final void setLocalToFileRec(long rec) throws CoreException {
getDB().putRecPtr(record + LOCAL_TO_FILE, rec);
}
public String getName() {
@ -329,7 +329,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
}
final public boolean isFileLocal() throws CoreException {
return getDB().getInt(record + LOCAL_TO_FILE) != 0;
return getDB().getRecPtr(record + LOCAL_TO_FILE) != 0;
}
public boolean hasDefinition() throws CoreException {
@ -361,8 +361,8 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
IString s0 = b0.getDBName(), s1 = b1.getDBName();
cmp = s0.compare(s1, true);
if (cmp == 0) {
int l1= b0.getLocalToFileRec();
int l2= b1.getLocalToFileRec();
long l1= b0.getLocalToFileRec();
long l2= b1.getLocalToFileRec();
if (l1 != l2) {
return l1 < l2 ? -1 : 1;
}

View file

@ -58,7 +58,7 @@ import org.eclipse.core.runtime.Status;
*/
public class PDOMFile implements IIndexFragmentFile {
private final PDOMLinkage fLinkage;
private final int record;
private final long record;
private IIndexFileLocation location;
private static final int FIRST_NAME = 0;
@ -81,9 +81,9 @@ public class PDOMFile implements IIndexFragmentFile {
this.db = db;
}
public int compare(int record1, int record2) throws CoreException {
IString name1 = db.getString(db.getInt(record1 + LOCATION_REPRESENTATION));
IString name2 = db.getString(db.getInt(record2 + LOCATION_REPRESENTATION));
public int compare(long record1, long record2) throws CoreException {
IString name1 = db.getString(db.getRecPtr(record1 + LOCATION_REPRESENTATION));
IString name2 = db.getString(db.getRecPtr(record2 + LOCATION_REPRESENTATION));
int cmp= name1.compare(name2, true);
if (cmp == 0) {
cmp= db.getInt(record1 + LINKAGE_ID) - db.getInt(record2 + LINKAGE_ID);
@ -92,7 +92,7 @@ public class PDOMFile implements IIndexFragmentFile {
}
}
public PDOMFile(PDOMLinkage linkage, int record) {
public PDOMFile(PDOMLinkage linkage, long record) {
fLinkage = linkage;
this.record = record;
}
@ -106,7 +106,7 @@ public class PDOMFile implements IIndexFragmentFile {
if (locationString==null)
throw new CoreException(CCorePlugin.createStatus(Messages.getString("PDOMFile.toInternalProblem")+location.getURI())); //$NON-NLS-1$
IString locationDBString = db.newString(locationString);
db.putInt(record + LOCATION_REPRESENTATION, locationDBString.getRecord());
db.putRecPtr(record + LOCATION_REPRESENTATION, locationDBString.getRecord());
db.putInt(record + LINKAGE_ID, linkageID);
db.putLong(record + TIME_STAMP, 0);
setFirstName(null);
@ -115,7 +115,7 @@ public class PDOMFile implements IIndexFragmentFile {
setTimestamp(-1);
}
public int getRecord() {
public long getRecord() {
return record;
}
@ -132,7 +132,7 @@ public class PDOMFile implements IIndexFragmentFile {
@Override
public final int hashCode() {
return System.identityHashCode(fLinkage.getPDOM()) + 41*record;
return System.identityHashCode(fLinkage.getPDOM()) + (int)(41*record);
}
/**
@ -144,9 +144,9 @@ public class PDOMFile implements IIndexFragmentFile {
*/
public void setInternalLocation(String internalLocation) throws CoreException {
Database db = fLinkage.getDB();
int oldRecord = db.getInt(record + LOCATION_REPRESENTATION);
long oldRecord = db.getRecPtr(record + LOCATION_REPRESENTATION);
db.free(oldRecord);
db.putInt(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord());
db.putRecPtr(record + LOCATION_REPRESENTATION, db.newString(internalLocation).getRecord());
location= null;
}
@ -176,37 +176,37 @@ public class PDOMFile implements IIndexFragmentFile {
}
private PDOMName getFirstName() throws CoreException {
int namerec = fLinkage.getDB().getInt(record + FIRST_NAME);
long namerec = fLinkage.getDB().getRecPtr(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;
fLinkage.getDB().putInt(record + FIRST_NAME, namerec);
long namerec = firstName != null ? firstName.getRecord() : 0;
fLinkage.getDB().putRecPtr(record + FIRST_NAME, namerec);
}
private PDOMMacroReferenceName getFirstMacroReference() throws CoreException {
int namerec = fLinkage.getDB().getInt(record + FIRST_MACRO_REFERENCE);
long namerec = fLinkage.getDB().getRecPtr(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;
fLinkage.getDB().putInt(record + FIRST_MACRO_REFERENCE, namerec);
long namerec = firstName != null ? firstName.getRecord() : 0;
fLinkage.getDB().putRecPtr(record + FIRST_MACRO_REFERENCE, namerec);
}
public PDOMInclude getFirstInclude() throws CoreException {
int increc = fLinkage.getDB().getInt(record + FIRST_INCLUDE);
long increc = fLinkage.getDB().getRecPtr(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;
fLinkage.getDB().putInt(record + FIRST_INCLUDE, rec);
long rec = include != null ? include.getRecord() : 0;
fLinkage.getDB().putRecPtr(record + FIRST_INCLUDE, rec);
}
public PDOMInclude getFirstIncludedBy() throws CoreException {
int rec = fLinkage.getDB().getInt(record + FIRST_INCLUDED_BY);
long rec = fLinkage.getDB().getRecPtr(record + FIRST_INCLUDED_BY);
return rec != 0 ? new PDOMInclude(fLinkage, rec) : null;
}
@ -215,18 +215,18 @@ public class PDOMFile implements IIndexFragmentFile {
}
public void setFirstIncludedBy(PDOMInclude includedBy) throws CoreException {
int rec = includedBy != null ? includedBy.getRecord() : 0;
fLinkage.getDB().putInt(record + FIRST_INCLUDED_BY, rec);
long rec = includedBy != null ? includedBy.getRecord() : 0;
fLinkage.getDB().putRecPtr(record + FIRST_INCLUDED_BY, rec);
}
public PDOMMacro getFirstMacro() throws CoreException {
int rec = fLinkage.getDB().getInt(record + FIRST_MACRO);
long rec = fLinkage.getDB().getRecPtr(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;
fLinkage.getDB().putInt(record + FIRST_MACRO, rec);
long rec = macro != null ? macro.getRecord() : 0;
fLinkage.getDB().putRecPtr(record + FIRST_MACRO, rec);
}
public void addMacros(IASTPreprocessorStatement[] macros) throws CoreException {
@ -293,7 +293,7 @@ public class PDOMFile implements IIndexFragmentFile {
}
}
private IIndexFragmentName createPDOMName(PDOMLinkage linkage, IASTName name, PDOMName caller) {
private IIndexFragmentName createPDOMName(PDOMLinkage linkage, IASTName name, PDOMName caller) throws CoreException {
final IBinding binding = name.getBinding();
if (binding instanceof IParameter) {
return null;
@ -310,6 +310,9 @@ public class PDOMFile implements IIndexFragmentFile {
return result;
}
} catch (CoreException e) {
if( e.getStatus() != null && e.getStatus().getCode() == CCorePlugin.STATUS_PDOM_TOO_LARGE ) {
throw e;
}
CCorePlugin.log(e);
}
return null;
@ -490,7 +493,7 @@ public class PDOMFile implements IIndexFragmentFile {
public static PDOMFile findFile(PDOMLinkage linkage, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy)
throws CoreException {
String internalRepresentation= strategy.toInternalFormat(location);
int record= 0;
long record= 0;
if (internalRepresentation != null) {
Finder finder = new Finder(linkage.getDB(), internalRepresentation, linkage.getLinkageID());
btree.accept(finder);
@ -508,7 +511,7 @@ public class PDOMFile implements IIndexFragmentFile {
if (internalRepresentation != null) {
Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1);
btree.accept(finder);
int[] records= finder.getRecords();
long[] records= finder.getRecords();
PDOMFile[] result= new PDOMFile[records.length];
for (int i = 0; i < result.length; i++) {
result[i] = recreateFile(pdom, records[i]);
@ -518,7 +521,7 @@ public class PDOMFile implements IIndexFragmentFile {
return new IIndexFragmentFile[0];
}
public static PDOMFile recreateFile(PDOM pdom, final int record) throws CoreException {
public static PDOMFile recreateFile(PDOM pdom, final long record) throws CoreException {
final Database db= pdom.getDB();
final int linkageID= db.getInt(record + PDOMFile.LINKAGE_ID);
PDOMLinkage linkage= pdom.getLinkage(linkageID);
@ -529,11 +532,11 @@ public class PDOMFile implements IIndexFragmentFile {
}
private static class Finder implements IBTreeVisitor {
private static final int[] EMPTY = {};
private static final long[] EMPTY = {};
private final Database db;
private final String rawKey;
private int record;
private int[] records;
private long record;
private long[] records;
private final int linkageID;
/**
@ -545,18 +548,18 @@ public class PDOMFile implements IIndexFragmentFile {
this.linkageID= linkageID;
}
public int[] getRecords() {
public long[] getRecords() {
if (records == null) {
if (record == 0) {
return EMPTY;
}
return new int[] { record };
return new long[] { record };
}
return records;
}
public int compare(int record) throws CoreException {
IString name = db.getString(db.getInt(record + PDOMFile.LOCATION_REPRESENTATION));
public int compare(long record) throws CoreException {
IString name = db.getString(db.getRecPtr(record + PDOMFile.LOCATION_REPRESENTATION));
int cmp= name.compare(rawKey, true);
if (cmp == 0 && linkageID >= 0) {
cmp= db.getInt(record + PDOMFile.LINKAGE_ID) - linkageID;
@ -564,7 +567,7 @@ public class PDOMFile implements IIndexFragmentFile {
return cmp;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
if (linkageID >= 0) {
this.record = record;
return false;
@ -572,9 +575,9 @@ public class PDOMFile implements IIndexFragmentFile {
if (this.record == 0) {
this.record= record;
} else if (this.records == null) {
this.records= new int[] {this.record, record};
this.records= new long[] {this.record, record};
} else {
int[] cpy= new int[this.records.length+1];
long[] cpy= new long[this.records.length+1];
System.arraycopy(this.records, 0, cpy, 0, this.records.length);
cpy[cpy.length-1]= record;
this.records= cpy;
@ -582,7 +585,7 @@ public class PDOMFile implements IIndexFragmentFile {
return linkageID < 0;
}
public int getRecord() {
public long getRecord() {
return record;
}
}
@ -590,7 +593,7 @@ public class PDOMFile implements IIndexFragmentFile {
public IIndexFileLocation getLocation() throws CoreException {
if (location == null) {
Database db = fLinkage.getDB();
String raw = db.getString(db.getInt(record + LOCATION_REPRESENTATION)).getString();
String raw = db.getString(db.getRecPtr(record + LOCATION_REPRESENTATION)).getString();
location= fLinkage.getPDOM().getLocationConverter().fromInternalFormat(raw);
if (location == null) {
URI uri;
@ -623,12 +626,12 @@ public class PDOMFile implements IIndexFragmentFile {
setFirstIncludedBy(null);
}
public int getLastUsingDirectiveRec() throws CoreException {
return fLinkage.getDB().getInt(record + LAST_USING_DIRECTIVE);
public long getLastUsingDirectiveRec() throws CoreException {
return fLinkage.getDB().getRecPtr(record + LAST_USING_DIRECTIVE);
}
public void setFirstUsingDirectiveRec(int rec) throws CoreException {
fLinkage.getDB().putInt(record + LAST_USING_DIRECTIVE, rec);
public void setFirstUsingDirectiveRec(long rec) throws CoreException {
fLinkage.getDB().putRecPtr(record + LAST_USING_DIRECTIVE, rec);
}
/* (non-Javadoc)

View file

@ -38,7 +38,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
// we store the length of the name instead of the name itself, and indicate that
// by turning on FLAG_DEDUCIBLE_NAME flag. Notice that the length of include name
// can be different from the node length, if the name is defined by a macro.
private static final int INCLUDE_NAME_OR_LENGTH = 20;
private static final int INCLUDE_NAME_OR_LENGTH = 20; // TODO: assumes that int and stored pointers are the same size
private static final int NODE_OFFSET = 24; // 3-byte unsigned int (sufficient for files <= 16mb)
private static final int NODE_LENGTH = 27; // short (sufficient for names <= 32k)
private static final int FLAGS = 29;
@ -50,12 +50,12 @@ public class PDOMInclude implements IIndexFragmentInclude {
private static final int FLAG_DEDUCIBLE_NAME = 0x08;
private final PDOMLinkage linkage;
private final int record;
private final long record;
// Cached fields
private String fName;
public PDOMInclude(PDOMLinkage pdom, int record) {
public PDOMInclude(PDOMLinkage pdom, long record) {
this.linkage = pdom;
this.record = record;
}
@ -75,13 +75,16 @@ public class PDOMInclude implements IIndexFragmentInclude {
final Database db = linkage.getDB();
if (targetFile != null) {
db.putInt(record + INCLUDED_FILE, targetFile.getRecord());
db.putRecPtr(record + INCLUDED_FILE, targetFile.getRecord());
}
boolean deducible_name = isDeducibleName(targetFile, nameChars);
// If the name is the same as an end part of the path of the included file,
// store the length of the name instead of the name itself.
int rec= deducible_name ? nameChars.length : db.newString(nameChars).getRecord();
db.putInt(record + INCLUDE_NAME_OR_LENGTH, rec);
if( deducible_name ) {
db.putInt( record + INCLUDE_NAME_OR_LENGTH, nameChars.length );
} else {
db.putRecPtr( record + INCLUDE_NAME_OR_LENGTH, db.newString(nameChars).getRecord() );
}
setFlag(encodeFlags(include, deducible_name));
setIncludedBy(containerFile);
}
@ -102,7 +105,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
return flags;
}
public int getRecord() {
public long getRecord() {
return record;
}
@ -113,7 +116,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
}
final Database db = linkage.getDB();
if ((getFlag() & FLAG_DEDUCIBLE_NAME) == 0) {
int rec = db.getInt(record + INCLUDE_NAME_OR_LENGTH);
long rec = db.getRecPtr(record + INCLUDE_NAME_OR_LENGTH);
db.getString(rec).delete();
}
// Delete our record
@ -134,7 +137,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
}
public IIndexFragmentFile getIncludes() throws CoreException {
int rec = linkage.getDB().getInt(record + INCLUDED_FILE);
long rec = linkage.getDB().getRecPtr(record + INCLUDED_FILE);
return rec != 0 ? new PDOMFile(linkage, rec) : null;
}
@ -159,47 +162,47 @@ public class PDOMInclude implements IIndexFragmentInclude {
}
public IIndexFile getIncludedBy() throws CoreException {
int rec = linkage.getDB().getInt(record + INCLUDED_BY);
long rec = linkage.getDB().getRecPtr(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;
linkage.getDB().putInt(record + INCLUDED_BY, rec);
long rec = includedBy != null ? includedBy.getRecord() : 0;
linkage.getDB().putRecPtr(record + INCLUDED_BY, rec);
}
public PDOMInclude getNextInIncludes() throws CoreException {
int rec = linkage.getDB().getInt(record + INCLUDES_NEXT);
long rec = linkage.getDB().getRecPtr(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;
linkage.getDB().putInt(record + INCLUDES_NEXT, rec);
long rec = include != null ? include.getRecord() : 0;
linkage.getDB().putRecPtr(record + INCLUDES_NEXT, rec);
}
public PDOMInclude getNextInIncludedBy() throws CoreException {
int rec = linkage.getDB().getInt(record + INCLUDED_BY_NEXT);
long rec = linkage.getDB().getRecPtr(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;
linkage.getDB().putInt(record + INCLUDED_BY_NEXT, rec);
long rec = include != null ? include.getRecord() : 0;
linkage.getDB().putRecPtr(record + INCLUDED_BY_NEXT, rec);
}
public PDOMInclude getPrevInIncludedBy() throws CoreException {
int rec = getPrevInIncludedByRecord();
long rec = getPrevInIncludedByRecord();
return rec != 0 ? new PDOMInclude(linkage, rec) : null;
}
int getPrevInIncludedByRecord() throws CoreException {
return linkage.getDB().getInt(record + INCLUDED_BY_PREV);
long getPrevInIncludedByRecord() throws CoreException {
return linkage.getDB().getRecPtr(record + INCLUDED_BY_PREV);
}
public void setPrevInIncludedBy(PDOMInclude include) throws CoreException {
int rec = include != null ? include.getRecord() : 0;
linkage.getDB().putInt(record + INCLUDED_BY_PREV, rec);
long rec = include != null ? include.getRecord() : 0;
linkage.getDB().putRecPtr(record + INCLUDED_BY_PREV, rec);
}
public IIndexFileLocation getIncludedByLocation() throws CoreException {
@ -232,7 +235,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
}
public boolean isResolved() throws CoreException {
return linkage.getDB().getInt(record + INCLUDED_FILE) != 0;
return linkage.getDB().getRecPtr(record + INCLUDED_FILE) != 0;
}
public boolean isResolvedByHeuristics() throws CoreException {
@ -253,7 +256,7 @@ public class PDOMInclude implements IIndexFragmentInclude {
// The include name is either stored explicitly, or can be deduced from the path
// of the included file.
if ((getFlag() & FLAG_DEDUCIBLE_NAME) == 0) {
int rec = db.getInt(record + INCLUDE_NAME_OR_LENGTH);
long rec = db.getRecPtr(record + INCLUDE_NAME_OR_LENGTH);
fName = db.getString(rec).getString();
} else {
String path = getIncludes().getLocation().getURI().getPath();
@ -276,11 +279,11 @@ public class PDOMInclude implements IIndexFragmentInclude {
int flag = getFlag();
// Since included file is going away, the name is no longer deducible.
if ((flag & FLAG_DEDUCIBLE_NAME) != 0) {
int rec= db.newString(getFullName()).getRecord();
db.putInt(record + INCLUDE_NAME_OR_LENGTH, rec);
long rec= db.newString(getFullName()).getRecord();
db.putRecPtr(record + INCLUDE_NAME_OR_LENGTH, rec);
setFlag((byte) (flag & ~FLAG_DEDUCIBLE_NAME));
}
db.putInt(record + INCLUDED_FILE, 0);
db.putRecPtr(record + INCLUDED_FILE, 0);
}
}
}

View file

@ -64,7 +64,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 20;
protected static final int[] FILE_LOCAL_REC_DUMMY = new int[]{0};
protected static final long[] FILE_LOCAL_REC_DUMMY = new long[]{0};
// node types
protected static final int LINKAGE= 0; // special one for myself
@ -73,7 +73,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
private final PDOM fPDOM;
private final Database fDatabase;
public PDOMLinkage(PDOM pdom, int record) {
public PDOMLinkage(PDOM pdom, long record) {
super(null, record);
fPDOM= pdom;
fDatabase= pdom.getDB();
@ -85,7 +85,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
fPDOM= pdom;
fDatabase= db;
db.putInt(record + ID_OFFSET, db.newString(languageId).getRecord());
db.putRecPtr(record + ID_OFFSET, db.newString(languageId).getRecord());
pdom.insertLinkage(this);
}
@ -114,18 +114,18 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return LINKAGE;
}
public static IString getLinkageID(PDOM pdom, int record) throws CoreException {
public static IString getLinkageID(PDOM pdom, long record) throws CoreException {
Database db = pdom.getDB();
int namerec = db.getInt(record + ID_OFFSET);
long namerec = db.getRecPtr(record + ID_OFFSET);
return db.getString(namerec);
}
public static int getNextLinkageRecord(PDOM pdom, int record) throws CoreException {
return pdom.getDB().getInt(record + NEXT_OFFSET);
public static long getNextLinkageRecord(PDOM pdom, long record) throws CoreException {
return pdom.getDB().getRecPtr(record + NEXT_OFFSET);
}
public void setNext(int nextrec) throws CoreException {
getDB().putInt(record + NEXT_OFFSET, nextrec);
public void setNext(long nextrec) throws CoreException {
getDB().putRecPtr(record + NEXT_OFFSET, nextrec);
}
public BTree getIndex() throws CoreException {
@ -146,10 +146,10 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
getIndex().accept((IBTreeVisitor) visitor);
} else {
getIndex().accept(new IBTreeVisitor() {
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
PDOMNode node= getNode(record);
if (node != null) {
if (visitor.visit(node))
@ -168,14 +168,14 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
getIndex().insert(child.getRecord());
}
public final PDOMBinding getBinding(int record) throws CoreException {
public final PDOMBinding getBinding(long record) throws CoreException {
final PDOMNode node= getNode(record);
if (node instanceof PDOMBinding)
return (PDOMBinding) node;
return null;
}
public PDOMNode getNode(int record) throws CoreException {
public PDOMNode getNode(long record) throws CoreException {
switch (PDOMNode.getNodeType(fDatabase, record)) {
case POINTER_TYPE:
return new PDOMPointerType(this, record);
@ -230,8 +230,8 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
public abstract PDOMBinding addBinding(IASTName name) throws CoreException;
final protected int getLocalToFileRec(PDOMNode parent, IBinding binding, PDOMBinding glob) throws CoreException {
int rec= 0;
final protected long getLocalToFileRec(PDOMNode parent, IBinding binding, PDOMBinding glob) throws CoreException {
long rec= 0;
if (parent instanceof PDOMBinding) {
rec= ((PDOMBinding) parent).getLocalToFileRec();
}
@ -334,7 +334,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
}
}
public void deleteType(IType type, int ownerRec) throws CoreException {
public void deleteType(IType type, long ownerRec) throws CoreException {
if (type instanceof PDOMNode) {
PDOMNode node= (PDOMNode) type;
// at this point only delete types that are actually owned by the requesting party.
@ -442,7 +442,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
}
private CharArrayMap<PDOMBinding[]> getBindingMap() {
final Integer key= getRecord();
final Long key= getRecord();
final PDOM pdom = getPDOM();
@SuppressWarnings("unchecked")
Reference<CharArrayMap<PDOMBinding[]>> cached= (Reference<CharArrayMap<PDOMBinding[]>>) pdom.getCachedResult(key);

View file

@ -59,14 +59,14 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
private static final char[] UNINITIALIZED1= {};
private final PDOMLinkage fLinkage;
private final int fRecord;
private final long fRecord;
private char[][] fParameterList= UNINITIALIZED;
private char[] fExpansion= UNINITIALIZED1;
private PDOMMacroContainer fContainer;
private PDOMMacroDefinitionName fDefinition;
public PDOMMacro(PDOMLinkage linkage, int record) {
public PDOMMacro(PDOMLinkage linkage, long record) {
fLinkage = linkage;
fRecord = record;
}
@ -80,14 +80,14 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
final char[][] params= binding.getParameterList();
final Database db= linkage.getDB();
db.putInt(fRecord + EXPANSION, db.newString(binding.getExpansionImage()).getRecord());
db.putRecPtr(fRecord + EXPANSION, db.newString(binding.getExpansionImage()).getRecord());
if (params != null) {
StringBuilder buf= new StringBuilder();
for (char[] param : params) {
buf.append(param);
buf.append(',');
}
db.putInt(fRecord + PARAMETERS, db.newString(buf.toString().toCharArray()).getRecord());
db.putRecPtr(fRecord + PARAMETERS, db.newString(buf.toString().toCharArray()).getRecord());
}
}
@ -104,8 +104,8 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
fContainer= container;
final IASTFileLocation fileloc = name.getFileLocation();
db.putInt(fRecord + CONTAINER, container.getRecord());
db.putInt(fRecord + FILE, file.getRecord());
db.putRecPtr(fRecord + CONTAINER, container.getRecord());
db.putRecPtr(fRecord + FILE, file.getRecord());
db.putInt(fRecord + NAME_OFFSET, fileloc.getNodeOffset());
db.putShort(fRecord + NAME_LENGTH, (short) fileloc.getNodeLength());
@ -116,7 +116,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
return fLinkage.getPDOM();
}
public int getRecord() {
public long getRecord() {
return fRecord;
}
@ -149,25 +149,25 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
public PDOMMacroContainer getContainer() throws CoreException {
if (fContainer == null) {
fContainer= new PDOMMacroContainer(fLinkage, fLinkage.getDB().getInt(fRecord + CONTAINER));
fContainer= new PDOMMacroContainer(fLinkage, fLinkage.getDB().getRecPtr(fRecord + CONTAINER));
}
return fContainer;
}
private IString getExpansionInDB() throws CoreException {
Database db = fLinkage.getDB();
int rec = db.getInt(fRecord + EXPANSION);
long rec = db.getRecPtr(fRecord + EXPANSION);
return rec == 0 ? null : db.getString(rec);
}
private IString getParamListInDB() throws CoreException {
Database db = fLinkage.getDB();
int rec = db.getInt(fRecord + PARAMETERS);
long rec = db.getRecPtr(fRecord + PARAMETERS);
return rec == 0 ? null : db.getString(rec);
}
public PDOMMacro getNextMacro() throws CoreException {
int rec = fLinkage.getDB().getInt(fRecord + NEXT_IN_FILE);
long rec = fLinkage.getDB().getRecPtr(fRecord + NEXT_IN_FILE);
return rec != 0 ? new PDOMMacro(fLinkage, rec) : null;
}
@ -175,8 +175,8 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
setNextMacro(macro != null ? macro.getRecord() : 0);
}
private void setNextMacro(int rec) throws CoreException {
fLinkage.getDB().putInt(fRecord + NEXT_IN_FILE, rec);
private void setNextMacro(long rec) throws CoreException {
fLinkage.getDB().putRecPtr(fRecord + NEXT_IN_FILE, rec);
}
private PDOMMacro getPrevInContainer() throws CoreException {
@ -196,12 +196,12 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
}
private void setMacroField(int offset, PDOMMacro macro) throws CoreException {
int namerec = macro != null ? macro.getRecord() : 0;
fLinkage.getDB().putInt(fRecord + offset, namerec);
long namerec = macro != null ? macro.getRecord() : 0;
fLinkage.getDB().putRecPtr(fRecord + offset, namerec);
}
private PDOMMacro getMacroField(int offset) throws CoreException {
int namerec= fLinkage.getDB().getInt(fRecord + offset);
long namerec= fLinkage.getDB().getRecPtr(fRecord + offset);
return namerec != 0 ? new PDOMMacro(fLinkage, namerec) : null;
}
@ -232,7 +232,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
public boolean isMacroDefinition() throws CoreException {
if (fExpansion == UNINITIALIZED1) {
return fLinkage.getDB().getInt(fRecord + EXPANSION) != 0;
return fLinkage.getDB().getRecPtr(fRecord + EXPANSION) != 0;
}
return fExpansion != null;
}
@ -264,7 +264,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
}
public PDOMFile getFile() throws CoreException {
int filerec = fLinkage.getDB().getInt(fRecord + FILE);
long filerec = fLinkage.getDB().getRecPtr(fRecord + FILE);
return filerec != 0 ? new PDOMFile(fLinkage, filerec) : null;
}
@ -408,7 +408,7 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation {
public void accept(IPDOMVisitor visitor) {
}
public int getBindingID() {
public long getBindingID() {
return fRecord;
}
}

View file

@ -39,7 +39,7 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
super(linkage, linkage, name);
}
PDOMMacroContainer(PDOMLinkage linkage, int record) {
PDOMMacroContainer(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -55,8 +55,8 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
public boolean isOrphaned() throws CoreException {
Database db = getDB();
return db.getInt(record + FIRST_DEF_OFFSET) == 0
&& db.getInt(record + FIRST_REF_OFFSET) == 0;
return db.getRecPtr(record + FIRST_DEF_OFFSET) == 0
&& db.getRecPtr(record + FIRST_REF_OFFSET) == 0;
}
public void addDefinition(PDOMMacro name) throws CoreException {
@ -78,23 +78,23 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
}
public PDOMMacro getFirstDefinition() throws CoreException {
int namerec = getDB().getInt(record + FIRST_DEF_OFFSET);
long namerec = getDB().getRecPtr(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;
getDB().putInt(record + FIRST_DEF_OFFSET, namerec);
long namerec = macro != null ? macro.getRecord() : 0;
getDB().putRecPtr(record + FIRST_DEF_OFFSET, namerec);
}
public PDOMMacroReferenceName getFirstReference() throws CoreException {
int namerec = getDB().getInt(record + FIRST_REF_OFFSET);
long namerec = getDB().getRecPtr(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;
getDB().putInt(record + FIRST_REF_OFFSET, namerec);
long namerec = nextName != null ? nextName.getRecord() : 0;
getDB().putRecPtr(record + FIRST_REF_OFFSET, namerec);
}
public IIndexMacro[] getDefinitions() throws CoreException {
@ -134,7 +134,7 @@ public class PDOMMacroContainer extends PDOMNamedNode implements IIndexMacroCont
}
public boolean hasDefinition() throws CoreException {
return getDB().getInt(record + FIRST_DEF_OFFSET) != 0;
return getDB().getRecPtr(record + FIRST_DEF_OFFSET) != 0;
}
public IIndexFile getLocalToFile() throws CoreException {

View file

@ -30,7 +30,7 @@ import org.eclipse.core.runtime.IPath;
*/
public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFileLocation {
private final PDOMLinkage linkage;
private final int record;
private final long record;
private static final int FILE_REC_OFFSET = 0;
private static final int FILE_NEXT_OFFSET = 4;
@ -48,8 +48,8 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
Database db = linkage.getDB();
record = db.malloc(RECORD_SIZE);
db.putInt(record + CONTAINER_REC_OFFSET, container.getRecord());
db.putInt(record + FILE_REC_OFFSET, file.getRecord());
db.putRecPtr(record + CONTAINER_REC_OFFSET, container.getRecord());
db.putRecPtr(record + FILE_REC_OFFSET, file.getRecord());
// Record our location in the file
IASTFileLocation fileloc = name.getFileLocation();
@ -58,35 +58,35 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
container.addReference(this);
}
public PDOMMacroReferenceName(PDOMLinkage linkage, int nameRecord) {
public PDOMMacroReferenceName(PDOMLinkage linkage, long nameRecord) {
this.linkage = linkage;
this.record = nameRecord;
}
public int getRecord() {
public long getRecord() {
return record;
}
private int getRecField(int offset) throws CoreException {
return linkage.getDB().getInt(record + offset);
private long getRecField(int offset) throws CoreException {
return linkage.getDB().getRecPtr(record + offset);
}
private void setRecField(int offset, int fieldrec) throws CoreException {
linkage.getDB().putInt(record + offset, fieldrec);
private void setRecField(int offset, long fieldrec) throws CoreException {
linkage.getDB().putRecPtr(record + offset, fieldrec);
}
public PDOMMacroContainer getContainer() throws CoreException {
int bindingrec = getRecField(CONTAINER_REC_OFFSET);
long bindingrec = getRecField(CONTAINER_REC_OFFSET);
return new PDOMMacroContainer(linkage, bindingrec);
}
private PDOMMacroReferenceName getNameField(int offset) throws CoreException {
int namerec = getRecField(offset);
long namerec = getRecField(offset);
return namerec != 0 ? new PDOMMacroReferenceName(linkage, namerec) : null;
}
private void setNameField(int offset, PDOMMacroReferenceName name) throws CoreException {
int namerec = name != null ? name.getRecord() : 0;
long namerec = name != null ? name.getRecord() : 0;
setRecField(offset, namerec);
}
@ -107,7 +107,7 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil
}
public PDOMFile getFile() throws CoreException {
int filerec = linkage.getDB().getInt(record + FILE_REC_OFFSET);
long filerec = linkage.getDB().getRecPtr(record + FILE_REC_OFFSET);
return filerec != 0 ? new PDOMFile(linkage, filerec) : null;
}

View file

@ -31,7 +31,7 @@ import org.eclipse.core.runtime.IPath;
*/
public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
private final PDOMLinkage linkage;
private final int record;
private final long record;
private static final int FILE_REC_OFFSET = 0;
private static final int FILE_NEXT_OFFSET = 4;
@ -81,11 +81,11 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
break;
}
db.putInt(record + BINDING_REC_OFFSET, binding.getRecord());
db.putRecPtr(record + BINDING_REC_OFFSET, binding.getRecord());
db.putInt(record + FILE_REC_OFFSET, file.getRecord());
db.putRecPtr(record + FILE_REC_OFFSET, file.getRecord());
if (caller != null) {
db.putInt(record + CALLER_REC_OFFSET, caller.getRecord());
db.putRecPtr(record + CALLER_REC_OFFSET, caller.getRecord());
}
// Record our location in the file
@ -104,40 +104,40 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
return IS_REFERENCE;
}
public PDOMName(PDOMLinkage linkage, int nameRecord) {
public PDOMName(PDOMLinkage linkage, long nameRecord) {
this.linkage = linkage;
this.record = nameRecord;
}
public int getRecord() {
public long getRecord() {
return record;
}
private int getRecField(int offset) throws CoreException {
return linkage.getDB().getInt(record + offset);
private long getRecField(int offset) throws CoreException {
return linkage.getDB().getRecPtr(record + offset);
}
private void setRecField(int offset, int fieldrec) throws CoreException {
linkage.getDB().putInt(record + offset, fieldrec);
private void setRecField(int offset, long fieldrec) throws CoreException {
linkage.getDB().putRecPtr(record + offset, fieldrec);
}
public PDOMBinding getBinding() throws CoreException {
int bindingrec = getRecField(BINDING_REC_OFFSET);
long bindingrec = getRecField(BINDING_REC_OFFSET);
return linkage.getBinding(bindingrec);
}
public void setBinding(PDOMBinding binding) throws CoreException {
int bindingrec = binding != null ? binding.getRecord() : 0;
long bindingrec = binding != null ? binding.getRecord() : 0;
setRecField(BINDING_REC_OFFSET, bindingrec);
}
private PDOMName getNameField(int offset) throws CoreException {
int namerec = getRecField(offset);
long namerec = getRecField(offset);
return namerec != 0 ? new PDOMName(linkage, namerec) : null;
}
private void setNameField(int offset, PDOMName name) throws CoreException {
int namerec = name != null ? name.getRecord() : 0;
long namerec = name != null ? name.getRecord() : 0;
setRecField(offset, namerec);
}
@ -158,17 +158,17 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
}
public PDOMFile getFile() throws CoreException {
int filerec = linkage.getDB().getInt(record + FILE_REC_OFFSET);
long filerec = linkage.getDB().getRecPtr(record + FILE_REC_OFFSET);
return filerec != 0 ? new PDOMFile(linkage, filerec) : null;
}
public IIndexName getEnclosingDefinition() throws CoreException {
int namerec = getEnclosingDefinitionRecord();
long namerec = getEnclosingDefinitionRecord();
return namerec != 0 ? new PDOMName(linkage, namerec) : null;
}
int getEnclosingDefinitionRecord() throws CoreException {
return linkage.getDB().getInt(record + CALLER_REC_OFFSET);
long getEnclosingDefinitionRecord() throws CoreException {
return linkage.getDB().getRecPtr(record + CALLER_REC_OFFSET);
}
public PDOMName getNextInFile() throws CoreException {
@ -190,7 +190,7 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation {
public char[] getSimpleID() {
try {
Database db = linkage.getDB();
int bindingRec = db.getInt(record + BINDING_REC_OFFSET);
long bindingRec = db.getRecPtr(record + BINDING_REC_OFFSET);
PDOMBinding binding = linkage.getBinding(bindingRec);
return binding != null ? binding.getNameCharArray() : null;
} catch (CoreException e) {

View file

@ -42,7 +42,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
private char[] fName;
public PDOMNamedNode(PDOMLinkage linkage, int record) {
public PDOMNamedNode(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -51,7 +51,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
fName= name;
final Database db = linkage.getDB();
db.putInt(record + NAME, name != null ? db.newString(name).getRecord() : 0);
db.putRecPtr(record + NAME, name != null ? db.newString(name).getRecord() : 0);
}
/**
@ -60,7 +60,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
protected PDOMNamedNode(Database db, char[] name) throws CoreException {
super(db);
fName= name;
db.putInt(record + NAME, name != null ? db.newString(name).getRecord() : 0);
db.putRecPtr(record + NAME, name != null ? db.newString(name).getRecord() : 0);
}
@Override
@ -70,8 +70,8 @@ public abstract class PDOMNamedNode extends PDOMNode {
return getDBName(getDB(), record);
}
public static IString getDBName(Database db, int record) throws CoreException {
int namerec = db.getInt(record + NAME);
public static IString getDBName(Database db, long record) throws CoreException {
long namerec = db.getRecPtr(record + NAME);
return db.getString(namerec);
}
@ -101,7 +101,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
if (!name.equals(nameCharArray)) {
name.delete();
final Database db= getDB();
db.putInt(record + NAME, db.newString(nameCharArray).getRecord());
db.putRecPtr(record + NAME, db.newString(nameCharArray).getRecord());
}
fName= nameCharArray;
}
@ -110,7 +110,7 @@ public abstract class PDOMNamedNode extends PDOMNode {
@Override
public void delete(PDOMLinkage linkage) throws CoreException {
final Database db = getDB();
final int namerec= db.getInt(record + NAME);
final long namerec= db.getRecPtr(record + NAME);
if (namerec != 0) {
db.free(namerec);
}

View file

@ -32,11 +32,11 @@ public abstract class PDOMNode implements IInternalPDOMNode {
protected static final int RECORD_SIZE = 8;
private final PDOMLinkage fLinkage;
protected final int record;
protected final long record;
private int cachedParentRecord;
private long cachedParentRecord;
protected PDOMNode(PDOMLinkage linkage, int record) {
protected PDOMNode(PDOMLinkage linkage, long record) {
fLinkage = linkage;
this.record = record;
}
@ -52,14 +52,14 @@ public abstract class PDOMNode implements IInternalPDOMNode {
this(db, null, 0);
}
protected PDOMNode(Database db, PDOMLinkage linkage, int parentRec) throws CoreException {
protected PDOMNode(Database db, PDOMLinkage linkage, long parentRec) throws CoreException {
this.fLinkage = linkage;
record = db.malloc(getRecordSize());
db.putInt(record + TYPE, getNodeType());
cachedParentRecord= parentRec;
db.putInt(record + PARENT, parentRec);
db.putRecPtr(record + PARENT, parentRec);
}
protected Database getDB() {
@ -78,11 +78,11 @@ public abstract class PDOMNode implements IInternalPDOMNode {
public abstract int getNodeType();
public final int getRecord() {
public final long getRecord() {
return record;
}
public final int getBindingID() {
public final long getBindingID() {
return record;
}
@ -113,26 +113,26 @@ public abstract class PDOMNode implements IInternalPDOMNode {
@Override
public final int hashCode() {
return System.identityHashCode(getPDOM()) + 41*record;
return System.identityHashCode(getPDOM()) + (int)(41*record);
}
public void accept(IPDOMVisitor visitor) throws CoreException {
// No children here.
}
public static int getNodeType(Database db, int record) throws CoreException {
public static int getNodeType(Database db, long record) throws CoreException {
return db.getInt(record + TYPE);
}
public int getParentNodeRec() throws CoreException {
public long getParentNodeRec() throws CoreException {
if (cachedParentRecord != 0) {
return cachedParentRecord;
}
return cachedParentRecord= getDB().getInt(record + PARENT);
return cachedParentRecord= getDB().getRecPtr(record + PARENT);
}
public PDOMNode getParentNode() throws CoreException {
int parentrec = getParentNodeRec();
long parentrec = getParentNodeRec();
return parentrec != 0 ? getLinkage().getNode(parentrec) : null;
}
@ -145,7 +145,7 @@ public abstract class PDOMNode implements IInternalPDOMNode {
* @param offset Location of the byte.
* @return a byte from the database.
*/
protected byte getByte(int offset) {
protected byte getByte(long offset) {
try {
return getDB().getByte(offset);
}

View file

@ -48,7 +48,7 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
private byte flags= -1;
private IType targetType;
public PDOMPointerType(PDOMLinkage linkage, int record) {
public PDOMPointerType(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -59,7 +59,7 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
try {
// type
int typeRec = 0;
long typeRec = 0;
byte flags = 0;
if (type != null) {
IType targetType= type.getType();
@ -71,7 +71,7 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
if (type.isVolatile())
flags |= VOLATILE;
}
db.putInt(record + TYPE, typeRec);
db.putRecPtr(record + TYPE, typeRec);
db.putByte(record + FLAGS, flags);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
@ -104,7 +104,7 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
private IType readType() {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -47,7 +47,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
private byte flags= -1;
private IType targetType;
public PDOMQualifierType(PDOMLinkage linkage, int record) {
public PDOMQualifierType(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -62,7 +62,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
IType targetType = type.getType();
PDOMNode targetTypeNode = getLinkage().addType(this, targetType);
if (targetTypeNode != null) {
db.putInt(record + TYPE, targetTypeNode.getRecord());
db.putRecPtr(record + TYPE, targetTypeNode.getRecord());
}
// flags
byte flags = 0;
@ -98,7 +98,7 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType, ICQua
private IType readType() {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -26,14 +26,14 @@ public class PDOMValue {
* Stores a value and returns the offset of where it was stored.
* @throws CoreException
*/
public static int store(Database db, PDOMLinkage linkage, IValue val) throws CoreException {
public static long store(Database db, PDOMLinkage linkage, IValue val) throws CoreException {
if (val == null)
return 0;
final IBinding[] unknown= val.getUnknownBindings();
int[] unknownRecs= {};
long[] unknownRecs= {};
if (unknown.length != 0) {
unknownRecs= new int[unknown.length];
unknownRecs= new long[unknown.length];
for (int i = 0; i < unknown.length; i++) {
PDOMNode node= linkage.addUnknownValue(unknown[i]);
if (node == null) {
@ -44,15 +44,15 @@ public class PDOMValue {
}
final short len= (short) Math.min(unknown.length, (Database.MAX_MALLOC_SIZE-6)/4);
final int block= db.malloc(6+4*len);
final int repRec= db.newString(val.getInternalExpression()).getRecord();
final long block= db.malloc(6+4*len);
final long repRec= db.newString(val.getInternalExpression()).getRecord();
db.putShort(block, len);
db.putInt(block+2, repRec);
db.putRecPtr(block+2, repRec);
int p= block+6;
long p= block+6;
for (int i = 0; i < len; i++) {
db.putInt(p, unknownRecs[i]);
db.putRecPtr(p, unknownRecs[i]);
p+= 4;
}
return block;
@ -62,21 +62,21 @@ public class PDOMValue {
* Restores a value from the given record
* @throws CoreException
*/
public static IValue restore(Database db, PDOMLinkage linkage, int valRec) throws CoreException {
public static IValue restore(Database db, PDOMLinkage linkage, long valRec) throws CoreException {
if (valRec == 0)
return null;
final int len= db.getShort(valRec);
final int repRec = db.getInt(valRec+2);
final long repRec = db.getRecPtr(valRec+2);
final char[] rep= db.getString(repRec).getChars();
if (len == 0)
return Value.fromInternalRepresentation(rep, ICPPUnknownBinding.EMPTY_UNKNOWN_BINDING_ARRAY);
ICPPUnknownBinding[] unknown= new ICPPUnknownBinding[len];
int p= valRec+6;
long p= valRec+6;
for (int i = 0; i < unknown.length; i++) {
int rec= db.getInt(p);
long rec= db.getRecPtr(p);
PDOMNode node= linkage.getNode(rec);
if (node instanceof ICPPUnknownBinding) {
unknown[i]= (ICPPUnknownBinding) node;
@ -92,10 +92,10 @@ public class PDOMValue {
/**
* Deletes a value stored at the given record.
*/
public static void delete(Database db, int valueRec) throws CoreException {
public static void delete(Database db, long valueRec) throws CoreException {
if (valueRec == 0)
return;
final int repRec = db.getInt(valueRec+2);
final long repRec = db.getRecPtr(valueRec+2);
db.getString(repRec).delete();
db.free(valueRec);
}

View file

@ -45,7 +45,7 @@ class PDOMCBasicType extends PDOMNode implements ICBasicType, IIndexType {
public static final int IS_IMAGINARY = 0x20;
public static final int IS_COMPLEX = 0x40;
public PDOMCBasicType(PDOMLinkage linkage, int record) {
public PDOMCBasicType(PDOMLinkage linkage, long record) {
super(linkage, record);
}

View file

@ -44,7 +44,7 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
super(linkage, parent, enumeration.getNameCharArray());
}
public PDOMCEnumeration(PDOMLinkage linkage, int record) {
public PDOMCEnumeration(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -77,14 +77,14 @@ class PDOMCEnumeration extends PDOMBinding implements IEnumeration, IIndexType {
}
private PDOMCEnumerator getFirstEnumerator() throws CoreException {
int value = getDB().getInt(record + FIRST_ENUMERATOR);
long value = getDB().getRecPtr(record + FIRST_ENUMERATOR);
return value != 0 ? new PDOMCEnumerator(getLinkage(), value) : null;
}
public void addEnumerator(PDOMCEnumerator enumerator) throws CoreException {
PDOMCEnumerator first = getFirstEnumerator();
enumerator.setNextEnumerator(first);
getDB().putInt(record + FIRST_ENUMERATOR, enumerator.getRecord());
getDB().putRecPtr(record + FIRST_ENUMERATOR, enumerator.getRecord());
}
public boolean isSameType(IType type) {

View file

@ -41,12 +41,12 @@ class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
super(linkage, parent, enumerator.getNameCharArray());
final Database db = getDB();
db.putInt(record + ENUMERATION, enumeration.getRecord());
db.putRecPtr(record + ENUMERATION, enumeration.getRecord());
storeValue(db, enumerator);
enumeration.addEnumerator(this);
}
public PDOMCEnumerator(PDOMLinkage linkage, int record) {
public PDOMCEnumerator(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -76,18 +76,18 @@ class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
public PDOMCEnumerator getNextEnumerator() throws CoreException {
int value = getDB().getInt(record + NEXT_ENUMERATOR);
long value = getDB().getRecPtr(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;
getDB().putInt(record + NEXT_ENUMERATOR, value);
long value = enumerator != null ? enumerator.getRecord() : 0;
getDB().putRecPtr(record + NEXT_ENUMERATOR, value);
}
public IType getType() throws DOMException {
try {
return new PDOMCEnumeration(getLinkage(), getDB().getInt(record + ENUMERATION));
return new PDOMCEnumeration(getLinkage(), getDB().getRecPtr(record + ENUMERATION));
} catch (CoreException e) {
CCorePlugin.log(e);
return null;

View file

@ -31,7 +31,7 @@ class PDOMCField extends PDOMCVariable implements IField {
super(linkage, (PDOMNode) parent, field);
}
public PDOMCField(PDOMLinkage linkage, int record) {
public PDOMCField(PDOMLinkage linkage, long record) {
super(linkage, record);
}

View file

@ -63,7 +63,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
@SuppressWarnings("hiding")
public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 13;
public PDOMCFunction(PDOMLinkage linkage, int record) {
public PDOMCFunction(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -115,34 +115,34 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
}
private void setType(PDOMLinkage linkage, IFunctionType ft) throws CoreException {
int rec= 0;
long rec= 0;
if (ft != null) {
PDOMNode typeNode = linkage.addType(this, ft);
if (typeNode != null) {
rec= typeNode.getRecord();
}
}
getDB().putInt(record + FUNCTION_TYPE, rec);
getDB().putRecPtr(record + FUNCTION_TYPE, rec);
}
private void setParameters(IParameter[] params) throws CoreException {
getDB().putInt(record + NUM_PARAMS, params.length);
getDB().putInt(record + FIRST_PARAM, 0);
getDB().putRecPtr(record + FIRST_PARAM, 0);
for (int i = 0; i < params.length; ++i) {
setFirstParameter(new PDOMCParameter(getLinkage(), this, params[i]));
}
}
public PDOMCParameter getFirstParameter() throws CoreException {
int rec = getDB().getInt(record + FIRST_PARAM);
long rec = getDB().getRecPtr(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;
getDB().putInt(record + FIRST_PARAM, rec);
long rec = param != null ? param.getRecord() : 0;
getDB().putRecPtr(record + FIRST_PARAM, rec);
}
@ -165,7 +165,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
* both the IType and IBinding interfaces.
*/
try {
int offset= getDB().getInt(record + FUNCTION_TYPE);
long offset= getDB().getRecPtr(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCFunctionType(getLinkage(), offset);
} catch(CoreException ce) {
CCorePlugin.log(ce);

View file

@ -54,7 +54,7 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
private IType[] parameterTypes;
public PDOMCFunctionType(PDOMLinkage linkage, int record) {
public PDOMCFunctionType(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -177,7 +177,7 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
public IType getReturnType() {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + RETURN_TYPE));
PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + RETURN_TYPE));
if (node instanceof IType) {
return (IType) node;
}
@ -190,7 +190,7 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
public void setReturnType(IType type) throws CoreException {
PDOMNode typeNode = getLinkage().addType(this, type);
if (typeNode != null) {
getDB().putInt(record + RETURN_TYPE, typeNode.getRecord());
getDB().putRecPtr(record + RETURN_TYPE, typeNode.getRecord());
}
}

View file

@ -47,7 +47,7 @@ import org.eclipse.core.runtime.CoreException;
*/
class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
public PDOMCLinkage(PDOM pdom, int record) {
public PDOMCLinkage(PDOM pdom, long record) {
super(pdom, record);
}
@ -85,7 +85,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
if (parent == null)
return null;
int[] localToFileHolder= {0};
long[] localToFileHolder= {0};
pdomBinding = adaptBinding(parent, binding, localToFileHolder);
if (pdomBinding == null) {
pdomBinding = createBinding(parent, binding, localToFileHolder[0]);
@ -104,7 +104,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
return pdomBinding;
}
private PDOMBinding createBinding(PDOMNode parent, IBinding binding, int localToFile) throws CoreException {
private PDOMBinding createBinding(PDOMNode parent, IBinding binding, long localToFile) throws CoreException {
PDOMBinding pdomBinding= null;
if (binding instanceof IField) { // must be before IVariable
@ -230,7 +230,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
return adaptBinding(null, inputBinding, FILE_LOCAL_REC_DUMMY);
}
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, int[] localToFileHolder) throws CoreException {
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, long[] localToFileHolder) throws CoreException {
if (inputBinding instanceof CompositeIndexBinding) {
inputBinding= ((CompositeIndexBinding) inputBinding).getRawBinding();
}
@ -256,7 +256,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
return result;
}
private final PDOMBinding doAdaptBinding(PDOMNode parent, final IBinding binding, int[] localToFileHolder) throws CoreException {
private final PDOMBinding doAdaptBinding(PDOMNode parent, final IBinding binding, long[] localToFileHolder) throws CoreException {
if (parent == null) {
parent= getAdaptedParent(binding);
}
@ -276,7 +276,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
final int[] bindingTypes = new int[] {getBindingType(binding)};
final char[] nameChars = binding.getNameCharArray();
PDOMBinding nonLocal= FindBinding.findBinding(getIndex(), this, nameChars, bindingTypes, 0);
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
long localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
if (localToFileRec == 0)
return nonLocal;
localToFileHolder[0]= localToFileRec;
@ -286,7 +286,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
final int[] bindingTypes = new int[] {getBindingType(binding)};
final char[] nameChars = binding.getNameCharArray();
PDOMBinding nonLocal= FindBinding.findBinding(parent, this, nameChars, bindingTypes, 0);
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
long localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
if (localToFileRec == 0)
return nonLocal;
localToFileHolder[0]= localToFileRec;
@ -296,7 +296,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
}
@Override
public PDOMNode getNode(int record) throws CoreException {
public PDOMNode getNode(long record) throws CoreException {
if (record == 0)
return null;

View file

@ -21,7 +21,7 @@ import org.eclipse.core.runtime.CoreException;
*/
public class PDOMCLinkageFactory implements IPDOMLinkageFactory {
public PDOMLinkage getLinkage(PDOM pdom, int record) {
public PDOMLinkage getLinkage(PDOM pdom, long record) {
return new PDOMCLinkage(pdom, record);
}

View file

@ -48,7 +48,7 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
assert RECORD_SIZE <= 22; // 23 would yield a 32-byte block
}
public PDOMCParameter(PDOMLinkage linkage, int record) {
public PDOMCParameter(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -58,13 +58,13 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
Database db = getDB();
db.putInt(record + NEXT_PARAM, 0);
db.putRecPtr(record + NEXT_PARAM, 0);
try {
if(!(param instanceof IProblemBinding)) {
IType type = param.getType();
if (type != null) {
PDOMNode typeNode = getLinkage().addType(this, type);
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
db.putRecPtr(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
byte flags = encodeFlags(param);
db.putByte(record + FLAGS, flags);
@ -85,12 +85,12 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
}
public void setNextParameter(PDOMCParameter nextParam) throws CoreException {
int rec = nextParam != null ? nextParam.getRecord() : 0;
getDB().putInt(record + NEXT_PARAM, rec);
long rec = nextParam != null ? nextParam.getRecord() : 0;
getDB().putRecPtr(record + NEXT_PARAM, rec);
}
public PDOMCParameter getNextParameter() throws CoreException {
int rec = getDB().getInt(record + NEXT_PARAM);
long rec = getDB().getRecPtr(record + NEXT_PARAM);
return rec != 0 ? new PDOMCParameter(getLinkage(), rec) : null;
}
@ -102,7 +102,7 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBinding {
public IType getType() {
try {
PDOMLinkage linkage = getLinkage();
PDOMNode node = linkage.getNode(getDB().getInt(record + TYPE));
PDOMNode node = linkage.getNode(getDB().getRecPtr(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -63,7 +63,7 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
// linked list is initialized by malloc zeroing allocated storage
}
public PDOMCStructure(PDOMLinkage linkage, int record) {
public PDOMCStructure(PDOMLinkage linkage, long record) {
super(linkage, record);
}

View file

@ -50,7 +50,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
}
}
public PDOMCTypedef(PDOMLinkage linkage, int record) {
public PDOMCTypedef(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -77,7 +77,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
linkage.deleteType((IType) typeNode, record);
typeNode= null;
}
getDB().putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
getDB().putRecPtr(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
private boolean introducesRecursion(IType type, char[] tdname) throws DOMException {
@ -122,7 +122,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
public IType getType() {
try {
int typeRec = getDB().getInt(record + TYPE);
long typeRec = getDB().getRecPtr(record + TYPE);
return (IType)getLinkage().getNode(typeRec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -75,8 +75,8 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
private void setValue(final Database db, IVariable variable) throws CoreException {
IValue val= variable.getInitialValue();
int valrec= PDOMValue.store(db, getLinkage(), val);
db.putInt(record + VALUE_OFFSET, valrec);
long valrec= PDOMValue.store(db, getLinkage(), val);
db.putRecPtr(record + VALUE_OFFSET, valrec);
}
@Override
@ -85,7 +85,7 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
final Database db = getDB();
IVariable var= (IVariable) newBinding;
IType mytype= getType();
int valueRec= db.getInt(record + VALUE_OFFSET);
long valueRec= db.getRecPtr(record + VALUE_OFFSET);
try {
IType newType= var.getType();
setType(linkage, newType);
@ -103,10 +103,10 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
private void setType(final PDOMLinkage linkage, final IType type) throws CoreException {
final PDOMNode typeNode = linkage.addType(this, type);
getDB().putInt(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
getDB().putRecPtr(record + TYPE_OFFSET, typeNode != null ? typeNode.getRecord() : 0);
}
public PDOMCVariable(PDOMLinkage linkage, int record) {
public PDOMCVariable(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -122,7 +122,7 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
public IType getType() {
try {
int typeRec = getDB().getInt(record + TYPE_OFFSET);
long typeRec = getDB().getRecPtr(record + TYPE_OFFSET);
return (IType)getLinkage().getNode(typeRec);
} catch (CoreException e) {
CCorePlugin.log(e);
@ -133,7 +133,7 @@ class PDOMCVariable extends PDOMBinding implements IVariable {
public IValue getInitialValue() {
try {
final Database db = getDB();
int valRec = db.getInt(record + VALUE_OFFSET);
long valRec = db.getRecPtr(record + VALUE_OFFSET);
return PDOMValue.restore(db, getLinkage(), valRec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -35,7 +35,7 @@ public class CPPFindBinding extends FindBinding {
super(linkage);
}
@Override
public int compare(int record1, int record2) throws CoreException {
public int compare(long record1, long record2) throws CoreException {
int cmp = super.compare(record1, record2);
if (cmp == 0) {
PDOMBinding binding1 = linkage.getBinding(record1);
@ -53,14 +53,14 @@ public class CPPFindBinding extends FindBinding {
public static class CPPFindBindingVisitor extends FindBinding.DefaultFindBindingVisitor {
private final int fConstant;
private final int fSigHash;
public CPPFindBindingVisitor(PDOMLinkage linkage, char[] name, int constant, int hash, int localToFile) {
public CPPFindBindingVisitor(PDOMLinkage linkage, char[] name, int constant, int hash, long localToFile) {
super(linkage, name, new int[] {constant}, localToFile);
fConstant= constant;
fSigHash= hash;
}
@Override
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
int cmp= super.compare(record);
if (cmp == 0) {
int c1 = PDOMNode.getNodeType(fLinkage.getDB(), record);
@ -78,7 +78,7 @@ public class CPPFindBinding extends FindBinding {
}
@Override
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
fResult= fLinkage.getBinding(record);
return false;
}
@ -96,14 +96,14 @@ public class CPPFindBinding extends FindBinding {
}
public static PDOMBinding findBinding(BTree btree, final PDOMLinkage linkage, final char[] name,
final int c2, final int ty2, int localToFileRec) throws CoreException {
final int c2, final int ty2, long localToFileRec) throws CoreException {
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(linkage, name, c2, ty2, localToFileRec);
btree.accept(visitor);
return visitor.getResult();
}
public static PDOMBinding findBinding(PDOMNode node, PDOMLinkage linkage, char[] name, int constant,
int sigHash, int localToFileRec) throws CoreException {
int sigHash, long localToFileRec) throws CoreException {
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(linkage, name, constant, sigHash,
localToFileRec);
try {
@ -114,7 +114,7 @@ public class CPPFindBinding extends FindBinding {
}
public static PDOMBinding findBinding(BTree btree, PDOMLinkage linkage, IBinding binding,
int localToFileRec) throws CoreException {
long localToFileRec) throws CoreException {
Integer hash= 0;
try {
hash = IndexCPPSignatureUtil.getSignatureHash(binding);
@ -129,7 +129,7 @@ public class CPPFindBinding extends FindBinding {
}
public static PDOMBinding findBinding(PDOMNode node, PDOMLinkage linkage, IBinding binding,
int localToFileRec) throws CoreException {
long localToFileRec) throws CoreException {
Integer hash = null;
try {
hash = IndexCPPSignatureUtil.getSignatureHash(binding);

View file

@ -30,12 +30,12 @@ public class PDOMCPPArgumentList {
* Stores the given template arguments in the database.
* @return the record by which the arguments can be referenced.
*/
public static int putArguments(PDOMNode parent, ICPPTemplateArgument[] templateArguments) throws CoreException {
public static long putArguments(PDOMNode parent, ICPPTemplateArgument[] templateArguments) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
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;
final long block= db.malloc(2+8*len);
long p= block;
db.putShort(p, len); p+=2;
for (int i=0; i<len; i++, p+=8) {
@ -44,13 +44,13 @@ public class PDOMCPPArgumentList {
if (isNonType) {
final PDOMNode type= linkage.addType(parent, arg.getTypeOfNonTypeValue());
// type can be null, if it is a local type
db.putInt(p, type == null ? 0 : type.getRecord());
int valueRec= PDOMValue.store(db, linkage, arg.getNonTypeValue());
db.putInt(p+4, valueRec);
db.putRecPtr(p, type == null ? 0 : type.getRecord());
long valueRec= PDOMValue.store(db, linkage, arg.getNonTypeValue());
db.putRecPtr(p+4, valueRec);
} else {
final PDOMNode type= linkage.addType(parent, arg.getTypeValue());
// type can be null, if it is a local type.
db.putInt(p, type == null ? 0 : type.getRecord());
db.putRecPtr(p, type == null ? 0 : type.getRecord());
}
}
return block;
@ -60,20 +60,20 @@ public class PDOMCPPArgumentList {
/**
* Restores an array of template arguments from the database.
*/
public static void clearArguments(PDOMNode parent, final int record) throws CoreException {
public static void clearArguments(PDOMNode parent, final long record) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getDB();
final short len= db.getShort(record);
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/8);
int p= record+2;
long p= record+2;
for (int i=0; i<len; i++) {
final int typeRec= db.getInt(p);
final long typeRec= db.getRecPtr(p);
if (typeRec != 0) {
final IType t= (IType) linkage.getNode(typeRec);
linkage.deleteType(t, parent.getRecord());
}
final int nonTypeValueRec= db.getInt(p+4);
final long nonTypeValueRec= db.getRecPtr(p+4);
PDOMValue.delete(db, nonTypeValueRec);
p+= 8;
}
@ -83,7 +83,7 @@ public class PDOMCPPArgumentList {
/**
* Restores an array of template arguments from the database.
*/
public static ICPPTemplateArgument[] getArguments(PDOMNode parent, int rec) throws CoreException {
public static ICPPTemplateArgument[] getArguments(PDOMNode parent, long rec) throws CoreException {
final PDOMLinkage linkage= parent.getLinkage();
final Database db= linkage.getDB();
final short len= db.getShort(rec);
@ -96,9 +96,9 @@ public class PDOMCPPArgumentList {
rec+=2;
ICPPTemplateArgument[] result= new ICPPTemplateArgument[len];
for (int i=0; i<len; i++) {
final int typeRec= db.getInt(rec);
final long typeRec= db.getRecPtr(rec);
final IType type= typeRec == 0 ? new CPPBasicType(-1,0) : (IType) linkage.getNode(typeRec);
final int nonTypeValRec= db.getInt(rec+4);
final long nonTypeValRec= db.getRecPtr(rec+4);
if (nonTypeValRec != 0) {
final IValue val= PDOMValue.restore(db, linkage, nonTypeValRec);
result[i]= new CPPTemplateArgument(val, type);

View file

@ -36,11 +36,11 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
protected static final int RECORD_SIZE = 9;
private final PDOMLinkage linkage;
private final int record;
private final long record;
private PDOMBinding fCachedBaseClass;
public PDOMCPPBase(PDOMLinkage linkage, int record) {
public PDOMCPPBase(PDOMLinkage linkage, long record) {
this.linkage = linkage;
this.record = record;
}
@ -50,8 +50,8 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
Database db = getDB();
this.record = db.malloc(RECORD_SIZE);
int baserec = baseClassSpec != null ? baseClassSpec.getRecord() : 0;
db.putInt(record + BASECLASS_SPECIFIER, baserec);
long baserec = baseClassSpec != null ? baseClassSpec.getRecord() : 0;
db.putRecPtr(record + BASECLASS_SPECIFIER, baserec);
byte flags = (byte)(visibility | (isVirtual ? 4 : 0));
db.putByte(record + FLAGS, flags);
@ -61,17 +61,17 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
return linkage.getDB();
}
public int getRecord() {
public long getRecord() {
return record;
}
public void setNextBase(PDOMCPPBase nextBase) throws CoreException {
int rec = nextBase != null ? nextBase.getRecord() : 0;
getDB().putInt(record + NEXTBASE, rec);
long rec = nextBase != null ? nextBase.getRecord() : 0;
getDB().putRecPtr(record + NEXTBASE, rec);
}
public PDOMCPPBase getNextBase() throws CoreException {
int rec = getDB().getInt(record + NEXTBASE);
long rec = getDB().getRecPtr(record + NEXTBASE);
return rec != 0 ? new PDOMCPPBase(linkage, rec) : null;
}
@ -81,7 +81,7 @@ class PDOMCPPBase implements ICPPBase, ICPPInternalBase {
public PDOMName getBaseClassSpecifierName() {
try {
int rec = getDB().getInt(record + BASECLASS_SPECIFIER);
long rec = getDB().getRecPtr(record + BASECLASS_SPECIFIER);
if (rec != 0) {
return new PDOMName(linkage, rec);
}

View file

@ -41,7 +41,7 @@ class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType, IIndexType {
protected short fFlags= -1;
protected short fType= -1;
public PDOMCPPBasicType(PDOMLinkage linkage, int record) {
public PDOMCPPBasicType(PDOMLinkage linkage, long record) {
super(linkage, record);
}

View file

@ -36,7 +36,7 @@ abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE= PDOMBinding.RECORD_SIZE + 0;
public PDOMCPPBinding(PDOMLinkage linkage, int record) {
public PDOMCPPBinding(PDOMLinkage linkage, long record) {
super(linkage, record);
}
public PDOMCPPBinding(PDOMLinkage linkage, PDOMNode parent, char[] name) throws CoreException {

View file

@ -45,11 +45,11 @@ class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTem
throws CoreException {
super(linkage, parent, classType, orig);
final ICPPTemplateInstance asInstance= (ICPPTemplateInstance) classType;
final int argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
getDB().putInt(record + ARGUMENTS, argListRec);
final long argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
getDB().putRecPtr(record + ARGUMENTS, argListRec);
}
public PDOMCPPClassInstance(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPClassInstance(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -69,7 +69,7 @@ class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTem
public ICPPTemplateArgument[] getTemplateArguments() {
try {
final int rec= getPDOM().getDB().getInt(record + ARGUMENTS);
final long rec= getPDOM().getDB().getRecPtr(record + ARGUMENTS);
return PDOMCPPArgumentList.getArguments(this, rec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -172,7 +172,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
* Visit bindings via the cache.
*/
public static void acceptViaCache(IPDOMCPPClassType ct, IPDOMVisitor visitor, boolean includeNestedInAnonymous) throws CoreException {
final int record= ct.getRecord();
final long record= ct.getRecord();
CharArrayMap<List<PDOMBinding>> map= getBindingMap(ct);
for (List<PDOMBinding> list : map.values()) {
for (PDOMBinding node : list) {
@ -187,7 +187,7 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
}
public static CharArrayMap<List<PDOMBinding>> getBindingMap(IPDOMCPPClassType ct) throws CoreException {
final Integer key= ct.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
final Long key= ct.getRecord() + PDOMCPPLinkage.CACHE_MEMBERS;
final PDOM pdom = ct.getPDOM();
@SuppressWarnings("unchecked")
Reference<CharArrayMap<List<PDOMBinding>>> cached= (Reference<CharArrayMap<List<PDOMBinding>>>) pdom.getCachedResult(key);

View file

@ -72,7 +72,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
super(linkage, parent, (ICPPSpecialization) classType, specialized);
}
public PDOMCPPClassSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPClassSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -93,7 +93,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
public IBinding specializeMember(IBinding original) {
if (specializationMap == null) {
final Integer key= record+PDOMCPPLinkage.CACHE_INSTANCE_SCOPE;
final Long key= record+PDOMCPPLinkage.CACHE_INSTANCE_SCOPE;
Object cached= getPDOM().getCachedResult(key);
if (cached != null) {
specializationMap= (ObjectMap) cached;
@ -145,13 +145,13 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
}
public PDOMCPPBase getFirstBase() throws CoreException {
int rec = getDB().getInt(record + FIRSTBASE);
long rec = getDB().getRecPtr(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(getLinkage(), rec) : null;
}
private void setFirstBase(PDOMCPPBase base) throws CoreException {
int rec = base != null ? base.getRecord() : 0;
getDB().putInt(record + FIRSTBASE, rec);
long rec = base != null ? base.getRecord() : 0;
getDB().putRecPtr(record + FIRSTBASE, rec);
}
public void addBase(PDOMCPPBase base) throws CoreException {
@ -163,7 +163,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
public void removeBase(PDOMName pdomName) throws CoreException {
PDOMCPPBase base= getFirstBase();
PDOMCPPBase predecessor= null;
int nameRec= pdomName.getRecord();
long nameRec= pdomName.getRecord();
while (base != null) {
PDOMName name = base.getBaseClassSpecifierName();
if (name != null && name.getRecord() == nameRec) {
@ -191,7 +191,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
}
// this is an explicit specialization
Integer key= record + PDOMCPPLinkage.CACHE_BASES;
Long key= record + PDOMCPPLinkage.CACHE_BASES;
ICPPBase[] bases= (ICPPBase[]) getPDOM().getCachedResult(key);
if (bases != null)
return bases;

View file

@ -66,13 +66,13 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
final Database db = getDB();
final ICPPTemplateParameter[] origParams= template.getTemplateParameters();
final IPDOMCPPTemplateParameter[] params = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
int rec= PDOMTemplateParameterArray.putArray(db, params);
db.putInt(record + PARAMETERS, rec);
long rec= PDOMTemplateParameterArray.putArray(db, params);
db.putRecPtr(record + PARAMETERS, rec);
db.putShort(record + RELEVANT_PARAMETERS, (short) params.length);
linkage.new ConfigureTemplateParameters(origParams, params);
}
public PDOMCPPClassTemplate(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPClassTemplate(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -90,7 +90,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
if (params == null) {
try {
final Database db = getDB();
int rec= db.getInt(record + PARAMETERS);
long rec= db.getRecPtr(record + PARAMETERS);
int count= Math.max(0, db.getShort(record + RELEVANT_PARAMETERS));
if (rec == 0 || count == 0) {
params= ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
@ -127,7 +127,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
private void updateTemplateParameters(PDOMLinkage linkage, ICPPTemplateParameter[] newParams) throws CoreException, DOMException {
final Database db = getDB();
int rec= db.getInt(record + PARAMETERS);
long rec= db.getRecPtr(record + PARAMETERS);
IPDOMCPPTemplateParameter[] allParams;
if (rec == 0) {
allParams= IPDOMCPPTemplateParameter.EMPTY_ARRAY;
@ -184,7 +184,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
if (rec != 0)
db.free(rec);
rec= PDOMTemplateParameterArray.putArray(db, newAllParams);
db.putInt(record + PARAMETERS, rec);
db.putRecPtr(record + PARAMETERS, rec);
}
db.putShort(record + RELEVANT_PARAMETERS, (short) newParamLength);
}
@ -199,14 +199,14 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
}
private PDOMCPPClassTemplatePartialSpecialization getFirstPartial() throws CoreException {
int value = getDB().getInt(record + FIRST_PARTIAL);
long value = getDB().getRecPtr(record + FIRST_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecialization(getLinkage(), value) : null;
}
public void addPartial(PDOMCPPClassTemplatePartialSpecialization partial) throws CoreException {
PDOMCPPClassTemplatePartialSpecialization first = getFirstPartial();
partial.setNextPartial(first);
getDB().putInt(record + FIRST_PARTIAL, partial.getRecord());
getDB().putRecPtr(record + FIRST_PARTIAL, partial.getRecord());
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {

View file

@ -57,7 +57,7 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
ICPPClassTemplatePartialSpecialization partial, PDOMCPPClassTemplate primary)
throws CoreException, DOMException {
super(linkage, parent, partial);
getDB().putInt(record + PRIMARY, primary.getRecord());
getDB().putRecPtr(record + PRIMARY, primary.getRecord());
primary.addPartial(this);
try {
@ -70,7 +70,7 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
}
public PDOMCPPClassTemplatePartialSpecialization(PDOMLinkage linkage,
int bindingRecord) {
long bindingRecord) {
super(linkage, bindingRecord);
}
@ -89,18 +89,18 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
}
public PDOMCPPClassTemplatePartialSpecialization getNextPartial() throws CoreException {
int value = getDB().getInt(record + NEXT_PARTIAL);
long value = getDB().getRecPtr(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;
getDB().putInt(record + NEXT_PARTIAL, value);
long value = partial != null ? partial.getRecord() : 0;
getDB().putRecPtr(record + NEXT_PARTIAL, value);
}
public ICPPClassTemplate getPrimaryClassTemplate() {
try {
return new PDOMCPPClassTemplate(getLinkage(), getDB().getInt(record + PRIMARY));
return new PDOMCPPClassTemplate(getLinkage(), getDB().getRecPtr(record + PRIMARY));
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
@ -113,9 +113,9 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
public void setArguments(ICPPTemplateArgument[] templateArguments) throws CoreException {
final Database db = getPDOM().getDB();
int oldRec = db.getInt(record+ARGUMENTS);
int rec= PDOMCPPArgumentList.putArguments(this, templateArguments);
db.putInt(record+ARGUMENTS, rec);
long oldRec = db.getRecPtr(record+ARGUMENTS);
long rec= PDOMCPPArgumentList.putArguments(this, templateArguments);
db.putRecPtr(record+ARGUMENTS, rec);
if (oldRec != 0) {
PDOMCPPArgumentList.clearArguments(this, oldRec);
}
@ -123,7 +123,7 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
public ICPPTemplateArgument[] getTemplateArguments() {
try {
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
final long rec= getPDOM().getDB().getRecPtr(record+ARGUMENTS);
return PDOMCPPArgumentList.getArguments(this, rec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -46,14 +46,14 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
PDOMCPPClassTemplateSpecialization primary) throws CoreException {
super(linkage, parent, partial, specialized);
getDB().putInt(record + PRIMARY_TEMPLATE, primary.getRecord());
getDB().putRecPtr(record + PRIMARY_TEMPLATE, primary.getRecord());
primary.addPartial(this);
linkage.new ConfigurePartialSpecialization(this, partial);
}
public PDOMCPPClassTemplatePartialSpecializationSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPClassTemplatePartialSpecializationSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -73,13 +73,13 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
}
public PDOMCPPClassTemplatePartialSpecializationSpecialization getNextPartial() throws CoreException {
int value = getDB().getInt(record + NEXT_PARTIAL);
long value = getDB().getRecPtr(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;
getDB().putInt(record + NEXT_PARTIAL, value);
long value = partial != null ? partial.getRecord() : 0;
getDB().putRecPtr(record + NEXT_PARTIAL, value);
}
@Override
@ -135,9 +135,9 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
public void setArguments(ICPPTemplateArgument[] templateArguments) throws CoreException {
final Database db = getPDOM().getDB();
int oldRec = db.getInt(record+ARGUMENTS);
int rec= PDOMCPPArgumentList.putArguments(this, templateArguments);
db.putInt(record+ARGUMENTS, rec);
long oldRec = db.getRecPtr(record+ARGUMENTS);
long rec= PDOMCPPArgumentList.putArguments(this, templateArguments);
db.putRecPtr(record+ARGUMENTS, rec);
if (oldRec != 0) {
PDOMCPPArgumentList.clearArguments(this, oldRec);
}
@ -145,7 +145,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
public ICPPTemplateArgument[] getTemplateArguments() {
try {
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
final long rec= getPDOM().getDB().getRecPtr(record+ARGUMENTS);
return PDOMCPPArgumentList.getArguments(this, rec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -54,7 +54,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
super(linkage, parent, template, specialized);
}
public PDOMCPPClassTemplateSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPClassTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -162,14 +162,14 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
}
private PDOMCPPClassTemplatePartialSpecializationSpecialization getFirstPartial() throws CoreException {
int value = getDB().getInt(record + FIRST_PARTIAL);
long value = getDB().getRecPtr(record + FIRST_PARTIAL);
return value != 0 ? new PDOMCPPClassTemplatePartialSpecializationSpecialization(getLinkage(), value) : null;
}
public void addPartial(PDOMCPPClassTemplatePartialSpecializationSpecialization pspecspec) throws CoreException {
PDOMCPPClassTemplatePartialSpecializationSpecialization first = getFirstPartial();
pspecspec.setNextPartial(first);
getDB().putInt(record + FIRST_PARTIAL, pspecspec.getRecord());
getDB().putRecPtr(record + FIRST_PARTIAL, pspecspec.getRecord());
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {

View file

@ -72,7 +72,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
// linked list is initialized by storage being zero'd by malloc
}
public PDOMCPPClassType(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPClassType(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -139,13 +139,13 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
}
private PDOMCPPBase getFirstBase() throws CoreException {
int rec = getDB().getInt(record + FIRSTBASE);
long rec = getDB().getRecPtr(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(getLinkage(), rec) : null;
}
private void setFirstBase(PDOMCPPBase base) throws CoreException {
int rec = base != null ? base.getRecord() : 0;
getDB().putInt(record + FIRSTBASE, rec);
long rec = base != null ? base.getRecord() : 0;
getDB().putRecPtr(record + FIRSTBASE, rec);
}
public void addBase(PDOMCPPBase base) throws CoreException {
@ -160,7 +160,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
PDOMCPPBase base= getFirstBase();
PDOMCPPBase predecessor= null;
int nameRec= pdomName.getRecord();
long nameRec= pdomName.getRecord();
while (base != null) {
PDOMName name = base.getBaseClassSpecifierName();
if (name != null && name.getRecord() == nameRec) {
@ -187,19 +187,19 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
}
private PDOMCPPFriend getFirstFriend() throws CoreException {
int rec = getDB().getInt(record + FIRSTFRIEND);
long rec = getDB().getRecPtr(record + FIRSTFRIEND);
return rec != 0 ? new PDOMCPPFriend(getLinkage(), rec) : null;
}
private void setFirstFriend(PDOMCPPFriend friend) throws CoreException {
int rec = friend != null ? friend.getRecord() : 0;
getDB().putInt(record + FIRSTFRIEND, rec);
long rec = friend != null ? friend.getRecord() : 0;
getDB().putRecPtr(record + FIRSTFRIEND, rec);
}
public void removeFriend(PDOMName pdomName) throws CoreException {
PDOMCPPFriend friend = getFirstFriend();
PDOMCPPFriend predecessor= null;
int nameRec= pdomName.getRecord();
long nameRec= pdomName.getRecord();
while (friend != null) {
PDOMName name = friend.getSpecifierName();
if (name != null && name.getRecord() == nameRec) {
@ -277,7 +277,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
}
public ICPPBase[] getBases() throws DOMException {
Integer key= record + PDOMCPPLinkage.CACHE_BASES;
Long key= record + PDOMCPPLinkage.CACHE_BASES;
ICPPBase[] bases= (ICPPBase[]) getPDOM().getCachedResult(key);
if (bases != null)
return bases;

View file

@ -25,7 +25,7 @@ class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor {
super(linkage, parent, method);
}
public PDOMCPPConstructor(PDOMLinkage linkage, int record) {
public PDOMCPPConstructor(PDOMLinkage linkage, long record) {
super(linkage, record);
}

View file

@ -37,7 +37,7 @@ public class PDOMCPPConstructorInstance extends PDOMCPPMethodInstance implements
super(linkage, parent, method, instantiated);
}
public PDOMCPPConstructorInstance(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPConstructorInstance(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -35,7 +35,7 @@ class PDOMCPPConstructorSpecialization extends
super(linkage, parent, constructor, specialized);
}
public PDOMCPPConstructorSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPConstructorSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -29,7 +29,7 @@ class PDOMCPPConstructorTemplate extends PDOMCPPMethodTemplate implements
super(linkage, parent, method);
}
public PDOMCPPConstructorTemplate(PDOMLinkage linkage, int record) {
public PDOMCPPConstructorTemplate(PDOMLinkage linkage, long record) {
super(linkage, record);
}

View file

@ -36,7 +36,7 @@ class PDOMCPPConstructorTemplateSpecialization extends
super(linkage, parent, constructor, specialized);
}
public PDOMCPPConstructorTemplateSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPConstructorTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -63,11 +63,11 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
throws CoreException {
super(linkage, parent, classType, instantiated);
final int argListRec= PDOMCPPArgumentList.putArguments(this, classType.getTemplateArguments());
getDB().putInt(record+ARGUMENTS, argListRec);
final long argListRec= PDOMCPPArgumentList.putArguments(this, classType.getTemplateArguments());
getDB().putRecPtr(record+ARGUMENTS, argListRec);
}
public PDOMCPPDeferredClassInstance(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPDeferredClassInstance(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -189,7 +189,7 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
public ICPPTemplateArgument[] getTemplateArguments() {
try {
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
final long rec= getPDOM().getDB().getRecPtr(record+ARGUMENTS);
return PDOMCPPArgumentList.getArguments(this, rec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -45,7 +45,7 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IEnumeration, IIndexT
super(linkage, parent, enumeration.getNameCharArray());
}
public PDOMCPPEnumeration(PDOMLinkage linkage, int record) {
public PDOMCPPEnumeration(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -86,14 +86,14 @@ class PDOMCPPEnumeration extends PDOMCPPBinding implements IEnumeration, IIndexT
}
private PDOMCPPEnumerator getFirstEnumerator() throws CoreException {
int value = getDB().getInt(record + FIRST_ENUMERATOR);
long value = getDB().getRecPtr(record + FIRST_ENUMERATOR);
return value != 0 ? new PDOMCPPEnumerator(getLinkage(), value) : null;
}
public void addEnumerator(PDOMCPPEnumerator enumerator) throws CoreException {
PDOMCPPEnumerator first = getFirstEnumerator();
enumerator.setNextEnumerator(first);
getDB().putInt(record + FIRST_ENUMERATOR, enumerator.getRecord());
getDB().putRecPtr(record + FIRST_ENUMERATOR, enumerator.getRecord());
}
public boolean isSameType(IType type) {

View file

@ -43,12 +43,12 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
super(linkage, parent, enumerator.getNameCharArray());
final Database db = getDB();
db.putInt(record + ENUMERATION, enumeration.getRecord());
db.putRecPtr(record + ENUMERATION, enumeration.getRecord());
storeValue(db, enumerator);
enumeration.addEnumerator(this);
}
public PDOMCPPEnumerator(PDOMLinkage linkage, int record) {
public PDOMCPPEnumerator(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -77,18 +77,18 @@ class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator {
}
public PDOMCPPEnumerator getNextEnumerator() throws CoreException {
int value = getDB().getInt(record + NEXT_ENUMERATOR);
long value = getDB().getRecPtr(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;
getDB().putInt(record + NEXT_ENUMERATOR, value);
long value = enumerator != null ? enumerator.getRecord() : 0;
getDB().putRecPtr(record + NEXT_ENUMERATOR, value);
}
public IType getType() throws DOMException {
try {
return new PDOMCPPEnumeration(getLinkage(), getDB().getInt(record + ENUMERATION));
return new PDOMCPPEnumeration(getLinkage(), getDB().getRecPtr(record + ENUMERATION));
} catch (CoreException e) {
CCorePlugin.log(e);
return null;

View file

@ -31,7 +31,7 @@ class PDOMCPPField extends PDOMCPPVariable implements ICPPField {
super(linkage, parent, field);
}
public PDOMCPPField(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPField(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -58,17 +58,17 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
IType type = field.getType();
PDOMNode typeNode = linkage.addType(this, type);
if (typeNode != null) {
db.putInt(record + TYPE, typeNode.getRecord());
db.putRecPtr(record + TYPE, typeNode.getRecord());
}
IValue val= field.getInitialValue();
int rec= PDOMValue.store(db, linkage, val);
db.putInt(record + VALUE_OFFSET, rec);
long rec= PDOMValue.store(db, linkage, val);
db.putRecPtr(record + VALUE_OFFSET, rec);
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public PDOMCPPFieldSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPFieldSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -92,7 +92,7 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
public IType getType() throws DOMException {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + TYPE));
if (node instanceof IType) {
return (IType) node;
}
@ -105,7 +105,7 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
public IValue getInitialValue() {
try {
final Database db = getDB();
int valRec = db.getInt(record + VALUE_OFFSET);
long valRec = db.getRecPtr(record + VALUE_OFFSET);
return PDOMValue.restore(db, getLinkage(), valRec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -26,15 +26,15 @@ class PDOMCPPFriend extends PDOMNode {
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 8;
public PDOMCPPFriend(PDOMLinkage linkage, int record) {
public PDOMCPPFriend(PDOMLinkage linkage, long record) {
super(linkage, record);
}
public PDOMCPPFriend(PDOMLinkage linkage, PDOMName friendSpec) throws CoreException {
super(linkage, null);
int friendrec = friendSpec != null ? friendSpec.getRecord() : 0;
linkage.getDB().putInt(record + FRIEND_SPECIFIER, friendrec);
long friendrec = friendSpec != null ? friendSpec.getRecord() : 0;
linkage.getDB().putRecPtr(record + FRIEND_SPECIFIER, friendrec);
}
@Override
@ -48,7 +48,7 @@ class PDOMCPPFriend extends PDOMNode {
}
public PDOMName getSpecifierName() throws CoreException {
int rec = getDB().getInt(record + FRIEND_SPECIFIER);
long rec = getDB().getRecPtr(record + FRIEND_SPECIFIER);
if (rec != 0) return new PDOMName(getLinkage(), rec);
return null;
}
@ -67,12 +67,12 @@ class PDOMCPPFriend extends PDOMNode {
}
public void setNextFriend(PDOMCPPFriend nextFriend) throws CoreException {
int rec = nextFriend != null ? nextFriend.getRecord() : 0;
getDB().putInt(record + NEXT_FRIEND, rec);
long rec = nextFriend != null ? nextFriend.getRecord() : 0;
getDB().putRecPtr(record + NEXT_FRIEND, rec);
}
public PDOMCPPFriend getNextFriend() throws CoreException {
int rec = getDB().getInt(record + NEXT_FRIEND);
long rec = getDB().getRecPtr(record + NEXT_FRIEND);
return rec != 0 ? new PDOMCPPFriend(getLinkage(), rec) : null;
}

View file

@ -134,7 +134,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
db.putByte(record + ANNOTATION, newAnnotation);
annotation= newAnnotation;
int oldRec = db.getInt(record+EXCEPTION_SPEC);
long oldRec = db.getRecPtr(record+EXCEPTION_SPEC);
storeExceptionSpec(db, func);
if (oldRec != 0) {
PDOMCPPTypeList.clearTypes(this, oldRec);
@ -143,7 +143,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
private void storeExceptionSpec(final Database db, ICPPFunction binding) throws CoreException {
int typelist= 0;
long typelist= 0;
try {
if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isImplicit()) {
// don't store the exception specification, computed it on demand.
@ -153,23 +153,23 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
} catch (DOMException e) {
// ignore problems in the exception specification.
}
db.putInt(record + EXCEPTION_SPEC, typelist);
db.putRecPtr(record + EXCEPTION_SPEC, typelist);
}
private void setParameters(PDOMCPPFunctionType pft, IParameter[] params) throws CoreException {
final Database db= getDB();
db.putInt(record + NUM_PARAMS, params.length);
db.putInt(record + FIRST_PARAM, 0);
db.putRecPtr(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;
long ptRecord= i < paramTypes.length && paramTypes[i] != null ? ((PDOMNode) paramTypes[i]).getRecord() : 0;
setFirstParameter(new PDOMCPPParameter(getLinkage(), this, params[i], ptRecord));
}
}
private PDOMCPPFunctionType setType(ICPPFunctionType ft) throws CoreException {
PDOMCPPFunctionType pft = (PDOMCPPFunctionType) getLinkage().addType(this, ft);
getDB().putInt(record + FUNCTION_TYPE, pft.getRecord());
getDB().putRecPtr(record + FUNCTION_TYPE, pft.getRecord());
getPDOM().putCachedResult(record, pft, true);
return pft;
}
@ -178,11 +178,11 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
return getDB().getInt(record + SIGNATURE_HASH);
}
public static int getSignatureHash(PDOMLinkage linkage, int record) throws CoreException {
public static int getSignatureHash(PDOMLinkage linkage, long record) throws CoreException {
return linkage.getDB().getInt(record + SIGNATURE_HASH);
}
public PDOMCPPFunction(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPFunction(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -197,15 +197,15 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
private PDOMCPPParameter getFirstParameter() throws CoreException {
int rec = getDB().getInt(record + FIRST_PARAM);
long rec = getDB().getRecPtr(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;
getDB().putInt(record + FIRST_PARAM, rec);
long rec = param != null ? param.getRecord() : 0;
getDB().putRecPtr(record + FIRST_PARAM, rec);
}
public boolean isInline() throws DOMException {
@ -258,7 +258,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
private final ICPPFunctionType readFunctionType() {
try {
int offset= getDB().getInt(record + FUNCTION_TYPE);
long offset= getDB().getRecPtr(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCPPFunctionType(getLinkage(), offset);
} catch(CoreException ce) {
CCorePlugin.log(ce);
@ -317,7 +317,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
public IType[] getExceptionSpecification() throws DOMException {
try {
final int rec = getPDOM().getDB().getInt(record+EXCEPTION_SPEC);
final long rec = getPDOM().getDB().getRecPtr(record+EXCEPTION_SPEC);
return PDOMCPPTypeList.getTypes(this, rec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -44,19 +44,19 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
super(linkage, parent, function, orig);
final ICPPTemplateInstance asInstance= (ICPPTemplateInstance) function;
final int argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
final long argListRec= PDOMCPPArgumentList.putArguments(this, asInstance.getTemplateArguments());
final Database db = getDB();
db.putInt(record+ARGUMENTS, argListRec);
db.putRecPtr(record+ARGUMENTS, argListRec);
try {
int exceptSpecRec = PDOMCPPTypeList.putTypes(this, function.getExceptionSpecification());
db.putInt(record+EXCEPTION_SPEC, exceptSpecRec);
long exceptSpecRec = PDOMCPPTypeList.putTypes(this, function.getExceptionSpecification());
db.putRecPtr(record+EXCEPTION_SPEC, exceptSpecRec);
} catch (DOMException e) {
// ignore problems in the exception specification
}
}
public PDOMCPPFunctionInstance(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPFunctionInstance(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -77,7 +77,7 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
public ICPPTemplateArgument[] getTemplateArguments() {
try {
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
final long rec= getPDOM().getDB().getRecPtr(record+ARGUMENTS);
return PDOMCPPArgumentList.getArguments(this, rec);
} catch (CoreException e) {
CCorePlugin.log(e);
@ -88,7 +88,7 @@ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements I
@Override
public IType[] getExceptionSpecification() throws DOMException {
try {
final int rec = getPDOM().getDB().getInt(record+EXCEPTION_SPEC);
final long rec = getPDOM().getDB().getRecPtr(record+EXCEPTION_SPEC);
return PDOMCPPTypeList.getTypes(this, rec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -80,7 +80,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
if (ft != null) {
PDOMNode typeNode = getLinkage().addType(this, ft);
if (typeNode != null) {
db.putInt(record + FUNCTION_TYPE, typeNode.getRecord());
db.putRecPtr(record + FUNCTION_TYPE, typeNode.getRecord());
}
}
@ -95,7 +95,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
final int length= Math.min(sParams.length, params.length);
db.putInt(record + NUM_PARAMS, length);
for (int i=0; i<length; ++i) {
int typeRecord= i<paramTypes.length && paramTypes[i]!=null ? ((PDOMNode)paramTypes[i]).getRecord() : 0;
long 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(getLinkage(), this, sParams[i], type);
@ -106,20 +106,20 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
throw new CoreException(Util.createStatus(e));
}
try {
int typelist= 0;
long typelist= 0;
if (function instanceof ICPPMethod && ((ICPPMethod) function).isImplicit()) {
// don't store the exception specification, computed it on demand.
} else {
typelist = PDOMCPPTypeList.putTypes(this, function.getExceptionSpecification());
}
db.putInt(record + EXCEPTION_SPEC, typelist);
db.putRecPtr(record + EXCEPTION_SPEC, typelist);
} catch (DOMException e) {
// ignore problems in the exception specification
}
}
public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -134,15 +134,15 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
public PDOMCPPParameterSpecialization getFirstParameter() throws CoreException {
int rec = getDB().getInt(record + FIRST_PARAM);
long rec = getDB().getRecPtr(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;
getDB().putInt(record + FIRST_PARAM, rec);
long rec = param != null ? param.getRecord() : 0;
getDB().putRecPtr(record + FIRST_PARAM, rec);
}
public boolean isInline() throws DOMException {
@ -175,7 +175,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
public ICPPFunctionType getType() throws DOMException {
try {
int offset= getDB().getInt(record + FUNCTION_TYPE);
long offset= getDB().getRecPtr(record + FUNCTION_TYPE);
return offset==0 ? null : new PDOMCPPFunctionType(getLinkage(), offset);
} catch(CoreException ce) {
CCorePlugin.log(ce);
@ -229,7 +229,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
public IType[] getExceptionSpecification() throws DOMException {
try {
final int rec = getPDOM().getDB().getInt(record+EXCEPTION_SPEC);
final long rec = getPDOM().getDB().getRecPtr(record+EXCEPTION_SPEC);
return PDOMCPPTypeList.getTypes(this, rec);
} catch (CoreException e) {
CCorePlugin.log(e);

View file

@ -52,12 +52,12 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
final ICPPTemplateParameter[] origParams= template.getTemplateParameters();
params = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
final Database db = getDB();
int rec= PDOMTemplateParameterArray.putArray(db, params);
db.putInt(record + TEMPLATE_PARAMS, rec);
long rec= PDOMTemplateParameterArray.putArray(db, params);
db.putRecPtr(record + TEMPLATE_PARAMS, rec);
linkage.new ConfigureFunctionTemplate(template, this);
}
public PDOMCPPFunctionTemplate(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPFunctionTemplate(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@ -79,7 +79,7 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
public IPDOMCPPTemplateParameter[] getTemplateParameters() {
if (params == null) {
try {
int rec= getDB().getInt(record + TEMPLATE_PARAMS);
long rec= getDB().getRecPtr(record + TEMPLATE_PARAMS);
if (rec == 0) {
params= IPDOMCPPTemplateParameter.EMPTY_ARRAY;
} else {

View file

@ -36,7 +36,7 @@ class PDOMCPPFunctionTemplateSpecialization extends PDOMCPPFunctionSpecializatio
super(linkage, parent, template, specialized);
}
public PDOMCPPFunctionTemplateSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPFunctionTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -67,7 +67,7 @@ public class PDOMCPPFunctionType extends PDOMCFunctionType implements ICPPFuncti
IPointerType thisType; // Cached value
int cvq= -1; // Cached value
protected PDOMCPPFunctionType(PDOMLinkage linkage, int offset) {
protected PDOMCPPFunctionType(PDOMLinkage linkage, long offset) {
super(linkage, offset);
}

View file

@ -98,7 +98,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
private LinkedList<Runnable> postProcesses = new LinkedList<Runnable>();
public PDOMCPPLinkage(PDOM pdom, int record) {
public PDOMCPPLinkage(PDOM pdom, long record) {
super(pdom, record);
}
@ -247,7 +247,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (parent == null)
return null;
int fileLocalRec[]= {0};
long fileLocalRec[]= {0};
pdomBinding = adaptBinding(parent, binding, fileLocalRec);
if (pdomBinding != null) {
getPDOM().putCachedResult(inputBinding, pdomBinding);
@ -295,7 +295,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return false;
}
PDOMBinding createBinding(PDOMNode parent, IBinding binding, int fileLocalRec) throws CoreException, DOMException {
PDOMBinding createBinding(PDOMNode parent, IBinding binding, long fileLocalRec) throws CoreException, DOMException {
PDOMBinding pdomBinding= null;
// template parameters are created directly by their owners.
@ -425,7 +425,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
try {
final int fileLocalRec= type.getLocalToFileRec();
final long fileLocalRec= type.getLocalToFileRec();
IScope scope = binding.getCompositeScope();
if (scope instanceof ICPPClassScope) {
ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods();
@ -553,7 +553,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return adaptBinding(null, inputBinding, FILE_LOCAL_REC_DUMMY);
}
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, int[] fileLocalRecHolder) throws CoreException {
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, long[] fileLocalRecHolder) throws CoreException {
if (cannotAdapt(inputBinding)) {
return null;
}
@ -579,7 +579,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
/**
* Find the equivalent binding, or binding place holder within this PDOM
*/
private final PDOMBinding doAdaptBinding(PDOMNode parent, IBinding binding, int[] fileLocalRecHolder) throws CoreException {
private final PDOMBinding doAdaptBinding(PDOMNode parent, IBinding binding, long[] fileLocalRecHolder) throws CoreException {
if (parent == null) {
parent= adaptOrAddParent(false, binding);
}
@ -597,7 +597,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (parent == this) {
PDOMBinding glob= CPPFindBinding.findBinding(getIndex(), this, binding, 0);
final int loc= getLocalToFileRec(inheritFileLocal, binding, glob);
final long loc= getLocalToFileRec(inheritFileLocal, binding, glob);
if (loc == 0)
return glob;
fileLocalRecHolder[0]= loc;
@ -606,7 +606,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (parent instanceof PDOMCPPNamespace) {
final BTree btree = ((PDOMCPPNamespace) parent).getIndex();
PDOMBinding glob= CPPFindBinding.findBinding(btree, this, binding, 0);
final int loc= getLocalToFileRec(inheritFileLocal, binding, glob);
final long loc= getLocalToFileRec(inheritFileLocal, binding, glob);
if (loc == 0)
return glob;
fileLocalRecHolder[0]= loc;
@ -618,7 +618,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
if (parent instanceof IPDOMMemberOwner) {
PDOMBinding glob= CPPFindBinding.findBinding(parent, this, binding, 0);
final int loc= getLocalToFileRec(inheritFileLocal, binding, glob);
final long loc= getLocalToFileRec(inheritFileLocal, binding, glob);
if (loc == 0)
return glob;
fileLocalRecHolder[0]= loc;
@ -731,7 +731,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
@Override
public PDOMNode getNode(int record) throws CoreException {
public PDOMNode getNode(long record) throws CoreException {
if (record == 0)
return null;
@ -891,7 +891,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
}
}
if (doit) {
int rec= file.getLastUsingDirectiveRec();
long rec= file.getLastUsingDirectiveRec();
PDOMCPPUsingDirective ud= new PDOMCPPUsingDirective(this, rec, containerNS,
pdomName.getBinding(), pdomName.getFileLocation().getNodeOffset());
file.setFirstUsingDirectiveRec(ud.getRecord());
@ -931,7 +931,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
*/
@Override
public ICPPUsingDirective[] getUsingDirectives(PDOMFile file) throws CoreException {
int rec= file.getLastUsingDirectiveRec();
long rec= file.getLastUsingDirectiveRec();
if (rec == 0) {
return ICPPUsingDirective.EMPTY_ARRAY;
}

View file

@ -22,7 +22,7 @@ import org.eclipse.core.runtime.CoreException;
*/
public class PDOMCPPLinkageFactory implements IPDOMLinkageFactory {
public PDOMLinkage getLinkage(PDOM pdom, int record) {
public PDOMLinkage getLinkage(PDOM pdom, long record) {
return new PDOMCPPLinkage(pdom, record);
}

View file

@ -74,7 +74,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
}
}
public PDOMCPPMethod(PDOMLinkage linkage, int record) {
public PDOMCPPMethod(PDOMLinkage linkage, long record) {
super(linkage, record);
}

View file

@ -37,7 +37,7 @@ class PDOMCPPMethodInstance extends PDOMCPPFunctionInstance implements ICPPMetho
super(linkage, parent, method, instantiated);
}
public PDOMCPPMethodInstance(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPMethodInstance(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -65,7 +65,7 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
}
}
public PDOMCPPMethodSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPMethodSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -66,7 +66,7 @@ class PDOMCPPMethodTemplate extends PDOMCPPFunctionTemplate implements ICPPMetho
}
}
public PDOMCPPMethodTemplate(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPMethodTemplate(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -34,7 +34,7 @@ class PDOMCPPMethodTemplateSpecialization extends
super(linkage, parent, (ICPPFunctionTemplate) method, specialized);
}
public PDOMCPPMethodTemplateSpecialization(PDOMLinkage linkage, int bindingRecord) {
public PDOMCPPMethodTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}

View file

@ -58,7 +58,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
super(linkage, parent, namespace.getNameCharArray());
}
public PDOMCPPNamespace(PDOMLinkage linkage, int record) throws CoreException {
public PDOMCPPNamespace(PDOMLinkage linkage, long record) throws CoreException {
super(linkage, record);
}
@ -86,10 +86,10 @@ class PDOMCPPNamespace extends PDOMCPPBinding
getIndex().accept((IBTreeVisitor) visitor);
} else {
getIndex().accept(new IBTreeVisitor() {
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
PDOMBinding binding = getLinkage().getBinding(record);
if (binding != null) {
if (visitor.visit(binding))
@ -188,10 +188,10 @@ class PDOMCPPNamespace extends PDOMCPPBinding
final List<PDOMNode> preresult = new ArrayList<PDOMNode>();
try {
getIndex().accept(new IBTreeVisitor() {
public int compare(int record) throws CoreException {
public int compare(long record) throws CoreException {
return 0;
}
public boolean visit(int record) throws CoreException {
public boolean visit(long record) throws CoreException {
preresult.add(getLinkage().getNode(record));
return true;
}

View file

@ -40,7 +40,7 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias
setTargetBinding(parent.getLinkage(), alias.getBinding());
}
public PDOMCPPNamespaceAlias(PDOMLinkage linkage, int record) {
public PDOMCPPNamespaceAlias(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -59,7 +59,7 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias
private void setTargetBinding(PDOMLinkage linkage, IBinding target) throws CoreException {
PDOMBinding namespace = getLinkage().adaptBinding(target);
getDB().putInt(record + NAMESPACE_BINDING,
getDB().putRecPtr(record + NAMESPACE_BINDING,
namespace != null ? namespace.getRecord() : 0);
}
@ -98,7 +98,7 @@ class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements ICPPNamespaceAlias
public IBinding getBinding() {
try {
return (IBinding) getLinkage().getNode(getPDOM().getDB().getInt(record + NAMESPACE_BINDING));
return (IBinding) getLinkage().getNode(getPDOM().getDB().getRecPtr(record + NAMESPACE_BINDING));
} catch(CoreException ce) {
CCorePlugin.log(ce);
}

View file

@ -73,7 +73,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
private static final byte FLAG_DEFAULT_VALUE = 0x1;
public PDOMCPPParameter(PDOMLinkage linkage, int record) {
public PDOMCPPParameter(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@ -83,7 +83,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
Database db = getDB();
db.putInt(record + NEXT_PARAM, 0);
db.putRecPtr(record + NEXT_PARAM, 0);
byte flags= encodeFlags(param);
db.putByte(record + FLAGS, flags);
@ -92,7 +92,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
type= param.getType();
if (type != null) {
PDOMNode typeNode = getLinkage().addType(this, type);
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
db.putRecPtr(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
}
byte annotations = PDOMCPPAnnotation.encodeAnnotation(param);
db.putByte(record + ANNOTATIONS, annotations);
@ -101,17 +101,17 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
}
}
public PDOMCPPParameter(PDOMLinkage linkage, PDOMNode parent, IParameter param, int typeRecord)
public PDOMCPPParameter(PDOMLinkage linkage, PDOMNode parent, IParameter param, long typeRecord)
throws CoreException {
super(linkage, parent, param.getNameCharArray());
Database db = getDB();
db.putInt(record + NEXT_PARAM, 0);
db.putRecPtr(record + NEXT_PARAM, 0);
byte flags= encodeFlags(param);
db.putByte(record + FLAGS, flags);
db.putInt(record + TYPE, typeRecord);
db.putRecPtr(record + TYPE, typeRecord);
try {
byte annotations = PDOMCPPAnnotation.encodeAnnotation(param);
@ -142,12 +142,12 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
}
public void setNextParameter(PDOMCPPParameter nextParam) throws CoreException {
int rec = nextParam != null ? nextParam.getRecord() : 0;
getDB().putInt(record + NEXT_PARAM, rec);
long rec = nextParam != null ? nextParam.getRecord() : 0;
getDB().putRecPtr(record + NEXT_PARAM, rec);
}
public PDOMCPPParameter getNextParameter() throws CoreException {
int rec = getDB().getInt(record + NEXT_PARAM);
long rec = getDB().getRecPtr(record + NEXT_PARAM);
return rec != 0 ? new PDOMCPPParameter(getLinkage(), rec) : null;
}
@ -170,7 +170,7 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
public IType getType() {
try {
PDOMNode node = getLinkage().getNode(getDB().getInt(record + TYPE));
PDOMNode node = getLinkage().getNode(getDB().getRecPtr(record + TYPE));
return node instanceof IType ? (IType)node : null;
} catch (CoreException e) {
CCorePlugin.log(e);

Some files were not shown because too many files have changed in this diff Show more