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

fix terminology: memento->hash

This commit is contained in:
Andrew Ferguson 2008-04-21 12:01:20 +00:00
parent 0b8ddc570e
commit 390aa48830
7 changed files with 49 additions and 57 deletions

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Andrew Ferguson (Symbian)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index; 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.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; 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.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.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; 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; 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. * siblings with the same name.
* *
* @author Bryan Wilkinson * @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 * @param binding
* @return the hash code of the binding's signature string * @return the hash code of the binding's signature string
* @throws CoreException * @throws CoreException
* @throws DOMException * @throws DOMException
*/ */
public static Integer getSignatureMemento(IBinding binding) throws CoreException, DOMException { public static Integer getSignatureHash(IBinding binding) throws CoreException, DOMException {
String sig = getSignature(binding); String sig = getSignature(binding);
return sig.length() == 0 ? null : new Integer(sig.hashCode()); 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. * function signatures, or template specialization/instance arguments.
* @param a * @param a
* @param b * @param b
* @return
*/ */
public static int compareSignatures(IBinding a, IBinding b) { public static int compareSignatures(IBinding a, IBinding b) {
try { try {

View file

@ -36,7 +36,7 @@ public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPP
public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPClassTemplatePartialSpecialization) rbinding); } public IType[] getArguments() { return TemplateInstanceUtil.getArguments(cf, (ICPPClassTemplatePartialSpecialization) rbinding); }
public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); } public ObjectMap getArgumentMap() { return TemplateInstanceUtil.getArgumentMap(cf, rbinding); }
public IBinding getSpecializedBinding() { return TemplateInstanceUtil.getSpecializedBinding(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 @Override
public IBinding instantiate(IType[] args) { return InternalTemplateInstantiatorUtil.instantiate(args, cf, rbinding); } public IBinding instantiate(IType[] args) { return InternalTemplateInstantiatorUtil.instantiate(args, cf, rbinding); }
} }

View file

@ -22,11 +22,9 @@ import org.eclipse.core.runtime.CoreException;
public interface IPDOMOverloader { 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. * for all sibling IPDOMOverloaders with the same name.
*
* @return
* @throws CoreException * @throws CoreException
*/ */
public int getSignatureMemento() throws CoreException; public int getSignatureHash() throws CoreException;
} }

View file

@ -42,8 +42,8 @@ public class CPPFindBinding extends FindBinding {
PDOMBinding binding1 = pdom.getBinding(record1); PDOMBinding binding1 = pdom.getBinding(record1);
PDOMBinding binding2 = pdom.getBinding(record2); PDOMBinding binding2 = pdom.getBinding(record2);
if(binding1 instanceof IPDOMOverloader && binding2 instanceof IPDOMOverloader) { if(binding1 instanceof IPDOMOverloader && binding2 instanceof IPDOMOverloader) {
int ty1 = ((IPDOMOverloader)binding1).getSignatureMemento(); int ty1 = ((IPDOMOverloader)binding1).getSignatureHash();
int ty2 = ((IPDOMOverloader)binding2).getSignatureMemento(); int ty2 = ((IPDOMOverloader)binding2).getSignatureHash();
cmp = ty1 < ty2 ? -1 : (ty1 > ty2 ? 1 : 0); cmp = ty1 < ty2 ? -1 : (ty1 > ty2 ? 1 : 0);
} }
} }
@ -53,11 +53,11 @@ public class CPPFindBinding extends FindBinding {
public static class CPPFindBindingVisitor extends FindBinding.DefaultFindBindingVisitor { public static class CPPFindBindingVisitor extends FindBinding.DefaultFindBindingVisitor {
private final int fConstant; private final int fConstant;
private final int fSigMemento; private final int fSigHash;
public CPPFindBindingVisitor(PDOM pdom, char[] name, int constant, int memento, int localToFile) { public CPPFindBindingVisitor(PDOM pdom, char[] name, int constant, int hash, int localToFile) {
super(pdom, name, new int[] {constant}, localToFile); super(pdom, name, new int[] {constant}, localToFile);
fConstant= constant; fConstant= constant;
fSigMemento= memento; fSigHash= hash;
} }
@Override @Override
@ -69,8 +69,8 @@ public class CPPFindBinding extends FindBinding {
if (c1 == c2) { if (c1 == c2) {
PDOMBinding binding = fPdom.getBinding(record); PDOMBinding binding = fPdom.getBinding(record);
if (binding instanceof IPDOMOverloader) { if (binding instanceof IPDOMOverloader) {
c1 = ((IPDOMOverloader) binding).getSignatureMemento(); c1 = ((IPDOMOverloader) binding).getSignatureHash();
c2= fSigMemento; c2= fSigHash;
} }
} }
cmp = c1 < c2 ? -1 : (c1 > c2 ? 1 : 0); cmp = c1 < c2 ? -1 : (c1 > c2 ? 1 : 0);
@ -88,8 +88,8 @@ public class CPPFindBinding extends FindBinding {
protected boolean matches(PDOMBinding binding) throws CoreException { protected boolean matches(PDOMBinding binding) throws CoreException {
if (super.matches(binding)) { if (super.matches(binding)) {
if (binding instanceof IPDOMOverloader) { if (binding instanceof IPDOMOverloader) {
int ty1 = ((IPDOMOverloader)binding).getSignatureMemento(); int ty1 = ((IPDOMOverloader)binding).getSignatureHash();
return fSigMemento == ty1; return fSigHash == ty1;
} }
} }
return false; 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 { throws CoreException {
CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(pdom, name, constant, ty2, localToFileRec); CPPFindBindingVisitor visitor= new CPPFindBindingVisitor(pdom, name, constant, sigHash, localToFileRec);
try { try {
node.accept(visitor); node.accept(visitor);
} catch(OperationCanceledException ce) { } 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 { public static PDOMBinding findBinding(BTree btree, PDOMLinkage linkage, IBinding binding, int localToFileRec) throws CoreException {
Integer memento= 0; Integer hash= 0;
try { try {
memento = IndexCPPSignatureUtil.getSignatureMemento(binding); hash = IndexCPPSignatureUtil.getSignatureHash(binding);
} catch (DOMException e) { } catch (DOMException e) {
} }
if(memento != null) { if(hash != null) {
return findBinding(btree, linkage.getPDOM(), binding.getNameCharArray(), linkage.getBindingType(binding), memento.intValue(), localToFileRec); 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); 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 { public static PDOMBinding findBinding(PDOMNode node, PDOMLinkage linkage, IBinding binding, int localToFileRec) throws CoreException {
Integer memento = null; Integer hash = null;
try { try {
memento = IndexCPPSignatureUtil.getSignatureMemento(binding); hash = IndexCPPSignatureUtil.getSignatureHash(binding);
} catch (DOMException e) { } catch (DOMException e) {
} }
if(memento != null) { if(hash != null) {
return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(), linkage.getBindingType(binding), memento.intValue(), localToFileRec); 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); return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(), new int[] {linkage.getBindingType(binding)}, localToFileRec);
} }

View file

@ -46,7 +46,7 @@ class PDOMCPPClassTemplatePartialSpecialization extends
PDOMCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader { PDOMCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader {
private static final int ARGUMENTS = PDOMCPPClassTemplate.RECORD_SIZE + 0; 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 PRIMARY = PDOMCPPClassTemplate.RECORD_SIZE + 8;
private static final int NEXT_PARTIAL = PDOMCPPClassTemplate.RECORD_SIZE + 12; private static final int NEXT_PARTIAL = PDOMCPPClassTemplate.RECORD_SIZE + 12;
@ -63,8 +63,8 @@ class PDOMCPPClassTemplatePartialSpecialization extends
primary.addPartial(this); primary.addPartial(this);
try { try {
Integer memento = IndexCPPSignatureUtil.getSignatureMemento(partial); Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(partial);
pdom.getDB().putInt(record + SIGNATURE_MEMENTO, memento != null ? memento.intValue() : 0); pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }
@ -75,8 +75,8 @@ class PDOMCPPClassTemplatePartialSpecialization extends
super(pdom, bindingRecord); super(pdom, bindingRecord);
} }
public int getSignatureMemento() throws CoreException { public int getSignatureHash() throws CoreException {
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO); return pdom.getDB().getInt(record + SIGNATURE_HASH);
} }
@Override @Override
@ -153,8 +153,8 @@ class PDOMCPPClassTemplatePartialSpecialization extends
if(other instanceof PDOMCPPClassTemplatePartialSpecialization) { if(other instanceof PDOMCPPClassTemplatePartialSpecialization) {
try { try {
PDOMCPPClassTemplatePartialSpecialization otherSpec = (PDOMCPPClassTemplatePartialSpecialization) other; PDOMCPPClassTemplatePartialSpecialization otherSpec = (PDOMCPPClassTemplatePartialSpecialization) other;
int mySM = getSignatureMemento(); int mySM = getSignatureHash();
int otherSM = otherSpec.getSignatureMemento(); int otherSM = otherSpec.getSignatureHash();
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1; return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
} catch(CoreException ce) { } catch(CoreException ce) {
CCorePlugin.log(ce); CCorePlugin.log(ce);

View file

@ -64,7 +64,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
/** /**
* Offset of hash of parameter information to allow fast comparison * 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 * 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()); super(pdom, parent, function.getNameCharArray());
Database db = pdom.getDB(); Database db = pdom.getDB();
try { try {
Integer memento = IndexCPPSignatureUtil.getSignatureMemento(function); Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function);
pdom.getDB().putInt(record + SIGNATURE_MEMENTO, memento != null ? memento.intValue() : 0); pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
if(setTypes) { if(setTypes) {
initData((ICPPFunctionType) function.getType(), function.getParameters()); initData((ICPPFunctionType) function.getType(), function.getParameters());
@ -144,12 +144,12 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
return pft; return pft;
} }
public int getSignatureMemento() throws CoreException { public int getSignatureHash() throws CoreException {
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO); return pdom.getDB().getInt(record + SIGNATURE_HASH);
} }
public static int getSignatureMemento(PDOM pdom, int record) throws CoreException { public static int getSignatureHash(PDOM pdom, int record) throws CoreException {
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO); return pdom.getDB().getInt(record + SIGNATURE_HASH);
} }
public PDOMCPPFunction(PDOM pdom, int bindingRecord) { public PDOMCPPFunction(PDOM pdom, int bindingRecord) {
@ -271,8 +271,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
if(b instanceof IPDOMOverloader) { if(b instanceof IPDOMOverloader) {
IPDOMOverloader bb= (IPDOMOverloader) b; IPDOMOverloader bb= (IPDOMOverloader) b;
try { try {
int mySM = a.getSignatureMemento(); int mySM = a.getSignatureHash();
int otherSM = bb.getSignatureMemento(); int otherSM = bb.getSignatureHash();
return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1; return mySM == otherSM ? 0 : mySM < otherSM ? -1 : 1;
} catch(CoreException ce) { } catch(CoreException ce) {
CCorePlugin.log(ce); CCorePlugin.log(ce);

View file

@ -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_PARAMS = PDOMCPPBinding.RECORD_SIZE + 0;
private static final int ARGMAP_ARGS = PDOMCPPBinding.RECORD_SIZE + 4; 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; private static final int SPECIALIZED = PDOMCPPBinding.RECORD_SIZE + 12;
/** /**
@ -75,8 +75,8 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements
} }
} }
try { try {
Integer memento = IndexCPPSignatureUtil.getSignatureMemento(spec); Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(spec);
pdom.getDB().putInt(record + SIGNATURE_MEMENTO, memento != null ? memento.intValue() : 0); pdom.getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0);
} catch (DOMException e) { } catch (DOMException e) {
} }
} }
@ -135,8 +135,8 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements
return null; return null;
} }
public int getSignatureMemento() throws CoreException { public int getSignatureHash() throws CoreException {
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO); return pdom.getDB().getInt(record + SIGNATURE_HASH);
} }
private IType[] getArguments() { private IType[] getArguments() {