Skip to content

Commit

Permalink
Merge pull request #1661 from clasp-developers/hash-tables
Browse files Browse the repository at this point in the history
Hash tables
  • Loading branch information
Bike authored Jan 22, 2025
2 parents 85c3e01 + e6a83c3 commit e44cf82
Show file tree
Hide file tree
Showing 96 changed files with 2,081 additions and 3,138 deletions.
10 changes: 10 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Version 2.8.0 (LLVM15-19) Pending

## Added
* Weak-value and weak-key-and-value hash tables, as well as an interface
for weak-key-or-value tables, although at present they are actually
strong tables in practice.

## Fixed
* Weak pointers and weak hash tables survive snapshot save/load.

# Version 2.7.0 (LLVM15-19) 2025-01-21

## Added
Expand Down
2 changes: 1 addition & 1 deletion include/clasp/asttooling/translators.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ template <> struct to_object<std::vector<clang::tooling::CompileCommand>> {
template <> struct to_object<std::map<std::string, clang::tooling::Replacements>&, translate::dont_adopt_pointer> {
typedef std::map<std::string, clang::tooling::Replacements> GivenType;
static core::T_sp convert(GivenType vals) {
core::HashTableEqual_sp result = core::HashTableEqual_O::create_default();
core::HashTable_sp result = core::HashTable_O::createEqual();
for (auto pair : vals) {
core::SimpleBaseString_sp str = core::SimpleBaseString_O::make(pair.first);
core::T_sp obj = to_object<const clang::tooling::Replacements&>::convert(pair.second);
Expand Down
2 changes: 1 addition & 1 deletion include/clasp/clbind/class_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ClassRegistry_O : public core::General_O {
GCPRIVATE :

/*! Index on the type_id.id converted to a core::Pointer and use EQL equality */
core::HashTableEql_sp m_classes;
core::HashTable_sp m_classes;
// std::map<type_id, ClassRep_sp> m_classes;

#if 0
Expand Down
3 changes: 0 additions & 3 deletions include/clasp/core/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ class Array_O : public General_O {
return this->unsafe_setf_subseq(p.start, p.end, newVec);
}
void fillInitialContents(T_sp initialContents);
virtual void sxhash_(HashGenerator& hg) const override = 0;
virtual void sxhash_equalp(HashGenerator& hg) const override;
// --------------------------------------------------
// Ranged operations with explicit limits
Expand Down Expand Up @@ -324,7 +323,6 @@ class MDArray_O : public Array_O {
virtual size_t displacedIndexOffset() const override { return this->_DisplacedIndexOffset; }
virtual bool arrayHasFillPointerP() const override { return this->_Flags.fillPointerP(); };
virtual T_sp replaceArray(T_sp other) override;
virtual void sxhash_(HashGenerator& hg) const override;
void fillPointerSet(size_t idx) override {
// This better not be bigger than the vector size (must be a vector)
if (idx > this->_ArrayTotalSize)
Expand Down Expand Up @@ -420,7 +418,6 @@ class AbstractSimpleVector_O : public Array_O {
virtual void ranged_sxhash(HashGenerator& hg, size_t start, size_t end) const {
TYPE_ERROR(this->asSmartPtr(), Cons_O::createList(cl::_sym_string, cl::_sym_bit_vector));
};
virtual void sxhash_(HashGenerator& hg) const override { this->General_O::sxhash_(hg); }
virtual bool equal(T_sp other) const override { return this->eq(other); };
virtual bool equalp(T_sp other) const override;
void asAbstractSimpleVectorRange(AbstractSimpleVector_sp& sv, size_t& start, size_t& end) const override {
Expand Down
4 changes: 2 additions & 2 deletions include/clasp/core/array_bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SimpleBitVector_O : public specialized_SimpleBitVector {
// for convenience if not speed
virtual void __write__(T_sp strm) const override final;
virtual bool equal(T_sp other) const final;
virtual void sxhash_(HashGenerator& hg) const final { this->ranged_sxhash(hg, 0, this->length()); }
virtual void sxhash_equal(HashGenerator& hg) const final { this->ranged_sxhash(hg, 0, this->length()); }
virtual void ranged_sxhash(HashGenerator& hg, size_t start, size_t end) const final {
if (hg.isFilling()) {
Fixnum hash = 5381;
Expand Down Expand Up @@ -100,7 +100,7 @@ class BitVectorNs_O : public template_Vector<BitVectorNs_O, SimpleBitVector_O, C
virtual bool equal(T_sp other) const final;

public:
virtual void sxhash_(HashGenerator& hg) const final {
virtual void sxhash_equal(HashGenerator& hg) const final {
if (hg.isFilling()) {
AbstractSimpleVector_sp svec;
size_t start, end;
Expand Down
2 changes: 1 addition & 1 deletion include/clasp/core/bignum.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Bignum_O : public Integer_O {
mp_size_t length() const { return _limbs.signedLength(); }
const mp_limb_t* limbs() const { return &(_limbs._Data[0]); }

void sxhash_(HashGenerator& hg) const;
void sxhash_equal(HashGenerator& hg) const;

mpz_class mpz() const;

Expand Down
4 changes: 3 additions & 1 deletion include/clasp/core/character.fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace core {
bool clasp_charEqual2(T_sp x, T_sp y);

struct CharacterInfo {
HashTableEqual_sp _NamesToCharacterIndex;
HashTable_sp _NamesToCharacterIndex;
gctools::Vec0<T_sp> gIndexedCharacters;
gctools::Vec0<T_sp> gCharacterNames;
const char* repr() const { return "CharacterInfo"; };
Expand All @@ -42,4 +42,6 @@ inline Character_sp clasp_make_character(claspCharacter c) { return gc::make_tag

inline claspCharacter clasp_as_claspCharacter(Character_sp c) { return c.unsafe_character(); }

claspCharacter char_upcase(claspCharacter);

} // namespace core
2 changes: 0 additions & 2 deletions include/clasp/core/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ namespace core {

inline bool clasp_invalid_base_char_p(claspCharacter c) { return (c <= 32) || (c == 127); }

claspCharacter char_upcase(claspCharacter code);

claspCharacter char_downcase(claspCharacter code);

// See character.fwd.h for the following
Expand Down
12 changes: 7 additions & 5 deletions include/clasp/core/cons.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,13 @@ class Cons_O : public T_O {

public:
/*! Recursively hash the car and cdr parts - until the HashGenerator fills up */
inline void sxhash_(HashGenerator& hg) const {
if (hg.isFilling())
hg.hashObject(this->car());
if (hg.isFilling())
hg.hashObject(this->cdr());
inline void sxhash_equal(HashGenerator& hg) const {
if (hg.isFilling()) hg.hashObject(this->car());
if (hg.isFilling()) hg.hashObject(this->cdr());
}
inline void sxhash_equalp(HashGenerator& hg) const {
if (hg.isFilling()) hg.hashObjectEqualp(this->car());
if (hg.isFilling()) hg.hashObjectEqualp(this->cdr());
}

bool equal(T_sp obj) const;
Expand Down
5 changes: 2 additions & 3 deletions include/clasp/core/coretypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ typedef gctools::smart_ptr<Pointer_O> Pointer_sp;
class SimpleVector_O;
typedef gctools::smart_ptr<SimpleVector_O> SimpleVector_sp;

class HashTableEqual_O;
typedef gctools::smart_ptr<HashTableEqual_O> HashTableEqual_sp;
class HashTable_O;
typedef gctools::smart_ptr<HashTable_O> HashTable_sp;

class Instance_O;
typedef gctools::smart_ptr<Instance_O> Instance_sp;
Expand Down Expand Up @@ -62,7 +62,6 @@ class Null_O;
class Stream_O;
class SourcePosInfo_O;
class FileScope_O;
class WeakKeyHashTable_O;
class DynamicScopeManager;

class Function_O;
Expand Down
2 changes: 1 addition & 1 deletion include/clasp/core/fileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Path_O : public General_O {
void setPath(const std::filesystem::path& p);
void setPathFromString(const string& path);

void sxhash_(HashGenerator& hg) const;
void sxhash_equal(HashGenerator& hg) const;
Path_sp parent_path();

/*! Return just the fileName (*--end) as a string*/
Expand Down
2 changes: 1 addition & 1 deletion include/clasp/core/funcallableInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class FuncallableInstance_O : public Function_O {

public:
virtual bool compiledP() const { return true; };
void accumulateSuperClasses(HashTableEq_sp supers, ComplexVector_T_sp arrayedSupers, Instance_sp mc);
void accumulateSuperClasses(HashTable_sp supers, ComplexVector_T_sp arrayedSupers, Instance_sp mc);
void lowLevel_calculateClassPrecedenceList();

// virtual bool isSubClassOf(Instance_sp mc) const;
Expand Down
Loading

0 comments on commit e44cf82

Please sign in to comment.