// cl_make_heap_GV_I().
// General includes.
-#include "cl_sysdep.h"
-
-CL_PROVIDE(cl_GV_I)
+#include "base/cl_sysdep.h"
// Specification.
#include "cln/GV_integer.h"
// Implementation.
-#include "cl_I.h"
-#include "cl_DS.h"
-#include "cln/abort.h"
-#include "cl_offsetof.h"
+#include "integer/cl_I.h"
+#include "base/digitseq/cl_DS.h"
+#include "cln/exception.h"
+#include "base/cl_offsetof.h"
namespace cln {
#endif
}
-cl_class cl_class_gvector_integer = {
- cl_gvector_integer_destructor,
- 0
-};
-
+// XXX: Ugh, this needs to be non-const (and non-static) for overriding
+// the printing function (see cl_GV_I_debug.cc)
+cl_class& cl_class_gvector_integer()
+{
+ static cl_class instance = {
+ cl_gvector_integer_destructor,
+ 0
+ };
+ return instance;
+}
static inline cl_heap_GV_I * outcast (cl_GV_inner<cl_I>* vec)
{
struct cl_heap_GV_I_general : public cl_heap_GV_I {
cl_I data[1];
// Standard allocation disabled.
- void* operator new (size_t size) { unused size; cl_abort(); return (void*)1; }
+ void* operator new (size_t size) { unused size; throw runtime_exception(); }
// Standard deallocation disabled.
- void operator delete (void* ptr) { unused ptr; cl_abort(); }
+ void operator delete (void* ptr) { unused ptr; throw runtime_exception(); }
// No default constructor.
cl_heap_GV_I_general ();
};
var uintC srclen = srcv->v.length();
var uintC destlen = destv->v.length();
if (!(srcindex <= srcindex+count && srcindex+count <= srclen))
- cl_abort();
+ throw runtime_exception();
if (!(destindex <= destindex+count && destindex+count <= destlen))
- cl_abort();
+ throw runtime_exception();
do {
destv->data[destindex++] = srcv->data[srcindex++];
} while (--count > 0);
{
var cl_heap_GV_I_general* hv = (cl_heap_GV_I_general*) malloc_hook(offsetofa(cl_heap_GV_I_general,data)+sizeof(cl_I)*len);
hv->refcount = 1;
- hv->type = &cl_class_gvector_integer;
+ hv->type = &cl_class_gvector_integer();
new (&hv->v) cl_GV_inner<cl_I> (len,&general_vectorops.ops);
for (var uintC i = 0; i < len; i++)
init1(cl_I, hv->data[i]) ();
struct cl_heap_GV_I_bits##m : public cl_heap_GV_I { \
uint_t data[1]; \
/* Standard allocation disabled. */ \
- void* operator new (size_t size) { unused size; cl_abort(); return (void*)1; } \
+ void* operator new (size_t size) { unused size; throw runtime_exception(); } \
/* Standard deallocation disabled. */ \
- void operator delete (void* ptr) { unused ptr; cl_abort(); } \
+ void operator delete (void* ptr) { unused ptr; throw runtime_exception(); } \
/* No default constructor. */ \
cl_heap_GV_I_bits##m (); \
}; \
var uintC srclen = srcv->v.length(); \
var uintC destlen = destv->v.length(); \
if (!(srcindex <= srcindex+count && srcindex+count <= srclen)) \
- cl_abort(); \
+ throw runtime_exception(); \
if (!(destindex <= destindex+count && destindex+count <= destlen)) \
- cl_abort(); \
+ throw runtime_exception(); \
if (m == intDsize) { \
var const uintD* srcptr = &srcv->data[srcindex]; \
var uintD* destptr = &destv->data[destindex]; \
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
return;
}
}
- cl_abort();
+ throw runtime_exception();
}
(((sintC)len-1)>>(log2_intDsize-log2_bits))+1;
var cl_heap_GV_I_bits32* hv = (cl_heap_GV_I_bits32*) malloc_hook(offsetofa(cl_heap_GV_I_bits32,data)+sizeof(uintD)*words);
hv->refcount = 1;
- hv->type = &cl_class_gvector_integer;
+ hv->type = &cl_class_gvector_integer();
new (&hv->v) cl_GV_inner<cl_I> (len,&bits_vectorops[log2_bits]->ops);
var uintD* ptr = (uintD*)(hv->data);
for (var uintC i = 0; i < words; i++)
// An empty vector.
-const cl_GV_I cl_null_GV_I = cl_GV_I((uintC)0);
+const cl_GV_I cl_null_GV_I = cl_null_GV_I;
+
+int cl_GV_I_init_helper::count = 0;
+
+cl_GV_I_init_helper::cl_GV_I_init_helper()
+{
+ if (count++ == 0)
+ new ((void *)&cl_null_GV_I) cl_GV_I((uintC)0);
+}
+
+cl_GV_I_init_helper::~cl_GV_I_init_helper()
+{
+ if (--count == 0) {
+ // Nothing to clean up
+ }
+};
} // namespace cln
-CL_PROVIDE_END(cl_GV_I)