1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 23:05:47 +02:00

Only global scope in should be converted to file local.

This commit is contained in:
Sergey Prigogin 2008-01-27 03:43:45 +00:00
parent b44d607a4f
commit 8146a961b8

View file

@ -72,13 +72,13 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
private static final int NEXT_OFFSET = PDOMNamedNode.RECORD_SIZE + 4; private static final int NEXT_OFFSET = PDOMNamedNode.RECORD_SIZE + 4;
private static final int INDEX_OFFSET = PDOMNamedNode.RECORD_SIZE + 8; private static final int INDEX_OFFSET = PDOMNamedNode.RECORD_SIZE + 8;
private static final int NESTED_BINDINGS_INDEX = PDOMNamedNode.RECORD_SIZE + 12; private static final int NESTED_BINDINGS_INDEX = PDOMNamedNode.RECORD_SIZE + 12;
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 16; protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 16;
// node types // node types
protected static final int LINKAGE= 0; // special one for myself protected static final int LINKAGE= 0; // special one for myself
public PDOMLinkage(PDOM pdom, int record) { public PDOMLinkage(PDOM pdom, int record) {
super(pdom, record); super(pdom, record);
} }
@ -89,10 +89,10 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
// id // id
db.putInt(record + ID_OFFSET, db.newString(languageId).getRecord()); db.putInt(record + ID_OFFSET, db.newString(languageId).getRecord());
pdom.insertLinkage(this); pdom.insertLinkage(this);
} }
protected int getRecordSize() { protected int getRecordSize() {
return RECORD_SIZE; return RECORD_SIZE;
} }
@ -106,19 +106,19 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
int namerec = db.getInt(record + ID_OFFSET); int namerec = db.getInt(record + ID_OFFSET);
return db.getString(namerec); return db.getString(namerec);
} }
public static int getNextLinkageRecord(PDOM pdom, int record) throws CoreException { public static int getNextLinkageRecord(PDOM pdom, int record) throws CoreException {
return pdom.getDB().getInt(record + NEXT_OFFSET); return pdom.getDB().getInt(record + NEXT_OFFSET);
} }
public void setNext(int nextrec) throws CoreException { public void setNext(int nextrec) throws CoreException {
pdom.getDB().putInt(record + NEXT_OFFSET, nextrec); pdom.getDB().putInt(record + NEXT_OFFSET, nextrec);
} }
public BTree getIndex() throws CoreException { public BTree getIndex() throws CoreException {
return new BTree(pdom.getDB(), record + INDEX_OFFSET, getIndexComparator()); return new BTree(pdom.getDB(), record + INDEX_OFFSET, getIndexComparator());
} }
/** /**
* Returns the BTree for the nested bindings. * Returns the BTree for the nested bindings.
* @return * @return
@ -127,7 +127,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
public BTree getNestedBindingsIndex() throws CoreException { public BTree getNestedBindingsIndex() throws CoreException {
return new BTree(getPDOM().getDB(), record + NESTED_BINDINGS_INDEX, getNestedBindingsComparator()); return new BTree(getPDOM().getDB(), record + NESTED_BINDINGS_INDEX, getNestedBindingsComparator());
} }
public void accept(final IPDOMVisitor visitor) throws CoreException { public void accept(final IPDOMVisitor visitor) throws CoreException {
if (visitor instanceof IBTreeVisitor) { if (visitor instanceof IBTreeVisitor) {
getIndex().accept((IBTreeVisitor) visitor); getIndex().accept((IBTreeVisitor) visitor);
@ -148,7 +148,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
}); });
} }
} }
public ILinkage getLinkage() throws CoreException { public ILinkage getLinkage() throws CoreException {
return this; return this;
} }
@ -156,7 +156,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
public final void addChild(PDOMNode child) throws CoreException { public final void addChild(PDOMNode child) throws CoreException {
getIndex().insert(child.getRecord()); getIndex().insert(child.getRecord());
} }
public PDOMNode getNode(int record) throws CoreException { public PDOMNode getNode(int record) throws CoreException {
switch (PDOMNode.getNodeType(pdom, record)) { switch (PDOMNode.getNodeType(pdom, record)) {
case POINTER_TYPE: case POINTER_TYPE:
@ -168,8 +168,8 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
} }
return null; return null;
} }
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException { public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
if (type instanceof IPointerType) if (type instanceof IPointerType)
return new PDOMPointerType(pdom, parent, (IPointerType)type); return new PDOMPointerType(pdom, parent, (IPointerType)type);
else if (type instanceof IArrayType) else if (type instanceof IArrayType)
@ -185,16 +185,16 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
public IBTreeComparator getNestedBindingsComparator() { public IBTreeComparator getNestedBindingsComparator() {
return new FindBinding.NestedBindingsBTreeComparator(this); return new FindBinding.NestedBindingsBTreeComparator(this);
} }
public abstract PDOMBinding addBinding(IASTName name) throws CoreException; public abstract PDOMBinding addBinding(IASTName name) throws CoreException;
public abstract PDOMBinding addBinding(IBinding binding, IASTName fromName) throws CoreException; public abstract PDOMBinding addBinding(IBinding binding, IASTName fromName) throws CoreException;
public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException { public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException {
if (inputBinding == null || inputBinding instanceof IProblemBinding) { if (inputBinding == null || inputBinding instanceof IProblemBinding) {
return null; return null;
} }
boolean isFromAST= true; boolean isFromAST= true;
IBinding binding= inputBinding; IBinding binding= inputBinding;
if (binding instanceof PDOMBinding) { if (binding instanceof PDOMBinding) {
@ -209,12 +209,12 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
} }
isFromAST= false; isFromAST= false;
} }
PDOMBinding result= (PDOMBinding) pdom.getCachedResult(inputBinding); PDOMBinding result= (PDOMBinding) pdom.getCachedResult(inputBinding);
if (result != null) { if (result != null) {
return result; return result;
} }
int fileLocalRec= 0; int fileLocalRec= 0;
if (isFromAST) { if (isFromAST) {
// assign names to anonymous types. // assign names to anonymous types.
@ -233,9 +233,9 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
} }
return result; return result;
} }
protected abstract PDOMBinding doAdaptBinding(IBinding binding, int fileLocalRec) throws CoreException; protected abstract PDOMBinding doAdaptBinding(IBinding binding, int fileLocalRec) throws CoreException;
public final PDOMBinding resolveBinding(IASTName name) throws CoreException { public final PDOMBinding resolveBinding(IASTName name) throws CoreException {
IBinding binding= name.resolveBinding(); IBinding binding= name.resolveBinding();
if (binding != null) { if (binding != null) {
@ -243,7 +243,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
} }
return null; return null;
} }
/** /**
* *
* @param binding * @param binding
@ -321,13 +321,13 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
if (scope instanceof ICPPClassScope) { if (scope instanceof ICPPClassScope) {
scopeBinding = ((ICPPClassScope)scope).getClassType(); scopeBinding = ((ICPPClassScope)scope).getClassType();
} else { } else {
IName scopeName = scope.getScopeName(); IName scopeName = scope.getScopeName();
if (scopeName instanceof IASTName) { if (scopeName instanceof IASTName) {
scopeBinding = ((IASTName) scopeName).resolveBinding(); scopeBinding = ((IASTName) scopeName).resolveBinding();
} }
} }
} }
} }
if (scopeBinding != null && scopeBinding != binding) { if (scopeBinding != null && scopeBinding != binding) {
PDOMBinding scopePDOMBinding = null; PDOMBinding scopePDOMBinding = null;
if (addParent) { if (addParent) {
@ -359,8 +359,10 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
} else if (binding instanceof IFunction) { } else if (binding instanceof IFunction) {
IFunction f= (IFunction) binding; IFunction f= (IFunction) binding;
isFileLocal= ASTInternal.isStatic(f, false); isFileLocal= ASTInternal.isStatic(f, false);
} else if (binding instanceof ICPPUsingDeclaration || } else if ((binding instanceof ICPPUsingDeclaration ||
binding instanceof ICPPNamespaceAlias) { binding instanceof ICPPNamespaceAlias) && binding.getScope() == null) {
// Using declarations and namespace aliases in global scope are restricted
// to the containing file.
isFileLocal= true; isFileLocal= true;
} }
@ -377,7 +379,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
} }
public abstract int getBindingType(IBinding binding); public abstract int getBindingType(IBinding binding);
/** /**
* Callback informing the linkage that a name has been added. This is * Callback informing the linkage that a name has been added. This is
* used to do additional processing, like establishing inheritance relationships. * used to do additional processing, like establishing inheritance relationships.
@ -408,7 +410,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
*/ */
public void onDeleteName(PDOMName nextName) throws CoreException { public void onDeleteName(PDOMName nextName) throws CoreException {
} }
/** /**
* Callback informing the linkage that a binding has been added. Used to index nested bindings. * Callback informing the linkage that a binding has been added. Used to index nested bindings.
* @param pdomBinding * @param pdomBinding
@ -432,7 +434,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
getNestedBindingsIndex().delete(pdomBinding.getRecord()); getNestedBindingsIndex().delete(pdomBinding.getRecord());
} }
} }
public void deleteType(IType type, int ownerRec) throws CoreException { public void deleteType(IType type, int ownerRec) throws CoreException {
if (type instanceof PDOMNode) { if (type instanceof PDOMNode) {
PDOMNode node= (PDOMNode) type; PDOMNode node= (PDOMNode) type;
@ -443,11 +445,11 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
} }
} }
} }
public void deleteBinding(IBinding binding) throws CoreException { public void deleteBinding(IBinding binding) throws CoreException {
// no implementation, yet. // no implementation, yet.
} }
public void delete(PDOMLinkage linkage) throws CoreException { public void delete(PDOMLinkage linkage) throws CoreException {
assert false; // no need to delete linkages. assert false; // no need to delete linkages.
} }