From a0601001a4a8df331cbb9b95d5c0af20405eef03 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Sat, 20 Aug 2011 23:25:37 +0000 Subject: * interp/sys-utility.boot (constructorDB): New. * interp/daase.lisp (dbNiladic?): New. Use it to access niladic property. of a constructor. * interp/database.boot: Import daase. (niladicContructorFromDB): Use it. * interp/define.boot (compDefineCategory): Don't write compilerInfo garbage. (compDefineFunctor1): Likewise. (compDefineCategory2): Set niladic property. (compDefineFunctor): Likewise. * interp/lisplib.boot (loadLib): Do not set niladic property. It is now a side-effect of loading. (loadLibNoUpdate): Do not check for version. (makeConstructorAutoload): Do not set niladic property. (initializeLisplib): Do not emit code to check version. (mkCtorDBForm): New. (writeNiladic?): Likewise. (finalizeLisplib): Do not set niladic property. * interp/patches.lisp: Remove deadcode. * interp/sys-constants.boot (MAJOR-VERSION): Remove. --- src/utils/storage.H | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'src/utils/storage.H') diff --git a/src/utils/storage.H b/src/utils/storage.H index 72b9eb1e..f2fdc8ae 100644 --- a/src/utils/storage.H +++ b/src/utils/storage.H @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -195,6 +196,28 @@ namespace OpenAxiom { size_t population() const; protected: + // +----+----+--+----- + // | | | | + // +----+----+--+----- + // ^ ^ ^ ^ + // | | | `-- first allocatable T object + // | | `-- possible padding for proper T alignment + // | `-- link to next storage pages + // `-- link to previous storage pages + enum { + link_size = sizeof(Storage*) + }; + + // The `previous' link in the chain of storage. + static Storage*& previous(Storage* s) { + return *static_cast(s->at_offset(0)); + } + + // The `next' link in the chain of storage. + static Storage*& next(Storage* s) { + return *static_cast(s->at_offset(link_size)); + } + // Address of the first object of type `T' in a storage. static T* first_object(Handle* h) { return static_cast(BlockStorage::begin(h)); @@ -264,6 +287,18 @@ namespace OpenAxiom { Factory() : Arena(nominal_population()) { } ~Factory(); + iterator begin() { + Storage* s = this->store; + while (Storage* p = Arena::previous(s)) + s = p; + return iterator(s, Arena::first_object(s)); + } + + iterator end() { + Storage* s = this->store; + return iterator(s, static_cast(s->next_available())); + } + // Allocate storage and value-construct an object of type `T'. T* make() { return new(this->allocate(1)) T(); @@ -307,6 +342,47 @@ namespace OpenAxiom { } } + template + struct Factory::iterator: + std::iterator { + + iterator& operator++() { + if (ptr < store->next_available()) { + ++ptr; + return *this; + } + store = Arena::next(store); + ptr = Arena::first_object(store); + return *this; + } + + iterator operator++(int) { + iterator t = *this; + ++*this; + return t; + } + + T* operator->() { return ptr; } + + T& operator*() { return *ptr; } + + friend bool operator==(iterator p, iterator q) { + return p.store == q.store and p.ptr == q.ptr; + } + + friend bool operator!=(iterator p, iterator q) { + return not(p == q); + } + + private: + Storage* store; + T* ptr; + friend class Factory; + + iterator(Storage* s, T* p) : store(s), ptr(p) { } + + }; + // ----------------- // -- FileMapping -- // ----------------- -- cgit v1.2.3