vm: add two missing files
							parent
							
								
									6c2c87758a
								
							
						
					
					
						commit
						68217016d0
					
				| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
namespace factor
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
struct code_root {
 | 
			
		||||
	cell value;
 | 
			
		||||
	bool valid;
 | 
			
		||||
	factor_vm *parent;
 | 
			
		||||
 | 
			
		||||
	void push()
 | 
			
		||||
	{
 | 
			
		||||
		parent->code_roots.push_back(this);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	explicit code_root(cell value_, factor_vm *parent_) :
 | 
			
		||||
		value(value_), valid(true), parent(parent_)
 | 
			
		||||
	{
 | 
			
		||||
		push();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~code_root()
 | 
			
		||||
	{
 | 
			
		||||
#ifdef FACTOR_DEBUG
 | 
			
		||||
		assert(parent->code_roots.back() == this);
 | 
			
		||||
#endif
 | 
			
		||||
		parent->code_roots.pop_back();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,59 @@
 | 
			
		|||
namespace factor
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
template<typename Type>
 | 
			
		||||
struct data_root : public tagged<Type> {
 | 
			
		||||
	factor_vm *parent;
 | 
			
		||||
 | 
			
		||||
	void push()
 | 
			
		||||
	{
 | 
			
		||||
		parent->data_roots.push_back((cell)this);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	explicit data_root(cell value_, factor_vm *parent_)
 | 
			
		||||
		: tagged<Type>(value_), parent(parent_)
 | 
			
		||||
	{
 | 
			
		||||
		push();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	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()
 | 
			
		||||
	{
 | 
			
		||||
#ifdef FACTOR_DEBUG
 | 
			
		||||
		assert(parent->data_roots.back() == (cell)this);
 | 
			
		||||
#endif
 | 
			
		||||
		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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~gc_bignum()
 | 
			
		||||
	{
 | 
			
		||||
#ifdef FACTOR_DEBUG
 | 
			
		||||
		assert(parent->bignum_roots.back() == (cell)addr);
 | 
			
		||||
#endif
 | 
			
		||||
		parent->bignum_roots.pop_back();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define GC_BIGNUM(x) gc_bignum x##__data_root(&x,this)
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue