]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/data_roots.hpp
webapps.wiki: adding search bar
[factor.git] / vm / data_roots.hpp
index 628733291a2d763e4a1ee9ca0002a29faaccc3f4..c0e4ce68f36fdfb018547ef8e73fdf01480f2d59 100644 (file)
@@ -14,38 +14,19 @@ template <typename Type> struct data_root : public tagged<Type> {
 
   data_root(Type* value, factor_vm* parent)
       : tagged<Type>(value), parent(parent) {
+    FACTOR_ASSERT(value);
     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(); }
-};
-
-/* A similar hack for the bignum implementation */
-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);
-    parent->bignum_roots.push_back((cell)addr);
+  ~data_root() {
+    parent->data_roots.pop_back();
   }
 
-  ~gc_bignum() {
-    FACTOR_ASSERT(parent->bignum_roots.back() == (cell)addr);
-    parent->bignum_roots.pop_back();
+  friend void swap(data_root<Type>& a, data_root<Type>& b) {
+    cell tmp = a.value_;
+    a.value_ = b.value_;
+    b.value_ = tmp;
   }
 };
 
-#define GC_BIGNUM(x) gc_bignum x##__data_root(&x, this)
-
 }