forked from ground/cground
Further struct work, fix lots of warnings
This commit is contained in:
16
src/types.c
16
src/types.c
@@ -74,7 +74,7 @@ GroundValue copyGroundValue(const GroundValue* gv) {
|
||||
break;
|
||||
case LIST: {
|
||||
List newList = createList();
|
||||
for (int i = 0; i < gv->data.listVal.size; i++) {
|
||||
for (size_t i = 0; i < gv->data.listVal.size; i++) {
|
||||
// Recursive call to handle nested lists and other types
|
||||
appendToList(&newList, copyGroundValue(&gv->data.listVal.values[i]));
|
||||
}
|
||||
@@ -93,6 +93,10 @@ GroundValue copyGroundValue(const GroundValue* gv) {
|
||||
// FIXME
|
||||
newGv.data.customVal = gv->data.customVal;
|
||||
break;
|
||||
case NONE:
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
return newGv;
|
||||
}
|
||||
@@ -125,7 +129,7 @@ void printGroundValue(GroundValue* gv) {
|
||||
}
|
||||
case LIST: {
|
||||
printf("[");
|
||||
for (int i = 0; i < gv->data.listVal.size; i++) {
|
||||
for (size_t i = 0; i < gv->data.listVal.size; i++) {
|
||||
printGroundValue(&gv->data.listVal.values[i]);
|
||||
if (i < gv->data.listVal.size - 1) {
|
||||
printf(", ");
|
||||
@@ -152,7 +156,7 @@ void freeGroundValue(GroundValue* gv) {
|
||||
}
|
||||
if (gv->type == LIST && gv->data.listVal.values != NULL) {
|
||||
List* list = &gv->data.listVal;
|
||||
for (int i = 0; i < list->size; i++) {
|
||||
for (size_t i = 0; i < list->size; i++) {
|
||||
freeGroundValue(&list->values[i]);
|
||||
}
|
||||
free(list->values);
|
||||
@@ -394,7 +398,7 @@ void printGroundInstruction(GroundInstruction* gi) {
|
||||
break;
|
||||
}
|
||||
if (gi->type != CREATELABEL) printf(" ");
|
||||
for (int i = 0; i < gi->args.length; i++) {
|
||||
for (size_t i = 0; i < gi->args.length; i++) {
|
||||
if (gi->args.args[i].type == VALUE && gi->args.args[i].value.value.type == STRING) {
|
||||
printf("\"");
|
||||
printGroundArg(&gi->args.args[i]);
|
||||
@@ -428,7 +432,7 @@ void appendToList(List* list, GroundValue value) {
|
||||
list->values[list->size - 1] = value;
|
||||
}
|
||||
|
||||
ListAccess getListAt(List* list, int idx) {
|
||||
ListAccess getListAt(List* list, size_t idx) {
|
||||
if (list == NULL) {
|
||||
printf("Expecting a List ptr, got a null pointer instead.\nThis is likely not an error with your Ground program.\nPlease report this issue to https://chsp.au/ground/cground\n");
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -446,7 +450,7 @@ ListAccess getListAt(List* list, int idx) {
|
||||
}
|
||||
}
|
||||
|
||||
ListAccessStatus setListAt(List* list, int idx, GroundValue value) {
|
||||
ListAccessStatus setListAt(List* list, size_t idx, GroundValue value) {
|
||||
if (list == NULL) {
|
||||
printf("Expecting a List ptr, got a null pointer instead.\nThis is likely not an error with your Ground program.\nPlease report this issue to https://chsp.au/ground/cground\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
Reference in New Issue
Block a user