4 template<typename Type>
5 struct gc_root : public tagged<Type>
9 void push() { parent->check_tagged_pointer(tagged<Type>::value()); parent->gc_locals.push_back((cell)this); }
11 explicit gc_root(cell value_,factor_vm *vm) : tagged<Type>(value_),parent(vm) { push(); }
12 explicit gc_root(Type *value_, factor_vm *vm) : tagged<Type>(value_),parent(vm) { push(); }
14 const gc_root<Type>& operator=(const Type *x) { tagged<Type>::operator=(x); return *this; }
15 const gc_root<Type>& operator=(const cell &x) { tagged<Type>::operator=(x); return *this; }
19 assert(parent->gc_locals.back() == (cell)this);
21 parent->gc_locals.pop_back();
25 /* A similar hack for the bignum implementation */
30 gc_bignum(bignum **addr_, factor_vm *vm) : addr(addr_), parent(vm) {
32 parent->check_data_pointer(*addr_);
33 parent->gc_bignums.push_back((cell)addr);
38 assert(parent->gc_bignums.back() == (cell)addr);
40 parent->gc_bignums.pop_back();
44 #define GC_BIGNUM(x) gc_bignum x##__gc_root(&x,this)