]> gitweb.factorcode.org Git - factor.git/blob - vm/data_roots.hpp
VM: Remove unnecessary _ suffix in constructors
[factor.git] / vm / data_roots.hpp
1 namespace factor {
2
3 template <typename Type> struct data_root : public tagged<Type> {
4   factor_vm* parent;
5
6   void push() {
7     parent->data_roots.push_back(data_root_range(&this->value_, 1));
8   }
9
10   data_root(cell value, factor_vm* parent)
11       : tagged<Type>(value), parent(parent) {
12     push();
13   }
14
15   data_root(Type* value, factor_vm* parent)
16       : tagged<Type>(value), parent(parent) {
17     push();
18   }
19
20   const data_root<Type>& operator=(const Type* x) {
21     tagged<Type>::operator=(x);
22     return *this;
23   }
24   const data_root<Type>& operator=(const cell& x) {
25     tagged<Type>::operator=(x);
26     return *this;
27   }
28
29   ~data_root() { parent->data_roots.pop_back(); }
30 };
31
32 /* A similar hack for the bignum implementation */
33 struct gc_bignum {
34   bignum** addr;
35   factor_vm* parent;
36
37   gc_bignum(bignum** addr, factor_vm* parent) : addr(addr), parent(parent) {
38     if (*addr)
39       parent->check_data_pointer(*addr);
40     parent->bignum_roots.push_back((cell) addr);
41   }
42
43   ~gc_bignum() {
44 #ifdef FACTOR_DEBUG
45     FACTOR_ASSERT(parent->bignum_roots.back() == (cell) addr);
46 #endif
47     parent->bignum_roots.pop_back();
48   }
49 };
50
51 #define GC_BIGNUM(x) gc_bignum x##__data_root(&x, this)
52
53 }