njvm/record.c
2024-01-23 16:58:57 +01:00

25 lines
598 B
C

//
// Created by Nils Polek on 23.01.24.
//
#ifndef RECORD
#define RECORD
#include "stackslot.c"
#include "instruktion.c"
ObjRef newRecord(int size){
ObjRef record;
if((record = malloc(*record + size * sizeof(void *)))== NULL){
perror("malloc")
}
record->size = MSB & size;
for(int i = 0; i < size; i++) {
GET_REFS_PTR(record)[i] = malloc(8)
}
}
ObjRef getField(ObjRef array, int point){
return *(ObjRef *)GET_REFS_PTR(array)[point]->data
}
setField(ObjRef array, int point, ObjRef value){
(ObjRef *)GET_REFS_PTR(array)[point]->data = value
}
#endif