mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
fix terminology: memento->hash
This commit is contained in:
parent
0b8ddc570e
commit
390aa48830
7 changed files with 49 additions and 57 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2007, 2008 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
|
@ -22,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
|
@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Determines the signatures and signature mementos for bindings that can have
|
||||
* Determines the signatures and signature hashes for bindings that can have
|
||||
* siblings with the same name.
|
||||
*
|
||||
* @author Bryan Wilkinson
|
||||
|
@ -153,29 +153,23 @@ public class IndexCPPSignatureUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the signature memento for the passed binding.
|
||||
* Gets the signature hash for the passed binding.
|
||||
*
|
||||
* @param binding
|
||||
* @return the hash code of the binding's signature string
|
||||
* @throws CoreException
|
||||
* @throws DOMException
|
||||
*/
|
||||
public static Integer getSignatureMemento(IBinding binding) throws CoreException, DOMException {
|
||||
public static Integer getSignatureHash(IBinding binding) throws CoreException, DOMException {
|
||||
String sig = getSignature(binding);
|
||||
return sig.length() == 0 ? null : new Integer(sig.hashCode());
|
||||
}
|
||||
|
||||
public static Integer getSignatureMemento(ICPPFunctionType type) throws DOMException {
|
||||
String sig= getFunctionParameterString(type);
|
||||
return sig.length() == 0 ? null : new Integer(sig.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two bindings for signature information. Signature information covers
|
||||
* @return compares two bindings for signature information. Signature information covers
|
||||
* function signatures, or template specialization/instance arguments.
|
||||
* @param a
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
public static int compareSignatures(IBinding a, IBinding b) {
|
||||
try {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPP
|
|||
public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPClassTemplatePartialSpecialization) rbinding); }
|
||||
public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
|
||||
public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); }
|
||||
public int getSignatureMemento() throws CoreException { return ((IPDOMOverloader) rbinding).getSignatureMemento(); }
|
||||
public int getSignatureHash() throws CoreException { return ((IPDOMOverloader) rbinding).getSignatureHash(); }
|
||||
@Override
|
||||
public IBinding instantiate(IType[] args) { return InternalTemplateInstantiatorUtil.instantiate(args, cf, rbinding); }
|
||||
}
|
||||
|
|
|
@ -22,11 +22,9 @@ import org.eclipse.core.runtime.CoreException;
|
|||
public interface IPDOMOverloader {
|
||||
|
||||
/**
|
||||
* Gets the signature memento for this PDOM element, which will be unique
|
||||
* @return the signature hash for this PDOM element, which will be unique
|
||||
* for all sibling IPDOMOverloaders with the same name.
|
||||
*
|
||||
* @return
|
||||
* @throws CoreException
|
||||
*/
|
||||
public int getSignatureMemento() throws CoreException;
|
||||
public int getSignatureHash() throws CoreException;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ public class CPPFindBinding extends FindBinding {
|
|||
PDOMBinding binding1 = pdom.getBinding(record1);
|
||||
PDOMBinding binding2 = pdom.getBinding(record2);
|
||||
if(binding1 instanceof IPDOMOverloader && binding2 instanceof IPDOMOverloader) {
|
||||
int ty1 = ((IPDOMOverloader)binding1).getSignatureMemento();
|
||||
int ty2 = ((IPDOMOverloader)binding2).getSignatureMemento();
|
||||
int ty1 = ((IPDOMOverloader)binding1).getSignatureHash();
|
||||
int ty2 = ((IPDOMOverloader)binding2).getSignatureHash();
|
||||
cmp = ty1 < ty2 ? -1 : (ty1 > ty2 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
@ -53,11 +53,11 @@ public class CPPFindBinding extends FindBinding {
|
|||
|
||||
public static class CPPFindBindingVisitor extends FindBinding.DefaultFindBindingVisitor {
|
||||
private final int fConstant;
|
||||
private final int fSigMemento;
|
||||
public CPPFindBindingVisitor(PDOM pdom, char[] name, int constant, int memento, int localToFile) {
|
||||
private final int fSigHash;
|
||||
public CPPFindBindingVisitor(PDOM pdom, char[] name, int constant, int hash, int localToFile) {
|
||||
super(pdom, name, new int[] {constant}, localToFile);
|
||||
fConstant= constant;
|
||||
fSigMemento= memento;
|
||||
fSigHash= hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,8 +69,8 @@ public class CPPFindBinding extends FindBinding {
|
|||
if (c1 == c2) {
|
||||
PDOMBinding binding = fPdom.getBinding(record);
|
||||
if (binding instanceof IPDOMOverloader) {
|
||||
c1 = ((IPDOMOverloader) binding).getSignatureMemento();
|
||||
c2= fSigMemento;
|
||||
c1 = ((IPDOMOverloader) binding).getSignatureHash();
|
||||
c2= fSigHash;
|
||||
}
|
||||
}
|
||||
cmp = c1 < c2 ? -1 : (c1 > c2 ? 1 : 0);
|
||||
|
@ -88,8 +88,8 @@ public class CPPFindBinding extends FindBinding {
|
|||
protected boolean matches(PDOMBinding binding) throws CoreException {
|
||||
if (super.matches(binding)) {
|
||||
if (binding instanceof IPDOMOverloader) {
|
||||
int ty1 = ((IPDOMOverloader)binding).getSignatureMemento();
|
||||
return fSigMemento == ty1;
|
||||
int ty1 = ((IPDOMOverloader)binding).getSignatureHash();
|
||||
return fSigHash == ty1;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -103,9 +103,9 @@ public class CPPFindBinding extends FindBinding {
|
|||
}
|
||||
|
||||
|
||||
public static PDOMBinding findBinding(PDOMNode node, PDOM pdom, char[]name, int constant, int ty2, int localToFileRec)
|
||||
public static PDOMBinding findBinding(PDOMNode node, PDOM pdom, char[]name, int constant, int sigHash, int localToFileRec)
|
||||
throws CoreException {
|
||||
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(pdom, name, constant, ty2, localToFileRec);
|
||||
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(pdom, name, constant, sigHash, localToFileRec);
|
||||
try {
|
||||
node.accept(visitor);
|
||||
} catch(OperationCanceledException ce) {
|
||||
|
@ -115,25 +115,25 @@ public class CPPFindBinding extends FindBinding {
|
|||
|
||||
|
||||
public static PDOMBinding findBinding(BTree btree, PDOMLinkage linkage, IBinding binding, int localToFileRec) throws CoreException {
|
||||
Integer memento= 0;
|
||||
Integer hash= 0;
|
||||
try {
|
||||
memento = IndexCPPSignatureUtil.getSignatureMemento(binding);
|
||||
hash = IndexCPPSignatureUtil.getSignatureHash(binding);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
if(memento != null) {
|
||||
return findBinding(btree, linkage.getPDOM(), binding.getNameCharArray(), linkage.getBindingType(binding), memento.intValue(), localToFileRec);
|
||||
if(hash != null) {
|
||||
return findBinding(btree, linkage.getPDOM(), binding.getNameCharArray(), linkage.getBindingType(binding), hash.intValue(), localToFileRec);
|
||||
}
|
||||
return findBinding(btree, linkage.getPDOM(), binding.getNameCharArray(), new int [] {linkage.getBindingType(binding)}, localToFileRec);
|
||||
}
|
||||
|
||||
public static PDOMBinding findBinding(PDOMNode node, PDOMLinkage linkage, IBinding binding, int localToFileRec) throws CoreException {
|
||||
Integer memento = null;
|
||||
Integer hash = null;
|
||||
try {
|
||||
memento = IndexCPPSignatureUtil.getSignatureMemento(binding);
|
||||
hash = IndexCPPSignatureUtil.getSignatureHash(binding);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
if(memento != null) {
|
||||
return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(), linkage.getBindingType(binding), memento.intValue(), localToFileRec);
|
||||
if(hash != null) {
|
||||
return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(), linkage.getBindingType(binding), hash.intValue(), localToFileRec);
|
||||
}
|
||||
return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(), new int[] {linkage.getBindingType(binding)}, localToFileRec);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
PDOMCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader {
|
||||
|
||||
private static final int ARGUMENTS = PDOMCPPClassTemplate.RECORD_SIZE + 0;
|
||||
private static final int SIGNATURE_MEMENTO = PDOMCPPClassTemplate.RECORD_SIZE + 4;
|
||||
private static final int SIGNATURE_HASH = PDOMCPPClassTemplate.RECORD_SIZE + 4;
|
||||
private static final int PRIMARY = PDOMCPPClassTemplate.RECORD_SIZE + 8;
|
||||
private static final int NEXT_PARTIAL = PDOMCPPClassTemplate.RECORD_SIZE + 12;
|
||||
|
||||
|
@ -63,8 +63,8 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
primary.addPartial(this);
|
||||
|
||||
try {
|
||||
Integer memento = IndexCPPSignatureUtil.getSignatureMemento(partial);
|
||||
pdom.getDB().putInt(record + SIGNATURE_MEMENTO, memento != null ? memento.intValue() : 0);
|
||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(partial);
|
||||
pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
public int getSignatureMemento() throws CoreException {
|
||||
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO);
|
||||
public int getSignatureHash() throws CoreException {
|
||||
return pdom.getDB().getInt(record + SIGNATURE_HASH);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,8 +153,8 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
if(other instanceof PDOMCPPClassTemplatePartialSpecialization) {
|
||||
try {
|
||||
PDOMCPPClassTemplatePartialSpecialization otherSpec = (PDOMCPPClassTemplatePartialSpecialization) other;
|
||||
int mySM = getSignatureMemento();
|
||||
int otherSM = otherSpec.getSignatureMemento();
|
||||
int mySM = getSignatureHash();
|
||||
int otherSM = otherSpec.getSignatureHash();
|
||||
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
|
|
|
@ -64,7 +64,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
/**
|
||||
* Offset of hash of parameter information to allow fast comparison
|
||||
*/
|
||||
private static final int SIGNATURE_MEMENTO = PDOMCPPBinding.RECORD_SIZE + 12;
|
||||
private static final int SIGNATURE_HASH = PDOMCPPBinding.RECORD_SIZE + 12;
|
||||
|
||||
/**
|
||||
* Offset of annotation information (relative to the beginning of the
|
||||
|
@ -82,8 +82,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
super(pdom, parent, function.getNameCharArray());
|
||||
Database db = pdom.getDB();
|
||||
try {
|
||||
Integer memento = IndexCPPSignatureUtil.getSignatureMemento(function);
|
||||
pdom.getDB().putInt(record + SIGNATURE_MEMENTO, memento != null ? memento.intValue() : 0);
|
||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
|
||||
pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
|
||||
|
||||
if(setTypes) {
|
||||
initData((ICPPFunctionType) function.getType(), function.getParameters());
|
||||
|
@ -144,12 +144,12 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
return pft;
|
||||
}
|
||||
|
||||
public int getSignatureMemento() throws CoreException {
|
||||
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO);
|
||||
public int getSignatureHash() throws CoreException {
|
||||
return pdom.getDB().getInt(record + SIGNATURE_HASH);
|
||||
}
|
||||
|
||||
public static int getSignatureMemento(PDOM pdom, int record) throws CoreException {
|
||||
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO);
|
||||
public static int getSignatureHash(PDOM pdom, int record) throws CoreException {
|
||||
return pdom.getDB().getInt(record + SIGNATURE_HASH);
|
||||
}
|
||||
|
||||
public PDOMCPPFunction(PDOM pdom, int bindingRecord) {
|
||||
|
@ -271,8 +271,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
if(b instanceof IPDOMOverloader) {
|
||||
IPDOMOverloader bb= (IPDOMOverloader) b;
|
||||
try {
|
||||
int mySM = a.getSignatureMemento();
|
||||
int otherSM = bb.getSignatureMemento();
|
||||
int mySM = a.getSignatureHash();
|
||||
int otherSM = bb.getSignatureHash();
|
||||
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
|
|
|
@ -40,7 +40,7 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements
|
|||
|
||||
private static final int ARGMAP_PARAMS = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int ARGMAP_ARGS = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||
private static final int SIGNATURE_MEMENTO = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
private static final int SIGNATURE_HASH = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
private static final int SPECIALIZED = PDOMCPPBinding.RECORD_SIZE + 12;
|
||||
|
||||
/**
|
||||
|
@ -75,8 +75,8 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements
|
|||
}
|
||||
}
|
||||
try {
|
||||
Integer memento = IndexCPPSignatureUtil.getSignatureMemento(spec);
|
||||
pdom.getDB().putInt(record + SIGNATURE_MEMENTO, memento != null ? memento.intValue() : 0);
|
||||
Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(spec);
|
||||
pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
|
@ -135,8 +135,8 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements
|
|||
return null;
|
||||
}
|
||||
|
||||
public int getSignatureMemento() throws CoreException {
|
||||
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO);
|
||||
public int getSignatureHash() throws CoreException {
|
||||
return pdom.getDB().getInt(record + SIGNATURE_HASH);
|
||||
}
|
||||
|
||||
private IType[] getArguments() {
|
||||
|
|
Loading…
Add table
Reference in a new issue