mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-11-15 01:25:05 +03:00
Add a new Closure type for raw data and have that be allocated
with idris_alloc.
This commit is contained in:
parent
68d844cdf8
commit
610387c171
@ -53,6 +53,13 @@ VAL copy(VM* vm, VAL x) {
|
||||
break;
|
||||
case FWD:
|
||||
return x->info.ptr;
|
||||
case RAWDATA:
|
||||
{
|
||||
size_t size = x->info.size + sizeof(Closure);
|
||||
cl = allocate(size, 0);
|
||||
memcpy(cl, x, size);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -143,7 +143,10 @@ int space(VM* vm, size_t size) {
|
||||
}
|
||||
|
||||
void* idris_alloc(size_t size) {
|
||||
return allocate(size, 0);
|
||||
Closure* cl = (Closure*) allocate(sizeof(Closure)+size, 0);
|
||||
SETTY(cl, RAWDATA);
|
||||
cl->info.size = size;
|
||||
return (void*)cl+sizeof(Closure);
|
||||
}
|
||||
|
||||
void* idris_realloc(void* old, size_t old_size, size_t size) {
|
||||
@ -712,6 +715,13 @@ VAL doCopyTo(VM* vm, VAL x) {
|
||||
case BITS64:
|
||||
cl = idris_b64CopyForGC(vm, x);
|
||||
break;
|
||||
case RAWDATA:
|
||||
{
|
||||
size_t size = x->info.size + sizeof(Closure);
|
||||
cl = allocate(size, 0);
|
||||
memcpy(cl, x, size);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0); // We're in trouble if this happens...
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
typedef enum {
|
||||
CON, INT, BIGINT, FLOAT, STRING, STROFFSET,
|
||||
BITS8, BITS16, BITS32, BITS64, UNIT, PTR, FWD,
|
||||
MANAGEDPTR
|
||||
MANAGEDPTR, RAWDATA
|
||||
} ClosureType;
|
||||
|
||||
typedef struct Closure *VAL;
|
||||
@ -76,6 +76,7 @@ typedef struct Closure {
|
||||
__m128i* bits128p;
|
||||
Buffer* buf;
|
||||
ManagedPtr* mptr;
|
||||
size_t size;
|
||||
} info;
|
||||
} Closure;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user