mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-09-11 08:55:23 +03:00
Simplify
This commit is contained in:
parent
5ff335060b
commit
807f0097b3
@ -2,38 +2,6 @@
|
||||
|
||||
#include "idris_rts.h"
|
||||
|
||||
VAL idris_b8CopyForGC(VM *vm, VAL a) {
|
||||
uint8_t A = GETBITS8(a);
|
||||
VAL cl = allocate(sizeof(Closure), 1);
|
||||
SETTY(cl, CT_BITS8);
|
||||
cl->info.bits8 = A;
|
||||
return cl;
|
||||
}
|
||||
|
||||
VAL idris_b16CopyForGC(VM *vm, VAL a) {
|
||||
uint16_t A = GETBITS16(a);
|
||||
VAL cl = allocate(sizeof(Closure), 1);
|
||||
SETTY(cl, CT_BITS16);
|
||||
cl->info.bits16 = A;
|
||||
return cl;
|
||||
}
|
||||
|
||||
VAL idris_b32CopyForGC(VM *vm, VAL a) {
|
||||
uint32_t A = GETBITS32(a);
|
||||
VAL cl = allocate(sizeof(Closure), 1);
|
||||
SETTY(cl, CT_BITS32);
|
||||
cl->info.bits32 = A;
|
||||
return cl;
|
||||
}
|
||||
|
||||
VAL idris_b64CopyForGC(VM *vm, VAL a) {
|
||||
uint64_t A = GETBITS64(a);
|
||||
VAL cl = allocate(sizeof(Closure), 1);
|
||||
SETTY(cl, CT_BITS64);
|
||||
cl->info.bits64 = A;
|
||||
return cl;
|
||||
}
|
||||
|
||||
VAL idris_b8(VM *vm, VAL a) {
|
||||
uint8_t A = GETINT(a);
|
||||
VAL cl = allocate(sizeof(Closure), 0);
|
||||
|
@ -1,11 +1,6 @@
|
||||
#ifndef _IDRISBITSTRING_H
|
||||
#define _IDRISBITSTRING_H
|
||||
|
||||
VAL idris_b8CopyForGC(VM *vm, VAL a);
|
||||
VAL idris_b16CopyForGC(VM *vm, VAL a);
|
||||
VAL idris_b32CopyForGC(VM *vm, VAL a);
|
||||
VAL idris_b64CopyForGC(VM *vm, VAL a);
|
||||
|
||||
VAL idris_b8(VM *vm, VAL a);
|
||||
VAL idris_b16(VM *vm, VAL a);
|
||||
VAL idris_b32(VM *vm, VAL a);
|
||||
|
@ -11,55 +11,32 @@ VAL copy(VM* vm, VAL x) {
|
||||
return x;
|
||||
}
|
||||
switch(GETTY(x)) {
|
||||
case CT_FWD:
|
||||
return GETPTR(x);
|
||||
case CT_CDATA:
|
||||
cl = MKCDATAc(vm, GETCDATA(x));
|
||||
c_heap_mark_item(GETCDATA(x));
|
||||
break;
|
||||
case CT_BIGINT:
|
||||
cl = MKBIGMc(vm, GETPTR(x));
|
||||
break;
|
||||
case CT_CON:
|
||||
ar = CARITY(x);
|
||||
if (ar == 0 && CTAG(x) < 256) {
|
||||
return x;
|
||||
} else {
|
||||
allocCon(cl, vm, CTAG(x), ar, 1);
|
||||
memcpy(cl->extra.cargs, x->extra.cargs, sizeof(VAL)*ar);
|
||||
}
|
||||
break;
|
||||
// FALLTHROUGH
|
||||
case CT_ARRAY:
|
||||
len = CELEM(x);
|
||||
allocArray(cl, vm, len, 1);
|
||||
memcpy(cl->extra.array, x->extra.array, len * sizeof(VAL));
|
||||
break;
|
||||
case CT_FLOAT:
|
||||
cl = MKFLOATc(vm, GETFLOAT(x));
|
||||
break;
|
||||
case CT_STRING:
|
||||
cl = MKSTRclen(vm, getstr(x), getstrlen(x));
|
||||
break;
|
||||
case CT_STROFFSET:
|
||||
cl = MKSTROFFc(vm, x->extra.basestr[0]);
|
||||
break;
|
||||
case CT_BIGINT:
|
||||
cl = MKBIGMc(vm, GETPTR(x));
|
||||
break;
|
||||
case CT_PTR:
|
||||
cl = MKPTRc(vm, GETPTR(x));
|
||||
break;
|
||||
case CT_MANAGEDPTR:
|
||||
cl = MKMPTRc(vm, x->extra.mptr, x->extrasz);
|
||||
break;
|
||||
case CT_BITS8:
|
||||
cl = idris_b8CopyForGC(vm, x);
|
||||
break;
|
||||
case CT_BITS16:
|
||||
cl = idris_b16CopyForGC(vm, x);
|
||||
break;
|
||||
case CT_BITS32:
|
||||
cl = idris_b32CopyForGC(vm, x);
|
||||
break;
|
||||
case CT_BITS64:
|
||||
cl = idris_b64CopyForGC(vm, x);
|
||||
break;
|
||||
case CT_REF:
|
||||
cl = idris_newRefLock((VAL)(GETPTR(x)), 1);
|
||||
break;
|
||||
case CT_FWD:
|
||||
return GETPTR(x);
|
||||
case CT_FLOAT:
|
||||
case CT_STROFFSET:
|
||||
case CT_PTR:
|
||||
case CT_MANAGEDPTR:
|
||||
case CT_BITS8:
|
||||
case CT_BITS16:
|
||||
case CT_BITS32:
|
||||
case CT_BITS64:
|
||||
case CT_RAWDATA:
|
||||
{
|
||||
size_t size = sizeof(Closure) + x->extrasz;
|
||||
@ -67,10 +44,6 @@ VAL copy(VM* vm, VAL x) {
|
||||
memcpy(cl, x, size);
|
||||
}
|
||||
break;
|
||||
case CT_CDATA:
|
||||
cl = MKCDATAc(vm, GETCDATA(x));
|
||||
c_heap_mark_item(GETCDATA(x));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -853,6 +853,12 @@ static VAL doCopyTo(VM* vm, VAL x) {
|
||||
return x;
|
||||
}
|
||||
switch(GETTY(x)) {
|
||||
case CT_CDATA:
|
||||
cl = MKCDATAc(vm, GETCDATA(x));
|
||||
break;
|
||||
case CT_BIGINT:
|
||||
cl = MKBIGMc(vm, GETPTR(x));
|
||||
break;
|
||||
case CT_CON:
|
||||
ar = CARITY(x);
|
||||
if (ar == 0 && CTAG(x) < 256) { // globally allocated
|
||||
@ -867,36 +873,14 @@ static VAL doCopyTo(VM* vm, VAL x) {
|
||||
allocArray(cl, vm, len, 1);
|
||||
copyArray(vm, cl->extra.array, x->extra.array, len);
|
||||
break;
|
||||
case CT_FLOAT:
|
||||
cl = MKFLOATc(vm, GETFLOAT(x));
|
||||
break;
|
||||
case CT_STRING:
|
||||
cl = MKSTRclen(vm, x->extra.str, getstrlen(x));
|
||||
break;
|
||||
case CT_BIGINT:
|
||||
cl = MKBIGMc(vm, GETPTR(x));
|
||||
break;
|
||||
case CT_FLOAT:
|
||||
case CT_PTR:
|
||||
cl = MKPTRc(vm, GETPTR(x));
|
||||
break;
|
||||
case CT_MANAGEDPTR:
|
||||
cl = MKMPTRc(vm, x->extra.mptr, x->extrasz);
|
||||
break;
|
||||
case CT_CDATA:
|
||||
cl = MKCDATAc(vm, GETCDATA(x));
|
||||
break;
|
||||
case CT_BITS8:
|
||||
cl = idris_b8CopyForGC(vm, x);
|
||||
break;
|
||||
case CT_BITS16:
|
||||
cl = idris_b16CopyForGC(vm, x);
|
||||
break;
|
||||
case CT_BITS32:
|
||||
cl = idris_b32CopyForGC(vm, x);
|
||||
break;
|
||||
case CT_BITS64:
|
||||
cl = idris_b64CopyForGC(vm, x);
|
||||
break;
|
||||
case CT_RAWDATA:
|
||||
{
|
||||
size_t size = sizeof(Closure) + x->extrasz;
|
||||
|
Loading…
Reference in New Issue
Block a user