This commit is contained in:
nilspolek 2024-01-28 18:54:43 +01:00
parent c43f02da8e
commit 968965d430
7 changed files with 3 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
njvm.c
View File

@ -51,7 +51,7 @@ void execute(struct program program) {
ObjRef tempObj2;
int tempInt;
for (i = 0; i < *program.size; ++i) {
if (debug == 1 || bp == i) debugMenu(fp, stack, &debug, i, &bp);
// if (debug == 1 || bp == i) debugMenu(fp, stack, &debug, i, &bp);
if (debug == 1) printf("(%i)", i);
switch (program.program[i] >> 24) {
case HALT:
@ -360,7 +360,6 @@ ObjRef relocate(ObjRef orig) {
printf("%s%d\n","Size in relocate ", GET_SIZE(orig));
}
*/
ObjRef copy;
if (orig == NULL) {
/* relocate(nil) = nil */

BIN
njvm.o

Binary file not shown.

View File

@ -23,6 +23,7 @@ ObjRef newRecord(int size){
}
int getSize(ObjRef arr){
if(arr == NULL) return 0;
if(IS_PRIMITIVE(arr)) perror("Record is a primitive");
return GET_ELEMENT_COUNT(arr);
}
ObjRef getField(ObjRef arr, int point){
@ -30,6 +31,7 @@ ObjRef getField(ObjRef arr, int point){
if(0 > point || point > getSize(arr)){
printf("Index %i out of bounds for length %i\n",point, getSize(arr));
}
return *(ObjRef *)GET_REFS_PTR(arr)[point]->data;
}
void setField(ObjRef arr, int point, ObjRef value){