made some updates

This commit is contained in:
nilspolek 2024-01-27 18:49:59 +01:00
parent 8d667ec836
commit 84320f00c7
6 changed files with 7 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
njvm.o

Binary file not shown.

View File

@ -32,7 +32,13 @@ void setField(ObjRef arr, int point, ObjRef value){
if(0 > point || point > getSize(arr)){ if(0 > point || point > getSize(arr)){
printf("Index %i out of bounds for length %i\n",point, getSize(arr)); printf("Index %i out of bounds for length %i\n",point, getSize(arr));
} }
GET_REFS_PTR(arr)[point] = malloc(28); if(IS_PRIMITIVE(value)){
int size = sizeof(*value);
GET_REFS_PTR(arr)[point] = malloc(size);
}else{
int size = sizeof(*value) + (GET_ELEMENT_COUNT(value) * sizeof(void *));
GET_REFS_PTR(arr)[point] = malloc(size);
}
* (ObjRef *)GET_REFS_PTR(arr)[point]->data = value; * (ObjRef *)GET_REFS_PTR(arr)[point]->data = value;
} }