VM: Refactor data_roots.hpp to Factor style
parent
75e6c88534
commit
7a05bf1993
|
@ -1,34 +1,32 @@
|
|||
namespace factor
|
||||
{
|
||||
namespace factor {
|
||||
|
||||
template<typename Type>
|
||||
struct data_root : public tagged<Type> {
|
||||
template <typename Type> struct data_root : public tagged<Type> {
|
||||
factor_vm* parent;
|
||||
|
||||
void push()
|
||||
{
|
||||
void push() {
|
||||
parent->data_roots.push_back(data_root_range(&this->value_, 1));
|
||||
}
|
||||
|
||||
explicit data_root(cell value_, factor_vm* parent_)
|
||||
: tagged<Type>(value_), parent(parent_)
|
||||
{
|
||||
: tagged<Type>(value_), parent(parent_) {
|
||||
push();
|
||||
}
|
||||
|
||||
explicit data_root(Type *value_, factor_vm *parent_) :
|
||||
tagged<Type>(value_), parent(parent_)
|
||||
{
|
||||
explicit data_root(Type* value_, factor_vm* parent_)
|
||||
: tagged<Type>(value_), parent(parent_) {
|
||||
push();
|
||||
}
|
||||
|
||||
const data_root<Type>& operator=(const Type *x) { tagged<Type>::operator=(x); return *this; }
|
||||
const data_root<Type>& operator=(const cell &x) { tagged<Type>::operator=(x); return *this; }
|
||||
|
||||
~data_root()
|
||||
{
|
||||
parent->data_roots.pop_back();
|
||||
const data_root<Type>& operator=(const Type* x) {
|
||||
tagged<Type>::operator=(x);
|
||||
return *this;
|
||||
}
|
||||
const data_root<Type>& operator=(const cell& x) {
|
||||
tagged<Type>::operator=(x);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~data_root() { parent->data_roots.pop_back(); }
|
||||
};
|
||||
|
||||
/* A similar hack for the bignum implementation */
|
||||
|
@ -36,14 +34,13 @@ struct gc_bignum {
|
|||
bignum** addr;
|
||||
factor_vm* parent;
|
||||
|
||||
gc_bignum(bignum **addr_, factor_vm *parent_) : addr(addr_), parent(parent_)
|
||||
{
|
||||
if(*addr_) parent->check_data_pointer(*addr_);
|
||||
gc_bignum(bignum** addr_, factor_vm* parent_) : addr(addr_), parent(parent_) {
|
||||
if (*addr_)
|
||||
parent->check_data_pointer(*addr_);
|
||||
parent->bignum_roots.push_back((cell) addr);
|
||||
}
|
||||
|
||||
~gc_bignum()
|
||||
{
|
||||
~gc_bignum() {
|
||||
#ifdef FACTOR_DEBUG
|
||||
FACTOR_ASSERT(parent->bignum_roots.back() == (cell) addr);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue