mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Moved TypeMarshalBuffer from org.eclipse.cdt.internal.core.pdom.db to
org.eclipse.cdt.internal.core.pdom.dom Change-Id: Ie4614ba8972cf6cb86ccfa5ef3d5cbc620fe9787
This commit is contained in:
parent
15da05324a
commit
fa989bde50
6 changed files with 31 additions and 37 deletions
|
@ -76,7 +76,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.TypeMarshalBuffer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -111,7 +111,7 @@ final class Chunk {
|
|||
* A free Record Pointer is a pointer to a raw block, i.e. the
|
||||
* pointer is not moved past the BLOCK_HEADER_SIZE.
|
||||
*/
|
||||
private static int compressFreeRecPtr(final long value) {
|
||||
static int compressFreeRecPtr(final long value) {
|
||||
// This assert verifies the alignment. We expect the low bits to be clear.
|
||||
assert (value & (Database.BLOCK_SIZE_DELTA - 1)) == 0;
|
||||
final int dense = (int) (value >> Database.BLOCK_SIZE_DELTA_BITS);
|
||||
|
@ -122,7 +122,7 @@ final class Chunk {
|
|||
* A free Record Pointer is a pointer to a raw block,
|
||||
* i.e. the pointer is not moved past the BLOCK_HEADER_SIZE.
|
||||
*/
|
||||
private static long expandToFreeRecPtr(int value) {
|
||||
static long expandToFreeRecPtr(int 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
|
||||
|
@ -134,25 +134,6 @@ final class Chunk {
|
|||
return address << Database.BLOCK_SIZE_DELTA_BITS;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Record Pointer is a pointer as returned by Database.malloc().
|
||||
* This is a pointer to a block + BLOCK_HEADER_SIZE.
|
||||
*/
|
||||
static void putRecPtr(final long value, byte[] buffer, int idx) {
|
||||
final int denseValue = value == 0 ? 0 : compressFreeRecPtr(value - Database.BLOCK_HEADER_SIZE);
|
||||
putInt(denseValue, buffer, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Record Pointer is a pointer as returned by Database.malloc().
|
||||
* This is a pointer to a block + BLOCK_HEADER_SIZE.
|
||||
*/
|
||||
static long getRecPtr(byte[] buffer, final int idx) {
|
||||
int value = getInt(buffer, idx);
|
||||
long address = expandToFreeRecPtr(value);
|
||||
return address != 0 ? (address + Database.BLOCK_HEADER_SIZE) : address;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Record Pointer is a pointer as returned by Database.malloc().
|
||||
* This is a pointer to a block + BLOCK_HEADER_SIZE.
|
||||
|
@ -161,7 +142,7 @@ final class Chunk {
|
|||
assert fLocked;
|
||||
fDirty = true;
|
||||
int idx = recPtrToIndex(offset);
|
||||
putRecPtr(value, fBuffer, idx);
|
||||
Database.putRecPtr(value, fBuffer, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,7 +158,7 @@ final class Chunk {
|
|||
|
||||
public long getRecPtr(final long offset) {
|
||||
final int idx = recPtrToIndex(offset);
|
||||
return getRecPtr(fBuffer, idx);
|
||||
return Database.getRecPtr(fBuffer, idx);
|
||||
}
|
||||
|
||||
public long getFreeRecPtr(final long offset) {
|
||||
|
|
|
@ -796,4 +796,23 @@ public class Database {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Record Pointer is a pointer as returned by Database.malloc().
|
||||
* This is a pointer to a block + BLOCK_HEADER_SIZE.
|
||||
*/
|
||||
public static void putRecPtr(final long value, byte[] buffer, int idx) {
|
||||
final int denseValue = value == 0 ? 0 : Chunk.compressFreeRecPtr(value - BLOCK_HEADER_SIZE);
|
||||
Chunk.putInt(denseValue, buffer, idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Record Pointer is a pointer as returned by Database.malloc().
|
||||
* This is a pointer to a block + BLOCK_HEADER_SIZE.
|
||||
*/
|
||||
public static long getRecPtr(byte[] buffer, final int idx) {
|
||||
int value = Chunk.getInt(buffer, idx);
|
||||
long address = Chunk.expandToFreeRecPtr(value);
|
||||
return address != 0 ? (address + BLOCK_HEADER_SIZE) : address;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
|
|||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IString;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2014 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2015 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
|
||||
|
@ -9,7 +9,7 @@
|
|||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.db;
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
|
@ -28,15 +28,14 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* For marshalling types to byte arrays.
|
||||
*/
|
||||
public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
||||
public static final byte[] EMPTY= { 0, 0, 0, 0, 0, 0 };
|
||||
public static final byte[] EMPTY = new byte[Database.TYPE_SIZE];
|
||||
public static final byte NULL_TYPE = 0x00;
|
||||
public static final byte INDIRECT_TYPE = 0x1F;
|
||||
public static final byte BINDING_TYPE = 0x1E;
|
||||
|
@ -44,10 +43,6 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
|
||||
public static final IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
|
||||
static {
|
||||
assert EMPTY.length == Database.TYPE_SIZE;
|
||||
}
|
||||
|
||||
private final PDOMLinkage fLinkage;
|
||||
private int fPos;
|
||||
private byte[] fBuffer;
|
||||
|
@ -346,7 +341,7 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
|
||||
private void putRecordPointer(long record) {
|
||||
request(Database.PTR_SIZE);
|
||||
Chunk.putRecPtr(record, fBuffer, fPos);
|
||||
Database.putRecPtr(record, fBuffer, fPos);
|
||||
fPos += Database.PTR_SIZE;
|
||||
}
|
||||
|
||||
|
@ -357,7 +352,7 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
|||
fPos= fBuffer.length;
|
||||
throw unmarshallingError();
|
||||
}
|
||||
return Chunk.getRecPtr(fBuffer, pos);
|
||||
return Database.getRecPtr(fBuffer, pos);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -131,7 +131,6 @@ import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
|||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
|
@ -140,6 +139,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMGlobalScope;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.TypeMarshalBuffer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue