Skip to content

Commit

Permalink
Merge pull request #1499 from clasp-developers/vcell
Browse files Browse the repository at this point in the history
Variable cells

Since I just did #1496 might as well knock this one out too. Stores dynamic variable values in cells rather than straight in the symbols. Bla bla bla separation of concerns is good, and this will make first class environments easier. Also important for the xref implementation coming up next.
  • Loading branch information
Bike authored Sep 25, 2023
2 parents 7a85494 + d5ca9a4 commit b61c990
Show file tree
Hide file tree
Showing 36 changed files with 535 additions and 429 deletions.
2 changes: 0 additions & 2 deletions include/clasp/clbind/derivable.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ redirect its virtual functions to the Derivable<T> functions. */
template <class Alien>
class Derivable : public core::DerivableCxxObject_O, public Alien {
public:
// All classes derived from Derivable must be put in the non-moving pool
struct metadata_gc_do_not_move {};
typedef Derivable<Alien> DerivableType;
typedef Alien AlienType;
public:
Expand Down
16 changes: 11 additions & 5 deletions include/clasp/core/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,23 @@ class AuxArgument : public Argument {
// this will be a problem because some of the have smart_ptr's in them
class DynamicScopeManager : gctools::StackBoundClass {
private:
Symbol_sp _OldVar;
VariableCell_sp _Cell;
T_sp _OldBinding;
public:
inline explicit DynamicScopeManager(VariableCell_sp cell, T_sp val) {
_Cell = cell;
_OldBinding = _Cell->bind(val);
}
// Compatibility
inline explicit DynamicScopeManager(Symbol_sp sym, T_sp val) {
_OldVar = sym;
_OldBinding = sym->threadLocalSymbolValue();
sym->set_threadLocalSymbolValue(val);
_Cell = sym->ensureVariableCell();
_OldBinding = _Cell->bind(val);
}
virtual ~DynamicScopeManager() {
_OldVar->set_threadLocalSymbolValue(_OldBinding);
_Cell->unbind(_OldBinding);
}
// used in unwind.h
inline T_sp oldBinding() { return _OldBinding; }
};

};
Expand Down
2 changes: 1 addition & 1 deletion include/clasp/core/bytecode_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ class VariableCellInfo_O : public General_O {
}
public:
CL_LISPIFY_NAME(VariableCellInfo/vname)
CL_DEFMETHOD T_sp vname() { return this->_vname; }
CL_DEFMETHOD Symbol_sp vname() { return this->_vname; }
};

class Module_O : public General_O {
Expand Down
2 changes: 1 addition & 1 deletion include/clasp/core/external_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class externalClass_ {
reg::lisp_registerClassSymbol<OT>(this->_ClassSymbol);
/*! Accumulate all of the classes in reverse order of how they were initialized
in the core::*all-cxx-classes* variable */
if (_sym_STARallCxxClassesSTAR->symbolValueUnsafe()) {
if (_sym_STARallCxxClassesSTAR->boundP()) {
_sym_STARallCxxClassesSTAR->setf_symbolValue(Cons_O::create(OT::static_classSymbol(), _sym_STARallCxxClassesSTAR->symbolValue()));
}

Expand Down
1 change: 0 additions & 1 deletion include/clasp/core/hashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ struct KeyValuePair {

FORWARD(HashTable);
class HashTable_O : public HashTableBase_O {
struct metadata_bootstrap_class {};
friend T_sp cl__make_hash_table(T_sp test, Fixnum_sp size, Number_sp rehash_size, Real_sp orehash_threshold, Symbol_sp weakness, T_sp debug, T_sp thread_safe, T_sp hashf);
friend class HashTableReadLock;
friend class HashTableWriteLock;
Expand Down
1 change: 0 additions & 1 deletion include/clasp/core/hashTableBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ THE SOFTWARE.
namespace core {
FORWARD(HashTableBase);
class HashTableBase_O : public General_O {
struct metadata_bootstrap_class {};
LISP_ABSTRACT_CLASS(core, CorePkg, HashTableBase_O, "HashTableBase",core::General_O);
HashTableBase_O() {};
public:
Expand Down
Loading

0 comments on commit b61c990

Please sign in to comment.